github.com/gopacket/gopacket@v1.1.0/layers/enums.go (about)

     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/gopacket/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  )
    55  
    56  // IPProtocol is an enumeration of IP protocol values, and acts as a decoder
    57  // for any type it supports.
    58  type IPProtocol uint8
    59  
    60  const (
    61  	IPProtocolIPv6HopByHop    IPProtocol = 0
    62  	IPProtocolICMPv4          IPProtocol = 1
    63  	IPProtocolIGMP            IPProtocol = 2
    64  	IPProtocolIPv4            IPProtocol = 4
    65  	IPProtocolTCP             IPProtocol = 6
    66  	IPProtocolUDP             IPProtocol = 17
    67  	IPProtocolRUDP            IPProtocol = 27
    68  	IPProtocolIPv6            IPProtocol = 41
    69  	IPProtocolIPv6Routing     IPProtocol = 43
    70  	IPProtocolIPv6Fragment    IPProtocol = 44
    71  	IPProtocolGRE             IPProtocol = 47
    72  	IPProtocolESP             IPProtocol = 50
    73  	IPProtocolAH              IPProtocol = 51
    74  	IPProtocolICMPv6          IPProtocol = 58
    75  	IPProtocolNoNextHeader    IPProtocol = 59
    76  	IPProtocolIPv6Destination IPProtocol = 60
    77  	IPProtocolOSPF            IPProtocol = 89
    78  	IPProtocolIPIP            IPProtocol = 94
    79  	IPProtocolEtherIP         IPProtocol = 97
    80  	IPProtocolVRRP            IPProtocol = 112
    81  	IPProtocolSCTP            IPProtocol = 132
    82  	IPProtocolUDPLite         IPProtocol = 136
    83  	IPProtocolMPLSInIP        IPProtocol = 137
    84  )
    85  
    86  // LinkType is an enumeration of link types, and acts as a decoder for any
    87  // link type it supports.
    88  type LinkType uint16
    89  
    90  const (
    91  	// According to pcap-linktype(7) and http://www.tcpdump.org/linktypes.html
    92  	LinkTypeNull           LinkType = iota
    93  	LinkTypeEthernet       LinkType = 1
    94  	LinkTypeAX25           LinkType = 3
    95  	LinkTypeTokenRing      LinkType = 6
    96  	LinkTypeArcNet         LinkType = 7
    97  	LinkTypeSLIP           LinkType = 8
    98  	LinkTypePPP            LinkType = 9
    99  	LinkTypeFDDI           LinkType = 10
   100  	LinkTypePPP_HDLC       LinkType = 50
   101  	LinkTypePPPEthernet    LinkType = 51
   102  	LinkTypeATM_RFC1483    LinkType = 100
   103  	LinkTypeRaw            LinkType = 101
   104  	LinkTypeC_HDLC         LinkType = 104
   105  	LinkTypeIEEE802_11     LinkType = 105
   106  	LinkTypeFRelay         LinkType = 107
   107  	LinkTypeLoop           LinkType = 108
   108  	LinkTypeLinuxSLL       LinkType = 113
   109  	LinkTypeLTalk          LinkType = 114
   110  	LinkTypePFLog          LinkType = 117
   111  	LinkTypePrismHeader    LinkType = 119
   112  	LinkTypeIPOverFC       LinkType = 122
   113  	LinkTypeSunATM         LinkType = 123
   114  	LinkTypeIEEE80211Radio LinkType = 127
   115  	LinkTypeARCNetLinux    LinkType = 129
   116  	LinkTypeIPOver1394     LinkType = 138
   117  	LinkTypeMTP2Phdr       LinkType = 139
   118  	LinkTypeMTP2           LinkType = 140
   119  	LinkTypeMTP3           LinkType = 141
   120  	LinkTypeSCCP           LinkType = 142
   121  	LinkTypeDOCSIS         LinkType = 143
   122  	LinkTypeLinuxIRDA      LinkType = 144
   123  	LinkTypeLinuxLAPD      LinkType = 177
   124  	LinkTypeLinuxUSB       LinkType = 220
   125  	LinkTypeFC2            LinkType = 224
   126  	LinkTypeFC2Framed      LinkType = 225
   127  	LinkTypeIPv4           LinkType = 228
   128  	LinkTypeIPv6           LinkType = 229
   129  	LinkTypeLinuxSLL2      LinkType = 276
   130  
   131  	// Warning: this const should always be 1 larger than the largest valid value
   132  	LinkTypeMax LinkType = 277
   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  func (d Dot11Type) QOS() bool {
   223  	return d&dot11QOSMask == Dot11TypeDataQOSData
   224  }
   225  
   226  const (
   227  	Dot11TypeMgmt     Dot11Type = 0x00
   228  	Dot11TypeCtrl     Dot11Type = 0x01
   229  	Dot11TypeData     Dot11Type = 0x02
   230  	Dot11TypeReserved Dot11Type = 0x03
   231  	dot11TypeMask               = 0x03
   232  	dot11QOSMask                = 0x23
   233  
   234  	// The following are type/subtype conglomerations.
   235  
   236  	// Management
   237  	Dot11TypeMgmtAssociationReq    Dot11Type = 0x00
   238  	Dot11TypeMgmtAssociationResp   Dot11Type = 0x04
   239  	Dot11TypeMgmtReassociationReq  Dot11Type = 0x08
   240  	Dot11TypeMgmtReassociationResp Dot11Type = 0x0c
   241  	Dot11TypeMgmtProbeReq          Dot11Type = 0x10
   242  	Dot11TypeMgmtProbeResp         Dot11Type = 0x14
   243  	Dot11TypeMgmtMeasurementPilot  Dot11Type = 0x18
   244  	Dot11TypeMgmtBeacon            Dot11Type = 0x20
   245  	Dot11TypeMgmtATIM              Dot11Type = 0x24
   246  	Dot11TypeMgmtDisassociation    Dot11Type = 0x28
   247  	Dot11TypeMgmtAuthentication    Dot11Type = 0x2c
   248  	Dot11TypeMgmtDeauthentication  Dot11Type = 0x30
   249  	Dot11TypeMgmtAction            Dot11Type = 0x34
   250  	Dot11TypeMgmtActionNoAck       Dot11Type = 0x38
   251  
   252  	// Control
   253  	Dot11TypeCtrlWrapper       Dot11Type = 0x1d
   254  	Dot11TypeCtrlBlockAckReq   Dot11Type = 0x21
   255  	Dot11TypeCtrlBlockAck      Dot11Type = 0x25
   256  	Dot11TypeCtrlPowersavePoll Dot11Type = 0x29
   257  	Dot11TypeCtrlRTS           Dot11Type = 0x2d
   258  	Dot11TypeCtrlCTS           Dot11Type = 0x31
   259  	Dot11TypeCtrlAck           Dot11Type = 0x35
   260  	Dot11TypeCtrlCFEnd         Dot11Type = 0x39
   261  	Dot11TypeCtrlCFEndAck      Dot11Type = 0x3d
   262  
   263  	// Data
   264  	Dot11TypeDataCFAck              Dot11Type = 0x06
   265  	Dot11TypeDataCFPoll             Dot11Type = 0x0a
   266  	Dot11TypeDataCFAckPoll          Dot11Type = 0x0e
   267  	Dot11TypeDataNull               Dot11Type = 0x12
   268  	Dot11TypeDataCFAckNoData        Dot11Type = 0x16
   269  	Dot11TypeDataCFPollNoData       Dot11Type = 0x1a
   270  	Dot11TypeDataCFAckPollNoData    Dot11Type = 0x1e
   271  	Dot11TypeDataQOSData            Dot11Type = 0x22
   272  	Dot11TypeDataQOSDataCFAck       Dot11Type = 0x26
   273  	Dot11TypeDataQOSDataCFPoll      Dot11Type = 0x2a
   274  	Dot11TypeDataQOSDataCFAckPoll   Dot11Type = 0x2e
   275  	Dot11TypeDataQOSNull            Dot11Type = 0x32
   276  	Dot11TypeDataQOSCFPollNoData    Dot11Type = 0x3a
   277  	Dot11TypeDataQOSCFAckPollNoData Dot11Type = 0x3e
   278  )
   279  
   280  // Decode a raw v4 or v6 IP packet.
   281  func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error {
   282  	version := data[0] >> 4
   283  	switch version {
   284  	case 4:
   285  		return decodeIPv4(data, p)
   286  	case 6:
   287  		return decodeIPv6(data, p)
   288  	}
   289  	return fmt.Errorf("Invalid IP packet version %v", version)
   290  }
   291  
   292  func initActualTypeData() {
   293  	// Each of the XXXTypeMetadata arrays contains mappings of how to handle enum
   294  	// values for various enum types in gopacket/layers.
   295  	// These arrays are actually created by gen2.go and stored in
   296  	// enums_generated.go.
   297  	//
   298  	// So, EthernetTypeMetadata[2] contains information on how to handle EthernetType
   299  	// 2, including which name to give it and which decoder to use to decode
   300  	// packet data of that type.  These arrays are filled by default with all of the
   301  	// protocols gopacket/layers knows how to handle, but users of the library can
   302  	// add new decoders or override existing ones.  For example, if you write a better
   303  	// TCP decoder, you can override IPProtocolMetadata[IPProtocolTCP].DecodeWith
   304  	// with your new decoder, and all gopacket/layers decoding will use your new
   305  	// decoder whenever they encounter that IPProtocol.
   306  
   307  	// Here we link up all enumerations with their respective names and decoders.
   308  	EthernetTypeMetadata[EthernetTypeLLC] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLLC), Name: "LLC", LayerType: LayerTypeLLC}
   309  	EthernetTypeMetadata[EthernetTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
   310  	EthernetTypeMetadata[EthernetTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6}
   311  	EthernetTypeMetadata[EthernetTypeARP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeARP), Name: "ARP", LayerType: LayerTypeARP}
   312  	EthernetTypeMetadata[EthernetTypeDot1Q] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot1Q), Name: "Dot1Q", LayerType: LayerTypeDot1Q}
   313  	EthernetTypeMetadata[EthernetTypePPP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP", LayerType: LayerTypePPP}
   314  	EthernetTypeMetadata[EthernetTypePPPoEDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPPoE), Name: "PPPoEDiscovery", LayerType: LayerTypePPPoE}
   315  	EthernetTypeMetadata[EthernetTypePPPoESession] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPPoE), Name: "PPPoESession", LayerType: LayerTypePPPoE}
   316  	EthernetTypeMetadata[EthernetTypeEthernetCTP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernetCTP), Name: "EthernetCTP", LayerType: LayerTypeEthernetCTP}
   317  	EthernetTypeMetadata[EthernetTypeCiscoDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeCiscoDiscovery), Name: "CiscoDiscovery", LayerType: LayerTypeCiscoDiscovery}
   318  	EthernetTypeMetadata[EthernetTypeNortelDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeNortelDiscovery), Name: "NortelDiscovery", LayerType: LayerTypeNortelDiscovery}
   319  	EthernetTypeMetadata[EthernetTypeLinkLayerDiscovery] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinkLayerDiscovery), Name: "LinkLayerDiscovery", LayerType: LayerTypeLinkLayerDiscovery}
   320  	EthernetTypeMetadata[EthernetTypeMPLSUnicast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSUnicast", LayerType: LayerTypeMPLS}
   321  	EthernetTypeMetadata[EthernetTypeMPLSMulticast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSMulticast", LayerType: LayerTypeMPLS}
   322  	EthernetTypeMetadata[EthernetTypeEAPOL] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEAPOL), Name: "EAPOL", LayerType: LayerTypeEAPOL}
   323  	EthernetTypeMetadata[EthernetTypeQinQ] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot1Q), Name: "Dot1Q", LayerType: LayerTypeDot1Q}
   324  	EthernetTypeMetadata[EthernetTypeTransparentEthernetBridging] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernet), Name: "TransparentEthernetBridging", LayerType: LayerTypeEthernet}
   325  	EthernetTypeMetadata[EthernetTypeERSPAN] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeERSPANII), Name: "ERSPAN Type II", LayerType: LayerTypeERSPANII}
   326  
   327  	IPProtocolMetadata[IPProtocolIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
   328  	IPProtocolMetadata[IPProtocolTCP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeTCP), Name: "TCP", LayerType: LayerTypeTCP}
   329  	IPProtocolMetadata[IPProtocolUDP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDP), Name: "UDP", LayerType: LayerTypeUDP}
   330  	IPProtocolMetadata[IPProtocolICMPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeICMPv4), Name: "ICMPv4", LayerType: LayerTypeICMPv4}
   331  	IPProtocolMetadata[IPProtocolICMPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeICMPv6), Name: "ICMPv6", LayerType: LayerTypeICMPv6}
   332  	IPProtocolMetadata[IPProtocolSCTP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTP), Name: "SCTP", LayerType: LayerTypeSCTP}
   333  	IPProtocolMetadata[IPProtocolIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6", LayerType: LayerTypeIPv6}
   334  	IPProtocolMetadata[IPProtocolIPIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4", LayerType: LayerTypeIPv4}
   335  	IPProtocolMetadata[IPProtocolEtherIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEtherIP), Name: "EtherIP", LayerType: LayerTypeEtherIP}
   336  	IPProtocolMetadata[IPProtocolRUDP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeRUDP), Name: "RUDP", LayerType: LayerTypeRUDP}
   337  	IPProtocolMetadata[IPProtocolGRE] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeGRE), Name: "GRE", LayerType: LayerTypeGRE}
   338  	IPProtocolMetadata[IPProtocolIPv6HopByHop] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6HopByHop), Name: "IPv6HopByHop", LayerType: LayerTypeIPv6HopByHop}
   339  	IPProtocolMetadata[IPProtocolIPv6Routing] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Routing), Name: "IPv6Routing", LayerType: LayerTypeIPv6Routing}
   340  	IPProtocolMetadata[IPProtocolIPv6Fragment] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Fragment), Name: "IPv6Fragment", LayerType: LayerTypeIPv6Fragment}
   341  	IPProtocolMetadata[IPProtocolIPv6Destination] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6Destination), Name: "IPv6Destination", LayerType: LayerTypeIPv6Destination}
   342  	IPProtocolMetadata[IPProtocolOSPF] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeOSPF), Name: "OSPF", LayerType: LayerTypeOSPF}
   343  	IPProtocolMetadata[IPProtocolAH] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecAH), Name: "IPSecAH", LayerType: LayerTypeIPSecAH}
   344  	IPProtocolMetadata[IPProtocolESP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPSecESP), Name: "IPSecESP", LayerType: LayerTypeIPSecESP}
   345  	IPProtocolMetadata[IPProtocolUDPLite] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUDPLite), Name: "UDPLite", LayerType: LayerTypeUDPLite}
   346  	IPProtocolMetadata[IPProtocolMPLSInIP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLS", LayerType: LayerTypeMPLS}
   347  	IPProtocolMetadata[IPProtocolNoNextHeader] = EnumMetadata{DecodeWith: gopacket.DecodePayload, Name: "NoNextHeader", LayerType: gopacket.LayerTypePayload}
   348  	IPProtocolMetadata[IPProtocolIGMP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIGMP), Name: "IGMP", LayerType: LayerTypeIGMP}
   349  	IPProtocolMetadata[IPProtocolVRRP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeVRRP), Name: "VRRP", LayerType: LayerTypeVRRP}
   350  
   351  	SCTPChunkTypeMetadata[SCTPChunkTypeData] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPData), Name: "Data"}
   352  	SCTPChunkTypeMetadata[SCTPChunkTypeInit] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPInit), Name: "Init"}
   353  	SCTPChunkTypeMetadata[SCTPChunkTypeInitAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPInit), Name: "InitAck"}
   354  	SCTPChunkTypeMetadata[SCTPChunkTypeSack] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPSack), Name: "Sack"}
   355  	SCTPChunkTypeMetadata[SCTPChunkTypeHeartbeat] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPHeartbeat), Name: "Heartbeat"}
   356  	SCTPChunkTypeMetadata[SCTPChunkTypeHeartbeatAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPHeartbeat), Name: "HeartbeatAck"}
   357  	SCTPChunkTypeMetadata[SCTPChunkTypeAbort] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPError), Name: "Abort"}
   358  	SCTPChunkTypeMetadata[SCTPChunkTypeError] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPError), Name: "Error"}
   359  	SCTPChunkTypeMetadata[SCTPChunkTypeShutdown] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPShutdown), Name: "Shutdown"}
   360  	SCTPChunkTypeMetadata[SCTPChunkTypeShutdownAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPShutdownAck), Name: "ShutdownAck"}
   361  	SCTPChunkTypeMetadata[SCTPChunkTypeCookieEcho] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPCookieEcho), Name: "CookieEcho"}
   362  	SCTPChunkTypeMetadata[SCTPChunkTypeCookieAck] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPEmptyLayer), Name: "CookieAck"}
   363  	SCTPChunkTypeMetadata[SCTPChunkTypeShutdownComplete] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeSCTPEmptyLayer), Name: "ShutdownComplete"}
   364  
   365  	PPPTypeMetadata[PPPTypeIPv4] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4), Name: "IPv4"}
   366  	PPPTypeMetadata[PPPTypeIPv6] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv6), Name: "IPv6"}
   367  	PPPTypeMetadata[PPPTypeMPLSUnicast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSUnicast"}
   368  	PPPTypeMetadata[PPPTypeMPLSMulticast] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeMPLS), Name: "MPLSMulticast"}
   369  
   370  	PPPoECodeMetadata[PPPoECodeSession] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP"}
   371  
   372  	LinkTypeMetadata[LinkTypeEthernet] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeEthernet), Name: "Ethernet"}
   373  	LinkTypeMetadata[LinkTypePPP] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePPP), Name: "PPP"}
   374  	LinkTypeMetadata[LinkTypeFDDI] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeFDDI), Name: "FDDI"}
   375  	LinkTypeMetadata[LinkTypeNull] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLoopback), Name: "Null"}
   376  	LinkTypeMetadata[LinkTypeIEEE802_11] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11), Name: "Dot11"}
   377  	LinkTypeMetadata[LinkTypeLoop] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLoopback), Name: "Loop"}
   378  	LinkTypeMetadata[LinkTypeIEEE802_11] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeDot11), Name: "802.11"}
   379  	LinkTypeMetadata[LinkTypeRaw] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"}
   380  	// See https://github.com/the-tcpdump-group/libpcap/blob/170f717e6e818cdc4bcbbfd906b63088eaa88fa0/pcap/dlt.h#L85
   381  	// Or https://github.com/wireshark/wireshark/blob/854cfe53efe44080609c78053ecfb2342ad84a08/wiretap/pcap-common.c#L508
   382  	if runtime.GOOS == "openbsd" {
   383  		LinkTypeMetadata[14] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"}
   384  	} else {
   385  		LinkTypeMetadata[12] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeIPv4or6), Name: "Raw"}
   386  	}
   387  	LinkTypeMetadata[LinkTypePFLog] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePFLog), Name: "PFLog"}
   388  	LinkTypeMetadata[LinkTypeIEEE80211Radio] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeRadioTap), Name: "RadioTap"}
   389  	LinkTypeMetadata[LinkTypeLinuxUSB] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeUSB), Name: "USB"}
   390  	LinkTypeMetadata[LinkTypeLinuxSLL] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinuxSLL), Name: "Linux SLL"}
   391  	LinkTypeMetadata[LinkTypePrismHeader] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodePrismHeader), Name: "Prism"}
   392  	LinkTypeMetadata[LinkTypeLinuxSLL2] = EnumMetadata{DecodeWith: gopacket.DecodeFunc(decodeLinuxSLL2), Name: "Linux SLL2"}
   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  }