- fixup the fact that the query section was not compressed to,
the code was there but was called by value instead of by reference.
And test for the case, uses xxd and nc.
+ - more portable ip6 check for sockaddr types.
8 October 2007: Wouter
- --disable-rpath option in configure for 64bit systems with
if(donotq_lookup(iter_env->donotq, &a->addr, a->addrlen)) {
return -1; /* server is on the donotquery list */
}
- if(!iter_env->supports_ipv6 && addr_is_ip6(&a->addr)) {
+ if(!iter_env->supports_ipv6 && addr_is_ip6(&a->addr, a->addrlen)) {
return -1; /* there is no ip6 available */
}
/* check lameness - need zone , class info */
log_assert(pkt);
/* open socket */
#ifdef INET6
- if(addr_is_ip6(&w->addr))
+ if(addr_is_ip6(&w->addr, w->addrlen))
s = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP);
else
#endif
log_assert(outnet && pend);
/* first select ip4 or ip6. */
- if(addr_is_ip6(&pend->addr))
+ if(addr_is_ip6(&pend->addr, pend->addrlen))
nummax = (int)outnet->num_udp6;
else nummax = (int)outnet->num_udp4;
if(chosen < 0) chosen = 0;
if(chosen >= nummax) chosen = nummax-1;
- if(addr_is_ip6(&pend->addr))
+ if(addr_is_ip6(&pend->addr, pend->addrlen))
pend->c = outnet->udp6_ports[chosen];
else pend->c = outnet->udp4_ports[chosen];
log_assert(pend->c);
}
int
-addr_is_ip6(struct sockaddr_storage* addr)
+addr_is_ip6(struct sockaddr_storage* addr, socklen_t len)
{
- short family = *(short*)addr;
- if(family == AF_INET6)
+ if(len == (socklen_t)sizeof(struct sockaddr_in6) &&
+ ((struct sockaddr_in6*)addr)->sin6_family == AF_INET6)
return 1;
else return 0;
}
/**
* Checkout address family.
* @param addr: the sockaddr to examine.
+ * @param len: the length of addr.
* return: true if sockaddr is ip6.
*/
-int addr_is_ip6(struct sockaddr_storage* addr);
+int addr_is_ip6(struct sockaddr_storage* addr, socklen_t len);
#endif /* NET_HELP_H */