diff options
author | delphij <delphij@FreeBSD.org> | 2010-02-26 00:54:47 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2010-02-26 00:54:47 +0000 |
commit | 2c255a85f1a94490d53a0d50a11a7292322fdebb (patch) | |
tree | 8c253d3e96cef0c433208d7c21a093ea7c8e1ccd /contrib/libpcap | |
parent | d6816492901c7ee5e4aeda381c2493e6d40b3d8d (diff) | |
download | FreeBSD-src-2c255a85f1a94490d53a0d50a11a7292322fdebb.zip FreeBSD-src-2c255a85f1a94490d53a0d50a11a7292322fdebb.tar.gz |
MFC 203052:
Add interface description capability as inspired by OpenBSD. Thanks for
rwatson@, jhb@, brooks@ and others for feedback to the old implementation!
Sponsored by: iXsystems, Inc.
Diffstat (limited to 'contrib/libpcap')
-rw-r--r-- | contrib/libpcap/inet.c | 16 |
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 |