From c8157aa6b4afdbc2f84779ffbeea4f8d3bdc8666 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 25 Aug 2016 14:14:11 -0700 Subject: [PATCH] Go back to having only one SocketCAN LINKTYPE_ value. Libpcap just backed out the "host-endian" SocketCAN LINKTYPE_ value; we don't need it any more. Change-Id: I33a7dc21207a0009e20b4abaefe1119eb649c39a Reviewed-on: https://code.wireshark.org/review/17327 Reviewed-by: Guy Harris --- epan/dissectors/packet-socketcan.c | 4 +-- test/lua/globals_2.2.txt | 3 +-- wiretap/pcap-common.c | 43 ++---------------------------- wiretap/wtap.h | 3 +-- 4 files changed, 5 insertions(+), 48 deletions(-) diff --git a/epan/dissectors/packet-socketcan.c b/epan/dissectors/packet-socketcan.c index eaa73ceaf0..d5aa554a61 100644 --- a/epan/dissectors/packet-socketcan.c +++ b/epan/dissectors/packet-socketcan.c @@ -285,12 +285,10 @@ proto_reg_handoff_socketcan(void) socketcan_bigendian_handle = create_dissector_handle(dissect_socketcan_bigendian, proto_can); - dissector_add_uint("wtap_encap", WTAP_ENCAP_SOCKETCAN_BIGENDIAN, + dissector_add_uint("wtap_encap", WTAP_ENCAP_SOCKETCAN, socketcan_bigendian_handle); socketcan_hostendian_handle = create_dissector_handle(dissect_socketcan_hostendian, proto_can); - dissector_add_uint("wtap_encap", WTAP_ENCAP_SOCKETCAN_HOSTENDIAN, - socketcan_hostendian_handle); dissector_add_uint("sll.ltype", LINUX_SLL_P_CAN, socketcan_hostendian_handle); } diff --git a/test/lua/globals_2.2.txt b/test/lua/globals_2.2.txt index 7813601b43..77b0f85fec 100644 --- a/test/lua/globals_2.2.txt +++ b/test/lua/globals_2.2.txt @@ -1123,8 +1123,7 @@ ["SITA"] = 100, ["SLIP"] = 3, ["SLL"] = 25, - ["SOCKETCAN_BIGENDIAN"] = 125, - ["SOCKETCAN_HOSTENDIAN"] = 182, + ["SOCKETCAN"] = 125, ["STANAG_4607"] = 156, ["STANAG_5066_D_PDU"] = 157, ["SYMANTEC"] = 61, diff --git a/wiretap/pcap-common.c b/wiretap/pcap-common.c index 57b2207dce..316e1a36c5 100644 --- a/wiretap/pcap-common.c +++ b/wiretap/pcap-common.c @@ -378,8 +378,8 @@ static const struct { { 225, WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS }, /* Solaris IPNET */ { 226, WTAP_ENCAP_IPNET }, - /* SocketCAN frame, with CAN ID in big-endian byte order */ - { 227, WTAP_ENCAP_SOCKETCAN_BIGENDIAN }, + /* SocketCAN frame */ + { 227, WTAP_ENCAP_SOCKETCAN }, /* Raw IPv4 */ { 228, WTAP_ENCAP_RAW_IP4 }, /* Raw IPv6 */ @@ -437,9 +437,6 @@ static const struct { /* ISO14443 contactless smartcard standards */ { 264, WTAP_ENCAP_ISO14443 }, - /* SocketCAN frame, with CAN ID in host-endian byte order */ - { 265, WTAP_ENCAP_SOCKETCAN_HOSTENDIAN }, - /* * To repeat: * @@ -1387,37 +1384,6 @@ pcap_byteswap_nflog_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) } } -static void -pcap_byteswap_can_socketcan_pseudoheader(struct wtap_pkthdr *phdr, guint8 *pd) -{ - guint packet_size; - struct can_socketcan_hdr *can_socketcan_phdr; - - /* - * Minimum of captured and actual length (just in case the - * actual length < the captured length, which Should Never - * Happen). - */ - packet_size = phdr->caplen; - if (packet_size > phdr->len) - packet_size = phdr->len; - - /* - * Greasy hack, but we never directly dereference any of - * the fields in *can_socketcan_phdr, we just get offsets - * of and addresses of its members and byte-swap it with a - * byte-at-a-time macro, so it's alignment-safe. - */ - can_socketcan_phdr = (struct can_socketcan_hdr *)(void *)pd; - - if (packet_size < sizeof(can_socketcan_phdr->can_id)) { - /* Not enough data to have the full CAN ID */ - return; - } - - PBSWAP32((guint8 *)&can_socketcan_phdr->can_id); -} - /* * Pseudo-header at the beginning of DLT_BLUETOOTH_HCI_H4_WITH_PHDR frames. * Values in network byte order. @@ -2000,11 +1966,6 @@ pcap_read_post_process(int file_type, int wtap_encap, phdr->caplen = MIN(phdr->len, phdr->caplen); break; - case WTAP_ENCAP_SOCKETCAN_HOSTENDIAN: - if (bytes_swapped) - pcap_byteswap_can_socketcan_pseudoheader(phdr, pd); - break; - default: break; } diff --git a/wiretap/wtap.h b/wiretap/wtap.h index fc73ebe5c9..20a3b188f3 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -212,7 +212,7 @@ extern "C" { #define WTAP_ENCAP_FIBRE_CHANNEL_FC2_WITH_FRAME_DELIMS 122 #define WTAP_ENCAP_JPEG_JFIF 123 /* obsoleted by WTAP_ENCAP_MIME*/ #define WTAP_ENCAP_IPNET 124 -#define WTAP_ENCAP_SOCKETCAN_BIGENDIAN 125 +#define WTAP_ENCAP_SOCKETCAN 125 #define WTAP_ENCAP_IEEE_802_11_NETMON 126 #define WTAP_ENCAP_IEEE802_15_4_NOFCS 127 #define WTAP_ENCAP_RAW_IPFIX 128 @@ -269,7 +269,6 @@ extern "C" { #define WTAP_ENCAP_GFP_F 179 #define WTAP_ENCAP_IP_OVER_IB_PCAP 180 #define WTAP_ENCAP_JUNIPER_VN 181 -#define WTAP_ENCAP_SOCKETCAN_HOSTENDIAN 182 /* After adding new item here, please also add new item to encap_table_base array */ #define WTAP_NUM_ENCAP_TYPES wtap_get_num_encap_types()