summaryrefslogtreecommitdiffstats
path: root/contrib/libpcap/nametoaddr.c
diff options
context:
space:
mode:
authorfenner <fenner@FreeBSD.org>2000-01-30 00:43:38 +0000
committerfenner <fenner@FreeBSD.org>2000-01-30 00:43:38 +0000
commit787eaee1ab20ef667522f74c0de780af3da9ee19 (patch)
tree3d97dbb185f58043dc42b43fc1544771c223280c /contrib/libpcap/nametoaddr.c
parentcd005a95696048ba76613daaa83178e68751c681 (diff)
downloadFreeBSD-src-787eaee1ab20ef667522f74c0de780af3da9ee19.zip
FreeBSD-src-787eaee1ab20ef667522f74c0de780af3da9ee19.tar.gz
Merge libpcap 0.5
Diffstat (limited to 'contrib/libpcap/nametoaddr.c')
-rw-r--r--contrib/libpcap/nametoaddr.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/contrib/libpcap/nametoaddr.c b/contrib/libpcap/nametoaddr.c
index 7b744c8..243f664 100644
--- a/contrib/libpcap/nametoaddr.c
+++ b/contrib/libpcap/nametoaddr.c
@@ -20,11 +20,13 @@
*
* Name to id translation routines used by the scanner.
* These functions are not time critical.
+ *
+ * $FreeBSD$
*/
#ifndef lint
static const char rcsid[] =
- "@(#) $Header: nametoaddr.c,v 1.48 98/07/12 13:15:36 leres Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/nametoaddr.c,v 1.51 1999/11/25 08:25:35 itojun Exp $ (LBL)";
#endif
#include <sys/param.h>
@@ -41,6 +43,10 @@ struct rtentry;
#include <net/ethernet.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#ifdef INET6
+#include <netdb.h>
+#include <sys/socket.h>
+#endif /*INET6*/
#include <ctype.h>
#include <errno.h>
@@ -70,6 +76,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 +100,23 @@ 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;
+ hints.ai_socktype = SOCK_STREAM; /*not really*/
+ error = getaddrinfo(name, NULL, &hints, &res);
+ if (error)
+ return NULL;
+ else
+ return res;
+}
+#endif /*INET6*/
/*
* Convert net name to internet address.
@@ -182,9 +206,21 @@ struct eproto {
/* Static data base of ether protocol types. */
struct eproto eproto_db[] = {
+#if 0
+ /* The FreeBSD elf linker generates a request to copy this array
+ * (including its size) when you link with -lpcap. In order to
+ * not bump the major version number of this libpcap.so, we need
+ * to ensure that the array stays the same size. Since PUP is
+ * likely never seen in real life any more, it's the first to
+ * be sacrificed (in favor of ip6).
+ */
{ "pup", ETHERTYPE_PUP },
+#endif
{ "xns", ETHERTYPE_NS },
{ "ip", ETHERTYPE_IP },
+#ifdef INET6
+ { "ip6", ETHERTYPE_IPV6 },
+#endif
{ "arp", ETHERTYPE_ARP },
{ "rarp", ETHERTYPE_REVARP },
{ "sprite", ETHERTYPE_SPRITE },
@@ -330,7 +366,7 @@ pcap_ether_hostton(const char *name)
}
#else
-#ifndef sgi
+#if !defined(sgi) && !defined(__NetBSD__)
extern int ether_hostton(char *, struct ether_addr *);
#endif
OpenPOWER on IntegriCloud