summaryrefslogtreecommitdiff
path: root/contrib/libpcap
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2009-11-11 21:30:58 +0000
committerXin LI <delphij@FreeBSD.org>2009-11-11 21:30:58 +0000
commit41c8c6e876843baf55e33637e7a7018cfce80f62 (patch)
treeeea1594231338258764b9d2c6a5b8c04a07d0269 /contrib/libpcap
parentf140aad88c4131d178f535323d00fbcb6f6504bf (diff)
downloadsrc-test-41c8c6e876843baf55e33637e7a7018cfce80f62.tar.gz
src-test-41c8c6e876843baf55e33637e7a7018cfce80f62.zip
Add interface description capability as inspired by OpenBSD.
MFC after: 3 months
Notes
Notes: svn path=/head/; revision=199201
Diffstat (limited to 'contrib/libpcap')
-rw-r--r--contrib/libpcap/inet.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/contrib/libpcap/inet.c b/contrib/libpcap/inet.c
index aad87963e7868..8955f2c49d695 100644
--- a/contrib/libpcap/inet.c
+++ b/contrib/libpcap/inet.c
@@ -403,22 +403,30 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags,
pcap_addr_t *curaddr, *prevaddr, *nextaddr;
#ifdef SIOCGIFDESCR
struct ifreq ifrdesc;
+#ifdef __FreeBSD__
+#define _IFDESCRSIZE 64
+ char ifdescr[_IFDESCRSIZE];
+#else
char ifdescr[IFDESCRSIZE];
- int s;
#endif
+ int s;
-#ifdef SIOCGIFDESCR
/*
* Get the description for the interface.
*/
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 = _IFDESCRSIZE;
+#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