aboutsummaryrefslogtreecommitdiffstats
path: root/nametoaddr.c
diff options
context:
space:
mode:
authoritojun <itojun>1999-10-19 15:18:28 +0000
committeritojun <itojun>1999-10-19 15:18:28 +0000
commit7fe3c1111adb85e0c50edc054340341b9ccd6c5b (patch)
treec42e8d5854ee3c97ce626284f7fcad1757449a7f /nametoaddr.c
parentdb0e314c6dbcbfe74c2c669e2e5b6ac63ba0bf0e (diff)
IPv6 packet filtering code.
./configure --enable-ipv6 (requires getaddrinfo(3) and getnameinfo(3)). TODO: make it work even without getaddrinfo(3) or getnameinfo(3) (or, tcpdump/configure.in should provide alternative version by AC_REPLACE_FUNCS) TODO: make IPv6 filtering code work by default TODO: make "protochain" friendly with optimization
Diffstat (limited to 'nametoaddr.c')
-rw-r--r--nametoaddr.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/nametoaddr.c b/nametoaddr.c
index 3c935a4..056e777 100644
--- a/nametoaddr.c
+++ b/nametoaddr.c
@@ -24,7 +24,7 @@
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.49 1999-10-17 21:29:18 mcr Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.50 1999-10-19 15:18:30 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -41,6 +41,10 @@ struct rtentry;
#include <netinet/in.h>
#include <netinet/if_ether.h>
#include <arpa/inet.h>
+#ifdef INET6
+#include <netdb.h>
+#include <sys/socket.h>
+#endif /*INET6*/
#include <ctype.h>
#include <errno.h>
@@ -70,6 +74,7 @@ static inline int xdtoi(int);
* Convert host name to internet address.
* Return 0 upon failure.
*/
+#ifndef INET6
bpf_u_int32 **
pcap_nametoaddr(const char *name)
{
@@ -93,6 +98,22 @@ pcap_nametoaddr(const char *name)
else
return 0;
}
+#else
+struct addrinfo *
+pcap_nametoaddr(const char *name)
+{
+ struct addrinfo hints, *res;
+ int error;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ error = getaddrinfo(name, NULL, &hints, &res);
+ if (error)
+ return NULL;
+ else
+ return res;
+}
+#endif /*INET6*/
/*
* Convert net name to internet address.
@@ -185,6 +206,9 @@ struct eproto eproto_db[] = {
{ "pup", ETHERTYPE_PUP },
{ "xns", ETHERTYPE_NS },
{ "ip", ETHERTYPE_IP },
+#ifdef INET6
+ { "ip6", ETHERTYPE_IPV6 },
+#endif
{ "arp", ETHERTYPE_ARP },
{ "rarp", ETHERTYPE_REVARP },
{ "sprite", ETHERTYPE_SPRITE },
@@ -330,6 +354,10 @@ pcap_ether_hostton(const char *name)
}
#else
+#if !defined(sgi) && !defined(__NetBSD__)
+extern int ether_hostton(char *, struct ether_addr *);
+#endif
+
/* Use the os supplied routines */
u_char *
pcap_ether_hostton(const char *name)