]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-linux.c
Add support for CANbus capture.
[libpcap] / pcap-linux.c
index 9703040f183298c3a0d04c5363d27c2528802f68..22339d6e9a58899b9b739b7ed0072e80924a44ca 100644 (file)
@@ -176,6 +176,10 @@ static const char rcsid[] _U_ =
 #include "pcap-bt-linux.h"
 #endif
 
+#ifdef PCAP_SUPPORT_CAN
+#include "pcap-can-linux.h"
+#endif
+
 /*
  * If PF_PACKET is defined, we can use {SOCK_RAW,SOCK_DGRAM}/PF_PACKET
  * sockets rather than SOCK_PACKET sockets.
@@ -376,6 +380,12 @@ pcap_create(const char *device, char *ebuf)
        }
 #endif
 
+#ifdef PCAP_SUPPORT_CAN
+       if (strstr(device, "can") || strstr(device, "vcan")) {
+               return can_create(device, ebuf);
+       }
+#endif
+
 #ifdef PCAP_SUPPORT_USB
        if (strstr(device, "usbmon")) {
                return usb_create(device, ebuf);
@@ -2073,6 +2083,12 @@ static void map_arphrd_to_dlt(pcap_t *handle, int arptype, int cooked_ok)
        case ARPHRD_CHAOS:
                handle->linktype = DLT_CHAOS;
                break;
+#ifndef ARPHRD_CAN
+#define ARPHRD_CAN 280
+#endif
+       case ARPHRD_CAN:
+               handle->linktype = DLT_CAN_SOCKETCAN;
+               break;
 
 #ifndef ARPHRD_IEEE802_TR
 #define ARPHRD_IEEE802_TR 800  /* From Linux 2.4 */