diff options
Diffstat (limited to 'lib/libpcap/inet.c')
-rw-r--r-- | lib/libpcap/inet.c | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/libpcap/inet.c b/lib/libpcap/inet.c index 9a29bea094a..fb0cb362d77 100644 --- a/lib/libpcap/inet.c +++ b/lib/libpcap/inet.c @@ -1,8 +1,7 @@ -/* $OpenBSD */ -/* $NetBSD: inet.c,v 1.2.6.1 1996/06/05 18:04:32 cgd Exp $ */ +/* $OpenBSD: inet.c,v 1.4 1996/07/12 13:19:09 mickey Exp $ */ /* - * Copyright (c) 1994 + * Copyright (c) 1994, 1995, 1996 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -36,28 +35,40 @@ #ifndef lint static char rcsid[] = - "@(#) Header: inet.c,v 1.4 94/06/07 01:16:50 leres Exp (LBL)"; + "@(#) Header: inet.c,v 1.16 96/06/23 14:28:22 leres Exp (LBL)"; #endif #include <sys/param.h> #include <sys/file.h> #include <sys/ioctl.h> #include <sys/socket.h> -#ifdef SOLARIS +#ifdef HAVE_SYS_SOCKIO_H #include <sys/sockio.h> #endif +#if __STDC__ +struct mbuf; +struct rtentry; +#endif + #include <net/if.h> #include <netinet/in.h> #include <ctype.h> #include <errno.h> +#include <memory.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <pcap.h> +#ifdef HAVE_OS_PROTO_H +#include "os-proto.h" +#endif + +#include "pcap-int.h" + /* Not all systems have IFF_LOOPBACK */ #ifdef IFF_LOOPBACK #define ISLOOPBACK(p) ((p)->ifr_flags & IFF_LOOPBACK) @@ -101,7 +112,7 @@ pcap_lookupdev(errbuf) mp = NULL; minunit = 666; for (; ifrp < ifend; ifrp = ifnext) { -#if BSD - 0 >= 199006 +#ifdef HAVE_SOCKADDR_SA_LEN n = ifrp->ifr_addr.sa_len + sizeof(ifrp->ifr_name); if (n < sizeof(*ifrp)) ifnext = ifrp + 1; @@ -152,7 +163,7 @@ pcap_lookupdev(errbuf) int pcap_lookupnet(device, netp, maskp, errbuf) register char *device; - register u_int32_t *netp, *maskp; + register bpf_u_int32 *netp, *maskp; register char *errbuf; { register int fd; @@ -164,6 +175,11 @@ pcap_lookupnet(device, netp, maskp, errbuf) (void)sprintf(errbuf, "socket: %s", pcap_strerror(errno)); return (-1); } + memset(&ifr, 0, sizeof(ifr)); +#ifdef linux + /* XXX Work around Linux kernel bug */ + ifr.ifr_addr.sa_family = AF_INET; +#endif (void)strncpy(ifr.ifr_name, device, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) < 0) { (void)sprintf(errbuf, "SIOCGIFADDR: %s: %s", |