dect
/
libpcap
Archived
13
0
Fork 0

fix "ip host foo" or "ip6 host foo" where foo has both A and AAAA records.

FreeBSD PR: 17083
This commit is contained in:
itojun 2000-03-01 03:37:24 +00:00
parent 47cea61df3
commit d27ad07fae
1 changed files with 10 additions and 4 deletions

View File

@ -21,7 +21,7 @@
*/ */
#ifndef lint #ifndef lint
static const char rcsid[] = static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.101 2000-01-29 21:01:27 fenner Exp $ (LBL)"; "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.102 2000-03-01 03:37:24 itojun Exp $ (LBL)";
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -2045,15 +2045,21 @@ gen_scode(name, q)
tproto = Q_IP; tproto = Q_IP;
tproto6 = Q_IPV6; tproto6 = Q_IPV6;
} }
while (res) { for (res = res0; res; res = res->ai_next) {
switch (res->ai_family) { switch (res->ai_family) {
case AF_INET: case AF_INET:
if (tproto == Q_IPV6)
continue;
sin = (struct sockaddr_in *) sin = (struct sockaddr_in *)
res->ai_addr; res->ai_addr;
tmp = gen_host(ntohl(sin->sin_addr.s_addr), tmp = gen_host(ntohl(sin->sin_addr.s_addr),
0xffffffff, tproto, dir); 0xffffffff, tproto, dir);
break; break;
case AF_INET6: case AF_INET6:
if (tproto6 == Q_IP)
continue;
sin6 = (struct sockaddr_in6 *) sin6 = (struct sockaddr_in6 *)
res->ai_addr; res->ai_addr;
tmp = gen_host6(&sin6->sin6_addr, tmp = gen_host6(&sin6->sin6_addr,
@ -2063,10 +2069,10 @@ gen_scode(name, q)
if (b) if (b)
gen_or(b, tmp); gen_or(b, tmp);
b = tmp; b = tmp;
res = res->ai_next;
} }
freeaddrinfo(res0); freeaddrinfo(res0);
if (b == NULL)
bpf_error("unknown host '%s'", name);
return b; return b;
#endif /*INET6*/ #endif /*INET6*/
} }