enums.go 29 KB

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