]> The Tcpdump Group git mirrors - libpcap/commitdiff
Add DLT_CAN_SOCKETCAN, for capturing on the Controller Area Network with
authorGuy Harris <[email protected]>
Sun, 11 Oct 2009 17:16:21 +0000 (10:16 -0700)
committerGuy Harris <[email protected]>
Sun, 11 Oct 2009 17:16:21 +0000 (10:16 -0700)
Linux SocketCAN.

gencode.c
pcap.c
pcap/bpf.h
savefile.c

index 935e7ec8853e7b858b903b33cd894c3a65421d73..8d9a1c78428543381ad1aa55b8565488b3a5758a 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -1559,6 +1559,16 @@ init_linktype(p)
                off_nl = -1;
                off_nl_nosnap = -1;
                return;
+
+       case DLT_CAN_SOCKETCAN:
+               /*
+                * Currently, only raw "link[N:M]" filtering is supported.
+                */
+               off_linktype = -1;
+               off_macpl = -1;
+               off_nl = -1;
+               off_nl_nosnap = -1;
+               return;
        }
        bpf_error("unknown data link type %d", linktype);
        /* NOTREACHED */
@@ -3420,7 +3430,8 @@ gen_linktype(proto)
                bpf_error("Bluetooth link-layer type filtering not implemented");
 
        case DLT_CAN20B:
-               bpf_error("CAN20B link-layer type filtering not implemented");
+       case DLT_CAN_SOCKETCAN:
+               bpf_error("CAN link-layer type filtering not implemented");
 
        case DLT_IEEE802_15_4:
        case DLT_IEEE802_15_4_LINUX:
diff --git a/pcap.c b/pcap.c
index ccf1d706d5f63d0ffbefb1b387ed00a6c2ee06a8..fc5af1bf78429d585c997d6dcb8d8bdeb05ac512 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -657,6 +657,13 @@ static struct dlt_choice dlt_choices[] = {
        DLT_CHOICE(DLT_IEEE802_15_4_NONASK_PHY, "IEEE 802.15.4 with non-ASK PHY data"),
        DLT_CHOICE(DLT_MPLS, "MPLS with label as link-layer header"),
        DLT_CHOICE(DLT_USB_LINUX_MMAPPED, "USB with padded Linux header"),
+       DLT_CHOICE(DLT_DECT, "DECT"),
+       DLT_CHOICE(DLT_AOS, "AOS Space Data Link protocol"),
+       DLT_CHOICE(DLT_WIHART, "Wireless HART"),
+       DLT_CHOICE(DLT_FC_2, "Fibre Channel FC-2"),
+       DLT_CHOICE(DLT_FC_2_WITH_FRAME_DELIMS, "Fibre Channel FC-2 with frame delimiters"),
+       DLT_CHOICE(DLT_IPNET, "Solaris ipnet"),
+       DLT_CHOICE(DLT_CAN_SOCKETCAN, "CAN-bus with SocketCAN headers"),
        DLT_CHOICE_SENTINEL
 };
 
index 91f33eb57264d07bc1c0232f88b91ac2ad6fb869..b5f5ed2fc689dfaa63b1736015ad51ed008c5094 100644 (file)
@@ -944,6 +944,15 @@ struct bpf_version {
  */
 #define DLT_IPNET                      226
 
+/*
+ * CAN (Controller Area Network) frames, with a pseudo-header as supplied
+ * by Linux SocketCAN.  See Documentation/networking/can.txt in the Linux
+ * source.
+ *
+ * Requested by Felix Obenhuber <[email protected]>.
+ */
+#define DLT_CAN_SOCKETCAN              227
+
 
 /*
  * DLT and savefile link type values are split into a class and
index 67da51fd629f82f50e0b19088ba2b584a54415c8..4832f34f2da97502dc8a01607fe2eb692c11d399 100644 (file)
@@ -784,6 +784,15 @@ static const char rcsid[] _U_ =
  */
 #define LINKTYPE_IPNET                         226
 
+/*
+ * CAN (Controller Area Network) frames, with a pseudo-header as supplied
+ * by Linux SocketCAN.  See Documentation/networking/can.txt in the Linux
+ * source.
+ *
+ * Requested by Felix Obenhuber <[email protected]>.
+ */
+#define LINKTYPE_CAN_SOCKETCAN                 227
+
 
 static struct linktype_map {
        int     dlt;
@@ -1123,6 +1132,9 @@ static struct linktype_map {
        /* Solaris IPNET */
        { DLT_IPNET,            LINKTYPE_IPNET },
 
+       /* CAN frames with SocketCAN headers */
+       { DLT_CAN_SOCKETCAN,    LINKTYPE_CAN_SOCKETCAN },
+
        { -1,                   -1 }
 };