[sane-devel] IPv6 patch for saned and net backend

Henning Meier-Geinitz henning@meier-geinitz.de
Sat, 22 Mar 2003 19:39:17 +0100


Hi,

On Sat, Mar 22, 2003 at 05:18:17PM +0100, Julien BLACHE wrote:
> Irvin Probst <irvin@irvinig.org> wrote:
> Ok, this is related to the IN6_* macros. Definitely need something
> better than these, it seems.

By the way: On FreeBSD (and the other platforms I reported), these are
errors (not warnings), too.

On FreeBSD the macros are defined like this:

#ifdef _KERNEL
#define IN6_ARE_ADDR_EQUAL(a, b)                        \
    (bcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
#else
#define IN6_ARE_ADDR_EQUAL(a, b)                        \
    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
#endif

#define IN6_IS_ADDR_LOOPBACK(a)         \
        ((*(const u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) && \
         (*(const u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) && \
         (*(const u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) && \
         (*(const u_int32_t *)(const void *)(&(a)->s6_addr[12]) == ntohl(1)))

So it likes to have the sin6p->sin6_addr, not sin6p->sin6_addr.s6_addr.

This is different from glibc:

#define IN6_IS_ADDR_LOOPBACK(a) \
	(((__const uint32_t *) (a))[0] == 0				      \
	 && ((__const uint32_t *) (a))[1] == 0				      \
	 && ((__const uint32_t *) (a))[2] == 0				      \
	 && ((__const uint32_t *) (a))[3] == htonl (1))


#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]))

So I guess we need a special test. Or just undef the system macros.

By the way: For shell access to FreeBSD, OpenBSD, NetBSD, HPUX, Tru64,
OpenVMS (and several Linux distributions) on several platforms (Alpha,
Itanium, PA-RISC, x86) see http://testdrive.hp.com/ .

Bye,
  Henning