Date: Wed, 16 May 2018 08:43:08 +0000 (UTC) From: Slava Shwartsman <slavash@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r333668 - vendor/tcpdump/dist Message-ID: <201805160843.w4G8h8oW050800@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: slavash Date: Wed May 16 08:43:08 2018 New Revision: 333668 URL: https://svnweb.freebsd.org/changeset/base/333668 Log: Vendor import two upstream commits: c1bb8784abd3ca978e376b0d10e324db0491237b 9c4af7213cc2543a1f5586d8f2c19f86aa0cbe72 When using tcpdump -I -i wlanN and wlanN is not a monitor mode VAP, tcpdump will print an error message saying rfmon is not supported. Give a concise explanation as to how one might solve this problem by creating a monitor mode VAP. Approved by: hselasky (mentor), kib (mentor) Sponsored by: Mellanox Technologies Modified: vendor/tcpdump/dist/tcpdump.c Modified: vendor/tcpdump/dist/tcpdump.c ============================================================================== --- vendor/tcpdump/dist/tcpdump.c Wed May 16 06:52:08 2018 (r333667) +++ vendor/tcpdump/dist/tcpdump.c Wed May 16 08:43:08 2018 (r333668) @@ -108,6 +108,10 @@ The Regents of the University of California. All righ #endif /* HAVE_CAP_NG_H */ #endif /* HAVE_LIBCAP_NG */ +#ifdef __FreeBSD__ +#include <sys/sysctl.h> +#endif /* __FreeBSD__ */ + #include "netdissect.h" #include "interface.h" #include "addrtoname.h" @@ -1044,6 +1048,30 @@ open_interface(const char *device, netdissect_options } else if (status == PCAP_ERROR_PERM_DENIED && *cp != '\0') error("%s: %s\n(%s)", device, pcap_statustostr(status), cp); +#ifdef __FreeBSD__ + else if (status == PCAP_ERROR_RFMON_NOTSUP && + strncmp(device, "wlan", 4) == 0) { + char parent[8], newdev[8]; + char sysctl[32]; + size_t s = sizeof(parent); + + snprintf(sysctl, sizeof(sysctl), + "net.wlan.%d.%%parent", atoi(device + 4)); + sysctlbyname(sysctl, parent, &s, NULL, 0); + strlcpy(newdev, device, sizeof(newdev)); + /* Suggest a new wlan device. */ + /* FIXME: incrementing the index this way is not going to work well + * when the index is 9 or greater but the only consequence in this + * specific case would be an error message that looks a bit odd. + */ + newdev[strlen(newdev)-1]++; + error("%s is not a monitor mode VAP\n" + "To create a new monitor mode VAP use:\n" + " ifconfig %s create wlandev %s wlanmode monitor\n" + "and use %s as the tcpdump interface", + device, newdev, parent, newdev); + } +#endif else error("%s: %s", device, pcap_statustostr(status));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805160843.w4G8h8oW050800>