diff options
author | Guy Harris <guy@alum.mit.edu> | 2010-03-01 15:01:02 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2010-03-01 15:01:02 -0800 |
commit | 2d3279a02fd04cd6896bf0fe7f6fd2816581d4e7 (patch) | |
tree | 20a9490d30702f0de066223fddf370c0132d297b | |
parent | 84a1f947bad081f30365ee8cb308ec18d4e7d4c5 (diff) |
Update to work with FreeBSD flavor of SIOCGIFDESCR.
Update to work with FreeBSD flavor of SIOCGIFDESCR as well as the
OpenBSD flavor. Also, a small tweak from me to use "ifdescr" as a
pointer to the string buffer in both cases ("&ifdescr" and "ifdescr",
although they have different types, point to the same location), and to
put "s" back inside #ifdef SIOCGIFDESCR/#endif, as it's not used if
SIOCGIFDESCR isn't defined.
-rw-r--r-- | inet.c | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -402,10 +402,15 @@ add_addr_to_iflist(pcap_if_t **alldevs, const char *name, u_int flags, char *description = NULL; pcap_addr_t *curaddr, *prevaddr, *nextaddr; #ifdef SIOCGIFDESCR + int s; struct ifreq ifrdesc; +#ifndef IFDESCRSIZE +#define _IFDESCRSIZE 64 + char ifdescr[_IFDESCRSIZE]; +#else /* IFDESCRSIZE */ char ifdescr[IFDESCRSIZE]; - int s; -#endif +#endif /* IFDESCRSIZE */ +#endif /* SIOCGIFDESCR */ #ifdef SIOCGIFDESCR /* @@ -413,15 +418,20 @@ 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); - ifrdesc.ifr_data = (caddr_t)&ifdescr; +#ifdef __FreeBSD__ + ifrdesc.ifr_buffer.buffer = ifdescr; + ifrdesc.ifr_buffer.length = sizeof(ifdescr); +#else /* __FreeBSD__ */ + ifrdesc.ifr_data = (caddr_t)ifdescr; +#endif /* __FreeBSD__ */ 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 +#endif /* SIOCGIFDESCR */ if (add_or_find_if(&curdev, alldevs, name, flags, description, errbuf) == -1) { |