Article View: borland.public.cppbuilder.internet.socket
Article #152Re: How can I Trace the Route to an IP Addres from within my program
From: Bob Gonder
Date: Wed, 25 Jun 2008 18:37
Date: Wed, 25 Jun 2008 18:37
38 lines
2461 bytes
2461 bytes
DreamChaser wrote:
>Thanks for the shout out Bob, but I haven't gotten IP_OPT_RR to work
>yet. Using the pseudo code that Gambit provided I am still getting an
>Options Bad error from IcmpSendEcho().
>if( IcmpSendEcho(icmp, addr, SendData, strlen(SendData), &info, reply, ReplySize, 1000) > 0 )
1) You don't check if icmp is valid.
2) You pass unitialized addr.
3) You overflow info.Ttl.
4) It might be objecting to the additional IP_OPT_EOL option
following the IP_OPT_RR option.
In addition,
5) ReplyBuffer and ReplySize are too small.
See what else ReplyBuffer needs to hold:
http://msdn.microsoft.com/en-us/library/aa366050(VS.85).aspx
Reply.Data is a pointer past the end of the used array
of ICMP_ECHO_REPLY. It is your memory, not the systems.
I think ReplyBuffer should be (at minimum)
sizeof(ICMP_ECHO_REPLY)+sizeof(options)+sizeof(SendData)+8;
>1 HANDLE icmp = IcmpCreateFile();
> IPAddr addr;
> char *SendData = "Hello";
>
>2 ipaddr.S_un.S_addr = inet_addr("74.125.47.147");
>
> BYTE options[sizeof(RecordRouteOption)+1] = {0};
>
> PRecordRouteOption option = (PRecordRouteOption) options;
>
>4 (++option)->type = IP_OPT_EOL;
>
> IP_OPTION_INFORMATION info = {0};
>3 info.Ttl = 256;
>
Technical Details
Message-ID:
<eat4641vo2sn26vtd22g2eqclul40qc76s@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<MPG.22c8301ab312798c989a97@newsgroups.borland.com> <485faf40$1@newsgroups.borland.com> <MPG.22cb3a3e698457ac989a9a@newsgroups.borland.com> <rrj264107nnff1gqarmhq4p0v1c23k6801@4ax.com> <4861dce2$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,7aa64e4617379849 X-Google-Attributes: gid11508e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: Bob Gonder <none@nowhere.invalid> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: How can I Trace the Route to an IP Addres from within my program Date: Wed, 25 Jun 2008 11:37:03 -0700 Message-ID: <eat4641vo2sn26vtd22g2eqclul40qc76s@4ax.com> References: <MPG.22c8301ab312798c989a97@newsgroups.borland.com> <485faf40$1@newsgroups.borland.com> <MPG.22cb3a3e698457ac989a9a@newsgroups.borland.com> <rrj264107nnff1gqarmhq4p0v1c23k6801@4ax.com> <4861dce2$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.77.145.54 X-Trace: newsgroups.borland.com 1214419021 67.77.145.54 (25 Jun 2008 11:37:01 -0700) Lines: 39 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail