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