enums.go 29 KB

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