All,
Thank you for such thorough replies (Guy especially). You've done an excellent
job of educating me on multiple subjects here (for example, I was under the
impression that inet_aton() would fail on certain non-valid addreses, like
0.0.1.2). I mean this sincerely, too (I say this just to make sure no one
mistakes this for bitter sarcasm) -- learning from one's mistakes is probably
one of the best ways of all to learn.
In any case, my problem has actually been solved by one of the methods that Guy
anticipated. It turns out that there is a flag value earlier on in the packet
that tells me whether this field is a single IP or a specifier of the number of
IP pairs to follow (pairs when the second bit, i.e. 2, is set, single IP when
it's not). Given that I'm working without any protocol documentation, I guess
it's not terribly surprising that I missed it earlier.
Thanks again, and like I said before, I hope that by the time I finish this I'll
have something useful to contribute in return. :-)
Alex Kirk
> Alex Kirk wrote:
> > Already had, actually. There's nothing that extracts IP addresses directly
> (at
> > least not that I can see), and getting the bytes individually with
> > tvb_get_guint8(), converting them to a string with dots, and then calling
> > inet_aton() seemed wasteful.
>
> It's especially wasteful because it won't tell you waht you want to know!
>
> If you convert the 4 bytes to a string with dots, then "inet_aton()"
> will *ALWAYS* be able to convert that string back to an IP address - it
> will *never* fail on a string of the form
>
> {integer from 0 to 255}.{integer from 0 to 255}.{integer from 0 to
> 255}.{integer from 0 to 255}
>
> and converting 4 bytes to a string with dots involves treating each byte
> as an unsigned integer in the range 0 to 255 and putting dots between them.
>
> I.e., as implied by Michael Tuexen's mail, all 2^32 4-byte integral
> values are, in some sense, syntactically valid IP addresses, although
> there are conventions that render some of them not valid as host
> addresses - but "inet_aton()" doesn't know that it's being asked to
> convert a valid host IP address, and doesn't check for an address being
> valid (doing so would require that it know what the network mask for the
> address is - and it might well be used in applications that are
> *intentionally* being supplied addresses with zeroes in the host part
> and that are *expected* to convert them to IP addresses).
>
> _______________________________________________
> Ethereal-dev mailing list
> Ethereal-dev@xxxxxxxxxxxx
> http://www.ethereal.com/mailman/listinfo/ethereal-dev
>