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