aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlava Shwartsman <slavash@FreeBSD.org>2018-05-16 08:43:08 +0000
committerSlava Shwartsman <slavash@FreeBSD.org>2018-05-16 08:43:08 +0000
commit810711ec13a9424633df50e0a1af057a68e2ed45 (patch)
tree1f2d43e14346662552999f9cc06a8690dd0b7f08
parent4533b6d8a9b95fc043b72b3656b98e79ac839041 (diff)
downloadsrc-810711ec13a9424633df50e0a1af057a68e2ed45.tar.gz
src-810711ec13a9424633df50e0a1af057a68e2ed45.zip
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
Notes
Notes: svn path=/vendor/tcpdump/dist/; revision=333668
-rw-r--r--tcpdump.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/tcpdump.c b/tcpdump.c
index d9c7f7ab8f97..7e566c21654a 100644
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -108,6 +108,10 @@ The Regents of the University of California. All rights reserved.\n";
#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 *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. */
+ /* 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));