fixup addr6 check.

git-svn-id: file:///svn/unbound/trunk@677 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-10-15 14:42:37 +00:00
parent aecdb781fc
commit fed59bca84
5 changed files with 10 additions and 8 deletions

View file

@ -4,6 +4,7 @@
- fixup the fact that the query section was not compressed to, - fixup the fact that the query section was not compressed to,
the code was there but was called by value instead of by reference. the code was there but was called by value instead of by reference.
And test for the case, uses xxd and nc. And test for the case, uses xxd and nc.
- more portable ip6 check for sockaddr types.
8 October 2007: Wouter 8 October 2007: Wouter
- --disable-rpath option in configure for 64bit systems with - --disable-rpath option in configure for 64bit systems with

View file

@ -136,7 +136,7 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
if(donotq_lookup(iter_env->donotq, &a->addr, a->addrlen)) { if(donotq_lookup(iter_env->donotq, &a->addr, a->addrlen)) {
return -1; /* server is on the donotquery list */ 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 */ return -1; /* there is no ip6 available */
} }
/* check lameness - need zone , class info */ /* check lameness - need zone , class info */

View file

@ -124,7 +124,7 @@ outnet_tcp_take_into_use(struct waiting_tcp* w, uint8_t* pkt, size_t pkt_len)
log_assert(pkt); log_assert(pkt);
/* open socket */ /* open socket */
#ifdef INET6 #ifdef INET6
if(addr_is_ip6(&w->addr)) if(addr_is_ip6(&w->addr, w->addrlen))
s = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP); s = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP);
else else
#endif #endif
@ -643,7 +643,7 @@ select_port(struct outside_network* outnet, struct pending* pend,
log_assert(outnet && pend); log_assert(outnet && pend);
/* first select ip4 or ip6. */ /* first select ip4 or ip6. */
if(addr_is_ip6(&pend->addr)) if(addr_is_ip6(&pend->addr, pend->addrlen))
nummax = (int)outnet->num_udp6; nummax = (int)outnet->num_udp6;
else nummax = (int)outnet->num_udp4; else nummax = (int)outnet->num_udp4;
@ -663,7 +663,7 @@ select_port(struct outside_network* outnet, struct pending* pend,
if(chosen < 0) chosen = 0; if(chosen < 0) chosen = 0;
if(chosen >= nummax) chosen = nummax-1; 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]; pend->c = outnet->udp6_ports[chosen];
else pend->c = outnet->udp4_ports[chosen]; else pend->c = outnet->udp4_ports[chosen];
log_assert(pend->c); log_assert(pend->c);

View file

@ -312,10 +312,10 @@ sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1,
} }
int int
addr_is_ip6(struct sockaddr_storage* addr) addr_is_ip6(struct sockaddr_storage* addr, socklen_t len)
{ {
short family = *(short*)addr; if(len == (socklen_t)sizeof(struct sockaddr_in6) &&
if(family == AF_INET6) ((struct sockaddr_in6*)addr)->sin6_family == AF_INET6)
return 1; return 1;
else return 0; else return 0;
} }

View file

@ -203,8 +203,9 @@ int sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1,
/** /**
* Checkout address family. * Checkout address family.
* @param addr: the sockaddr to examine. * @param addr: the sockaddr to examine.
* @param len: the length of addr.
* return: true if sockaddr is ip6. * 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 */ #endif /* NET_HELP_H */