Re: icmp traceroute
Re: icmp traceroute
- Subject: Re: icmp traceroute
- From: Dalton Hamilton <email@hidden>
- Date: Mon, 28 Aug 2006 15:30:33 +0200
You have to pay careful attention to the actual definition of these
structures. The IP header for example is not fixed length but may
include one or more options. The correct solution is to extract the
header length (ip->hlen) from the packet itself, something like this:
dp = (UInt8*)[[inMessage data] bytes];
inDataSize = [[inMessage data] length];
// setup pointer to ip header
ip_header = (ip_header_t*)dp;
// setup pointer to icmp header
icmp_header = (icmp_header_t*)&dp[(ip_header->hlen & 0x0F) * 4];
// setup pointer to ip header of triggering datagram
ip_header2 = (ip_header_t*)&icmp_header->data[0];
// setup pointer to icmp header of triggering datagram
icmp_header2 = (icmp_header_t*)&icmp_header->data[(ip_header2-
>hlen
& 0x0F) * 4];
// setup pointer to udp header of triggering datagram
udp_header2 = (udp_header_t*)&icmp_header->data[(ip_header2-
>hlen &
0x0F) * 4];
Notice the "hlen" field is 4-bits wide and gives the header length
in 4-
byte words. Having a good reference book like Stevens or Comer at
your
elbow can really help.
Yes. I was very close and tried variations of your solution above
with the hlen field of each IP header.
A rhetorical question is why the static structure method I pulled
from MTR is even working.
At any rate, my Stevens and Comer books are really old -- back with I
took Distributed Processing at UNC-Chapel Hill in 1989 -- so I guess
I better invest in the new books. I'll go check them out.
Many Thanks
Dalton
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden