Re: bug in addrlist_match (with IPv6 addresses)

Steve G <[email protected]> Wed, 6 Aug 2003 15:04:56 -0700 (PDT)
Newsgroups gmane.network.xinetd
Message-ID <[email protected]>
>Hmm, in case my fix just wasn't portable enough, this one
>might be better (untested):
>
>  uint32_t *tmp_addr = (uint32_t *)
>&SAIN6(addr)->sin6_addr.s6_addr[12];

Rob, Does this work for you? 

The patch was reverted since it didn't compile on Rob's
machine. I think the macros were not portable. Looking at
one of the IPv6 macros:

#define IN6_ARE_ADDR_EQUAL(a,b) \
        ((((__const uint32_t *) (a))[0] == ((__const
uint32_t *) (b))[0])     \
         && (((__const uint32_t *) (a))[1] == ((__const
uint32_t *) (b))[1])  \
         && (((__const uint32_t *) (a))[2] == ((__const
uint32_t *) (b))[2])  \
         && (((__const uint32_t *) (a))[3] == ((__const
uint32_t *) (b))[3]))

Probably the most portable way to do it is to make a macro

#define IPV4_ADDR_OFFSET (a) ((__const uint32_t *) (a))[3]

Then uint32_t *tmp_addr =
IPV4_ADDR_OFFSET(&SAIN6(addr)->sin6_addr.s6_addr);

-Steve Grubb

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