summaryrefslogtreecommitdiff
path: root/tcpdump.c
diff options
context:
space:
mode:
authorRui Paulo <rpaulo@FreeBSD.org>2017-02-02 14:02:49 -0800
committerDenis Ovsienko <denis@ovsienko.info>2017-04-02 21:42:54 +0100
commitc1bb8784abd3ca978e376b0d10e324db0491237b (patch)
tree369fdf0f5238aa8b411efe16765832c5edd840f8 /tcpdump.c
parent99f6d01b24d037f4d69ad098f085d98e3d1b73b4 (diff)
downloadtcpdump-c1bb8784abd3ca978e376b0d10e324db0491237b.tar.gz
On a FreeBSD system 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.
Diffstat (limited to 'tcpdump.c')
-rw-r--r--tcpdump.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/tcpdump.c b/tcpdump.c
index ae6c736b..b69de64e 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -1092,6 +1092,26 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
} 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. */
+ 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));