Naveen Sampath | 04696f7 | 2022-06-13 15:19:14 +0530 | [diff] [blame] | 1 | // Copyright 2012 Google, Inc. All rights reserved. |
| 2 | // Copyright 2009-2011 Andreas Krennmair. All rights reserved. |
| 3 | // |
| 4 | // Use of this source code is governed by a BSD-style license |
| 5 | // that can be found in the LICENSE file in the root of the source |
| 6 | // tree. |
| 7 | |
| 8 | package layers |
| 9 | |
| 10 | import ( |
| 11 | "fmt" |
| 12 | "runtime" |
| 13 | |
| 14 | "github.com/google/gopacket" |
| 15 | ) |
| 16 | |
| 17 | // EnumMetadata keeps track of a set of metadata for each enumeration value |
| 18 | // for protocol enumerations. |
| 19 | type EnumMetadata struct { |
| 20 | // DecodeWith is the decoder to use to decode this protocol's data. |
| 21 | DecodeWith gopacket.Decoder |
| 22 | // Name is the name of the enumeration value. |
| 23 | Name string |
| 24 | // LayerType is the layer type implied by the given enum. |
| 25 | LayerType gopacket.LayerType |
| 26 | } |
| 27 | |
| 28 | // EthernetType is an enumeration of ethernet type values, and acts as a decoder |
| 29 | // for any type it supports. |
| 30 | type EthernetType uint16 |
| 31 | |
| 32 | const ( |
| 33 | // EthernetTypeLLC is not an actual ethernet type. It is instead a |
| 34 | // placeholder we use in Ethernet frames that use the 802.3 standard of |
| 35 | // srcmac|dstmac|length|LLC instead of srcmac|dstmac|ethertype. |
| 36 | EthernetTypeLLC EthernetType = 0 |
| 37 | EthernetTypeIPv4 EthernetType = 0x0800 |
| 38 | EthernetTypeARP EthernetType = 0x0806 |
| 39 | EthernetTypeIPv6 EthernetType = 0x86DD |
| 40 | EthernetTypeCiscoDiscovery EthernetType = 0x2000 |
| 41 | EthernetTypeNortelDiscovery EthernetType = 0x01a2 |
| 42 | EthernetTypeTransparentEthernetBridging EthernetType = 0x6558 |
| 43 | EthernetTypeDot1Q EthernetType = 0x8100 |
| 44 | EthernetTypePPP EthernetType = 0x880b |
| 45 | EthernetTypePPPoEDiscovery EthernetType = 0x8863 |
| 46 | EthernetTypePPPoESession EthernetType = 0x8864 |
| 47 | EthernetTypeMPLSUnicast EthernetType = 0x8847 |
| 48 | EthernetTypeMPLSMulticast EthernetType = 0x8848 |
| 49 | EthernetTypeEAPOL EthernetType = 0x888e |
| 50 | EthernetTypeERSPAN EthernetType = 0x88be |
| 51 | EthernetTypeQinQ EthernetType = 0x88a8 |
| 52 | EthernetTypeLinkLayerDiscovery EthernetType = 0x88cc |
| 53 | EthernetTypeEthernetCTP EthernetType = 0x9000 |
| 54 | EthernetTypeDot1QDoubleTag EthernetType = 0x9100 |
| 55 | EthernetTypeQinQDoubleTag EthernetType = 0x9200 |
| 56 | ) |
| 57 | |
| 58 | // IPProtocol is an enumeration of IP protocol values, and acts as a decoder |
| 59 | // for any type it supports. |
| 60 | type IPProtocol uint8 |
| 61 | |
| 62 | const ( |
| 63 | IPProtocolIPv6HopByHop IPProtocol = 0 |
| 64 | IPProtocolICMPv4 IPProtocol = 1 |
| 65 | IPProtocolIGMP IPProtocol = 2 |
| 66 | IPProtocolIPv4 IPProtocol = 4 |
| 67 | IPProtocolTCP IPProtocol = 6 |
| 68 | IPProtocolUDP IPProtocol = 17 |
| 69 | IPProtocolRUDP IPProtocol = 27 |
| 70 | IPProtocolIPv6 IPProtocol = 41 |
| 71 | IPProtocolIPv6Routing IPProtocol = 43 |
| 72 | IPProtocolIPv6Fragment IPProtocol = 44 |
| 73 | IPProtocolGRE IPProtocol = 47 |
| 74 | IPProtocolESP IPProtocol = 50 |
| 75 | IPProtocolAH IPProtocol = 51 |
| 76 | IPProtocolICMPv6 IPProtocol = 58 |
| 77 | IPProtocolNoNextHeader IPProtocol = 59 |
| 78 | IPProtocolIPv6Destination IPProtocol = 60 |
| 79 | IPProtocolOSPF IPProtocol = 89 |
| 80 | IPProtocolIPIP IPProtocol = 94 |
| 81 | IPProtocolEtherIP IPProtocol = 97 |
| 82 | IPProtocolVRRP IPProtocol = 112 |
| 83 | IPProtocolSCTP IPProtocol = 132 |
| 84 | IPProtocolUDPLite IPProtocol = 136 |
| 85 | IPProtocolMPLSInIP IPProtocol = 137 |
| 86 | ) |
| 87 | |
| 88 | // LinkType is an enumeration of link types, and acts as a decoder for any |
| 89 | // link type it supports. |
| 90 | type LinkType uint8 |
| 91 | |
| 92 | const ( |
| 93 | // According to pcap-linktype(7) and http://www.tcpdump.org/linktypes.html |
| 94 | LinkTypeNull LinkType = 0 |
| 95 | LinkTypeEthernet LinkType = 1 |
| 96 | LinkTypeAX25 LinkType = 3 |
| 97 | LinkTypeTokenRing LinkType = 6 |
| 98 | LinkTypeArcNet LinkType = 7 |
| 99 | LinkTypeSLIP LinkType = 8 |
| 100 | LinkTypePPP LinkType = 9 |
| 101 | LinkTypeFDDI LinkType = 10 |
| 102 | LinkTypePPP_HDLC LinkType = 50 |
| 103 | LinkTypePPPEthernet LinkType = 51 |
| 104 | LinkTypeATM_RFC1483 LinkType = 100 |
| 105 | LinkTypeRaw LinkType = 101 |
| 106 | LinkTypeC_HDLC LinkType = 104 |
| 107 | LinkTypeIEEE802_11 LinkType = 105 |
| 108 | LinkTypeFRelay LinkType = 107 |
| 109 | LinkTypeLoop LinkType = 108 |
| 110 | LinkTypeLinuxSLL LinkType = 113 |
| 111 | LinkTypeLTalk LinkType = 114 |
| 112 | LinkTypePFLog LinkType = 117 |
| 113 | LinkTypePrismHeader LinkType = 119 |
| 114 | LinkTypeIPOverFC LinkType = 122 |
| 115 | LinkTypeSunATM LinkType = 123 |
| 116 | LinkTypeIEEE80211Radio LinkType = 127 |
| 117 | LinkTypeARCNetLinux LinkType = 129 |
| 118 | LinkTypeIPOver1394 LinkType = 138 |
| 119 | LinkTypeMTP2Phdr LinkType = 139 |
| 120 | LinkTypeMTP2 LinkType = 140 |
| 121 | LinkTypeMTP3 LinkType = 141 |
| 122 | LinkTypeSCCP LinkType = 142 |
| 123 | LinkTypeDOCSIS LinkType = 143 |
| 124 | LinkTypeLinuxIRDA LinkType = 144 |
| 125 | LinkTypeLinuxLAPD LinkType = 177 |
| 126 | LinkTypeLinuxUSB LinkType = 220 |
| 127 | LinkTypeFC2 LinkType = 224 |
| 128 | LinkTypeFC2Framed LinkType = 225 |
| 129 | LinkTypeIPv4 LinkType = 228 |
| 130 | LinkTypeIPv6 LinkType = 229 |
| 131 | ) |
| 132 | |
| 133 | // PPPoECode is the PPPoE code enum, taken from http://tools.ietf.org/html/rfc2516 |
| 134 | type PPPoECode uint8 |
| 135 | |
| 136 | const ( |
| 137 | PPPoECodePADI PPPoECode = 0x09 |
| 138 | PPPoECodePADO PPPoECode = 0x07 |
| 139 | PPPoECodePADR PPPoECode = 0x19 |
| 140 | PPPoECodePADS PPPoECode = 0x65 |
| 141 | PPPoECodePADT PPPoECode = 0xA7 |
| 142 | PPPoECodeSession PPPoECode = 0x00 |
| 143 | ) |
| 144 | |
| 145 | // PPPType is an enumeration of PPP type values, and acts as a decoder for any |
| 146 | // type it supports. |
| 147 | type PPPType uint16 |
| 148 | |
| 149 | const ( |
| 150 | PPPTypeIPv4 PPPType = 0x0021 |
| 151 | PPPTypeIPv6 PPPType = 0x0057 |
| 152 | PPPTypeMPLSUnicast PPPType = 0x0281 |
| 153 | PPPTypeMPLSMulticast PPPType = 0x0283 |
| 154 | ) |
| 155 | |
| 156 | // SCTPChunkType is an enumeration of chunk types inside SCTP packets. |
| 157 | type SCTPChunkType uint8 |
| 158 | |
| 159 | const ( |
| 160 | SCTPChunkTypeData SCTPChunkType = 0 |
| 161 | SCTPChunkTypeInit SCTPChunkType = 1 |
| 162 | SCTPChunkTypeInitAck SCTPChunkType = 2 |
| 163 | SCTPChunkTypeSack SCTPChunkType = 3 |
| 164 | SCTPChunkTypeHeartbeat SCTPChunkType = 4 |
| 165 | SCTPChunkTypeHeartbeatAck SCTPChunkType = 5 |
| 166 | SCTPChunkTypeAbort SCTPChunkType = 6 |
| 167 | SCTPChunkTypeShutdown SCTPChunkType = 7 |
| 168 | SCTPChunkTypeShutdownAck SCTPChunkType = 8 |
| 169 | SCTPChunkTypeError SCTPChunkType = 9 |
| 170 | SCTPChunkTypeCookieEcho SCTPChunkType = 10 |
| 171 | SCTPChunkTypeCookieAck SCTPChunkType = 11 |
| 172 | SCTPChunkTypeShutdownComplete SCTPChunkType = 14 |
| 173 | ) |
| 174 | |
| 175 | // FDDIFrameControl is an enumeration of FDDI frame control bytes. |
| 176 | type FDDIFrameControl uint8 |
| 177 | |
| 178 | const ( |
| 179 | FDDIFrameControlLLC FDDIFrameControl = 0x50 |
| 180 | ) |
| 181 | |
| 182 | // EAPOLType is an enumeration of EAPOL packet types. |
| 183 | type EAPOLType uint8 |
| 184 | |
| 185 | const ( |
| 186 | EAPOLTypeEAP EAPOLType = 0 |
| 187 | EAPOLTypeStart EAPOLType = 1 |
| 188 | EAPOLTypeLogOff EAPOLType = 2 |
| 189 | EAPOLTypeKey EAPOLType = 3 |
| 190 | EAPOLTypeASFAlert EAPOLType = 4 |
| 191 | ) |
| 192 | |
| 193 | // ProtocolFamily is the set of values defined as PF_* in sys/socket.h |
| 194 | type ProtocolFamily uint8 |
| 195 | |
| 196 | const ( |
| 197 | ProtocolFamilyIPv4 ProtocolFamily = 2 |
| 198 | // BSDs use different values for INET6... glory be. These values taken from |
| 199 | // tcpdump 4.3.0. |
| 200 | ProtocolFamilyIPv6BSD ProtocolFamily = 24 |
| 201 | ProtocolFamilyIPv6FreeBSD ProtocolFamily = 28 |
| 202 | ProtocolFamilyIPv6Darwin ProtocolFamily = 30 |
| 203 | ProtocolFamilyIPv6Linux ProtocolFamily = 10 |
| 204 | ) |
| 205 | |
| 206 | // Dot11Type is a combination of IEEE 802.11 frame's Type and Subtype fields. |
| 207 | // By combining these two fields together into a single type, we're able to |
| 208 | // provide a String function that correctly displays the subtype given the |
| 209 | // top-level type. |
| 210 | // |
| 211 | // If you just care about the top-level type, use the MainType function. |
| 212 | type Dot11Type uint8 |
| 213 | |
| 214 | // MainType strips the subtype information from the given type, |
| 215 | // returning just the overarching type (Mgmt, Ctrl, Data, Reserved). |
| 216 | func (d Dot11Type) MainType() Dot11Type { |
| 217 | return d & dot11TypeMask |
| 218 | } |
| 219 | |
| 220 | func (d Dot11Type) QOS() bool { |
| 221 | return d&dot11QOSMask == Dot11TypeDataQOSData |
| 222 | } |
| 223 | |
| 224 | const ( |
| 225 | Dot11TypeMgmt Dot11Type = 0x00 |
| 226 | Dot11TypeCtrl Dot11Type = 0x01 |
| 227 | Dot11TypeData Dot11Type = 0x02 |
| 228 | Dot11TypeReserved Dot11Type = 0x03 |
| 229 | dot11TypeMask = 0x03 |
| 230 | dot11QOSMask = 0x23 |
| 231 | |
| 232 | // The following are type/subtype conglomerations. |
| 233 | |
| 234 | // Management |
| 235 | Dot11TypeMgmtAssociationReq Dot11Type = 0x00 |
| 236 | Dot11TypeMgmtAssociationResp Dot11Type = 0x04 |
| 237 | Dot11TypeMgmtReassociationReq Dot11Type = 0x08 |
| 238 | Dot11TypeMgmtReassociationResp Dot11Type = 0x0c |
| 239 | Dot11TypeMgmtProbeReq Dot11Type = 0x10 |
| 240 | Dot11TypeMgmtProbeResp Dot11Type = 0x14 |
| 241 | Dot11TypeMgmtMeasurementPilot Dot11Type = 0x18 |
| 242 | Dot11TypeMgmtBeacon Dot11Type = 0x20 |
| 243 | Dot11TypeMgmtATIM Dot11Type = 0x24 |
| 244 | Dot11TypeMgmtDisassociation Dot11Type = 0x28 |
| 245 | Dot11TypeMgmtAuthentication Dot11Type = 0x2c |
| 246 | Dot11TypeMgmtDeauthentication Dot11Type = 0x30 |
| 247 | Dot11TypeMgmtAction Dot11Type = 0x34 |
| 248 | Dot11TypeMgmtActionNoAck Dot11Type = 0x38 |
| 249 | |
| 250 | // Control |
| 251 | Dot11TypeCtrlWrapper Dot11Type = 0x1d |
| 252 | Dot11TypeCtrlBlockAckReq Dot11Type = 0x21 |
| 253 | Dot11TypeCtrlBlockAck Dot11Type = 0x25 |
| 254 | Dot11TypeCtrlPowersavePoll Dot11Type = 0x29 |
| 255 | Dot11TypeCtrlRTS Dot11Type = 0x2d |
| 256 | Dot11TypeCtrlCTS Dot11Type = 0x31 |
| 257 | Dot11TypeCtrlAck Dot11Type = 0x35 |
| 258 | Dot11TypeCtrlCFEnd Dot11Type = 0x39 |
| 259 | Dot11TypeCtrlCFEndAck Dot11Type = 0x3d |
| 260 | |
| 261 | // Data |
| 262 | Dot11TypeDataCFAck Dot11Type = 0x06 |
| 263 | Dot11TypeDataCFPoll Dot11Type = 0x0a |
| 264 | Dot11TypeDataCFAckPoll Dot11Type = 0x0e |
| 265 | Dot11TypeDataNull Dot11Type = 0x12 |
| 266 | Dot11TypeDataCFAckNoData Dot11Type = 0x16 |
| 267 | Dot11TypeDataCFPollNoData Dot11Type = 0x1a |
| 268 | Dot11TypeDataCFAckPollNoData Dot11Type = 0x1e |
| 269 | Dot11TypeDataQOSData Dot11Type = 0x22 |
| 270 | Dot11TypeDataQOSDataCFAck Dot11Type = 0x26 |
| 271 | Dot11TypeDataQOSDataCFPoll Dot11Type = 0x2a |
| 272 | Dot11TypeDataQOSDataCFAckPoll Dot11Type = 0x2e |
| 273 | Dot11TypeDataQOSNull Dot11Type = 0x32 |
| 274 | Dot11TypeDataQOSCFPollNoData Dot11Type = 0x3a |
| 275 | Dot11TypeDataQOSCFAckPollNoData Dot11Type = 0x3e |
| 276 | ) |
| 277 | |
| 278 | // Decode a raw v4 or v6 IP packet. |
| 279 | func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error { |
| 280 | version := data[0] >> 4 |
| 281 | switch version { |
| 282 | case 4: |
| 283 | return decodeIPv4(data, p) |
| 284 | case 6: |
| 285 | return decodeIPv6(data, p) |
| 286 | } |
| 287 | return fmt.Errorf("Invalid IP packet version %v", version) |
| 288 | } |
| 289 | |
| 290 | func initActualTypeData() { |
| 291 | // Each of the XXXTypeMetadata arrays contains mappings of how to handle enum |
| 292 | // values for various enum types in gopacket/layers. |
| 293 | // These arrays are actually created by gen2.go and stored in |
| 294 | // enums_generated.go. |
| 295 | // |
| 296 | // So, EthernetTypeMetadata[2] contains information on how to handle EthernetType |
| 297 | // 2, including which name to give it and which decoder to use to decode |
| 298 | // packet data of that type. These arrays are filled by default with all of the |
| 299 | // protocols gopacket/layers knows how to handle, but users of the library can |
| 300 | // add new decoders or override existing ones. For example, if you write a better |
| 301 | // TCP decoder, you can override IPProtocolMetadata[IPProtocolTCP].DecodeWith |
| 302 | // with your new decoder, and all gopacket/layers decoding will use your new |
| 303 | // decoder whenever they encounter that IPProtocol. |
| 304 | |
| 305 | // Here we link up all enumerations with their respective names and decoders. |
| 306 | EthernetTypeMetadata[EthernetTypeLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC", LayerType: LayerTypeLLC} |
| 307 | EthernetTypeMetadata[EthernetTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} |
| 308 | EthernetTypeMetadata[EthernetTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} |
| 309 | EthernetTypeMetadata[EthernetTypeARP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeARP), Name: "ARP", LayerType: LayerTypeARP} |
| 310 | EthernetTypeMetadata[EthernetTypeDot1Q] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot1Q), Name: "Dot1Q", LayerType: LayerTypeDot1Q} |
| 311 | EthernetTypeMetadata[EthernetTypePPP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP", LayerType: LayerTypePPP} |
| 312 | EthernetTypeMetadata[EthernetTypePPPoEDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPPoE), Name: "PPPoEDiscovery", LayerType: LayerTypePPPoE} |
| 313 | EthernetTypeMetadata[EthernetTypePPPoESession] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPPoE), Name: "PPPoESession", LayerType: LayerTypePPPoE} |
| 314 | EthernetTypeMetadata[EthernetTypeEthernetCTP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernetCTP), Name: "EthernetCTP", LayerType: LayerTypeEthernetCTP} |
| 315 | EthernetTypeMetadata[EthernetTypeCiscoDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeCiscoDiscovery), Name: "CiscoDiscovery", LayerType: LayerTypeCiscoDiscovery} |
| 316 | EthernetTypeMetadata[EthernetTypeNortelDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeNortelDiscovery), Name: "NortelDiscovery", LayerType: LayerTypeNortelDiscovery} |
| 317 | EthernetTypeMetadata[EthernetTypeLinkLayerDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinkLayerDiscovery), Name: "LinkLayerDiscovery", LayerType: LayerTypeLinkLayerDiscovery} |
| 318 | EthernetTypeMetadata[EthernetTypeMPLSUnicast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSUnicast", LayerType: LayerTypeMPLS} |
| 319 | EthernetTypeMetadata[EthernetTypeMPLSMulticast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSMulticast", LayerType: LayerTypeMPLS} |
| 320 | EthernetTypeMetadata[EthernetTypeEAPOL] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAPOL), Name: "EAPOL", LayerType: LayerTypeEAPOL} |
| 321 | EthernetTypeMetadata[EthernetTypeQinQ] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot1Q), Name: "Dot1Q", LayerType: LayerTypeDot1Q} |
| 322 | EthernetTypeMetadata[EthernetTypeTransparentEthernetBridging] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernet), Name: "TransparentEthernetBridging", LayerType: LayerTypeEthernet} |
| 323 | EthernetTypeMetadata[EthernetTypeERSPAN] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeERSPANII), Name: "ERSPAN Type II", LayerType: LayerTypeERSPANII} |
| 324 | |
| 325 | IPProtocolMetadata[IPProtocolIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} |
| 326 | IPProtocolMetadata[IPProtocolTCP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeTCP), Name: "TCP", LayerType: LayerTypeTCP} |
| 327 | IPProtocolMetadata[IPProtocolUDP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDP), Name: "UDP", LayerType: LayerTypeUDP} |
| 328 | IPProtocolMetadata[IPProtocolICMPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeICMPv4), Name: "ICMPv4", LayerType: LayerTypeICMPv4} |
| 329 | IPProtocolMetadata[IPProtocolICMPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeICMPv6), Name: "ICMPv6", LayerType: LayerTypeICMPv6} |
| 330 | IPProtocolMetadata[IPProtocolSCTP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTP), Name: "SCTP", LayerType: LayerTypeSCTP} |
| 331 | IPProtocolMetadata[IPProtocolIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} |
| 332 | IPProtocolMetadata[IPProtocolIPIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} |
| 333 | IPProtocolMetadata[IPProtocolEtherIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEtherIP), Name: "EtherIP", LayerType: LayerTypeEtherIP} |
| 334 | IPProtocolMetadata[IPProtocolRUDP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeRUDP), Name: "RUDP", LayerType: LayerTypeRUDP} |
| 335 | IPProtocolMetadata[IPProtocolGRE] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeGRE), Name: "GRE", LayerType: LayerTypeGRE} |
| 336 | IPProtocolMetadata[IPProtocolIPv6HopByHop] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6HopByHop), Name: "IPv6HopByHop", LayerType: LayerTypeIPv6HopByHop} |
| 337 | IPProtocolMetadata[IPProtocolIPv6Routing] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Routing), Name: "IPv6Routing", LayerType: LayerTypeIPv6Routing} |
| 338 | IPProtocolMetadata[IPProtocolIPv6Fragment] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Fragment), Name: "IPv6Fragment", LayerType: LayerTypeIPv6Fragment} |
| 339 | IPProtocolMetadata[IPProtocolIPv6Destination] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Destination), Name: "IPv6Destination", LayerType: LayerTypeIPv6Destination} |
| 340 | IPProtocolMetadata[IPProtocolOSPF] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeOSPF), Name: "OSPF", LayerType: LayerTypeOSPF} |
| 341 | IPProtocolMetadata[IPProtocolAH] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecAH), Name: "IPSecAH", LayerType: LayerTypeIPSecAH} |
| 342 | IPProtocolMetadata[IPProtocolESP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecESP), Name: "IPSecESP", LayerType: LayerTypeIPSecESP} |
| 343 | IPProtocolMetadata[IPProtocolUDPLite] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDPLite), Name: "UDPLite", LayerType: LayerTypeUDPLite} |
| 344 | IPProtocolMetadata[IPProtocolMPLSInIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLS", LayerType: LayerTypeMPLS} |
| 345 | IPProtocolMetadata[IPProtocolNoNextHeader] = EnumMetadata{DecodeWith: gopacket.DecodePayload, Name: "NoNextHeader", LayerType: gopacket.LayerTypePayload} |
| 346 | IPProtocolMetadata[IPProtocolIGMP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIGMP), Name: "IGMP", LayerType: LayerTypeIGMP} |
| 347 | IPProtocolMetadata[IPProtocolVRRP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeVRRP), Name: "VRRP", LayerType: LayerTypeVRRP} |
| 348 | |
| 349 | SCTPChunkTypeMetadata[SCTPChunkTypeData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPData), Name: "Data"} |
| 350 | SCTPChunkTypeMetadata[SCTPChunkTypeInit] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPInit), Name: "Init"} |
| 351 | SCTPChunkTypeMetadata[SCTPChunkTypeInitAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPInit), Name: "InitAck"} |
| 352 | SCTPChunkTypeMetadata[SCTPChunkTypeSack] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPSack), Name: "Sack"} |
| 353 | SCTPChunkTypeMetadata[SCTPChunkTypeHeartbeat] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPHeartbeat), Name: "Heartbeat"} |
| 354 | SCTPChunkTypeMetadata[SCTPChunkTypeHeartbeatAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPHeartbeat), Name: "HeartbeatAck"} |
| 355 | SCTPChunkTypeMetadata[SCTPChunkTypeAbort] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPError), Name: "Abort"} |
| 356 | SCTPChunkTypeMetadata[SCTPChunkTypeError] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPError), Name: "Error"} |
| 357 | SCTPChunkTypeMetadata[SCTPChunkTypeShutdown] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPShutdown), Name: "Shutdown"} |
| 358 | SCTPChunkTypeMetadata[SCTPChunkTypeShutdownAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPShutdownAck), Name: "ShutdownAck"} |
| 359 | SCTPChunkTypeMetadata[SCTPChunkTypeCookieEcho] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPCookieEcho), Name: "CookieEcho"} |
| 360 | SCTPChunkTypeMetadata[SCTPChunkTypeCookieAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPEmptyLayer), Name: "CookieAck"} |
| 361 | SCTPChunkTypeMetadata[SCTPChunkTypeShutdownComplete] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPEmptyLayer), Name: "ShutdownComplete"} |
| 362 | |
| 363 | PPPTypeMetadata[PPPTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4"} |
| 364 | PPPTypeMetadata[PPPTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6"} |
| 365 | PPPTypeMetadata[PPPTypeMPLSUnicast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSUnicast"} |
| 366 | PPPTypeMetadata[PPPTypeMPLSMulticast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSMulticast"} |
| 367 | |
| 368 | PPPoECodeMetadata[PPPoECodeSession] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP"} |
| 369 | |
| 370 | LinkTypeMetadata[LinkTypeEthernet] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernet), Name: "Ethernet"} |
| 371 | LinkTypeMetadata[LinkTypePPP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP"} |
| 372 | LinkTypeMetadata[LinkTypeFDDI] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeFDDI), Name: "FDDI"} |
| 373 | LinkTypeMetadata[LinkTypeNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLoopback), Name: "Null"} |
| 374 | LinkTypeMetadata[LinkTypeIEEE802_11] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11), Name: "Dot11"} |
| 375 | LinkTypeMetadata[LinkTypeLoop] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLoopback), Name: "Loop"} |
| 376 | LinkTypeMetadata[LinkTypeIEEE802_11] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11), Name: "802.11"} |
| 377 | LinkTypeMetadata[LinkTypeRaw] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"} |
| 378 | // See https://github.com/the-tcpdump-group/libpcap/blob/170f717e6e818cdc4bcbbfd906b63088eaa88fa0/pcap/dlt.h#L85 |
| 379 | // Or https://github.com/wireshark/wireshark/blob/854cfe53efe44080609c78053ecfb2342ad84a08/wiretap/pcap-common.c#L508 |
| 380 | if runtime.GOOS == "openbsd" { |
| 381 | LinkTypeMetadata[14] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"} |
| 382 | } else { |
| 383 | LinkTypeMetadata[12] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"} |
| 384 | } |
| 385 | LinkTypeMetadata[LinkTypePFLog] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePFLog), Name: "PFLog"} |
| 386 | LinkTypeMetadata[LinkTypeIEEE80211Radio] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeRadioTap), Name: "RadioTap"} |
| 387 | LinkTypeMetadata[LinkTypeLinuxUSB] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSB), Name: "USB"} |
| 388 | LinkTypeMetadata[LinkTypeLinuxSLL] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinuxSLL), Name: "Linux SLL"} |
| 389 | LinkTypeMetadata[LinkTypePrismHeader] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePrismHeader), Name: "Prism"} |
| 390 | |
| 391 | FDDIFrameControlMetadata[FDDIFrameControlLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC"} |
| 392 | |
| 393 | EAPOLTypeMetadata[EAPOLTypeEAP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAP), Name: "EAP", LayerType: LayerTypeEAP} |
| 394 | EAPOLTypeMetadata[EAPOLTypeKey] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAPOLKey), Name: "EAPOLKey", LayerType: LayerTypeEAPOLKey} |
| 395 | |
| 396 | ProtocolFamilyMetadata[ProtocolFamilyIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4} |
| 397 | ProtocolFamilyMetadata[ProtocolFamilyIPv6BSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} |
| 398 | ProtocolFamilyMetadata[ProtocolFamilyIPv6FreeBSD] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} |
| 399 | ProtocolFamilyMetadata[ProtocolFamilyIPv6Darwin] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} |
| 400 | ProtocolFamilyMetadata[ProtocolFamilyIPv6Linux] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6} |
| 401 | |
| 402 | Dot11TypeMetadata[Dot11TypeMgmtAssociationReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAssociationReq), Name: "MgmtAssociationReq", LayerType: LayerTypeDot11MgmtAssociationReq} |
| 403 | Dot11TypeMetadata[Dot11TypeMgmtAssociationResp] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAssociationResp), Name: "MgmtAssociationResp", LayerType: LayerTypeDot11MgmtAssociationResp} |
| 404 | Dot11TypeMetadata[Dot11TypeMgmtReassociationReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtReassociationReq), Name: "MgmtReassociationReq", LayerType: LayerTypeDot11MgmtReassociationReq} |
| 405 | Dot11TypeMetadata[Dot11TypeMgmtReassociationResp] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtReassociationResp), Name: "MgmtReassociationResp", LayerType: LayerTypeDot11MgmtReassociationResp} |
| 406 | Dot11TypeMetadata[Dot11TypeMgmtProbeReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtProbeReq), Name: "MgmtProbeReq", LayerType: LayerTypeDot11MgmtProbeReq} |
| 407 | Dot11TypeMetadata[Dot11TypeMgmtProbeResp] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtProbeResp), Name: "MgmtProbeResp", LayerType: LayerTypeDot11MgmtProbeResp} |
| 408 | Dot11TypeMetadata[Dot11TypeMgmtMeasurementPilot] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtMeasurementPilot), Name: "MgmtMeasurementPilot", LayerType: LayerTypeDot11MgmtMeasurementPilot} |
| 409 | Dot11TypeMetadata[Dot11TypeMgmtBeacon] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtBeacon), Name: "MgmtBeacon", LayerType: LayerTypeDot11MgmtBeacon} |
| 410 | Dot11TypeMetadata[Dot11TypeMgmtATIM] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtATIM), Name: "MgmtATIM", LayerType: LayerTypeDot11MgmtATIM} |
| 411 | Dot11TypeMetadata[Dot11TypeMgmtDisassociation] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtDisassociation), Name: "MgmtDisassociation", LayerType: LayerTypeDot11MgmtDisassociation} |
| 412 | Dot11TypeMetadata[Dot11TypeMgmtAuthentication] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAuthentication), Name: "MgmtAuthentication", LayerType: LayerTypeDot11MgmtAuthentication} |
| 413 | Dot11TypeMetadata[Dot11TypeMgmtDeauthentication] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtDeauthentication), Name: "MgmtDeauthentication", LayerType: LayerTypeDot11MgmtDeauthentication} |
| 414 | Dot11TypeMetadata[Dot11TypeMgmtAction] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtAction), Name: "MgmtAction", LayerType: LayerTypeDot11MgmtAction} |
| 415 | Dot11TypeMetadata[Dot11TypeMgmtActionNoAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11MgmtActionNoAck), Name: "MgmtActionNoAck", LayerType: LayerTypeDot11MgmtActionNoAck} |
| 416 | Dot11TypeMetadata[Dot11TypeCtrl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11Ctrl), Name: "Ctrl", LayerType: LayerTypeDot11Ctrl} |
| 417 | Dot11TypeMetadata[Dot11TypeCtrlWrapper] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11Ctrl), Name: "CtrlWrapper", LayerType: LayerTypeDot11Ctrl} |
| 418 | Dot11TypeMetadata[Dot11TypeCtrlBlockAckReq] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlBlockAckReq), Name: "CtrlBlockAckReq", LayerType: LayerTypeDot11CtrlBlockAckReq} |
| 419 | Dot11TypeMetadata[Dot11TypeCtrlBlockAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlBlockAck), Name: "CtrlBlockAck", LayerType: LayerTypeDot11CtrlBlockAck} |
| 420 | Dot11TypeMetadata[Dot11TypeCtrlPowersavePoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlPowersavePoll), Name: "CtrlPowersavePoll", LayerType: LayerTypeDot11CtrlPowersavePoll} |
| 421 | Dot11TypeMetadata[Dot11TypeCtrlRTS] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlRTS), Name: "CtrlRTS", LayerType: LayerTypeDot11CtrlRTS} |
| 422 | Dot11TypeMetadata[Dot11TypeCtrlCTS] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlCTS), Name: "CtrlCTS", LayerType: LayerTypeDot11CtrlCTS} |
| 423 | Dot11TypeMetadata[Dot11TypeCtrlAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlAck), Name: "CtrlAck", LayerType: LayerTypeDot11CtrlAck} |
| 424 | Dot11TypeMetadata[Dot11TypeCtrlCFEnd] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlCFEnd), Name: "CtrlCFEnd", LayerType: LayerTypeDot11CtrlCFEnd} |
| 425 | Dot11TypeMetadata[Dot11TypeCtrlCFEndAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11CtrlCFEndAck), Name: "CtrlCFEndAck", LayerType: LayerTypeDot11CtrlCFEndAck} |
| 426 | Dot11TypeMetadata[Dot11TypeData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11Data), Name: "Data", LayerType: LayerTypeDot11Data} |
| 427 | Dot11TypeMetadata[Dot11TypeDataCFAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAck), Name: "DataCFAck", LayerType: LayerTypeDot11DataCFAck} |
| 428 | Dot11TypeMetadata[Dot11TypeDataCFPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFPoll), Name: "DataCFPoll", LayerType: LayerTypeDot11DataCFPoll} |
| 429 | Dot11TypeMetadata[Dot11TypeDataCFAckPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAckPoll), Name: "DataCFAckPoll", LayerType: LayerTypeDot11DataCFAckPoll} |
| 430 | Dot11TypeMetadata[Dot11TypeDataNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataNull), Name: "DataNull", LayerType: LayerTypeDot11DataNull} |
| 431 | Dot11TypeMetadata[Dot11TypeDataCFAckNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAckNoData), Name: "DataCFAckNoData", LayerType: LayerTypeDot11DataCFAckNoData} |
| 432 | Dot11TypeMetadata[Dot11TypeDataCFPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFPollNoData), Name: "DataCFPollNoData", LayerType: LayerTypeDot11DataCFPollNoData} |
| 433 | Dot11TypeMetadata[Dot11TypeDataCFAckPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataCFAckPollNoData), Name: "DataCFAckPollNoData", LayerType: LayerTypeDot11DataCFAckPollNoData} |
| 434 | Dot11TypeMetadata[Dot11TypeDataQOSData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSData), Name: "DataQOSData", LayerType: LayerTypeDot11DataQOSData} |
| 435 | Dot11TypeMetadata[Dot11TypeDataQOSDataCFAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSDataCFAck), Name: "DataQOSDataCFAck", LayerType: LayerTypeDot11DataQOSDataCFAck} |
| 436 | Dot11TypeMetadata[Dot11TypeDataQOSDataCFPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSDataCFPoll), Name: "DataQOSDataCFPoll", LayerType: LayerTypeDot11DataQOSDataCFPoll} |
| 437 | Dot11TypeMetadata[Dot11TypeDataQOSDataCFAckPoll] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSDataCFAckPoll), Name: "DataQOSDataCFAckPoll", LayerType: LayerTypeDot11DataQOSDataCFAckPoll} |
| 438 | Dot11TypeMetadata[Dot11TypeDataQOSNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSNull), Name: "DataQOSNull", LayerType: LayerTypeDot11DataQOSNull} |
| 439 | Dot11TypeMetadata[Dot11TypeDataQOSCFPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFPollNoData), Name: "DataQOSCFPollNoData", LayerType: LayerTypeDot11DataQOSCFPollNoData} |
| 440 | Dot11TypeMetadata[Dot11TypeDataQOSCFAckPollNoData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11DataQOSCFAckPollNoData), Name: "DataQOSCFAckPollNoData", LayerType: LayerTypeDot11DataQOSCFAckPollNoData} |
| 441 | |
| 442 | USBTransportTypeMetadata[USBTransportTypeInterrupt] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBInterrupt), Name: "Interrupt", LayerType: LayerTypeUSBInterrupt} |
| 443 | USBTransportTypeMetadata[USBTransportTypeControl] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBControl), Name: "Control", LayerType: LayerTypeUSBControl} |
| 444 | USBTransportTypeMetadata[USBTransportTypeBulk] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSBBulk), Name: "Bulk", LayerType: LayerTypeUSBBulk} |
| 445 | } |