On Feb 1, 2010, at 6:27 AM, David Horn wrote:

> I have created a patch to support the RFC 5006 IPv6 RA option 25
> (RDNSS) decoding in tcpdump.  The patch (against GIT) is available
> here:
> 
> https://sourceforge.net/tracker/?func=detail&aid=2942379&group_id=53066&atid=469575
> 
> I would appreciate a review of the code, as this is my first change to
> tcpdump.

There's no need for a "maximum DNS server addresses" value - the nd_opt_rdnss 
structure doesn't have to cover all possible addresses, it can just have one, 
and the printer can go past the nominal end of the structure.

Not all C compilers necessarily support declaration of variables in the middle 
of a block:

                        oprd = (struct nd_opt_rdnss *)op;
                        int rdnss_len = oprd->nd_opt_rdnss_len;

so I just used the "l" variable, used elsewhere for option lengths - and set it 
based on op->nd_opt_len, as is done with other options.

You just directly printed oprd->nd_opt_rdnss_lifetime, but it's a 4-byte value, 
and

        1) it's not guaranteed to be aligned on a 4-byte boundary, and not all 
machines can dereference unaligned pointers without trapping;

        2) it's not necessarily in the same byte order as the machine on which 
you're running (in fact, these days there's an extremely good chance that it's 
*not*, as most people running tcpdump are probably running it on a machine with 
an x86 or x86-64 processor, and those are little-endian);

so it should be fetched with EXTRACT_32BITS().

It's probably best to print the addresses in order, rather than in reverse 
order.

I've checked your patch in, with the changes in question.-
This is the tcpdump-workers list.
Visit https://cod.sandelman.ca/ to unsubscribe.

Reply via email to