Handle ETH_P_CANFD as well as ETH_P_CAN.
authorGuy Harris <guy@alum.mit.edu>
Thu, 25 Aug 2016 23:58:25 +0000 (16:58 -0700)
committerGuy Harris <guy@alum.mit.edu>
Thu, 25 Aug 2016 23:58:57 +0000 (23:58 +0000)
Both of them need to have the CAN ID/flags field of the header
byte-swapped as necessary to make sure it's in the *reading* host's byte
order, not the *writing* host's byte order, if the two are different.

Change-Id: Iac1589fdd9fe4d9ee6fbac8d821b48694d68919b
Reviewed-on: https://code.wireshark.org/review/17333
Reviewed-by: Guy Harris <guy@alum.mit.edu>
wiretap/pcap-common.c

index 316e1a36c5a1fe9c16f8be74b3c1c3d1f9eead37..27e3fd687f5939d88ef4185d9817db80ef55d103 100644 (file)
@@ -750,6 +750,12 @@ wtap_encap_requires_phdr(int wtap_encap)
 #define LINUX_SLL_PROTOCOL_OFFSET      14      /* protocol */
 #define LINUX_SLL_LEN                  16      /* length of the header */
 
+/*
+ * The protocols we have to check for.
+ */
+#define LINUX_SLL_P_CAN                        0x000C  /* Controller Area Network */
+#define LINUX_SLL_P_CANFD              0x000D  /* Controller Area Network flexible data rate */
+
 /*
  * The fake link-layer header of IrDA packets as introduced by Jean Tourrilhes
  * to libpcap.
@@ -1206,7 +1212,7 @@ pcap_byteswap_linux_sll_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd)
        }
 
        protocol = pntoh16(&pd[LINUX_SLL_PROTOCOL_OFFSET]);
-       if (protocol != 0x000C) {
+       if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD) {
                /* Not a CAN packet; nothing to fix */
                return;
        }