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