summaryrefslogtreecommitdiffstats
path: root/contrib/libpcap
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-01-27 00:30:07 +0000
committerdelphij <delphij@FreeBSD.org>2010-01-27 00:30:07 +0000
commitd9a0cd0982402f9faf826972323ba7e2c92d4da2 (patch)
treeff676986c0098bc03f0b66a25fb89a62e45f8b53 /contrib/libpcap
parentf58131e1e486131bc5b10b4db8adfbfb58a6db5f (diff)
downloadFreeBSD-src-d9a0cd0982402f9faf826972323ba7e2c92d4da2.zip
FreeBSD-src-d9a0cd0982402f9faf826972323ba7e2c92d4da2.tar.gz
Revised revision 199201 (add interface description capability as inspired
by OpenBSD), based on comments from many, including rwatson, jhb, brooks and others. Sponsored by: iXsystems, Inc. MFC after: 1 month
Diffstat (limited to 'contrib/libpcap')
-rw-r--r--contrib/libpcap/inet.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/contrib/libpcap/inet.c b/contrib/libpcap/inet.c
index aad8796..5f081a6 100644
--- a/contrib/libpcap/inet.c
+++ b/contrib/libpcap/inet.c
@@ -401,10 +401,15 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags,
pcap_if_t *curdev;
char *description = NULL;
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
+ int s;
#ifdef SIOCGIFDESCR
struct ifreq ifrdesc;
+#ifndef IFDESCRSIZE
+#define _IFDESCRSIZE 64
+ char ifdescr[_IFDESCRSIZE];
+#else
char ifdescr[IFDESCRSIZE];
- int s;
+#endif
#endif
#ifdef SIOCGIFDESCR
@@ -413,12 +418,17 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags,
*/
memset(&ifrdesc, 0, sizeof ifrdesc);
strlcpy(ifrdesc.ifr_name, name, sizeof ifrdesc.ifr_name);
+#ifdef __FreeBSD__
+ ifrdesc.ifr_buffer.buffer = ifdescr;
+ ifrdesc.ifr_buffer.length = sizeof(ifdescr);
+#else
ifrdesc.ifr_data = (caddr_t)&ifdescr;
+#endif
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s >= 0) {
if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0 &&
- strlen(ifrdesc.ifr_data) != 0)
- description = ifrdesc.ifr_data;
+ strlen(ifdescr) != 0)
+ description = ifdescr;
close(s);
}
#endif
OpenPOWER on IntegriCloud