aboutsummaryrefslogtreecommitdiff
path: root/pcap-linux.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-08-25 13:26:43 -0700
committerGuy Harris <guy@alum.mit.edu>2016-08-25 13:26:43 -0700
commit93ca5ff7030aaf1219e1de05ec89a68384bfc50b (patch)
tree3db074cb78c17f25208875e0b9ea2e99691a8dd1 /pcap-linux.c
parent4c9aed03ed8c10215839a8fb845e8893790d0948 (diff)
On Linux, handle all CAN captures with pcap-linux.c, in cooked mode.
There's no need to support capturing on PF_CAN sockets; CAN interfaces show up as regular interfaces on which you can capture with PF_PACKET sockets, so just let pcap-linux.c handle them, and get rid of pcap-can-linux.c. Capture on them in cooked mode, so we get the protocol field and can distinguish between "classic" CAN and CAN FD. The hardware for which pcap-canusb-linux.c was intended never reached production: https://github.com/axos88/libpcap/commit/f3edbb599b8cbcc7e4560000dcba8e992dc11a31#commitcomment-18716617 so we don't need pcap-canusb-linux.c, either. This all removes the need for the "host-endian" link-layer header type; it never made it into a libpcap release, so we just remove it. The "big-endian" link-layer header type is kept for the benefit of packets captured with the old pcap-can-linux.c code; we revert it to its old name.
Diffstat (limited to 'pcap-linux.c')
-rw-r--r--pcap-linux.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/pcap-linux.c b/pcap-linux.c
index a2ace7b7..b7fb6889 100644
--- a/pcap-linux.c
+++ b/pcap-linux.c
@@ -2944,23 +2944,13 @@ static void map_arphrd_to_dlt(pcap_t *handle, int sock_fd, int arptype,
#endif
case ARPHRD_CAN:
/*
- * DLT_CAN_SOCKETCAN_BIGENDIAN is defined to have the
- * can_id field of the pseudo-header in big-endian
- * (network) byte order.
- *
- * The packets delivered to sockets have that field
- * in host byte order.
- *
- * The code that implements it in packet-can-linux.c
- * passes that field to htonl() to put it into network
- * byte order.
- *
- * The code that reads from a PF_PACKET socket doesn't
- * change the byte order of that field, so we define
- * a new DLT_CAN_SOCKETCAN_HOSTENDIAN, where the can_id
- * is in host byte order.
+ * Map this to DLT_LINUX_SLL; that way, CAN frames will
+ * have ETH_P_CAN/LINUX_SLL_P_CAN as the protocol and
+ * CAN FD frames will have ETH_P_CANFD/LINUX_SLL_P_CANFD
+ * as the protocol, so they can be distinguished by the
+ * protocol in the SLL header.
*/
- handle->linktype = DLT_CAN_SOCKETCAN_HOSTENDIAN;
+ handle->linktype = DLT_LINUX_SLL;
break;
#ifndef ARPHRD_IEEE802_TR