1 /*
2 * Redistribution and use in source and binary forms, with or without
3 * modification, are permitted provided that: (1) source code
4 * distributions retain the above copyright notice and this paragraph
5 * in its entirety, and (2) distributions including binary code include
6 * the above copyright notice and this paragraph in its entirety in
7 * the documentation or other materials provided with the distribution.
8 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND
9 * WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
10 * LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
11 * FOR A PARTICULAR PURPOSE.
12 *
13 * Original code by Hannes Gredler (hannes@gredler.at)
14 */
15
16 #include <config.h>
17
18 #include "netdissect-stdinc.h"
19
20 #include "netdissect.h"
21 #include "ipproto.h"
22
23 const struct tok ipproto_values[] = {
24 { IPPROTO_HOPOPTS, "Options" },
25 { IPPROTO_ICMP, "ICMP" },
26 { IPPROTO_IGMP, "IGMP" },
27 { IPPROTO_IPV4, "IPIP" },
28 { IPPROTO_TCP, "TCP" },
29 { IPPROTO_EGP, "EGP" },
30 { IPPROTO_PIGP, "IGRP" },
31 { IPPROTO_UDP, "UDP" },
32 { IPPROTO_DCCP, "DCCP" },
33 { IPPROTO_IPV6, "IPv6" },
34 { IPPROTO_ROUTING, "Routing" },
35 { IPPROTO_FRAGMENT, "Fragment" },
36 { IPPROTO_RSVP, "RSVP" },
37 { IPPROTO_GRE, "GRE" },
38 { IPPROTO_ESP, "ESP" },
39 { IPPROTO_AH, "AH" },
40 { IPPROTO_MOBILE, "Mobile IP" },
41 { IPPROTO_ICMPV6, "ICMPv6" },
42 { IPPROTO_MOBILITY_OLD, "Mobile IP (old)" },
43 { IPPROTO_EIGRP, "EIGRP" },
44 { IPPROTO_OSPF, "OSPF" },
45 { IPPROTO_PIM, "PIM" },
46 { IPPROTO_IPCOMP, "Compressed IP" },
47 { IPPROTO_VRRP, "VRRP" }, /* See also CARP. */
48 { IPPROTO_PGM, "PGM" },
49 { IPPROTO_SCTP, "SCTP" },
50 { IPPROTO_MOBILITY, "Mobility" },
51 { IPPROTO_PFSYNC, "pfsync" },
52 { IPPROTO_ETHERNET, "Ethernet" },
53 { 0, NULL }
54 };
55
56 /*
57 * For completeness the number space in the array below comes from IANA:
58 * https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
59 * However, the spelling tries to match that of /etc/protocols to achieve as
60 * much consistency as possible with the previously implemented behaviour,
61 * which was based on getprotobynumber (3).
62 */
63 static const char *netdb_protocol_names[256] = {
64 "hopopt", /* 0 (IPPROTO_HOPOPTS, IPv6 Hop-by-Hop Option) */
65 "icmp", /* 1 (IPPROTO_ICMP, Internet Control Message) */
66 "igmp", /* 2 (IPPROTO_IGMP, Internet Group Management) */
67 "ggp", /* 3 (Gateway-to-Gateway) */
68 "ipencap", /* 4 (IPPROTO_IPV4, IPv4 encapsulation) */
69 "st", /* 5 (Stream, ST datagram mode) */
70 "tcp", /* 6 (IPPROTO_TCP, Transmission Control) */
71 "cbt", /* 7 (CBT) */
72 "egp", /* 8 (IPPROTO_EGP, Exterior Gateway Protocol) */
73 "igp", /* 9 (IPPROTO_PIGP, "any private interior gateway
74 * (used by Cisco for their IGRP)")
75 */
76 "bbn-rcc-mon", /* 10 (BBN RCC Monitoring) */
77 "nvp-ii", /* 11 (Network Voice Protocol) */
78 "pup", /* 12 (PARC universal packet protocol) */
79 "argus", /* 13 (ARGUS) */
80 "emcon", /* 14 (EMCON) */
81 "xnet", /* 15 (Cross Net Debugger) */
82 "chaos", /* 16 (Chaos) */
83 "udp", /* 17 (IPPROTO_UDP, User Datagram) */
84 "mux", /* 18 (Multiplexing) */
85 "dcn-meas", /* 19 (DCN Measurement Subsystems) */
86 "hmp", /* 20 (Host Monitoring) */
87 "prm", /* 21 (Packet Radio Measurement) */
88 "xns-idp", /* 22 (XEROX NS IDP) */
89 "trunk-1", /* 23 (Trunk-1) */
90 "trunk-2", /* 24 (Trunk-2) */
91 "leaf-1", /* 25 (Leaf-1) */
92 "leaf-2", /* 26 (Leaf-2) */
93 "rdp", /* 27 (Reliable Data Protocol) */
94 "irtp", /* 28 (Internet Reliable Transaction) */
95 "iso-tp4", /* 29 (ISO Transport Protocol Class 4) */
96 "netblt", /* 30 (Bulk Data Transfer Protocol) */
97 "mfe-nsp", /* 31 (MFE Network Services Protocol) */
98 "merit-inp", /* 32 (MERIT Internodal Protocol) */
99 "dccp", /* 33 (IPPROTO_DCCP, Datagram Congestion
100 * Control Protocol)
101 */
102 "3pc", /* 34 (Third Party Connect Protocol) */
103 "idpr", /* 35 (Inter-Domain Policy Routing Protocol) */
104 "xtp", /* 36 (Xpress Transfer Protocol) */
105 "ddp", /* 37 (Datagram Delivery Protocol) */
106 "idpr-cmtp", /* 38 (IDPR Control Message Transport Proto) */
107 "tp++", /* 39 (TP++ Transport Protocol) */
108 "il", /* 40 (IL Transport Protocol) */
109 "ipv6", /* 41 (IPPROTO_IPV6, IPv6 encapsulation) */
110 "sdrp", /* 42 (Source Demand Routing Protocol) */
111 "ipv6-route", /* 43 (IPPROTO_ROUTING, Routing Header for IPv6) */
112 "ipv6-frag", /* 44 (IPPROTO_FRAGMENT, Fragment Header for
113 * IPv6)
114 */
115 "idrp", /* 45 (Inter-Domain Routing Protocol) */
116 "rsvp", /* 46 (IPPROTO_RSVP, Reservation Protocol) */
117 "gre", /* 47 (IPPROTO_GRE, Generic Routing
118 * Encapsulation)
119 */
120 "dsr", /* 48 (Dynamic Source Routing Protocol) */
121 "bna", /* 49 (BNA) */
122 "esp", /* 50 (IPPROTO_ESP, Encap Security Payload) */
123 "ah", /* 51 (IPPROTO_AH, Authentication Header) */
124 "i-nlsp", /* 52 (Integrated Net Layer Security TUBA) */
125 "swipe", /* 53 (IP with Encryption) */
126 "narp", /* 54 (NBMA Address Resolution Protocol) */
127 "mobile", /* 55 (IPPROTO_MOBILE, IP Mobility) */
128 "tlsp", /* 56 (Transport Layer Security Protocol using
129 * Kryptonet key management)
130 */
131 "skip", /* 57 (SKIP) */
132 "ipv6-icmp", /* 58 (IPPROTO_ICMPV6, ICMP for IPv6) */
133 "ipv6-nonxt", /* 59 (IPPROTO_NONE, No Next Header for IPv6) */
134 "ipv6-opts", /* 60 (IPPROTO_DSTOPTS, Destination Options for
135 * IPv6)
136 */
137 NULL, /* 61 (any host internal protocol) */
138 "cftp", /* 62 (IPPROTO_MOBILITY_OLD, CFTP, see the note
139 * in ipproto.h)
140 */
141 NULL, /* 63 (any local network) */
142 "sat-expak", /* 64 (SATNET and Backroom EXPAK) */
143 "kryptolan", /* 65 (Kryptolan) */
144 "rvd", /* 66 (MIT Remote Virtual Disk Protocol) */
145 "ippc", /* 67 (Internet Pluribus Packet Core) */
146 NULL, /* 68 (any distributed file system) */
147 "sat-mon", /* 69 (SATNET Monitoring) */
148 "visa", /* 70 (VISA Protocol) */
149 "ipcv", /* 71 (Internet Packet Core Utility) */
150 "cpnx", /* 72 (Computer Protocol Network Executive) */
151 "rspf", /* 73 (Radio Shortest Path First, CPHB -- Computer
152 * Protocol Heart Beat -- in IANA)
153 */
154 "wsn", /* 74 (Wang Span Network) */
155 "pvp", /* 75 (Packet Video Protocol) */
156 "br-sat-mon", /* 76 (Backroom SATNET Monitoring) */
157 "sun-nd", /* 77 (IPPROTO_ND, SUN ND PROTOCOL-Temporary) */
158 "wb-mon", /* 78 (WIDEBAND Monitoring) */
159 "wb-expak", /* 79 (WIDEBAND EXPAK) */
160 "iso-ip", /* 80 (ISO Internet Protocol) */
161 "vmtp", /* 81 (Versatile Message Transport) */
162 "secure-vmtp", /* 82 (Secure VMTP) */
163 "vines", /* 83 (VINES) */
164 "ttp", /* 84 (Transaction Transport Protocol, also IPTM --
165 * Internet Protocol Traffic Manager)
166 */
167 "nsfnet-igp", /* 85 (NSFNET-IGP) */
168 "dgp", /* 86 (Dissimilar Gateway Protocol) */
169 "tcf", /* 87 (TCF) */
170 "eigrp", /* 88 (IPPROTO_EIGRP, Cisco EIGRP) */
171 "ospf", /* 89 (IPPROTO_OSPF, Open Shortest Path First
172 * IGP)
173 */
174 "sprite-rpc", /* 90 (Sprite RPC Protocol) */
175 "larp", /* 91 (Locus Address Resolution Protocol) */
176 "mtp", /* 92 (Multicast Transport Protocol) */
177 "ax.25", /* 93 (AX.25 Frames) */
178 "ipip", /* 94 (IP-within-IP Encapsulation Protocol) */
179 "micp", /* 95 (Mobile Internetworking Control Pro.) */
180 "scc-sp", /* 96 (Semaphore Communications Sec. Pro.) */
181 "etherip", /* 97 (Ethernet-within-IP Encapsulation) */
182 "encap", /* 98 (Encapsulation Header) */
183 NULL, /* 99 (any private encryption scheme) */
184 "gmtp", /* 100 (GMTP) */
185 "ifmp", /* 101 (Ipsilon Flow Management Protocol) */
186 "pnni", /* 102 (PNNI over IP) */
187 "pim", /* 103 (IPPROTO_PIM, Protocol Independent
188 * Multicast)
189 */
190 "aris", /* 104 (ARIS) */
191 "scps", /* 105 (SCPS) */
192 "qnx", /* 106 (QNX) */
193 "a/n", /* 107 (Active Networks) */
194 "ipcomp", /* 108 (IPPROTO_IPCOMP, IP Payload Compression
195 * Protocol)
196 */
197 "snp", /* 109 (Sitara Networks Protocol) */
198 "compaq-peer", /* 110 (Compaq Peer Protocol) */
199 "ipx-in-ip", /* 111 (IPX in IP) */
200 "vrrp", /* 112 (IPPROTO_VRRP, Virtual Router Redundancy
201 * Protocol)
202 */
203 "pgm", /* 113 (IPPROTO_PGM, PGM Reliable Transport
204 * Protocol)
205 */
206 NULL, /* 114 (any 0-hop protocol) */
207 "l2tp", /* 115 (Layer Two Tunneling Protocol) */
208 "ddx", /* 116 (D-II Data Exchange (DDX)) */
209 "iatp", /* 117 (Interactive Agent Transfer Protocol) */
210 "stp", /* 118 (Schedule Transfer Protocol) */
211 "srp", /* 119 (SpectraLink Radio Protocol) */
212 "uti", /* 120 (UTI) */
213 "smp", /* 121 (Simple Message Protocol) */
214 "sm", /* 122 (Simple Multicast Protocol) */
215 "ptp", /* 123 (Performance Transparency Protocol) */
216 "isis", /* 124 (ISIS over IPv4) */
217 "fire", /* 125 (FIRE) */
218 "crtp", /* 126 (Combat Radio Transport Protocol) */
219 "crudp", /* 127 (Combat Radio User Datagram) */
220 "sscopmce", /* 128 (SSCOPMCE) */
221 "iplt", /* 129 (IPLT) */
222 "sps", /* 130 (Secure Packet Shield) */
223 "pipe", /* 131 (Private IP Encapsulation within IP) */
224 "sctp", /* 132 (IPPROTO_SCTP, Stream Control Transmission
225 * Protocol)
226 */
227 "fc", /* 133 (Fibre Channel) */
228 "rsvp-e2e-ignore", /* 134 (RSVP-E2E-IGNORE) */
229 "mobility-header", /* 135 (IPPROTO_MOBILITY, Mobility Header) */
230 "udplite", /* 136 (UDPLite) */
231 "mpls-in-ip", /* 137 (MPLS-in-IP) */
232 "manet", /* 138 (MANET Protocols) */
233 "hip", /* 139 (Host Identity Protocol) */
234 "shim6", /* 140 (Shim6 Protocol) */
235 "wesp", /* 141 (Wrapped Encapsulating Security Payload) */
236 "rohc", /* 142 (Robust Header Compression) */
237 NULL, /* 143 (unassigned) */
238 NULL, /* 144 (unassigned) */
239 NULL, /* 145 (unassigned) */
240 NULL, /* 146 (unassigned) */
241 NULL, /* 147 (unassigned) */
242 NULL, /* 148 (unassigned) */
243 NULL, /* 149 (unassigned) */
244 NULL, /* 150 (unassigned) */
245 NULL, /* 151 (unassigned) */
246 NULL, /* 152 (unassigned) */
247 NULL, /* 153 (unassigned) */
248 NULL, /* 154 (unassigned) */
249 NULL, /* 155 (unassigned) */
250 NULL, /* 156 (unassigned) */
251 NULL, /* 157 (unassigned) */
252 NULL, /* 158 (unassigned) */
253 NULL, /* 159 (unassigned) */
254 NULL, /* 160 (unassigned) */
255 NULL, /* 161 (unassigned) */
256 NULL, /* 162 (unassigned) */
257 NULL, /* 163 (unassigned) */
258 NULL, /* 164 (unassigned) */
259 NULL, /* 165 (unassigned) */
260 NULL, /* 166 (unassigned) */
261 NULL, /* 167 (unassigned) */
262 NULL, /* 168 (unassigned) */
263 NULL, /* 169 (unassigned) */
264 NULL, /* 170 (unassigned) */
265 NULL, /* 171 (unassigned) */
266 NULL, /* 172 (unassigned) */
267 NULL, /* 173 (unassigned) */
268 NULL, /* 174 (unassigned) */
269 NULL, /* 175 (unassigned) */
270 NULL, /* 176 (unassigned) */
271 NULL, /* 177 (unassigned) */
272 NULL, /* 178 (unassigned) */
273 NULL, /* 179 (unassigned) */
274 NULL, /* 180 (unassigned) */
275 NULL, /* 181 (unassigned) */
276 NULL, /* 182 (unassigned) */
277 NULL, /* 183 (unassigned) */
278 NULL, /* 184 (unassigned) */
279 NULL, /* 185 (unassigned) */
280 NULL, /* 186 (unassigned) */
281 NULL, /* 187 (unassigned) */
282 NULL, /* 188 (unassigned) */
283 NULL, /* 189 (unassigned) */
284 NULL, /* 190 (unassigned) */
285 NULL, /* 191 (unassigned) */
286 NULL, /* 192 (unassigned) */
287 NULL, /* 193 (unassigned) */
288 NULL, /* 194 (unassigned) */
289 NULL, /* 195 (unassigned) */
290 NULL, /* 196 (unassigned) */
291 NULL, /* 197 (unassigned) */
292 NULL, /* 198 (unassigned) */
293 NULL, /* 199 (unassigned) */
294 NULL, /* 200 (unassigned) */
295 NULL, /* 201 (unassigned) */
296 NULL, /* 202 (unassigned) */
297 NULL, /* 203 (unassigned) */
298 NULL, /* 204 (unassigned) */
299 NULL, /* 205 (unassigned) */
300 NULL, /* 206 (unassigned) */
301 NULL, /* 207 (unassigned) */
302 NULL, /* 208 (unassigned) */
303 NULL, /* 209 (unassigned) */
304 NULL, /* 210 (unassigned) */
305 NULL, /* 211 (unassigned) */
306 NULL, /* 212 (unassigned) */
307 NULL, /* 213 (unassigned) */
308 NULL, /* 214 (unassigned) */
309 NULL, /* 215 (unassigned) */
310 NULL, /* 216 (unassigned) */
311 NULL, /* 217 (unassigned) */
312 NULL, /* 218 (unassigned) */
313 NULL, /* 219 (unassigned) */
314 NULL, /* 220 (unassigned) */
315 NULL, /* 221 (unassigned) */
316 NULL, /* 222 (unassigned) */
317 NULL, /* 223 (unassigned) */
318 NULL, /* 224 (unassigned) */
319 NULL, /* 225 (unassigned) */
320 NULL, /* 226 (unassigned) */
321 NULL, /* 227 (unassigned) */
322 NULL, /* 228 (unassigned) */
323 NULL, /* 229 (unassigned) */
324 NULL, /* 230 (unassigned) */
325 NULL, /* 231 (unassigned) */
326 NULL, /* 232 (unassigned) */
327 NULL, /* 233 (unassigned) */
328 NULL, /* 234 (unassigned) */
329 NULL, /* 235 (unassigned) */
330 NULL, /* 236 (unassigned) */
331 NULL, /* 237 (unassigned) */
332 NULL, /* 238 (unassigned) */
333 NULL, /* 239 (unassigned) */
334 NULL, /* 240 (unassigned) */
335 NULL, /* 241 (unassigned) */
336 NULL, /* 242 (unassigned) */
337 NULL, /* 243 (unassigned) */
338 NULL, /* 244 (unassigned) */
339 NULL, /* 245 (unassigned) */
340 NULL, /* 246 (unassigned) */
341 NULL, /* 247 (unassigned) */
342 NULL, /* 248 (unassigned) */
343 NULL, /* 249 (unassigned) */
344 NULL, /* 250 (unassigned) */
345 NULL, /* 251 (unassigned) */
346 NULL, /* 252 (unassigned) */
347 "exptest-253", /* 253 (Use for experimentation and testing,
348 * RFC 3692)
349 */
350 "exptest-254", /* 254 (Use for experimentation and testing,
351 * RFC 3692)
352 */
353 "reserved", /* 255 (reserved) */
354 };
355
356 /* The function enforces the array index to be 8-bit. */
357 const char *
netdb_protoname(const uint8_t protoid)358 netdb_protoname (const uint8_t protoid)
359 {
360 return netdb_protocol_names[protoid];
361 }
362