summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Syromyatnikov <evgsyr@gmail.com>2018-02-16 19:01:24 +0100
committerDmitry V. Levin <ldv@altlinux.org>2018-03-07 18:13:29 +0000
commit9495ddada47c0c04ef9aee9a7588dab5349f5566 (patch)
treeec06bf6b4bdb8111f0d616c4c244c0314d2b9b3c
parent9611ebbb97ad639fbb77d200dee4305b834a23b1 (diff)
downloadstrace-9495ddada47c0c04ef9aee9a7588dab5349f5566.tar.gz
Sort Ethernet protocols xlat
* defs.h (ethernet_protocols_size): New declaration. * netlink_packet_diag.c (decode_packet_diag_req): Use printxval_searchnn to print Ethernet protocols. * sockaddr.c (ethernet_protocols_size): New constant, item count in ethernet_protocols array. (print_sockaddr_data_ll): Use printxval_search instead of printxval to print Ethernet protocols. * xlat/ethernet_protocols.in: Sort it by value, add comment about the fact. Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
-rw-r--r--defs.h5
-rw-r--r--netlink_packet_diag.c6
-rw-r--r--sockaddr.c5
-rw-r--r--xlat/ethernet_protocols.in63
4 files changed, 45 insertions, 34 deletions
diff --git a/defs.h b/defs.h
index 6eb4b2450..8e30d86b3 100644
--- a/defs.h
+++ b/defs.h
@@ -283,7 +283,12 @@ extern const struct xlat arp_hardware_types[];
extern const struct xlat at_flags[];
extern const struct xlat clocknames[];
extern const struct xlat dirent_types[];
+
+/** Ethernet protocols list, sorted and unterminated, defined in sockaddr.c. */
extern const struct xlat ethernet_protocols[];
+/** Ethernet protocols array size without terminating record. */
+extern const size_t ethernet_protocols_size;
+
extern const struct xlat evdev_abs[];
extern const struct xlat iffflags[];
extern const struct xlat inet_protocols[];
diff --git a/netlink_packet_diag.c b/netlink_packet_diag.c
index 495238360..db688a9f9 100644
--- a/netlink_packet_diag.c
+++ b/netlink_packet_diag.c
@@ -52,8 +52,10 @@ DECL_NETLINK_DIAG_DECODER(decode_packet_diag_req)
if (!umoven_or_printaddr(tcp, addr + offset,
sizeof(req) - offset,
(char *) &req + offset)) {
- PRINT_FIELD_XVAL("", req, sdiag_protocol,
- ethernet_protocols, "ETH_P_???");
+ tprints("sdiag_protocol=");
+ printxval_searchn(ethernet_protocols,
+ ethernet_protocols_size,
+ req.sdiag_protocol, "ETH_P_???");
PRINT_FIELD_U(", ", req, pdiag_ino);
PRINT_FIELD_FLAGS(", ", req, pdiag_show,
packet_diag_show, "PACKET_SHOW_???");
diff --git a/sockaddr.c b/sockaddr.c
index ac42e164a..9c369cda7 100644
--- a/sockaddr.c
+++ b/sockaddr.c
@@ -66,6 +66,8 @@
#define SIZEOF_SA_FAMILY sizeof(((struct sockaddr *) 0)->sa_family)
+const size_t ethernet_protocols_size = ARRAY_SIZE(ethernet_protocols) - 1;
+
static void
print_sockaddr_data_un(const void *const buf, const int addrlen)
{
@@ -223,7 +225,8 @@ print_sockaddr_data_ll(const void *const buf, const int addrlen)
const struct sockaddr_ll *const sa_ll = buf;
tprints("sll_protocol=htons(");
- printxval(ethernet_protocols, ntohs(sa_ll->sll_protocol), "ETH_P_???");
+ printxval_search(ethernet_protocols, ntohs(sa_ll->sll_protocol),
+ "ETH_P_???");
PRINT_FIELD_IFINDEX("), ", *sa_ll, sll_ifindex);
tprints(", sll_hatype=");
printxval(arp_hardware_types, sa_ll->sll_hatype, "ARPHRD_???");
diff --git a/xlat/ethernet_protocols.in b/xlat/ethernet_protocols.in
index b11ccbe35..4420e12a5 100644
--- a/xlat/ethernet_protocols.in
+++ b/xlat/ethernet_protocols.in
@@ -1,14 +1,42 @@
+/* Sorted by value */
+ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
+ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
+ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
+ETH_P_802_2 0x0004 /* 802.2 frames */
+ETH_P_SNAP 0x0005 /* Internal only */
+ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
+ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
+ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
+ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
+ETH_P_CAN 0x000C /* CAN: Controller Area Network */
+ETH_P_CANFD 0x000D /* CANFD: CAN flexible data rate*/
+ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
+ETH_P_TR_802_2 0x0011 /* 802.2 frames */
+ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
+ETH_P_CONTROL 0x0016 /* Card specific control frames */
+ETH_P_IRDA 0x0017 /* Linux-IrDA */
+ETH_P_ECONET 0x0018 /* Acorn Econet */
+ETH_P_HDLC 0x0019 /* HDLC frames */
+ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */
+ETH_P_DSA 0x001B /* Distributed Switch Arch. */
+ETH_P_TRAILER 0x001C /* Trailer switch tagging */
ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */
+ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */
+ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */
+ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */
+ETH_P_XDSA 0x00F8 /* Multiplexed DSA protocol */
+ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and aggregation protocol */
ETH_P_PUP 0x0200 /* Xerox PUP packet */
ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */
-ETH_P_TSN 0x22F0 /* TSN (IEEE 1722) packet */
-ETH_P_ERSPAN2 0x22EB /* ERSPAN version 2 (type III) */
+ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value then the frame is Ethernet II. Else it is 802.3 */
ETH_P_IP 0x0800 /* Internet Protocol packet */
ETH_P_X25 0x0805 /* CCITT X.25 */
ETH_P_ARP 0x0806 /* Address Resolution packet */
ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */
ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */
ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */
+ETH_P_ERSPAN2 0x22EB /* ERSPAN version 2 (type III) */
+ETH_P_TSN 0x22F0 /* TSN (IEEE 1722) packet */
ETH_P_BATMAN 0x4305 /* B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] */
ETH_P_DEC 0x6000 /* DEC Assigned proto */
ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */
@@ -23,7 +51,6 @@ ETH_P_RARP 0x8035 /* Reverse Addr Res packet */
ETH_P_ATALK 0x809B /* Appletalk DDP */
ETH_P_AARP 0x80F3 /* Appletalk AARP */
ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */
-ETH_P_ERSPAN 0x88BE /* ERSPAN type II */
ETH_P_IPX 0x8137 /* IPX over DIX */
ETH_P_IPV6 0x86DD /* IPv6 over bluebook */
ETH_P_PAUSE 0x8808 /* IEEE Pause frames. See 802.3 31B */
@@ -40,6 +67,7 @@ ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
ETH_P_AOE 0x88A2 /* ATA over Ethernet */
ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */
ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */
+ETH_P_ERSPAN 0x88BE /* ERSPAN type II */
ETH_P_TIPC 0x88CA /* TIPC */
ETH_P_MACSEC 0x88E5 /* 802.1ae MACsec */
ETH_P_8021AH 0x88E7 /* 802.1ah Backbone Service Tag */
@@ -48,9 +76,9 @@ ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
ETH_P_NCSI 0x88F8 /* NCSI protocol */
ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */
ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
-ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */
ETH_P_TDLS 0x890D /* TDLS */
ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */
+ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */
ETH_P_80221 0x8917 /* IEEE 802.21 Media Independent Handover Protocol */
ETH_P_HSR 0x892F /* IEC 62439-3 HSRv1 */
ETH_P_NSH 0x894F /* Network Service Header */
@@ -61,30 +89,3 @@ ETH_P_QINQ3 0x9300 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ]
ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */
ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */
ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */
-ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value then the frame is Ethernet II. Else it is 802.3 */
-ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */
-ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */
-ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */
-ETH_P_802_2 0x0004 /* 802.2 frames */
-ETH_P_SNAP 0x0005 /* Internal only */
-ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */
-ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/
-ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */
-ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */
-ETH_P_CAN 0x000C /* CAN: Controller Area Network */
-ETH_P_CANFD 0x000D /* CANFD: CAN flexible data rate*/
-ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/
-ETH_P_TR_802_2 0x0011 /* 802.2 frames */
-ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */
-ETH_P_CONTROL 0x0016 /* Card specific control frames */
-ETH_P_IRDA 0x0017 /* Linux-IrDA */
-ETH_P_ECONET 0x0018 /* Acorn Econet */
-ETH_P_HDLC 0x0019 /* HDLC frames */
-ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */
-ETH_P_DSA 0x001B /* Distributed Switch Arch. */
-ETH_P_TRAILER 0x001C /* Trailer switch tagging */
-ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */
-ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */
-ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */
-ETH_P_XDSA 0x00F8 /* Multiplexed DSA protocol */
-ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and aggregation protocol */