[PATCH net-next v10 08/10] test: Add proto_nums.py in networking selftests

Tom Herbert
2026-05-04T18:53:05Z

Add proto_nums.py that contains various python definitions of
common protocol constants

Signed-off-by: Tom Herbert <tom@herbertland.com>
---
tools/testing/selftests/net/Makefile | 1 +
tools/testing/selftests/net/proto_nums.py | 231 ++++++++++++++++++++++
2 files changed, 232 insertions(+)
create mode 100644 tools/testing/selftests/net/proto_nums.py

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index a275ed584026..21897ee81916 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -69,6 +69,7 @@ TEST_PROGS := \
nl_netdev.py \
nl_nlctrl.py \
pmtu.sh \
+ proto_nums.py \
psock_snd.sh \
reuseaddr_ports_exhausted.sh \
reuseport_addr_any.sh \
diff --git a/tools/testing/selftests/net/proto_nums.py b/tools/testing/selftests/net/proto_nums.py
new file mode 100644
index 000000000000..dc775164dacc
--- /dev/null
+++ b/tools/testing/selftests/net/proto_nums.py
@@ -0,0 +1,231 @@
+# SPDX-License-Identifier: GPL-2.0
+
+# Various protocol constant definitions
+
+from enum import Enum
+
+# IP protocol numbers
+class IP_Proto(Enum):
+ IP_PROTO_HOPOPT = 0
+ IP_PROTO_ICMP = 1
+ IP_PROTO_IGMP = 2
+ IP_PROTO_GGP = 3
+ IP_PROTO_IPv4 = 4
+ IP_PROTO_ST = 5
+ IP_PROTO_TCP = 6
+ IP_PROTO_CBT = 7
+ IP_PROTO_EGP = 8
+ IP_PROTO_IGP = 9
+ IP_PROTO_BBN_RCC_MON = 10
+ IP_PROTO_NVP_II = 11
+ IP_PROTO_PUP = 12
+ IP_PROTO_ARGUS = 13
+ IP_PROTO_EMCON = 14
+ IP_PROTO_XNET = 15
+ IP_PROTO_CHAOS = 16
+ IP_PROTO_UDP = 17
+ IP_PROTO_MUX = 18
+ IP_PROTO_DCN_MEAS = 19
+ IP_PROTO_HMP = 20
+ IP_PROTO_PRM = 21
+ IP_PROTO_XNS_IDP = 22
+ IP_PROTO_TRUNK_1 = 23
+ IP_PROTO_TRUNK_2 = 24
+ IP_PROTO_LEAF_1 = 25
+ IP_PROTO_LEAF_2 = 26
+ IP_PROTO_RDP = 27
+ IP_PROTO_IRTP = 28
+ IP_PROTO_ISO_TP4 = 29
+ IP_PROTO_NETBLT = 30
+ IP_PROTO_MFE_NSP = 31
+ IP_PROTO_MERIT_INP = 32
+ IP_PROTO_DCCP = 33
+ IP_PROTO_3PC = 34
+ IP_PROTO_IDPR = 35
+ IP_PROTO_XTP = 36
+ IP_PROTO_DDP = 37
+ IP_PROTO_IDPR_CMTP = 38
+ IP_PROTO_TP_PLUS_PLUS = 39
+ IP_PROTO_IL = 40
+ IP_PROTO_IPv6 = 41
+ IP_PROTO_SDRP = 42
+ IP_PROTO_IPv6_Route = 43
+ IP_PROTO_IPv6_Frag = 44
+ IP_PROTO_IDRP = 45
+ IP_PROTO_RSVP = 46
+ IP_PROTO_GRE = 47
+ IP_PROTO_DSR = 48
+ IP_PROTO_BNA = 49
+ IP_PROTO_ESP = 50
+ IP_PROTO_AH = 51
+ IP_PROTO_I_NLSP = 52
+ IP_PROTO_SWIPE = 53
+ IP_PROTO_NARP = 54
+ IP_PROTO_Min_IPv4 = 55
+ IP_PROTO_TLSP = 56
+ IP_PROTO_SKIP = 57
+ IP_PROTO_IPv6_ICMP = 58
+ IP_PROTO_IPv6_NoNxt = 59
+ IP_PROTO_IPv6_Opts = 60
+ IP_PROTO_any_1 = 61
+ IP_PROTO_CFTP = 62
+ IP_PROTO_any_2 = 63
+ IP_PROTO_SAT_EXPAK = 64
+ IP_PROTO_KRYPTOLAN = 65
+ IP_PROTO_RVD = 66
+ IP_PROTO_IPPC = 67
+ IP_PROTO_any_3 = 68
+ IP_PROTO_SAT_MON = 69
+ IP_PROTO_VISA = 70
+ IP_PROTO_IPCV = 71
+ IP_PROTO_CPNX = 72
+ IP_PROTO_CPHB = 73
+ IP_PROTO_WSN = 74
+ IP_PROTO_PVP = 75
+ IP_PROTO_BR_SAT_MON = 76
+ IP_PROTO_SUN_ND = 77
+ IP_PROTO_WB_MON = 78
+ IP_PROTO_WB_EXPAK = 79
+ IP_PROTO_ISO_IP = 80
+ IP_PROTO_VMTP = 81
+ IP_PROTO_SECURE_VMTP = 82
+ IP_PROTO_VINES = 83
+ IP_PROTO_IPTM = 84
+ IP_PROTO_NSFNET_IGP = 85
+ IP_PROTO_DGP = 86
+ IP_PROTO_TCF = 87
+ IP_PROTO_EIGRP = 88
+ IP_PROTO_OSPFIGP = 89
+ IP_PROTO_Sprite_RPC = 90
+ IP_PROTO_LARP = 91
+ IP_PROTO_MTP = 92
+ IP_PROTO_AX_25 = 93
+ IP_PROTO_IPIP = 94
+ IP_PROTO_MICP = 95
+ IP_PROTO_SCC_SP = 96
+ IP_PROTO_ETHERIP = 97
+ IP_PROTO_ENCAP = 98
+ IP_PROTO_any_4 = 99
+ IP_PROTO_GMTP = 100
+ IP_PROTO_IFMP = 101
+ IP_PROTO_PNNI = 102
+ IP_PROTO_PIM = 103
+ IP_PROTO_ARIS = 104
+ IP_PROTO_SCPS = 105
+ IP_PROTO_QNX = 106
+ IP_PROTO_A_N = 107
+ IP_PROTO_IPComp = 108
+ IP_PROTO_SNP = 109
+ IP_PROTO_Compaq_Peer = 110
+ IP_PROTO_IPX_in_IP = 111
+ IP_PROTO_VRRP = 112
+ IP_PROTO_PGM = 113
+ IP_PROTO_any_5 = 114
+ IP_PROTO_L2TP = 115
+ IP_PROTO_DDX = 116
+ IP_PROTO_IATP = 117
+ IP_PROTO_STP = 118
+ IP_PROTO_SRP = 119
+ IP_PROTO_UTI = 120
+ IP_PROTO_SMP = 121
+ IP_PROTO_SM = 122
+ IP_PROTO_PTP = 123
+ IP_PROTO_ISIS = 124
+ IP_PROTO_FIRE = 125
+ IP_PROTO_CRTP = 126
+ IP_PROTO_CRUDP = 127
+ IP_PROTO_SSCOPMCE = 128
+ IP_PROTO_IPLT = 129
+ IP_PROTO_SPS = 130
+ IP_PROTO_PIPE = 131
+ IP_PROTO_SCTP = 132
+ IP_PROTO_FC = 133
+ IP_PROTO_RSVP_E2E_IGNORE = 134
+ IP_PROTO_Mobility = 135
+ IP_PROTO_UDPLite = 136
+ IP_PROTO_MPLS_in_IP = 137
+ IP_PROTO_manet = 138
+ IP_PROTO_HIP = 139
+ IP_PROTO_Shim6 = 140
+ IP_PROTO_WESP = 141
+ IP_PROTO_ROHC = 142
+ IP_PROTO_Ethernet = 143
+ IP_PROTO_AGGFRAG = 144
+ IP_PROTO_NSH = 145
+ IP_PROTO_Homa = 146
+ IP_PROTO_BIT_EMU = 147
+
+# Hop-by-Hop and Destination Options numbers
+class HBHDst_Types(Enum):
+ HBHDST_TYPE_PAD1 = 0x0
+ HBHDST_TYPE_PADN = 0x1
+ HBHDST_TYPE_JUMBO = 0xc2
+ HBHDST_TYPE_RPL = 0x23
+ HBHDST_TYPE_RPL_DEPRECATED = 0x63
+ HBHDST_TYPE_TNL_ENCAP_LIMIT = 0x4
+ HBHDST_TYPE_ROUTER_ALERT = 0x5
+ HBHDST_TYPE_QUICK_START = 0x26
+ HBHDST_TYPE_CALIPSO = 0x7
+ HBHDST_TYPE_SMF_DPD = 0x8
+ HBHDST_TYPE_HAO = 0xc9
+ HBHDST_TYPE_ENDPOINT_ID = 0x8a
+ HBHDST_TYPE_ILNP_NONCE = 0x8b
+ HBHDST_TYPE_LINE_ID = 0x8c
+ HBHDST_TYPE_DEPRECATED = 0x4d
+ HBHDST_TYPE_MPL = 0x6d
+ HBHDST_TYPE_DFF = 0xee
+ HBHDST_TYPE_PDM = 0x0f
+ HBHDST_TYPE_MIN_PATH_MTU = 0x30
+ HBHDST_TYPE_IOAM_NO_CHNG = 0x11
+ HBHDST_TYPE_IOAM_CHNG = 0x31
+ HBHDST_TYPE_ALT_MARK = 0x12
+ HBHDST_TYPE_RFC3692_1 = 0x1e
+ HBHDST_TYPE_RFC3692_2 = 0x3e
+ HBHDST_TYPE_RFC3692_3 = 0x5e
+ HBHDST_TYPE_RFC3692_4 = 0x7e
+ HBHDST_TYPE_RFC3692_5 = 0x9e
+ HBHDST_TYPE_RFC3692_6 = 0xbe
+ HBHDST_TYPE_RFC3692_7 = 0xde
+
+# Routing header types
+class RoutingTypes(Enum):
+ ROUTING_TYPE_SRC_RT = 0
+ ROUTING_TYPE_NIMROD = 1
+ ROUTING_TYPE_2 = 2
+ ROUTING_TYPE_RPL = 3
+ ROUTING_TYPE_SRH = 4
+ ROUTING_TYPE_CRH16 = 5
+ ROUTING_TYPE_CRH32 = 6
+ ROUTING_TYPE_RFC3692_1 = 253
+ ROUTING_TYPE_RFC3692_2 = 254
+
+# Canonical extension header order
+class EH_Order(Enum):
+ IPV6_EXT_HDR_ORDER_HOP = 1 << 0
+ IPV6_EXT_HDR_ORDER_DEST_BEFORE_RH = 1 << 1
+ IPV6_EXT_HDR_ORDER_ROUTING = 1 << 2
+ IPV6_EXT_HDR_ORDER_FRAGMENT = 1 << 3
+ IPV6_EXT_HDR_ORDER_AUTH = 1 << 4
+ IPV6_EXT_HDR_ORDER_ESP = 1 << 5
+ IPV6_EXT_HDR_ORDER_DEST = 1 << 6
+
+# ICMPv6 types
+class ICMP6_Type(Enum):
+ ICMPV6_DEST_UNREACH = 1
+ ICMPV6_PKT_TOOBIG = 2
+ ICMPV6_TIME_EXCEED = 3
+ ICMPV6_PARAMPROB = 4
+ ICMPV6_ECHO_REQUEST = 128
+ ICMPV6_ECHO_REPLY = 129
+ ICMPV6_MGM_QUERY = 130
+ ICMPV6_MGM_REPORT = 131
+ ICMPV6_MGM_REDUCTION = 132
+ ICMPV6_NI_QUERY = 139
+ ICMPV6_NI_REPLY = 140
+ ICMPV6_MLD2_REPORT = 143
+ ICMPV6_DHAAD_REQUEST = 144
+ ICMPV6_DHAAD_REPLY = 145
+ ICMPV6_MOBILE_PREFIX_SOL = 146
+ ICMPV6_MOBILE_PREFIX_ADV = 147
+ ICMPV6_MRDISC_ADV = 151
+ ICMPV6_MRDISC_SOL = 152
--
2.43.0