From: Guy Harris Date: Sat, 21 Feb 2015 02:48:27 +0000 (-0800) Subject: Check for Wi-Fi interfaces and don't offer DOCSIS on them. X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/25429610d38b228480d39ee12c03a007b403e31c Check for Wi-Fi interfaces and don't offer DOCSIS on them. --- diff --git a/pcap-linux.c b/pcap-linux.c index 32f5be66..cae755f5 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -2631,7 +2631,7 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, const char *device, } /* - * This is (presumably) a real Ethernet capture; give it a + * Is this a real Ethernet device? If so, give it a * link-layer-type list with DLT_EN10MB and DLT_DOCSIS, so * that an application can let you choose it, in case you're * capturing DOCSIS traffic that a Cisco Cable Modem @@ -2645,16 +2645,27 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, const char *device, * a Cisco CMTS won't put traffic onto it or get traffic * bridged onto it? ISDN is handled in "activate_new()", * as we fall back on cooked mode there; are there any - * others? + * others, and we handle 802.11 devices by using + * pcap_can_set_rfmon_linux(); are there any others?? */ - handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); - /* - * If that fails, just leave the list empty. - */ - if (handle->dlt_list != NULL) { - handle->dlt_list[0] = DLT_EN10MB; - handle->dlt_list[1] = DLT_DOCSIS; - handle->dlt_count = 2; +#ifdef IW_MODE_MONITOR + if (has_wext(handle->fd, device, handle->errbuf) != 1) { + /* + * It supports the wireless extensions, so it's a Wi-Fi + * device; don't offer DOCSIS. + */ + } else +#endif + { + handle->dlt_list = (u_int *) malloc(sizeof(u_int) * 2); + /* + * If that fails, just leave the list empty. + */ + if (handle->dlt_list != NULL) { + handle->dlt_list[0] = DLT_EN10MB; + handle->dlt_list[1] = DLT_DOCSIS; + handle->dlt_count = 2; + } } /* FALLTHROUGH */