aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2019-06-27 23:30:04 -0700
committerGuy Harris <guy@alum.mit.edu>2019-06-27 23:30:04 -0700
commite5721e93749a94d07957aaa6dd8fe284aa42fb5a (patch)
tree344c5bcf0c6bdd2448be711023a5881f949b17ff /pcap-linux.c
parentf542342e5e232c9ed522b99897cf7aedccc89fe8 (diff)
Report a warning for unkown link-layer header types on Linux and Windows.
That should help us fix those cases, by reporting the OS's link-layer type value.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index dd8795e5..0f7e47d5 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -3760,6 +3760,7 @@ activate_new(pcap_t *handle, int is_any_device)
{
struct pcap_linux *handlep = handle->priv;
const char *device = handle->opt.device;
+ int status = 0;
int sock_fd, arptype;
#ifdef HAVE_PACKET_AUXDATA
int val;
@@ -3863,6 +3864,10 @@ activate_new(pcap_t *handle, int is_any_device)
* type we can only determine by using
* APIs that may be different on different
* kernels) - reopen in cooked mode.
+ *
+ * If the type is unknown, return a warning;
+ * map_arphrd_to_dlt() has already set the
+ * warning message.
*/
if (close(sock_fd) == -1) {
pcap_fmt_errmsg_for_errno(handle->errbuf,
@@ -3932,6 +3937,12 @@ activate_new(pcap_t *handle, int is_any_device)
handle->linktype != DLT_LINUX_LAPD &&
handle->linktype != DLT_NETLINK)
handle->linktype = DLT_LINUX_SLL;
+ if (handle->linkype == -1) {
+ pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,
+ "unknown arptype %d, defaulting to cooked mode",
+ arptype);
+ status = PCAP_WARNING;
+ }
}
handlep->ifindex = iface_get_id(sock_fd, device,
@@ -4111,7 +4122,7 @@ activate_new(pcap_t *handle, int is_any_device)
}
#endif /* defined(SO_BPF_EXTENSIONS) && defined(SKF_AD_VLAN_TAG_PRESENT) */
- return 0;
+ return status;
}
#ifdef HAVE_PACKET_RING