From 26d2d7b7cc99e6096d2efb24136610f5b89f3292 Mon Sep 17 00:00:00 2001 From: rpaulo Date: Wed, 31 Jul 2013 02:13:18 +0000 Subject: 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. --- contrib/tcpdump/tcpdump.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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 #include +#include +#include #include #include #include @@ -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)); -- cgit v1.1