diff options
author | rpaulo <rpaulo@FreeBSD.org> | 2013-07-31 02:13:18 +0000 |
---|---|---|
committer | rpaulo <rpaulo@FreeBSD.org> | 2013-07-31 02:13:18 +0000 |
commit | 26d2d7b7cc99e6096d2efb24136610f5b89f3292 (patch) | |
tree | f1b08e0328ae883d145ba74e3b2f9891177b958b | |
parent | f0f219fe9b0dde8a6cf9e4149fec5d43a31ce7f1 (diff) | |
download | FreeBSD-src-26d2d7b7cc99e6096d2efb24136610f5b89f3292.zip FreeBSD-src-26d2d7b7cc99e6096d2efb24136610f5b89f3292.tar.gz |
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.
-rw-r--r-- | contrib/tcpdump/tcpdump.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c index 7cfcc68..48b774d 100644 --- a/contrib/tcpdump/tcpdump.c +++ b/contrib/tcpdump/tcpdump.c @@ -71,6 +71,8 @@ extern int SIZE_BUF; #ifdef __FreeBSD__ #include <sys/capability.h> #include <sys/ioccom.h> +#include <sys/types.h> +#include <sys/sysctl.h> #include <net/bpf.h> #include <fcntl.h> #include <libgen.h> @@ -1307,6 +1309,27 @@ main(int argc, char **argv) *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. */ + 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\nand use %s as the tcpdump " + "interface", device, newdev, parent, + newdev); + } +#endif else error("%s: %s", device, pcap_statustostr(status)); |