Re: bug in addrlist_match (with IPv6 addresses)

Steve G <[email protected]> Wed, 6 Aug 2003 16:08:33 -0700 (PDT)
Newsgroups gmane.network.xinetd
Message-ID <[email protected]>
>>Probably the most portable way to do it is to make a
macro
>>
>> #define IPV4_ADDR_OFFSET (a) ((__const uint32_t *)
(a))[3]
>
>One-word interjection: Ugh.

Right. :)

> -  uint32_t *tmp_addr = (unsigned *)&addr->sa_data[3];
> +  uint32_t *tmp_addr =
> &SAIN6(addr)->sin6_addr.s6_addr32[3];

I think I see what the problem is...missing parenthesis. It
should have been: 

uint32_t *tmp_addr = ((unsigned *)&addr->sa_data)[3];

It was supposed to be the 3rd int (or 12 bytes) from the
beginning of the structure. The macro at least hides all
the casting to make the compiler do what's intended.

-Steve

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com