dot11.go 74 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105
  1. // Copyright 2014 Google, Inc. All rights reserved.
  2. //
  3. // Use of this source code is governed by a BSD-style license
  4. // that can be found in the LICENSE file in the root of the source
  5. // tree.
  6. // See http://standards.ieee.org/findstds/standard/802.11-2012.html for info on
  7. // all of the layers in this file.
  8. package layers
  9. import (
  10. "bytes"
  11. "encoding/binary"
  12. "fmt"
  13. "hash/crc32"
  14. "net"
  15. "github.com/google/gopacket"
  16. )
  17. // Dot11Flags contains the set of 8 flags in the IEEE 802.11 frame control
  18. // header, all in one place.
  19. type Dot11Flags uint8
  20. const (
  21. Dot11FlagsToDS Dot11Flags = 1 << iota
  22. Dot11FlagsFromDS
  23. Dot11FlagsMF
  24. Dot11FlagsRetry
  25. Dot11FlagsPowerManagement
  26. Dot11FlagsMD
  27. Dot11FlagsWEP
  28. Dot11FlagsOrder
  29. )
  30. func (d Dot11Flags) ToDS() bool {
  31. return d&Dot11FlagsToDS != 0
  32. }
  33. func (d Dot11Flags) FromDS() bool {
  34. return d&Dot11FlagsFromDS != 0
  35. }
  36. func (d Dot11Flags) MF() bool {
  37. return d&Dot11FlagsMF != 0
  38. }
  39. func (d Dot11Flags) Retry() bool {
  40. return d&Dot11FlagsRetry != 0
  41. }
  42. func (d Dot11Flags) PowerManagement() bool {
  43. return d&Dot11FlagsPowerManagement != 0
  44. }
  45. func (d Dot11Flags) MD() bool {
  46. return d&Dot11FlagsMD != 0
  47. }
  48. func (d Dot11Flags) WEP() bool {
  49. return d&Dot11FlagsWEP != 0
  50. }
  51. func (d Dot11Flags) Order() bool {
  52. return d&Dot11FlagsOrder != 0
  53. }
  54. // String provides a human readable string for Dot11Flags.
  55. // This string is possibly subject to change over time; if you're storing this
  56. // persistently, you should probably store the Dot11Flags value, not its string.
  57. func (a Dot11Flags) String() string {
  58. var out bytes.Buffer
  59. if a.ToDS() {
  60. out.WriteString("TO-DS,")
  61. }
  62. if a.FromDS() {
  63. out.WriteString("FROM-DS,")
  64. }
  65. if a.MF() {
  66. out.WriteString("MF,")
  67. }
  68. if a.Retry() {
  69. out.WriteString("Retry,")
  70. }
  71. if a.PowerManagement() {
  72. out.WriteString("PowerManagement,")
  73. }
  74. if a.MD() {
  75. out.WriteString("MD,")
  76. }
  77. if a.WEP() {
  78. out.WriteString("WEP,")
  79. }
  80. if a.Order() {
  81. out.WriteString("Order,")
  82. }
  83. if length := out.Len(); length > 0 {
  84. return string(out.Bytes()[:length-1]) // strip final comma
  85. }
  86. return ""
  87. }
  88. type Dot11Reason uint16
  89. // TODO: Verify these reasons, and append more reasons if necessary.
  90. const (
  91. Dot11ReasonReserved Dot11Reason = 1
  92. Dot11ReasonUnspecified Dot11Reason = 2
  93. Dot11ReasonAuthExpired Dot11Reason = 3
  94. Dot11ReasonDeauthStLeaving Dot11Reason = 4
  95. Dot11ReasonInactivity Dot11Reason = 5
  96. Dot11ReasonApFull Dot11Reason = 6
  97. Dot11ReasonClass2FromNonAuth Dot11Reason = 7
  98. Dot11ReasonClass3FromNonAss Dot11Reason = 8
  99. Dot11ReasonDisasStLeaving Dot11Reason = 9
  100. Dot11ReasonStNotAuth Dot11Reason = 10
  101. )
  102. // String provides a human readable string for Dot11Reason.
  103. // This string is possibly subject to change over time; if you're storing this
  104. // persistently, you should probably store the Dot11Reason value, not its string.
  105. func (a Dot11Reason) String() string {
  106. switch a {
  107. case Dot11ReasonReserved:
  108. return "Reserved"
  109. case Dot11ReasonUnspecified:
  110. return "Unspecified"
  111. case Dot11ReasonAuthExpired:
  112. return "Auth. expired"
  113. case Dot11ReasonDeauthStLeaving:
  114. return "Deauth. st. leaving"
  115. case Dot11ReasonInactivity:
  116. return "Inactivity"
  117. case Dot11ReasonApFull:
  118. return "Ap. full"
  119. case Dot11ReasonClass2FromNonAuth:
  120. return "Class2 from non auth."
  121. case Dot11ReasonClass3FromNonAss:
  122. return "Class3 from non ass."
  123. case Dot11ReasonDisasStLeaving:
  124. return "Disass st. leaving"
  125. case Dot11ReasonStNotAuth:
  126. return "St. not auth."
  127. default:
  128. return "Unknown reason"
  129. }
  130. }
  131. type Dot11Status uint16
  132. const (
  133. Dot11StatusSuccess Dot11Status = 0
  134. Dot11StatusFailure Dot11Status = 1 // Unspecified failure
  135. Dot11StatusCannotSupportAllCapabilities Dot11Status = 10 // Cannot support all requested capabilities in the Capability Information field
  136. Dot11StatusInabilityExistsAssociation Dot11Status = 11 // Reassociation denied due to inability to confirm that association exists
  137. Dot11StatusAssociationDenied Dot11Status = 12 // Association denied due to reason outside the scope of this standard
  138. Dot11StatusAlgorithmUnsupported Dot11Status = 13 // Responding station does not support the specified authentication algorithm
  139. Dot11StatusOufOfExpectedSequence Dot11Status = 14 // Received an Authentication frame with authentication transaction sequence number out of expected sequence
  140. Dot11StatusChallengeFailure Dot11Status = 15 // Authentication rejected because of challenge failure
  141. Dot11StatusTimeout Dot11Status = 16 // Authentication rejected due to timeout waiting for next frame in sequence
  142. Dot11StatusAPUnableToHandle Dot11Status = 17 // Association denied because AP is unable to handle additional associated stations
  143. Dot11StatusRateUnsupported Dot11Status = 18 // Association denied due to requesting station not supporting all of the data rates in the BSSBasicRateSet parameter
  144. )
  145. // String provides a human readable string for Dot11Status.
  146. // This string is possibly subject to change over time; if you're storing this
  147. // persistently, you should probably store the Dot11Status value, not its string.
  148. func (a Dot11Status) String() string {
  149. switch a {
  150. case Dot11StatusSuccess:
  151. return "success"
  152. case Dot11StatusFailure:
  153. return "failure"
  154. case Dot11StatusCannotSupportAllCapabilities:
  155. return "cannot-support-all-capabilities"
  156. case Dot11StatusInabilityExistsAssociation:
  157. return "inability-exists-association"
  158. case Dot11StatusAssociationDenied:
  159. return "association-denied"
  160. case Dot11StatusAlgorithmUnsupported:
  161. return "algorithm-unsupported"
  162. case Dot11StatusOufOfExpectedSequence:
  163. return "out-of-expected-sequence"
  164. case Dot11StatusChallengeFailure:
  165. return "challenge-failure"
  166. case Dot11StatusTimeout:
  167. return "timeout"
  168. case Dot11StatusAPUnableToHandle:
  169. return "ap-unable-to-handle"
  170. case Dot11StatusRateUnsupported:
  171. return "rate-unsupported"
  172. default:
  173. return "unknown status"
  174. }
  175. }
  176. type Dot11AckPolicy uint8
  177. const (
  178. Dot11AckPolicyNormal Dot11AckPolicy = 0
  179. Dot11AckPolicyNone Dot11AckPolicy = 1
  180. Dot11AckPolicyNoExplicit Dot11AckPolicy = 2
  181. Dot11AckPolicyBlock Dot11AckPolicy = 3
  182. )
  183. // String provides a human readable string for Dot11AckPolicy.
  184. // This string is possibly subject to change over time; if you're storing this
  185. // persistently, you should probably store the Dot11AckPolicy value, not its string.
  186. func (a Dot11AckPolicy) String() string {
  187. switch a {
  188. case Dot11AckPolicyNormal:
  189. return "normal-ack"
  190. case Dot11AckPolicyNone:
  191. return "no-ack"
  192. case Dot11AckPolicyNoExplicit:
  193. return "no-explicit-ack"
  194. case Dot11AckPolicyBlock:
  195. return "block-ack"
  196. default:
  197. return "unknown-ack-policy"
  198. }
  199. }
  200. type Dot11Algorithm uint16
  201. const (
  202. Dot11AlgorithmOpen Dot11Algorithm = 0
  203. Dot11AlgorithmSharedKey Dot11Algorithm = 1
  204. )
  205. // String provides a human readable string for Dot11Algorithm.
  206. // This string is possibly subject to change over time; if you're storing this
  207. // persistently, you should probably store the Dot11Algorithm value, not its string.
  208. func (a Dot11Algorithm) String() string {
  209. switch a {
  210. case Dot11AlgorithmOpen:
  211. return "open"
  212. case Dot11AlgorithmSharedKey:
  213. return "shared-key"
  214. default:
  215. return "unknown-algorithm"
  216. }
  217. }
  218. type Dot11InformationElementID uint8
  219. const (
  220. Dot11InformationElementIDSSID Dot11InformationElementID = 0
  221. Dot11InformationElementIDRates Dot11InformationElementID = 1
  222. Dot11InformationElementIDFHSet Dot11InformationElementID = 2
  223. Dot11InformationElementIDDSSet Dot11InformationElementID = 3
  224. Dot11InformationElementIDCFSet Dot11InformationElementID = 4
  225. Dot11InformationElementIDTIM Dot11InformationElementID = 5
  226. Dot11InformationElementIDIBSSSet Dot11InformationElementID = 6
  227. Dot11InformationElementIDCountryInfo Dot11InformationElementID = 7
  228. Dot11InformationElementIDHoppingPatternParam Dot11InformationElementID = 8
  229. Dot11InformationElementIDHoppingPatternTable Dot11InformationElementID = 9
  230. Dot11InformationElementIDRequest Dot11InformationElementID = 10
  231. Dot11InformationElementIDQBSSLoadElem Dot11InformationElementID = 11
  232. Dot11InformationElementIDEDCAParamSet Dot11InformationElementID = 12
  233. Dot11InformationElementIDTrafficSpec Dot11InformationElementID = 13
  234. Dot11InformationElementIDTrafficClass Dot11InformationElementID = 14
  235. Dot11InformationElementIDSchedule Dot11InformationElementID = 15
  236. Dot11InformationElementIDChallenge Dot11InformationElementID = 16
  237. Dot11InformationElementIDPowerConst Dot11InformationElementID = 32
  238. Dot11InformationElementIDPowerCapability Dot11InformationElementID = 33
  239. Dot11InformationElementIDTPCRequest Dot11InformationElementID = 34
  240. Dot11InformationElementIDTPCReport Dot11InformationElementID = 35
  241. Dot11InformationElementIDSupportedChannels Dot11InformationElementID = 36
  242. Dot11InformationElementIDSwitchChannelAnnounce Dot11InformationElementID = 37
  243. Dot11InformationElementIDMeasureRequest Dot11InformationElementID = 38
  244. Dot11InformationElementIDMeasureReport Dot11InformationElementID = 39
  245. Dot11InformationElementIDQuiet Dot11InformationElementID = 40
  246. Dot11InformationElementIDIBSSDFS Dot11InformationElementID = 41
  247. Dot11InformationElementIDERPInfo Dot11InformationElementID = 42
  248. Dot11InformationElementIDTSDelay Dot11InformationElementID = 43
  249. Dot11InformationElementIDTCLASProcessing Dot11InformationElementID = 44
  250. Dot11InformationElementIDHTCapabilities Dot11InformationElementID = 45
  251. Dot11InformationElementIDQOSCapability Dot11InformationElementID = 46
  252. Dot11InformationElementIDERPInfo2 Dot11InformationElementID = 47
  253. Dot11InformationElementIDRSNInfo Dot11InformationElementID = 48
  254. Dot11InformationElementIDESRates Dot11InformationElementID = 50
  255. Dot11InformationElementIDAPChannelReport Dot11InformationElementID = 51
  256. Dot11InformationElementIDNeighborReport Dot11InformationElementID = 52
  257. Dot11InformationElementIDRCPI Dot11InformationElementID = 53
  258. Dot11InformationElementIDMobilityDomain Dot11InformationElementID = 54
  259. Dot11InformationElementIDFastBSSTrans Dot11InformationElementID = 55
  260. Dot11InformationElementIDTimeoutInt Dot11InformationElementID = 56
  261. Dot11InformationElementIDRICData Dot11InformationElementID = 57
  262. Dot11InformationElementIDDSERegisteredLoc Dot11InformationElementID = 58
  263. Dot11InformationElementIDSuppOperatingClass Dot11InformationElementID = 59
  264. Dot11InformationElementIDExtChanSwitchAnnounce Dot11InformationElementID = 60
  265. Dot11InformationElementIDHTInfo Dot11InformationElementID = 61
  266. Dot11InformationElementIDSecChanOffset Dot11InformationElementID = 62
  267. Dot11InformationElementIDBSSAverageAccessDelay Dot11InformationElementID = 63
  268. Dot11InformationElementIDAntenna Dot11InformationElementID = 64
  269. Dot11InformationElementIDRSNI Dot11InformationElementID = 65
  270. Dot11InformationElementIDMeasurePilotTrans Dot11InformationElementID = 66
  271. Dot11InformationElementIDBSSAvailAdmCapacity Dot11InformationElementID = 67
  272. Dot11InformationElementIDBSSACAccDelayWAPIParam Dot11InformationElementID = 68
  273. Dot11InformationElementIDTimeAdvertisement Dot11InformationElementID = 69
  274. Dot11InformationElementIDRMEnabledCapabilities Dot11InformationElementID = 70
  275. Dot11InformationElementIDMultipleBSSID Dot11InformationElementID = 71
  276. Dot11InformationElementID2040BSSCoExist Dot11InformationElementID = 72
  277. Dot11InformationElementID2040BSSIntChanReport Dot11InformationElementID = 73
  278. Dot11InformationElementIDOverlapBSSScanParam Dot11InformationElementID = 74
  279. Dot11InformationElementIDRICDescriptor Dot11InformationElementID = 75
  280. Dot11InformationElementIDManagementMIC Dot11InformationElementID = 76
  281. Dot11InformationElementIDEventRequest Dot11InformationElementID = 78
  282. Dot11InformationElementIDEventReport Dot11InformationElementID = 79
  283. Dot11InformationElementIDDiagnosticRequest Dot11InformationElementID = 80
  284. Dot11InformationElementIDDiagnosticReport Dot11InformationElementID = 81
  285. Dot11InformationElementIDLocationParam Dot11InformationElementID = 82
  286. Dot11InformationElementIDNonTransBSSIDCapability Dot11InformationElementID = 83
  287. Dot11InformationElementIDSSIDList Dot11InformationElementID = 84
  288. Dot11InformationElementIDMultipleBSSIDIndex Dot11InformationElementID = 85
  289. Dot11InformationElementIDFMSDescriptor Dot11InformationElementID = 86
  290. Dot11InformationElementIDFMSRequest Dot11InformationElementID = 87
  291. Dot11InformationElementIDFMSResponse Dot11InformationElementID = 88
  292. Dot11InformationElementIDQOSTrafficCapability Dot11InformationElementID = 89
  293. Dot11InformationElementIDBSSMaxIdlePeriod Dot11InformationElementID = 90
  294. Dot11InformationElementIDTFSRequest Dot11InformationElementID = 91
  295. Dot11InformationElementIDTFSResponse Dot11InformationElementID = 92
  296. Dot11InformationElementIDWNMSleepMode Dot11InformationElementID = 93
  297. Dot11InformationElementIDTIMBroadcastRequest Dot11InformationElementID = 94
  298. Dot11InformationElementIDTIMBroadcastResponse Dot11InformationElementID = 95
  299. Dot11InformationElementIDCollInterferenceReport Dot11InformationElementID = 96
  300. Dot11InformationElementIDChannelUsage Dot11InformationElementID = 97
  301. Dot11InformationElementIDTimeZone Dot11InformationElementID = 98
  302. Dot11InformationElementIDDMSRequest Dot11InformationElementID = 99
  303. Dot11InformationElementIDDMSResponse Dot11InformationElementID = 100
  304. Dot11InformationElementIDLinkIdentifier Dot11InformationElementID = 101
  305. Dot11InformationElementIDWakeupSchedule Dot11InformationElementID = 102
  306. Dot11InformationElementIDChannelSwitchTiming Dot11InformationElementID = 104
  307. Dot11InformationElementIDPTIControl Dot11InformationElementID = 105
  308. Dot11InformationElementIDPUBufferStatus Dot11InformationElementID = 106
  309. Dot11InformationElementIDInterworking Dot11InformationElementID = 107
  310. Dot11InformationElementIDAdvertisementProtocol Dot11InformationElementID = 108
  311. Dot11InformationElementIDExpBWRequest Dot11InformationElementID = 109
  312. Dot11InformationElementIDQOSMapSet Dot11InformationElementID = 110
  313. Dot11InformationElementIDRoamingConsortium Dot11InformationElementID = 111
  314. Dot11InformationElementIDEmergencyAlertIdentifier Dot11InformationElementID = 112
  315. Dot11InformationElementIDMeshConfiguration Dot11InformationElementID = 113
  316. Dot11InformationElementIDMeshID Dot11InformationElementID = 114
  317. Dot11InformationElementIDMeshLinkMetricReport Dot11InformationElementID = 115
  318. Dot11InformationElementIDCongestionNotification Dot11InformationElementID = 116
  319. Dot11InformationElementIDMeshPeeringManagement Dot11InformationElementID = 117
  320. Dot11InformationElementIDMeshChannelSwitchParam Dot11InformationElementID = 118
  321. Dot11InformationElementIDMeshAwakeWindows Dot11InformationElementID = 119
  322. Dot11InformationElementIDBeaconTiming Dot11InformationElementID = 120
  323. Dot11InformationElementIDMCCAOPSetupRequest Dot11InformationElementID = 121
  324. Dot11InformationElementIDMCCAOPSetupReply Dot11InformationElementID = 122
  325. Dot11InformationElementIDMCCAOPAdvertisement Dot11InformationElementID = 123
  326. Dot11InformationElementIDMCCAOPTeardown Dot11InformationElementID = 124
  327. Dot11InformationElementIDGateAnnouncement Dot11InformationElementID = 125
  328. Dot11InformationElementIDRootAnnouncement Dot11InformationElementID = 126
  329. Dot11InformationElementIDExtCapability Dot11InformationElementID = 127
  330. Dot11InformationElementIDAgereProprietary Dot11InformationElementID = 128
  331. Dot11InformationElementIDPathRequest Dot11InformationElementID = 130
  332. Dot11InformationElementIDPathReply Dot11InformationElementID = 131
  333. Dot11InformationElementIDPathError Dot11InformationElementID = 132
  334. Dot11InformationElementIDCiscoCCX1CKIPDeviceName Dot11InformationElementID = 133
  335. Dot11InformationElementIDCiscoCCX2 Dot11InformationElementID = 136
  336. Dot11InformationElementIDProxyUpdate Dot11InformationElementID = 137
  337. Dot11InformationElementIDProxyUpdateConfirmation Dot11InformationElementID = 138
  338. Dot11InformationElementIDAuthMeshPerringExch Dot11InformationElementID = 139
  339. Dot11InformationElementIDMIC Dot11InformationElementID = 140
  340. Dot11InformationElementIDDestinationURI Dot11InformationElementID = 141
  341. Dot11InformationElementIDUAPSDCoexistence Dot11InformationElementID = 142
  342. Dot11InformationElementIDWakeupSchedule80211ad Dot11InformationElementID = 143
  343. Dot11InformationElementIDExtendedSchedule Dot11InformationElementID = 144
  344. Dot11InformationElementIDSTAAvailability Dot11InformationElementID = 145
  345. Dot11InformationElementIDDMGTSPEC Dot11InformationElementID = 146
  346. Dot11InformationElementIDNextDMGATI Dot11InformationElementID = 147
  347. Dot11InformationElementIDDMSCapabilities Dot11InformationElementID = 148
  348. Dot11InformationElementIDCiscoUnknown95 Dot11InformationElementID = 149
  349. Dot11InformationElementIDVendor2 Dot11InformationElementID = 150
  350. Dot11InformationElementIDDMGOperating Dot11InformationElementID = 151
  351. Dot11InformationElementIDDMGBSSParamChange Dot11InformationElementID = 152
  352. Dot11InformationElementIDDMGBeamRefinement Dot11InformationElementID = 153
  353. Dot11InformationElementIDChannelMeasFeedback Dot11InformationElementID = 154
  354. Dot11InformationElementIDAwakeWindow Dot11InformationElementID = 157
  355. Dot11InformationElementIDMultiBand Dot11InformationElementID = 158
  356. Dot11InformationElementIDADDBAExtension Dot11InformationElementID = 159
  357. Dot11InformationElementIDNEXTPCPList Dot11InformationElementID = 160
  358. Dot11InformationElementIDPCPHandover Dot11InformationElementID = 161
  359. Dot11InformationElementIDDMGLinkMargin Dot11InformationElementID = 162
  360. Dot11InformationElementIDSwitchingStream Dot11InformationElementID = 163
  361. Dot11InformationElementIDSessionTransmission Dot11InformationElementID = 164
  362. Dot11InformationElementIDDynamicTonePairReport Dot11InformationElementID = 165
  363. Dot11InformationElementIDClusterReport Dot11InformationElementID = 166
  364. Dot11InformationElementIDRelayCapabilities Dot11InformationElementID = 167
  365. Dot11InformationElementIDRelayTransferParameter Dot11InformationElementID = 168
  366. Dot11InformationElementIDBeamlinkMaintenance Dot11InformationElementID = 169
  367. Dot11InformationElementIDMultipleMacSublayers Dot11InformationElementID = 170
  368. Dot11InformationElementIDUPID Dot11InformationElementID = 171
  369. Dot11InformationElementIDDMGLinkAdaptionAck Dot11InformationElementID = 172
  370. Dot11InformationElementIDSymbolProprietary Dot11InformationElementID = 173
  371. Dot11InformationElementIDMCCAOPAdvertOverview Dot11InformationElementID = 174
  372. Dot11InformationElementIDQuietPeriodRequest Dot11InformationElementID = 175
  373. Dot11InformationElementIDQuietPeriodResponse Dot11InformationElementID = 177
  374. Dot11InformationElementIDECPACPolicy Dot11InformationElementID = 182
  375. Dot11InformationElementIDClusterTimeOffset Dot11InformationElementID = 183
  376. Dot11InformationElementIDAntennaSectorID Dot11InformationElementID = 190
  377. Dot11InformationElementIDVHTCapabilities Dot11InformationElementID = 191
  378. Dot11InformationElementIDVHTOperation Dot11InformationElementID = 192
  379. Dot11InformationElementIDExtendedBSSLoad Dot11InformationElementID = 193
  380. Dot11InformationElementIDWideBWChannelSwitch Dot11InformationElementID = 194
  381. Dot11InformationElementIDVHTTxPowerEnvelope Dot11InformationElementID = 195
  382. Dot11InformationElementIDChannelSwitchWrapper Dot11InformationElementID = 196
  383. Dot11InformationElementIDOperatingModeNotification Dot11InformationElementID = 199
  384. Dot11InformationElementIDUPSIM Dot11InformationElementID = 200
  385. Dot11InformationElementIDReducedNeighborReport Dot11InformationElementID = 201
  386. Dot11InformationElementIDTVHTOperation Dot11InformationElementID = 202
  387. Dot11InformationElementIDDeviceLocation Dot11InformationElementID = 204
  388. Dot11InformationElementIDWhiteSpaceMap Dot11InformationElementID = 205
  389. Dot11InformationElementIDFineTuningMeasureParams Dot11InformationElementID = 206
  390. Dot11InformationElementIDVendor Dot11InformationElementID = 221
  391. )
  392. // String provides a human readable string for Dot11InformationElementID.
  393. // This string is possibly subject to change over time; if you're storing this
  394. // persistently, you should probably store the Dot11InformationElementID value,
  395. // not its string.
  396. func (a Dot11InformationElementID) String() string {
  397. switch a {
  398. case Dot11InformationElementIDSSID:
  399. return "SSID parameter set"
  400. case Dot11InformationElementIDRates:
  401. return "Supported Rates"
  402. case Dot11InformationElementIDFHSet:
  403. return "FH Parameter set"
  404. case Dot11InformationElementIDDSSet:
  405. return "DS Parameter set"
  406. case Dot11InformationElementIDCFSet:
  407. return "CF Parameter set"
  408. case Dot11InformationElementIDTIM:
  409. return "Traffic Indication Map (TIM)"
  410. case Dot11InformationElementIDIBSSSet:
  411. return "IBSS Parameter set"
  412. case Dot11InformationElementIDCountryInfo:
  413. return "Country Information"
  414. case Dot11InformationElementIDHoppingPatternParam:
  415. return "Hopping Pattern Parameters"
  416. case Dot11InformationElementIDHoppingPatternTable:
  417. return "Hopping Pattern Table"
  418. case Dot11InformationElementIDRequest:
  419. return "Request"
  420. case Dot11InformationElementIDQBSSLoadElem:
  421. return "QBSS Load Element"
  422. case Dot11InformationElementIDEDCAParamSet:
  423. return "EDCA Parameter Set"
  424. case Dot11InformationElementIDTrafficSpec:
  425. return "Traffic Specification"
  426. case Dot11InformationElementIDTrafficClass:
  427. return "Traffic Classification"
  428. case Dot11InformationElementIDSchedule:
  429. return "Schedule"
  430. case Dot11InformationElementIDChallenge:
  431. return "Challenge text"
  432. case Dot11InformationElementIDPowerConst:
  433. return "Power Constraint"
  434. case Dot11InformationElementIDPowerCapability:
  435. return "Power Capability"
  436. case Dot11InformationElementIDTPCRequest:
  437. return "TPC Request"
  438. case Dot11InformationElementIDTPCReport:
  439. return "TPC Report"
  440. case Dot11InformationElementIDSupportedChannels:
  441. return "Supported Channels"
  442. case Dot11InformationElementIDSwitchChannelAnnounce:
  443. return "Channel Switch Announcement"
  444. case Dot11InformationElementIDMeasureRequest:
  445. return "Measurement Request"
  446. case Dot11InformationElementIDMeasureReport:
  447. return "Measurement Report"
  448. case Dot11InformationElementIDQuiet:
  449. return "Quiet"
  450. case Dot11InformationElementIDIBSSDFS:
  451. return "IBSS DFS"
  452. case Dot11InformationElementIDERPInfo:
  453. return "ERP Information"
  454. case Dot11InformationElementIDTSDelay:
  455. return "TS Delay"
  456. case Dot11InformationElementIDTCLASProcessing:
  457. return "TCLAS Processing"
  458. case Dot11InformationElementIDHTCapabilities:
  459. return "HT Capabilities (802.11n D1.10)"
  460. case Dot11InformationElementIDQOSCapability:
  461. return "QOS Capability"
  462. case Dot11InformationElementIDERPInfo2:
  463. return "ERP Information-2"
  464. case Dot11InformationElementIDRSNInfo:
  465. return "RSN Information"
  466. case Dot11InformationElementIDESRates:
  467. return "Extended Supported Rates"
  468. case Dot11InformationElementIDAPChannelReport:
  469. return "AP Channel Report"
  470. case Dot11InformationElementIDNeighborReport:
  471. return "Neighbor Report"
  472. case Dot11InformationElementIDRCPI:
  473. return "RCPI"
  474. case Dot11InformationElementIDMobilityDomain:
  475. return "Mobility Domain"
  476. case Dot11InformationElementIDFastBSSTrans:
  477. return "Fast BSS Transition"
  478. case Dot11InformationElementIDTimeoutInt:
  479. return "Timeout Interval"
  480. case Dot11InformationElementIDRICData:
  481. return "RIC Data"
  482. case Dot11InformationElementIDDSERegisteredLoc:
  483. return "DSE Registered Location"
  484. case Dot11InformationElementIDSuppOperatingClass:
  485. return "Supported Operating Classes"
  486. case Dot11InformationElementIDExtChanSwitchAnnounce:
  487. return "Extended Channel Switch Announcement"
  488. case Dot11InformationElementIDHTInfo:
  489. return "HT Information (802.11n D1.10)"
  490. case Dot11InformationElementIDSecChanOffset:
  491. return "Secondary Channel Offset (802.11n D1.10)"
  492. case Dot11InformationElementIDBSSAverageAccessDelay:
  493. return "BSS Average Access Delay"
  494. case Dot11InformationElementIDAntenna:
  495. return "Antenna"
  496. case Dot11InformationElementIDRSNI:
  497. return "RSNI"
  498. case Dot11InformationElementIDMeasurePilotTrans:
  499. return "Measurement Pilot Transmission"
  500. case Dot11InformationElementIDBSSAvailAdmCapacity:
  501. return "BSS Available Admission Capacity"
  502. case Dot11InformationElementIDBSSACAccDelayWAPIParam:
  503. return "BSS AC Access Delay/WAPI Parameter Set"
  504. case Dot11InformationElementIDTimeAdvertisement:
  505. return "Time Advertisement"
  506. case Dot11InformationElementIDRMEnabledCapabilities:
  507. return "RM Enabled Capabilities"
  508. case Dot11InformationElementIDMultipleBSSID:
  509. return "Multiple BSSID"
  510. case Dot11InformationElementID2040BSSCoExist:
  511. return "20/40 BSS Coexistence"
  512. case Dot11InformationElementID2040BSSIntChanReport:
  513. return "20/40 BSS Intolerant Channel Report"
  514. case Dot11InformationElementIDOverlapBSSScanParam:
  515. return "Overlapping BSS Scan Parameters"
  516. case Dot11InformationElementIDRICDescriptor:
  517. return "RIC Descriptor"
  518. case Dot11InformationElementIDManagementMIC:
  519. return "Management MIC"
  520. case Dot11InformationElementIDEventRequest:
  521. return "Event Request"
  522. case Dot11InformationElementIDEventReport:
  523. return "Event Report"
  524. case Dot11InformationElementIDDiagnosticRequest:
  525. return "Diagnostic Request"
  526. case Dot11InformationElementIDDiagnosticReport:
  527. return "Diagnostic Report"
  528. case Dot11InformationElementIDLocationParam:
  529. return "Location Parameters"
  530. case Dot11InformationElementIDNonTransBSSIDCapability:
  531. return "Non Transmitted BSSID Capability"
  532. case Dot11InformationElementIDSSIDList:
  533. return "SSID List"
  534. case Dot11InformationElementIDMultipleBSSIDIndex:
  535. return "Multiple BSSID Index"
  536. case Dot11InformationElementIDFMSDescriptor:
  537. return "FMS Descriptor"
  538. case Dot11InformationElementIDFMSRequest:
  539. return "FMS Request"
  540. case Dot11InformationElementIDFMSResponse:
  541. return "FMS Response"
  542. case Dot11InformationElementIDQOSTrafficCapability:
  543. return "QoS Traffic Capability"
  544. case Dot11InformationElementIDBSSMaxIdlePeriod:
  545. return "BSS Max Idle Period"
  546. case Dot11InformationElementIDTFSRequest:
  547. return "TFS Request"
  548. case Dot11InformationElementIDTFSResponse:
  549. return "TFS Response"
  550. case Dot11InformationElementIDWNMSleepMode:
  551. return "WNM-Sleep Mode"
  552. case Dot11InformationElementIDTIMBroadcastRequest:
  553. return "TIM Broadcast Request"
  554. case Dot11InformationElementIDTIMBroadcastResponse:
  555. return "TIM Broadcast Response"
  556. case Dot11InformationElementIDCollInterferenceReport:
  557. return "Collocated Interference Report"
  558. case Dot11InformationElementIDChannelUsage:
  559. return "Channel Usage"
  560. case Dot11InformationElementIDTimeZone:
  561. return "Time Zone"
  562. case Dot11InformationElementIDDMSRequest:
  563. return "DMS Request"
  564. case Dot11InformationElementIDDMSResponse:
  565. return "DMS Response"
  566. case Dot11InformationElementIDLinkIdentifier:
  567. return "Link Identifier"
  568. case Dot11InformationElementIDWakeupSchedule:
  569. return "Wakeup Schedule"
  570. case Dot11InformationElementIDChannelSwitchTiming:
  571. return "Channel Switch Timing"
  572. case Dot11InformationElementIDPTIControl:
  573. return "PTI Control"
  574. case Dot11InformationElementIDPUBufferStatus:
  575. return "PU Buffer Status"
  576. case Dot11InformationElementIDInterworking:
  577. return "Interworking"
  578. case Dot11InformationElementIDAdvertisementProtocol:
  579. return "Advertisement Protocol"
  580. case Dot11InformationElementIDExpBWRequest:
  581. return "Expedited Bandwidth Request"
  582. case Dot11InformationElementIDQOSMapSet:
  583. return "QoS Map Set"
  584. case Dot11InformationElementIDRoamingConsortium:
  585. return "Roaming Consortium"
  586. case Dot11InformationElementIDEmergencyAlertIdentifier:
  587. return "Emergency Alert Identifier"
  588. case Dot11InformationElementIDMeshConfiguration:
  589. return "Mesh Configuration"
  590. case Dot11InformationElementIDMeshID:
  591. return "Mesh ID"
  592. case Dot11InformationElementIDMeshLinkMetricReport:
  593. return "Mesh Link Metric Report"
  594. case Dot11InformationElementIDCongestionNotification:
  595. return "Congestion Notification"
  596. case Dot11InformationElementIDMeshPeeringManagement:
  597. return "Mesh Peering Management"
  598. case Dot11InformationElementIDMeshChannelSwitchParam:
  599. return "Mesh Channel Switch Parameters"
  600. case Dot11InformationElementIDMeshAwakeWindows:
  601. return "Mesh Awake Windows"
  602. case Dot11InformationElementIDBeaconTiming:
  603. return "Beacon Timing"
  604. case Dot11InformationElementIDMCCAOPSetupRequest:
  605. return "MCCAOP Setup Request"
  606. case Dot11InformationElementIDMCCAOPSetupReply:
  607. return "MCCAOP SETUP Reply"
  608. case Dot11InformationElementIDMCCAOPAdvertisement:
  609. return "MCCAOP Advertisement"
  610. case Dot11InformationElementIDMCCAOPTeardown:
  611. return "MCCAOP Teardown"
  612. case Dot11InformationElementIDGateAnnouncement:
  613. return "Gate Announcement"
  614. case Dot11InformationElementIDRootAnnouncement:
  615. return "Root Announcement"
  616. case Dot11InformationElementIDExtCapability:
  617. return "Extended Capabilities"
  618. case Dot11InformationElementIDAgereProprietary:
  619. return "Agere Proprietary"
  620. case Dot11InformationElementIDPathRequest:
  621. return "Path Request"
  622. case Dot11InformationElementIDPathReply:
  623. return "Path Reply"
  624. case Dot11InformationElementIDPathError:
  625. return "Path Error"
  626. case Dot11InformationElementIDCiscoCCX1CKIPDeviceName:
  627. return "Cisco CCX1 CKIP + Device Name"
  628. case Dot11InformationElementIDCiscoCCX2:
  629. return "Cisco CCX2"
  630. case Dot11InformationElementIDProxyUpdate:
  631. return "Proxy Update"
  632. case Dot11InformationElementIDProxyUpdateConfirmation:
  633. return "Proxy Update Confirmation"
  634. case Dot11InformationElementIDAuthMeshPerringExch:
  635. return "Auhenticated Mesh Perring Exchange"
  636. case Dot11InformationElementIDMIC:
  637. return "MIC (Message Integrity Code)"
  638. case Dot11InformationElementIDDestinationURI:
  639. return "Destination URI"
  640. case Dot11InformationElementIDUAPSDCoexistence:
  641. return "U-APSD Coexistence"
  642. case Dot11InformationElementIDWakeupSchedule80211ad:
  643. return "Wakeup Schedule 802.11ad"
  644. case Dot11InformationElementIDExtendedSchedule:
  645. return "Extended Schedule"
  646. case Dot11InformationElementIDSTAAvailability:
  647. return "STA Availability"
  648. case Dot11InformationElementIDDMGTSPEC:
  649. return "DMG TSPEC"
  650. case Dot11InformationElementIDNextDMGATI:
  651. return "Next DMG ATI"
  652. case Dot11InformationElementIDDMSCapabilities:
  653. return "DMG Capabilities"
  654. case Dot11InformationElementIDCiscoUnknown95:
  655. return "Cisco Unknown 95"
  656. case Dot11InformationElementIDVendor2:
  657. return "Vendor Specific"
  658. case Dot11InformationElementIDDMGOperating:
  659. return "DMG Operating"
  660. case Dot11InformationElementIDDMGBSSParamChange:
  661. return "DMG BSS Parameter Change"
  662. case Dot11InformationElementIDDMGBeamRefinement:
  663. return "DMG Beam Refinement"
  664. case Dot11InformationElementIDChannelMeasFeedback:
  665. return "Channel Measurement Feedback"
  666. case Dot11InformationElementIDAwakeWindow:
  667. return "Awake Window"
  668. case Dot11InformationElementIDMultiBand:
  669. return "Multi Band"
  670. case Dot11InformationElementIDADDBAExtension:
  671. return "ADDBA Extension"
  672. case Dot11InformationElementIDNEXTPCPList:
  673. return "NEXTPCP List"
  674. case Dot11InformationElementIDPCPHandover:
  675. return "PCP Handover"
  676. case Dot11InformationElementIDDMGLinkMargin:
  677. return "DMG Link Margin"
  678. case Dot11InformationElementIDSwitchingStream:
  679. return "Switching Stream"
  680. case Dot11InformationElementIDSessionTransmission:
  681. return "Session Transmission"
  682. case Dot11InformationElementIDDynamicTonePairReport:
  683. return "Dynamic Tone Pairing Report"
  684. case Dot11InformationElementIDClusterReport:
  685. return "Cluster Report"
  686. case Dot11InformationElementIDRelayCapabilities:
  687. return "Relay Capabilities"
  688. case Dot11InformationElementIDRelayTransferParameter:
  689. return "Relay Transfer Parameter"
  690. case Dot11InformationElementIDBeamlinkMaintenance:
  691. return "Beamlink Maintenance"
  692. case Dot11InformationElementIDMultipleMacSublayers:
  693. return "Multiple MAC Sublayers"
  694. case Dot11InformationElementIDUPID:
  695. return "U-PID"
  696. case Dot11InformationElementIDDMGLinkAdaptionAck:
  697. return "DMG Link Adaption Acknowledgment"
  698. case Dot11InformationElementIDSymbolProprietary:
  699. return "Symbol Proprietary"
  700. case Dot11InformationElementIDMCCAOPAdvertOverview:
  701. return "MCCAOP Advertisement Overview"
  702. case Dot11InformationElementIDQuietPeriodRequest:
  703. return "Quiet Period Request"
  704. case Dot11InformationElementIDQuietPeriodResponse:
  705. return "Quiet Period Response"
  706. case Dot11InformationElementIDECPACPolicy:
  707. return "ECPAC Policy"
  708. case Dot11InformationElementIDClusterTimeOffset:
  709. return "Cluster Time Offset"
  710. case Dot11InformationElementIDAntennaSectorID:
  711. return "Antenna Sector ID"
  712. case Dot11InformationElementIDVHTCapabilities:
  713. return "VHT Capabilities (IEEE Std 802.11ac/D3.1)"
  714. case Dot11InformationElementIDVHTOperation:
  715. return "VHT Operation (IEEE Std 802.11ac/D3.1)"
  716. case Dot11InformationElementIDExtendedBSSLoad:
  717. return "Extended BSS Load"
  718. case Dot11InformationElementIDWideBWChannelSwitch:
  719. return "Wide Bandwidth Channel Switch"
  720. case Dot11InformationElementIDVHTTxPowerEnvelope:
  721. return "VHT Tx Power Envelope (IEEE Std 802.11ac/D5.0)"
  722. case Dot11InformationElementIDChannelSwitchWrapper:
  723. return "Channel Switch Wrapper"
  724. case Dot11InformationElementIDOperatingModeNotification:
  725. return "Operating Mode Notification"
  726. case Dot11InformationElementIDUPSIM:
  727. return "UP SIM"
  728. case Dot11InformationElementIDReducedNeighborReport:
  729. return "Reduced Neighbor Report"
  730. case Dot11InformationElementIDTVHTOperation:
  731. return "TVHT Op"
  732. case Dot11InformationElementIDDeviceLocation:
  733. return "Device Location"
  734. case Dot11InformationElementIDWhiteSpaceMap:
  735. return "White Space Map"
  736. case Dot11InformationElementIDFineTuningMeasureParams:
  737. return "Fine Tuning Measure Parameters"
  738. case Dot11InformationElementIDVendor:
  739. return "Vendor"
  740. default:
  741. return "Unknown information element id"
  742. }
  743. }
  744. // Dot11 provides an IEEE 802.11 base packet header.
  745. // See http://standards.ieee.org/findstds/standard/802.11-2012.html
  746. // for excruciating detail.
  747. type Dot11 struct {
  748. BaseLayer
  749. Type Dot11Type
  750. Proto uint8
  751. Flags Dot11Flags
  752. DurationID uint16
  753. Address1 net.HardwareAddr
  754. Address2 net.HardwareAddr
  755. Address3 net.HardwareAddr
  756. Address4 net.HardwareAddr
  757. SequenceNumber uint16
  758. FragmentNumber uint16
  759. Checksum uint32
  760. QOS *Dot11QOS
  761. HTControl *Dot11HTControl
  762. DataLayer gopacket.Layer
  763. }
  764. type Dot11QOS struct {
  765. TID uint8 /* Traffic IDentifier */
  766. EOSP bool /* End of service period */
  767. AckPolicy Dot11AckPolicy
  768. TXOP uint8
  769. }
  770. type Dot11HTControl struct {
  771. ACConstraint bool
  772. RDGMorePPDU bool
  773. VHT *Dot11HTControlVHT
  774. HT *Dot11HTControlHT
  775. }
  776. type Dot11HTControlHT struct {
  777. LinkAdapationControl *Dot11LinkAdapationControl
  778. CalibrationPosition uint8
  779. CalibrationSequence uint8
  780. CSISteering uint8
  781. NDPAnnouncement bool
  782. DEI bool
  783. }
  784. type Dot11HTControlVHT struct {
  785. MRQ bool
  786. UnsolicitedMFB bool
  787. MSI *uint8
  788. MFB Dot11HTControlMFB
  789. CompressedMSI *uint8
  790. STBCIndication bool
  791. MFSI *uint8
  792. GID *uint8
  793. CodingType *Dot11CodingType
  794. FbTXBeamformed bool
  795. }
  796. type Dot11HTControlMFB struct {
  797. NumSTS uint8
  798. VHTMCS uint8
  799. BW uint8
  800. SNR int8
  801. }
  802. type Dot11LinkAdapationControl struct {
  803. TRQ bool
  804. MRQ bool
  805. MSI uint8
  806. MFSI uint8
  807. ASEL *Dot11ASEL
  808. MFB *uint8
  809. }
  810. type Dot11ASEL struct {
  811. Command uint8
  812. Data uint8
  813. }
  814. type Dot11CodingType uint8
  815. const (
  816. Dot11CodingTypeBCC = 0
  817. Dot11CodingTypeLDPC = 1
  818. )
  819. func (a Dot11CodingType) String() string {
  820. switch a {
  821. case Dot11CodingTypeBCC:
  822. return "BCC"
  823. case Dot11CodingTypeLDPC:
  824. return "LDPC"
  825. default:
  826. return "Unknown coding type"
  827. }
  828. }
  829. func (m *Dot11HTControlMFB) NoFeedBackPresent() bool {
  830. return m.VHTMCS == 15 && m.NumSTS == 7
  831. }
  832. func decodeDot11(data []byte, p gopacket.PacketBuilder) error {
  833. d := &Dot11{}
  834. err := d.DecodeFromBytes(data, p)
  835. if err != nil {
  836. return err
  837. }
  838. p.AddLayer(d)
  839. if d.DataLayer != nil {
  840. p.AddLayer(d.DataLayer)
  841. }
  842. return p.NextDecoder(d.NextLayerType())
  843. }
  844. func (m *Dot11) LayerType() gopacket.LayerType { return LayerTypeDot11 }
  845. func (m *Dot11) CanDecode() gopacket.LayerClass { return LayerTypeDot11 }
  846. func (m *Dot11) NextLayerType() gopacket.LayerType {
  847. if m.DataLayer != nil {
  848. if m.Flags.WEP() {
  849. return LayerTypeDot11WEP
  850. }
  851. return m.DataLayer.(gopacket.DecodingLayer).NextLayerType()
  852. }
  853. return m.Type.LayerType()
  854. }
  855. func createU8(x uint8) *uint8 {
  856. return &x
  857. }
  858. var dataDecodeMap = map[Dot11Type]func() gopacket.DecodingLayer{
  859. Dot11TypeData: func() gopacket.DecodingLayer { return &Dot11Data{} },
  860. Dot11TypeDataCFAck: func() gopacket.DecodingLayer { return &Dot11DataCFAck{} },
  861. Dot11TypeDataCFPoll: func() gopacket.DecodingLayer { return &Dot11DataCFPoll{} },
  862. Dot11TypeDataCFAckPoll: func() gopacket.DecodingLayer { return &Dot11DataCFAckPoll{} },
  863. Dot11TypeDataNull: func() gopacket.DecodingLayer { return &Dot11DataNull{} },
  864. Dot11TypeDataCFAckNoData: func() gopacket.DecodingLayer { return &Dot11DataCFAckNoData{} },
  865. Dot11TypeDataCFPollNoData: func() gopacket.DecodingLayer { return &Dot11DataCFPollNoData{} },
  866. Dot11TypeDataCFAckPollNoData: func() gopacket.DecodingLayer { return &Dot11DataCFAckPollNoData{} },
  867. Dot11TypeDataQOSData: func() gopacket.DecodingLayer { return &Dot11DataQOSData{} },
  868. Dot11TypeDataQOSDataCFAck: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFAck{} },
  869. Dot11TypeDataQOSDataCFPoll: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFPoll{} },
  870. Dot11TypeDataQOSDataCFAckPoll: func() gopacket.DecodingLayer { return &Dot11DataQOSDataCFAckPoll{} },
  871. Dot11TypeDataQOSNull: func() gopacket.DecodingLayer { return &Dot11DataQOSNull{} },
  872. Dot11TypeDataQOSCFPollNoData: func() gopacket.DecodingLayer { return &Dot11DataQOSCFPollNoData{} },
  873. Dot11TypeDataQOSCFAckPollNoData: func() gopacket.DecodingLayer { return &Dot11DataQOSCFAckPollNoData{} },
  874. }
  875. func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  876. if len(data) < 10 {
  877. df.SetTruncated()
  878. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), 10)
  879. }
  880. m.Type = Dot11Type((data[0])&0xFC) >> 2
  881. m.Proto = uint8(data[0]) & 0x0003
  882. m.Flags = Dot11Flags(data[1])
  883. m.DurationID = binary.LittleEndian.Uint16(data[2:4])
  884. m.Address1 = net.HardwareAddr(data[4:10])
  885. offset := 10
  886. mainType := m.Type.MainType()
  887. switch mainType {
  888. case Dot11TypeCtrl:
  889. switch m.Type {
  890. case Dot11TypeCtrlRTS, Dot11TypeCtrlPowersavePoll, Dot11TypeCtrlCFEnd, Dot11TypeCtrlCFEndAck:
  891. if len(data) < offset+6 {
  892. df.SetTruncated()
  893. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
  894. }
  895. m.Address2 = net.HardwareAddr(data[offset : offset+6])
  896. offset += 6
  897. }
  898. case Dot11TypeMgmt, Dot11TypeData:
  899. if len(data) < offset+14 {
  900. df.SetTruncated()
  901. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+14)
  902. }
  903. m.Address2 = net.HardwareAddr(data[offset : offset+6])
  904. offset += 6
  905. m.Address3 = net.HardwareAddr(data[offset : offset+6])
  906. offset += 6
  907. m.SequenceNumber = (binary.LittleEndian.Uint16(data[offset:offset+2]) & 0xFFF0) >> 4
  908. m.FragmentNumber = (binary.LittleEndian.Uint16(data[offset:offset+2]) & 0x000F)
  909. offset += 2
  910. }
  911. if mainType == Dot11TypeData && m.Flags.FromDS() && m.Flags.ToDS() {
  912. if len(data) < offset+6 {
  913. df.SetTruncated()
  914. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
  915. }
  916. m.Address4 = net.HardwareAddr(data[offset : offset+6])
  917. offset += 6
  918. }
  919. if m.Type.QOS() {
  920. if len(data) < offset+2 {
  921. df.SetTruncated()
  922. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
  923. }
  924. m.QOS = &Dot11QOS{
  925. TID: (uint8(data[offset]) & 0x0F),
  926. EOSP: (uint8(data[offset]) & 0x10) == 0x10,
  927. AckPolicy: Dot11AckPolicy((uint8(data[offset]) & 0x60) >> 5),
  928. TXOP: uint8(data[offset+1]),
  929. }
  930. offset += 2
  931. }
  932. if m.Flags.Order() && (m.Type.QOS() || mainType == Dot11TypeMgmt) {
  933. if len(data) < offset+4 {
  934. df.SetTruncated()
  935. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
  936. }
  937. htc := &Dot11HTControl{
  938. ACConstraint: data[offset+3]&0x40 != 0,
  939. RDGMorePPDU: data[offset+3]&0x80 != 0,
  940. }
  941. m.HTControl = htc
  942. if data[offset]&0x1 != 0 { // VHT Variant
  943. vht := &Dot11HTControlVHT{}
  944. htc.VHT = vht
  945. vht.MRQ = data[offset]&0x4 != 0
  946. vht.UnsolicitedMFB = data[offset+3]&0x20 != 0
  947. vht.MFB = Dot11HTControlMFB{
  948. NumSTS: uint8(data[offset+1] >> 1 & 0x7),
  949. VHTMCS: uint8(data[offset+1] >> 4 & 0xF),
  950. BW: uint8(data[offset+2] & 0x3),
  951. SNR: int8((-(data[offset+2] >> 2 & 0x20))+data[offset+2]>>2&0x1F) + 22,
  952. }
  953. if vht.UnsolicitedMFB {
  954. if !vht.MFB.NoFeedBackPresent() {
  955. vht.CompressedMSI = createU8(data[offset] >> 3 & 0x3)
  956. vht.STBCIndication = data[offset]&0x20 != 0
  957. vht.CodingType = (*Dot11CodingType)(createU8(data[offset+3] >> 3 & 0x1))
  958. vht.FbTXBeamformed = data[offset+3]&0x10 != 0
  959. vht.GID = createU8(
  960. data[offset]>>6 +
  961. (data[offset+1] & 0x1 << 2) +
  962. data[offset+3]&0x7<<3)
  963. }
  964. } else {
  965. if vht.MRQ {
  966. vht.MSI = createU8((data[offset] >> 3) & 0x07)
  967. }
  968. vht.MFSI = createU8(data[offset]>>6 + (data[offset+1] & 0x1 << 2))
  969. }
  970. } else { // HT Variant
  971. ht := &Dot11HTControlHT{}
  972. htc.HT = ht
  973. lac := &Dot11LinkAdapationControl{}
  974. ht.LinkAdapationControl = lac
  975. lac.TRQ = data[offset]&0x2 != 0
  976. lac.MFSI = data[offset]>>6&0x3 + data[offset+1]&0x1<<3
  977. if data[offset]&0x3C == 0x38 { // ASEL
  978. lac.ASEL = &Dot11ASEL{
  979. Command: data[offset+1] >> 1 & 0x7,
  980. Data: data[offset+1] >> 4 & 0xF,
  981. }
  982. } else {
  983. lac.MRQ = data[offset]&0x4 != 0
  984. if lac.MRQ {
  985. lac.MSI = data[offset] >> 3 & 0x7
  986. }
  987. lac.MFB = createU8(data[offset+1] >> 1)
  988. }
  989. ht.CalibrationPosition = data[offset+2] & 0x3
  990. ht.CalibrationSequence = data[offset+2] >> 2 & 0x3
  991. ht.CSISteering = data[offset+2] >> 6 & 0x3
  992. ht.NDPAnnouncement = data[offset+3]&0x1 != 0
  993. if mainType != Dot11TypeMgmt {
  994. ht.DEI = data[offset+3]&0x20 != 0
  995. }
  996. }
  997. offset += 4
  998. }
  999. if len(data) < offset+4 {
  1000. df.SetTruncated()
  1001. return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+4)
  1002. }
  1003. m.BaseLayer = BaseLayer{
  1004. Contents: data[0:offset],
  1005. Payload: data[offset : len(data)-4],
  1006. }
  1007. if mainType == Dot11TypeData {
  1008. l := dataDecodeMap[m.Type]()
  1009. err := l.DecodeFromBytes(m.BaseLayer.Payload, df)
  1010. if err != nil {
  1011. return err
  1012. }
  1013. m.DataLayer = l.(gopacket.Layer)
  1014. }
  1015. m.Checksum = binary.LittleEndian.Uint32(data[len(data)-4 : len(data)])
  1016. return nil
  1017. }
  1018. func (m *Dot11) ChecksumValid() bool {
  1019. // only for CTRL and MGMT frames
  1020. h := crc32.NewIEEE()
  1021. h.Write(m.Contents)
  1022. h.Write(m.Payload)
  1023. return m.Checksum == h.Sum32()
  1024. }
  1025. func (m Dot11) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1026. buf, err := b.PrependBytes(24)
  1027. if err != nil {
  1028. return err
  1029. }
  1030. buf[0] = (uint8(m.Type) << 2) | m.Proto
  1031. buf[1] = uint8(m.Flags)
  1032. binary.LittleEndian.PutUint16(buf[2:4], m.DurationID)
  1033. copy(buf[4:10], m.Address1)
  1034. offset := 10
  1035. switch m.Type.MainType() {
  1036. case Dot11TypeCtrl:
  1037. switch m.Type {
  1038. case Dot11TypeCtrlRTS, Dot11TypeCtrlPowersavePoll, Dot11TypeCtrlCFEnd, Dot11TypeCtrlCFEndAck:
  1039. copy(buf[offset:offset+6], m.Address2)
  1040. offset += 6
  1041. }
  1042. case Dot11TypeMgmt, Dot11TypeData:
  1043. copy(buf[offset:offset+6], m.Address2)
  1044. offset += 6
  1045. copy(buf[offset:offset+6], m.Address3)
  1046. offset += 6
  1047. binary.LittleEndian.PutUint16(buf[offset:offset+2], (m.SequenceNumber<<4)|m.FragmentNumber)
  1048. offset += 2
  1049. }
  1050. if m.Type.MainType() == Dot11TypeData && m.Flags.FromDS() && m.Flags.ToDS() {
  1051. copy(buf[offset:offset+6], m.Address4)
  1052. offset += 6
  1053. }
  1054. return nil
  1055. }
  1056. // Dot11Mgmt is a base for all IEEE 802.11 management layers.
  1057. type Dot11Mgmt struct {
  1058. BaseLayer
  1059. }
  1060. func (m *Dot11Mgmt) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload }
  1061. func (m *Dot11Mgmt) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1062. m.Contents = data
  1063. return nil
  1064. }
  1065. // Dot11Ctrl is a base for all IEEE 802.11 control layers.
  1066. type Dot11Ctrl struct {
  1067. BaseLayer
  1068. }
  1069. func (m *Dot11Ctrl) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload }
  1070. func (m *Dot11Ctrl) LayerType() gopacket.LayerType { return LayerTypeDot11Ctrl }
  1071. func (m *Dot11Ctrl) CanDecode() gopacket.LayerClass { return LayerTypeDot11Ctrl }
  1072. func (m *Dot11Ctrl) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1073. m.Contents = data
  1074. return nil
  1075. }
  1076. func decodeDot11Ctrl(data []byte, p gopacket.PacketBuilder) error {
  1077. d := &Dot11Ctrl{}
  1078. return decodingLayerDecoder(d, data, p)
  1079. }
  1080. // Dot11WEP contains WEP encrpted IEEE 802.11 data.
  1081. type Dot11WEP struct {
  1082. BaseLayer
  1083. }
  1084. func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload }
  1085. func (m *Dot11WEP) LayerType() gopacket.LayerType { return LayerTypeDot11WEP }
  1086. func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeDot11WEP }
  1087. func (m *Dot11WEP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1088. m.Contents = data
  1089. return nil
  1090. }
  1091. func decodeDot11WEP(data []byte, p gopacket.PacketBuilder) error {
  1092. d := &Dot11WEP{}
  1093. return decodingLayerDecoder(d, data, p)
  1094. }
  1095. // Dot11Data is a base for all IEEE 802.11 data layers.
  1096. type Dot11Data struct {
  1097. BaseLayer
  1098. }
  1099. func (m *Dot11Data) NextLayerType() gopacket.LayerType {
  1100. return LayerTypeLLC
  1101. }
  1102. func (m *Dot11Data) LayerType() gopacket.LayerType { return LayerTypeDot11Data }
  1103. func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerTypeDot11Data }
  1104. func (m *Dot11Data) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1105. m.Payload = data
  1106. return nil
  1107. }
  1108. func decodeDot11Data(data []byte, p gopacket.PacketBuilder) error {
  1109. d := &Dot11Data{}
  1110. return decodingLayerDecoder(d, data, p)
  1111. }
  1112. type Dot11DataCFAck struct {
  1113. Dot11Data
  1114. }
  1115. func decodeDot11DataCFAck(data []byte, p gopacket.PacketBuilder) error {
  1116. d := &Dot11DataCFAck{}
  1117. return decodingLayerDecoder(d, data, p)
  1118. }
  1119. func (m *Dot11DataCFAck) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFAck }
  1120. func (m *Dot11DataCFAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAck }
  1121. func (m *Dot11DataCFAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1122. return m.Dot11Data.DecodeFromBytes(data, df)
  1123. }
  1124. type Dot11DataCFPoll struct {
  1125. Dot11Data
  1126. }
  1127. func decodeDot11DataCFPoll(data []byte, p gopacket.PacketBuilder) error {
  1128. d := &Dot11DataCFPoll{}
  1129. return decodingLayerDecoder(d, data, p)
  1130. }
  1131. func (m *Dot11DataCFPoll) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFPoll }
  1132. func (m *Dot11DataCFPoll) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFPoll }
  1133. func (m *Dot11DataCFPoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1134. return m.Dot11Data.DecodeFromBytes(data, df)
  1135. }
  1136. type Dot11DataCFAckPoll struct {
  1137. Dot11Data
  1138. }
  1139. func decodeDot11DataCFAckPoll(data []byte, p gopacket.PacketBuilder) error {
  1140. d := &Dot11DataCFAckPoll{}
  1141. return decodingLayerDecoder(d, data, p)
  1142. }
  1143. func (m *Dot11DataCFAckPoll) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFAckPoll }
  1144. func (m *Dot11DataCFAckPoll) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAckPoll }
  1145. func (m *Dot11DataCFAckPoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1146. return m.Dot11Data.DecodeFromBytes(data, df)
  1147. }
  1148. type Dot11DataNull struct {
  1149. Dot11Data
  1150. }
  1151. func decodeDot11DataNull(data []byte, p gopacket.PacketBuilder) error {
  1152. d := &Dot11DataNull{}
  1153. return decodingLayerDecoder(d, data, p)
  1154. }
  1155. func (m *Dot11DataNull) LayerType() gopacket.LayerType { return LayerTypeDot11DataNull }
  1156. func (m *Dot11DataNull) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataNull }
  1157. func (m *Dot11DataNull) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1158. return m.Dot11Data.DecodeFromBytes(data, df)
  1159. }
  1160. type Dot11DataCFAckNoData struct {
  1161. Dot11Data
  1162. }
  1163. func decodeDot11DataCFAckNoData(data []byte, p gopacket.PacketBuilder) error {
  1164. d := &Dot11DataCFAckNoData{}
  1165. return decodingLayerDecoder(d, data, p)
  1166. }
  1167. func (m *Dot11DataCFAckNoData) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFAckNoData }
  1168. func (m *Dot11DataCFAckNoData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAckNoData }
  1169. func (m *Dot11DataCFAckNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1170. return m.Dot11Data.DecodeFromBytes(data, df)
  1171. }
  1172. type Dot11DataCFPollNoData struct {
  1173. Dot11Data
  1174. }
  1175. func decodeDot11DataCFPollNoData(data []byte, p gopacket.PacketBuilder) error {
  1176. d := &Dot11DataCFPollNoData{}
  1177. return decodingLayerDecoder(d, data, p)
  1178. }
  1179. func (m *Dot11DataCFPollNoData) LayerType() gopacket.LayerType { return LayerTypeDot11DataCFPollNoData }
  1180. func (m *Dot11DataCFPollNoData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFPollNoData }
  1181. func (m *Dot11DataCFPollNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1182. return m.Dot11Data.DecodeFromBytes(data, df)
  1183. }
  1184. type Dot11DataCFAckPollNoData struct {
  1185. Dot11Data
  1186. }
  1187. func decodeDot11DataCFAckPollNoData(data []byte, p gopacket.PacketBuilder) error {
  1188. d := &Dot11DataCFAckPollNoData{}
  1189. return decodingLayerDecoder(d, data, p)
  1190. }
  1191. func (m *Dot11DataCFAckPollNoData) LayerType() gopacket.LayerType {
  1192. return LayerTypeDot11DataCFAckPollNoData
  1193. }
  1194. func (m *Dot11DataCFAckPollNoData) CanDecode() gopacket.LayerClass {
  1195. return LayerTypeDot11DataCFAckPollNoData
  1196. }
  1197. func (m *Dot11DataCFAckPollNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1198. return m.Dot11Data.DecodeFromBytes(data, df)
  1199. }
  1200. type Dot11DataQOS struct {
  1201. Dot11Ctrl
  1202. }
  1203. func (m *Dot11DataQOS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1204. m.BaseLayer = BaseLayer{Payload: data}
  1205. return nil
  1206. }
  1207. type Dot11DataQOSData struct {
  1208. Dot11DataQOS
  1209. }
  1210. func decodeDot11DataQOSData(data []byte, p gopacket.PacketBuilder) error {
  1211. d := &Dot11DataQOSData{}
  1212. return decodingLayerDecoder(d, data, p)
  1213. }
  1214. func (m *Dot11DataQOSData) LayerType() gopacket.LayerType { return LayerTypeDot11DataQOSData }
  1215. func (m *Dot11DataQOSData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSData }
  1216. func (m *Dot11DataQOSData) NextLayerType() gopacket.LayerType {
  1217. return LayerTypeDot11Data
  1218. }
  1219. type Dot11DataQOSDataCFAck struct {
  1220. Dot11DataQOS
  1221. }
  1222. func decodeDot11DataQOSDataCFAck(data []byte, p gopacket.PacketBuilder) error {
  1223. d := &Dot11DataQOSDataCFAck{}
  1224. return decodingLayerDecoder(d, data, p)
  1225. }
  1226. func (m *Dot11DataQOSDataCFAck) LayerType() gopacket.LayerType { return LayerTypeDot11DataQOSDataCFAck }
  1227. func (m *Dot11DataQOSDataCFAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSDataCFAck }
  1228. func (m *Dot11DataQOSDataCFAck) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataCFAck }
  1229. type Dot11DataQOSDataCFPoll struct {
  1230. Dot11DataQOS
  1231. }
  1232. func decodeDot11DataQOSDataCFPoll(data []byte, p gopacket.PacketBuilder) error {
  1233. d := &Dot11DataQOSDataCFPoll{}
  1234. return decodingLayerDecoder(d, data, p)
  1235. }
  1236. func (m *Dot11DataQOSDataCFPoll) LayerType() gopacket.LayerType {
  1237. return LayerTypeDot11DataQOSDataCFPoll
  1238. }
  1239. func (m *Dot11DataQOSDataCFPoll) CanDecode() gopacket.LayerClass {
  1240. return LayerTypeDot11DataQOSDataCFPoll
  1241. }
  1242. func (m *Dot11DataQOSDataCFPoll) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataCFPoll }
  1243. type Dot11DataQOSDataCFAckPoll struct {
  1244. Dot11DataQOS
  1245. }
  1246. func decodeDot11DataQOSDataCFAckPoll(data []byte, p gopacket.PacketBuilder) error {
  1247. d := &Dot11DataQOSDataCFAckPoll{}
  1248. return decodingLayerDecoder(d, data, p)
  1249. }
  1250. func (m *Dot11DataQOSDataCFAckPoll) LayerType() gopacket.LayerType {
  1251. return LayerTypeDot11DataQOSDataCFAckPoll
  1252. }
  1253. func (m *Dot11DataQOSDataCFAckPoll) CanDecode() gopacket.LayerClass {
  1254. return LayerTypeDot11DataQOSDataCFAckPoll
  1255. }
  1256. func (m *Dot11DataQOSDataCFAckPoll) NextLayerType() gopacket.LayerType {
  1257. return LayerTypeDot11DataCFAckPoll
  1258. }
  1259. type Dot11DataQOSNull struct {
  1260. Dot11DataQOS
  1261. }
  1262. func decodeDot11DataQOSNull(data []byte, p gopacket.PacketBuilder) error {
  1263. d := &Dot11DataQOSNull{}
  1264. return decodingLayerDecoder(d, data, p)
  1265. }
  1266. func (m *Dot11DataQOSNull) LayerType() gopacket.LayerType { return LayerTypeDot11DataQOSNull }
  1267. func (m *Dot11DataQOSNull) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSNull }
  1268. func (m *Dot11DataQOSNull) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataNull }
  1269. type Dot11DataQOSCFPollNoData struct {
  1270. Dot11DataQOS
  1271. }
  1272. func decodeDot11DataQOSCFPollNoData(data []byte, p gopacket.PacketBuilder) error {
  1273. d := &Dot11DataQOSCFPollNoData{}
  1274. return decodingLayerDecoder(d, data, p)
  1275. }
  1276. func (m *Dot11DataQOSCFPollNoData) LayerType() gopacket.LayerType {
  1277. return LayerTypeDot11DataQOSCFPollNoData
  1278. }
  1279. func (m *Dot11DataQOSCFPollNoData) CanDecode() gopacket.LayerClass {
  1280. return LayerTypeDot11DataQOSCFPollNoData
  1281. }
  1282. func (m *Dot11DataQOSCFPollNoData) NextLayerType() gopacket.LayerType {
  1283. return LayerTypeDot11DataCFPollNoData
  1284. }
  1285. type Dot11DataQOSCFAckPollNoData struct {
  1286. Dot11DataQOS
  1287. }
  1288. func decodeDot11DataQOSCFAckPollNoData(data []byte, p gopacket.PacketBuilder) error {
  1289. d := &Dot11DataQOSCFAckPollNoData{}
  1290. return decodingLayerDecoder(d, data, p)
  1291. }
  1292. func (m *Dot11DataQOSCFAckPollNoData) LayerType() gopacket.LayerType {
  1293. return LayerTypeDot11DataQOSCFAckPollNoData
  1294. }
  1295. func (m *Dot11DataQOSCFAckPollNoData) CanDecode() gopacket.LayerClass {
  1296. return LayerTypeDot11DataQOSCFAckPollNoData
  1297. }
  1298. func (m *Dot11DataQOSCFAckPollNoData) NextLayerType() gopacket.LayerType {
  1299. return LayerTypeDot11DataCFAckPollNoData
  1300. }
  1301. type Dot11InformationElement struct {
  1302. BaseLayer
  1303. ID Dot11InformationElementID
  1304. Length uint8
  1305. OUI []byte
  1306. Info []byte
  1307. }
  1308. func (m *Dot11InformationElement) LayerType() gopacket.LayerType {
  1309. return LayerTypeDot11InformationElement
  1310. }
  1311. func (m *Dot11InformationElement) CanDecode() gopacket.LayerClass {
  1312. return LayerTypeDot11InformationElement
  1313. }
  1314. func (m *Dot11InformationElement) NextLayerType() gopacket.LayerType {
  1315. return LayerTypeDot11InformationElement
  1316. }
  1317. func (m *Dot11InformationElement) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1318. if len(data) < 2 {
  1319. df.SetTruncated()
  1320. return fmt.Errorf("Dot11InformationElement length %v too short, %v required", len(data), 2)
  1321. }
  1322. m.ID = Dot11InformationElementID(data[0])
  1323. m.Length = data[1]
  1324. offset := int(2)
  1325. if len(data) < offset+int(m.Length) {
  1326. df.SetTruncated()
  1327. return fmt.Errorf("Dot11InformationElement length %v too short, %v required", len(data), offset+int(m.Length))
  1328. }
  1329. if m.ID == 221 {
  1330. // Vendor extension
  1331. m.OUI = data[offset : offset+4]
  1332. m.Info = data[offset+4 : offset+int(m.Length)]
  1333. } else {
  1334. m.Info = data[offset : offset+int(m.Length)]
  1335. }
  1336. offset += int(m.Length)
  1337. m.BaseLayer = BaseLayer{Contents: data[:offset], Payload: data[offset:]}
  1338. return nil
  1339. }
  1340. func (d *Dot11InformationElement) String() string {
  1341. if d.ID == 0 {
  1342. return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, SSID: %v)", d.ID, d.Length, string(d.Info))
  1343. } else if d.ID == 1 {
  1344. rates := ""
  1345. for i := 0; i < len(d.Info); i++ {
  1346. if d.Info[i]&0x80 == 0 {
  1347. rates += fmt.Sprintf("%.1f ", float32(d.Info[i])*0.5)
  1348. } else {
  1349. rates += fmt.Sprintf("%.1f* ", float32(d.Info[i]&0x7F)*0.5)
  1350. }
  1351. }
  1352. return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Rates: %s Mbit)", d.ID, d.Length, rates)
  1353. } else if d.ID == 221 {
  1354. return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, OUI: %X, Info: %X)", d.ID, d.Length, d.OUI, d.Info)
  1355. } else {
  1356. return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Info: %X)", d.ID, d.Length, d.Info)
  1357. }
  1358. }
  1359. func (m Dot11InformationElement) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1360. length := len(m.Info) + len(m.OUI)
  1361. if buf, err := b.PrependBytes(2 + length); err != nil {
  1362. return err
  1363. } else {
  1364. buf[0] = uint8(m.ID)
  1365. buf[1] = uint8(length)
  1366. copy(buf[2:], m.OUI)
  1367. copy(buf[2+len(m.OUI):], m.Info)
  1368. }
  1369. return nil
  1370. }
  1371. func decodeDot11InformationElement(data []byte, p gopacket.PacketBuilder) error {
  1372. d := &Dot11InformationElement{}
  1373. return decodingLayerDecoder(d, data, p)
  1374. }
  1375. type Dot11CtrlCTS struct {
  1376. Dot11Ctrl
  1377. }
  1378. func decodeDot11CtrlCTS(data []byte, p gopacket.PacketBuilder) error {
  1379. d := &Dot11CtrlCTS{}
  1380. return decodingLayerDecoder(d, data, p)
  1381. }
  1382. func (m *Dot11CtrlCTS) LayerType() gopacket.LayerType {
  1383. return LayerTypeDot11CtrlCTS
  1384. }
  1385. func (m *Dot11CtrlCTS) CanDecode() gopacket.LayerClass {
  1386. return LayerTypeDot11CtrlCTS
  1387. }
  1388. func (m *Dot11CtrlCTS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1389. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1390. }
  1391. type Dot11CtrlRTS struct {
  1392. Dot11Ctrl
  1393. }
  1394. func decodeDot11CtrlRTS(data []byte, p gopacket.PacketBuilder) error {
  1395. d := &Dot11CtrlRTS{}
  1396. return decodingLayerDecoder(d, data, p)
  1397. }
  1398. func (m *Dot11CtrlRTS) LayerType() gopacket.LayerType {
  1399. return LayerTypeDot11CtrlRTS
  1400. }
  1401. func (m *Dot11CtrlRTS) CanDecode() gopacket.LayerClass {
  1402. return LayerTypeDot11CtrlRTS
  1403. }
  1404. func (m *Dot11CtrlRTS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1405. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1406. }
  1407. type Dot11CtrlBlockAckReq struct {
  1408. Dot11Ctrl
  1409. }
  1410. func decodeDot11CtrlBlockAckReq(data []byte, p gopacket.PacketBuilder) error {
  1411. d := &Dot11CtrlBlockAckReq{}
  1412. return decodingLayerDecoder(d, data, p)
  1413. }
  1414. func (m *Dot11CtrlBlockAckReq) LayerType() gopacket.LayerType {
  1415. return LayerTypeDot11CtrlBlockAckReq
  1416. }
  1417. func (m *Dot11CtrlBlockAckReq) CanDecode() gopacket.LayerClass {
  1418. return LayerTypeDot11CtrlBlockAckReq
  1419. }
  1420. func (m *Dot11CtrlBlockAckReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1421. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1422. }
  1423. type Dot11CtrlBlockAck struct {
  1424. Dot11Ctrl
  1425. }
  1426. func decodeDot11CtrlBlockAck(data []byte, p gopacket.PacketBuilder) error {
  1427. d := &Dot11CtrlBlockAck{}
  1428. return decodingLayerDecoder(d, data, p)
  1429. }
  1430. func (m *Dot11CtrlBlockAck) LayerType() gopacket.LayerType { return LayerTypeDot11CtrlBlockAck }
  1431. func (m *Dot11CtrlBlockAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11CtrlBlockAck }
  1432. func (m *Dot11CtrlBlockAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1433. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1434. }
  1435. type Dot11CtrlPowersavePoll struct {
  1436. Dot11Ctrl
  1437. }
  1438. func decodeDot11CtrlPowersavePoll(data []byte, p gopacket.PacketBuilder) error {
  1439. d := &Dot11CtrlPowersavePoll{}
  1440. return decodingLayerDecoder(d, data, p)
  1441. }
  1442. func (m *Dot11CtrlPowersavePoll) LayerType() gopacket.LayerType {
  1443. return LayerTypeDot11CtrlPowersavePoll
  1444. }
  1445. func (m *Dot11CtrlPowersavePoll) CanDecode() gopacket.LayerClass {
  1446. return LayerTypeDot11CtrlPowersavePoll
  1447. }
  1448. func (m *Dot11CtrlPowersavePoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1449. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1450. }
  1451. type Dot11CtrlAck struct {
  1452. Dot11Ctrl
  1453. }
  1454. func decodeDot11CtrlAck(data []byte, p gopacket.PacketBuilder) error {
  1455. d := &Dot11CtrlAck{}
  1456. return decodingLayerDecoder(d, data, p)
  1457. }
  1458. func (m *Dot11CtrlAck) LayerType() gopacket.LayerType { return LayerTypeDot11CtrlAck }
  1459. func (m *Dot11CtrlAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11CtrlAck }
  1460. func (m *Dot11CtrlAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1461. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1462. }
  1463. type Dot11CtrlCFEnd struct {
  1464. Dot11Ctrl
  1465. }
  1466. func decodeDot11CtrlCFEnd(data []byte, p gopacket.PacketBuilder) error {
  1467. d := &Dot11CtrlCFEnd{}
  1468. return decodingLayerDecoder(d, data, p)
  1469. }
  1470. func (m *Dot11CtrlCFEnd) LayerType() gopacket.LayerType {
  1471. return LayerTypeDot11CtrlCFEnd
  1472. }
  1473. func (m *Dot11CtrlCFEnd) CanDecode() gopacket.LayerClass {
  1474. return LayerTypeDot11CtrlCFEnd
  1475. }
  1476. func (m *Dot11CtrlCFEnd) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1477. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1478. }
  1479. type Dot11CtrlCFEndAck struct {
  1480. Dot11Ctrl
  1481. }
  1482. func decodeDot11CtrlCFEndAck(data []byte, p gopacket.PacketBuilder) error {
  1483. d := &Dot11CtrlCFEndAck{}
  1484. return decodingLayerDecoder(d, data, p)
  1485. }
  1486. func (m *Dot11CtrlCFEndAck) LayerType() gopacket.LayerType {
  1487. return LayerTypeDot11CtrlCFEndAck
  1488. }
  1489. func (m *Dot11CtrlCFEndAck) CanDecode() gopacket.LayerClass {
  1490. return LayerTypeDot11CtrlCFEndAck
  1491. }
  1492. func (m *Dot11CtrlCFEndAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1493. return m.Dot11Ctrl.DecodeFromBytes(data, df)
  1494. }
  1495. type Dot11MgmtAssociationReq struct {
  1496. Dot11Mgmt
  1497. CapabilityInfo uint16
  1498. ListenInterval uint16
  1499. }
  1500. func decodeDot11MgmtAssociationReq(data []byte, p gopacket.PacketBuilder) error {
  1501. d := &Dot11MgmtAssociationReq{}
  1502. return decodingLayerDecoder(d, data, p)
  1503. }
  1504. func (m *Dot11MgmtAssociationReq) LayerType() gopacket.LayerType {
  1505. return LayerTypeDot11MgmtAssociationReq
  1506. }
  1507. func (m *Dot11MgmtAssociationReq) CanDecode() gopacket.LayerClass {
  1508. return LayerTypeDot11MgmtAssociationReq
  1509. }
  1510. func (m *Dot11MgmtAssociationReq) NextLayerType() gopacket.LayerType {
  1511. return LayerTypeDot11InformationElement
  1512. }
  1513. func (m *Dot11MgmtAssociationReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1514. if len(data) < 4 {
  1515. df.SetTruncated()
  1516. return fmt.Errorf("Dot11MgmtAssociationReq length %v too short, %v required", len(data), 4)
  1517. }
  1518. m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2])
  1519. m.ListenInterval = binary.LittleEndian.Uint16(data[2:4])
  1520. m.Payload = data[4:]
  1521. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1522. }
  1523. func (m Dot11MgmtAssociationReq) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1524. buf, err := b.PrependBytes(4)
  1525. if err != nil {
  1526. return err
  1527. }
  1528. binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo)
  1529. binary.LittleEndian.PutUint16(buf[2:4], m.ListenInterval)
  1530. return nil
  1531. }
  1532. type Dot11MgmtAssociationResp struct {
  1533. Dot11Mgmt
  1534. CapabilityInfo uint16
  1535. Status Dot11Status
  1536. AID uint16
  1537. }
  1538. func decodeDot11MgmtAssociationResp(data []byte, p gopacket.PacketBuilder) error {
  1539. d := &Dot11MgmtAssociationResp{}
  1540. return decodingLayerDecoder(d, data, p)
  1541. }
  1542. func (m *Dot11MgmtAssociationResp) CanDecode() gopacket.LayerClass {
  1543. return LayerTypeDot11MgmtAssociationResp
  1544. }
  1545. func (m *Dot11MgmtAssociationResp) LayerType() gopacket.LayerType {
  1546. return LayerTypeDot11MgmtAssociationResp
  1547. }
  1548. func (m *Dot11MgmtAssociationResp) NextLayerType() gopacket.LayerType {
  1549. return LayerTypeDot11InformationElement
  1550. }
  1551. func (m *Dot11MgmtAssociationResp) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1552. if len(data) < 6 {
  1553. df.SetTruncated()
  1554. return fmt.Errorf("Dot11MgmtAssociationResp length %v too short, %v required", len(data), 6)
  1555. }
  1556. m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2])
  1557. m.Status = Dot11Status(binary.LittleEndian.Uint16(data[2:4]))
  1558. m.AID = binary.LittleEndian.Uint16(data[4:6])
  1559. m.Payload = data[6:]
  1560. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1561. }
  1562. func (m Dot11MgmtAssociationResp) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1563. buf, err := b.PrependBytes(6)
  1564. if err != nil {
  1565. return err
  1566. }
  1567. binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo)
  1568. binary.LittleEndian.PutUint16(buf[2:4], uint16(m.Status))
  1569. binary.LittleEndian.PutUint16(buf[4:6], m.AID)
  1570. return nil
  1571. }
  1572. type Dot11MgmtReassociationReq struct {
  1573. Dot11Mgmt
  1574. CapabilityInfo uint16
  1575. ListenInterval uint16
  1576. CurrentApAddress net.HardwareAddr
  1577. }
  1578. func decodeDot11MgmtReassociationReq(data []byte, p gopacket.PacketBuilder) error {
  1579. d := &Dot11MgmtReassociationReq{}
  1580. return decodingLayerDecoder(d, data, p)
  1581. }
  1582. func (m *Dot11MgmtReassociationReq) LayerType() gopacket.LayerType {
  1583. return LayerTypeDot11MgmtReassociationReq
  1584. }
  1585. func (m *Dot11MgmtReassociationReq) CanDecode() gopacket.LayerClass {
  1586. return LayerTypeDot11MgmtReassociationReq
  1587. }
  1588. func (m *Dot11MgmtReassociationReq) NextLayerType() gopacket.LayerType {
  1589. return LayerTypeDot11InformationElement
  1590. }
  1591. func (m *Dot11MgmtReassociationReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1592. if len(data) < 10 {
  1593. df.SetTruncated()
  1594. return fmt.Errorf("Dot11MgmtReassociationReq length %v too short, %v required", len(data), 10)
  1595. }
  1596. m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2])
  1597. m.ListenInterval = binary.LittleEndian.Uint16(data[2:4])
  1598. m.CurrentApAddress = net.HardwareAddr(data[4:10])
  1599. m.Payload = data[10:]
  1600. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1601. }
  1602. func (m Dot11MgmtReassociationReq) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1603. buf, err := b.PrependBytes(10)
  1604. if err != nil {
  1605. return err
  1606. }
  1607. binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo)
  1608. binary.LittleEndian.PutUint16(buf[2:4], m.ListenInterval)
  1609. copy(buf[4:10], m.CurrentApAddress)
  1610. return nil
  1611. }
  1612. type Dot11MgmtReassociationResp struct {
  1613. Dot11Mgmt
  1614. }
  1615. func decodeDot11MgmtReassociationResp(data []byte, p gopacket.PacketBuilder) error {
  1616. d := &Dot11MgmtReassociationResp{}
  1617. return decodingLayerDecoder(d, data, p)
  1618. }
  1619. func (m *Dot11MgmtReassociationResp) LayerType() gopacket.LayerType {
  1620. return LayerTypeDot11MgmtReassociationResp
  1621. }
  1622. func (m *Dot11MgmtReassociationResp) CanDecode() gopacket.LayerClass {
  1623. return LayerTypeDot11MgmtReassociationResp
  1624. }
  1625. func (m *Dot11MgmtReassociationResp) NextLayerType() gopacket.LayerType {
  1626. return LayerTypeDot11InformationElement
  1627. }
  1628. type Dot11MgmtProbeReq struct {
  1629. Dot11Mgmt
  1630. }
  1631. func decodeDot11MgmtProbeReq(data []byte, p gopacket.PacketBuilder) error {
  1632. d := &Dot11MgmtProbeReq{}
  1633. return decodingLayerDecoder(d, data, p)
  1634. }
  1635. func (m *Dot11MgmtProbeReq) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtProbeReq }
  1636. func (m *Dot11MgmtProbeReq) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtProbeReq }
  1637. func (m *Dot11MgmtProbeReq) NextLayerType() gopacket.LayerType {
  1638. return LayerTypeDot11InformationElement
  1639. }
  1640. type Dot11MgmtProbeResp struct {
  1641. Dot11Mgmt
  1642. Timestamp uint64
  1643. Interval uint16
  1644. Flags uint16
  1645. }
  1646. func decodeDot11MgmtProbeResp(data []byte, p gopacket.PacketBuilder) error {
  1647. d := &Dot11MgmtProbeResp{}
  1648. return decodingLayerDecoder(d, data, p)
  1649. }
  1650. func (m *Dot11MgmtProbeResp) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtProbeResp }
  1651. func (m *Dot11MgmtProbeResp) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtProbeResp }
  1652. func (m *Dot11MgmtProbeResp) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1653. if len(data) < 12 {
  1654. df.SetTruncated()
  1655. return fmt.Errorf("Dot11MgmtProbeResp length %v too short, %v required", len(data), 12)
  1656. }
  1657. m.Timestamp = binary.LittleEndian.Uint64(data[0:8])
  1658. m.Interval = binary.LittleEndian.Uint16(data[8:10])
  1659. m.Flags = binary.LittleEndian.Uint16(data[10:12])
  1660. m.Payload = data[12:]
  1661. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1662. }
  1663. func (m *Dot11MgmtProbeResp) NextLayerType() gopacket.LayerType {
  1664. return LayerTypeDot11InformationElement
  1665. }
  1666. func (m Dot11MgmtProbeResp) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1667. buf, err := b.PrependBytes(12)
  1668. if err != nil {
  1669. return err
  1670. }
  1671. binary.LittleEndian.PutUint64(buf[0:8], m.Timestamp)
  1672. binary.LittleEndian.PutUint16(buf[8:10], m.Interval)
  1673. binary.LittleEndian.PutUint16(buf[10:12], m.Flags)
  1674. return nil
  1675. }
  1676. type Dot11MgmtMeasurementPilot struct {
  1677. Dot11Mgmt
  1678. }
  1679. func decodeDot11MgmtMeasurementPilot(data []byte, p gopacket.PacketBuilder) error {
  1680. d := &Dot11MgmtMeasurementPilot{}
  1681. return decodingLayerDecoder(d, data, p)
  1682. }
  1683. func (m *Dot11MgmtMeasurementPilot) LayerType() gopacket.LayerType {
  1684. return LayerTypeDot11MgmtMeasurementPilot
  1685. }
  1686. func (m *Dot11MgmtMeasurementPilot) CanDecode() gopacket.LayerClass {
  1687. return LayerTypeDot11MgmtMeasurementPilot
  1688. }
  1689. type Dot11MgmtBeacon struct {
  1690. Dot11Mgmt
  1691. Timestamp uint64
  1692. Interval uint16
  1693. Flags uint16
  1694. }
  1695. func decodeDot11MgmtBeacon(data []byte, p gopacket.PacketBuilder) error {
  1696. d := &Dot11MgmtBeacon{}
  1697. return decodingLayerDecoder(d, data, p)
  1698. }
  1699. func (m *Dot11MgmtBeacon) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtBeacon }
  1700. func (m *Dot11MgmtBeacon) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtBeacon }
  1701. func (m *Dot11MgmtBeacon) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1702. if len(data) < 12 {
  1703. df.SetTruncated()
  1704. return fmt.Errorf("Dot11MgmtBeacon length %v too short, %v required", len(data), 12)
  1705. }
  1706. m.Timestamp = binary.LittleEndian.Uint64(data[0:8])
  1707. m.Interval = binary.LittleEndian.Uint16(data[8:10])
  1708. m.Flags = binary.LittleEndian.Uint16(data[10:12])
  1709. m.Payload = data[12:]
  1710. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1711. }
  1712. func (m *Dot11MgmtBeacon) NextLayerType() gopacket.LayerType { return LayerTypeDot11InformationElement }
  1713. func (m Dot11MgmtBeacon) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1714. buf, err := b.PrependBytes(12)
  1715. if err != nil {
  1716. return err
  1717. }
  1718. binary.LittleEndian.PutUint64(buf[0:8], m.Timestamp)
  1719. binary.LittleEndian.PutUint16(buf[8:10], m.Interval)
  1720. binary.LittleEndian.PutUint16(buf[10:12], m.Flags)
  1721. return nil
  1722. }
  1723. type Dot11MgmtATIM struct {
  1724. Dot11Mgmt
  1725. }
  1726. func decodeDot11MgmtATIM(data []byte, p gopacket.PacketBuilder) error {
  1727. d := &Dot11MgmtATIM{}
  1728. return decodingLayerDecoder(d, data, p)
  1729. }
  1730. func (m *Dot11MgmtATIM) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtATIM }
  1731. func (m *Dot11MgmtATIM) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtATIM }
  1732. type Dot11MgmtDisassociation struct {
  1733. Dot11Mgmt
  1734. Reason Dot11Reason
  1735. }
  1736. func decodeDot11MgmtDisassociation(data []byte, p gopacket.PacketBuilder) error {
  1737. d := &Dot11MgmtDisassociation{}
  1738. return decodingLayerDecoder(d, data, p)
  1739. }
  1740. func (m *Dot11MgmtDisassociation) LayerType() gopacket.LayerType {
  1741. return LayerTypeDot11MgmtDisassociation
  1742. }
  1743. func (m *Dot11MgmtDisassociation) CanDecode() gopacket.LayerClass {
  1744. return LayerTypeDot11MgmtDisassociation
  1745. }
  1746. func (m *Dot11MgmtDisassociation) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1747. if len(data) < 2 {
  1748. df.SetTruncated()
  1749. return fmt.Errorf("Dot11MgmtDisassociation length %v too short, %v required", len(data), 2)
  1750. }
  1751. m.Reason = Dot11Reason(binary.LittleEndian.Uint16(data[0:2]))
  1752. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1753. }
  1754. func (m Dot11MgmtDisassociation) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1755. buf, err := b.PrependBytes(2)
  1756. if err != nil {
  1757. return err
  1758. }
  1759. binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Reason))
  1760. return nil
  1761. }
  1762. type Dot11MgmtAuthentication struct {
  1763. Dot11Mgmt
  1764. Algorithm Dot11Algorithm
  1765. Sequence uint16
  1766. Status Dot11Status
  1767. }
  1768. func decodeDot11MgmtAuthentication(data []byte, p gopacket.PacketBuilder) error {
  1769. d := &Dot11MgmtAuthentication{}
  1770. return decodingLayerDecoder(d, data, p)
  1771. }
  1772. func (m *Dot11MgmtAuthentication) LayerType() gopacket.LayerType {
  1773. return LayerTypeDot11MgmtAuthentication
  1774. }
  1775. func (m *Dot11MgmtAuthentication) CanDecode() gopacket.LayerClass {
  1776. return LayerTypeDot11MgmtAuthentication
  1777. }
  1778. func (m *Dot11MgmtAuthentication) NextLayerType() gopacket.LayerType {
  1779. return LayerTypeDot11InformationElement
  1780. }
  1781. func (m *Dot11MgmtAuthentication) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1782. if len(data) < 6 {
  1783. df.SetTruncated()
  1784. return fmt.Errorf("Dot11MgmtAuthentication length %v too short, %v required", len(data), 6)
  1785. }
  1786. m.Algorithm = Dot11Algorithm(binary.LittleEndian.Uint16(data[0:2]))
  1787. m.Sequence = binary.LittleEndian.Uint16(data[2:4])
  1788. m.Status = Dot11Status(binary.LittleEndian.Uint16(data[4:6]))
  1789. m.Payload = data[6:]
  1790. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1791. }
  1792. func (m Dot11MgmtAuthentication) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1793. buf, err := b.PrependBytes(6)
  1794. if err != nil {
  1795. return err
  1796. }
  1797. binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Algorithm))
  1798. binary.LittleEndian.PutUint16(buf[2:4], m.Sequence)
  1799. binary.LittleEndian.PutUint16(buf[4:6], uint16(m.Status))
  1800. return nil
  1801. }
  1802. type Dot11MgmtDeauthentication struct {
  1803. Dot11Mgmt
  1804. Reason Dot11Reason
  1805. }
  1806. func decodeDot11MgmtDeauthentication(data []byte, p gopacket.PacketBuilder) error {
  1807. d := &Dot11MgmtDeauthentication{}
  1808. return decodingLayerDecoder(d, data, p)
  1809. }
  1810. func (m *Dot11MgmtDeauthentication) LayerType() gopacket.LayerType {
  1811. return LayerTypeDot11MgmtDeauthentication
  1812. }
  1813. func (m *Dot11MgmtDeauthentication) CanDecode() gopacket.LayerClass {
  1814. return LayerTypeDot11MgmtDeauthentication
  1815. }
  1816. func (m *Dot11MgmtDeauthentication) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
  1817. if len(data) < 2 {
  1818. df.SetTruncated()
  1819. return fmt.Errorf("Dot11MgmtDeauthentication length %v too short, %v required", len(data), 2)
  1820. }
  1821. m.Reason = Dot11Reason(binary.LittleEndian.Uint16(data[0:2]))
  1822. return m.Dot11Mgmt.DecodeFromBytes(data, df)
  1823. }
  1824. func (m Dot11MgmtDeauthentication) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
  1825. buf, err := b.PrependBytes(2)
  1826. if err != nil {
  1827. return err
  1828. }
  1829. binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Reason))
  1830. return nil
  1831. }
  1832. type Dot11MgmtAction struct {
  1833. Dot11Mgmt
  1834. }
  1835. func decodeDot11MgmtAction(data []byte, p gopacket.PacketBuilder) error {
  1836. d := &Dot11MgmtAction{}
  1837. return decodingLayerDecoder(d, data, p)
  1838. }
  1839. func (m *Dot11MgmtAction) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtAction }
  1840. func (m *Dot11MgmtAction) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtAction }
  1841. type Dot11MgmtActionNoAck struct {
  1842. Dot11Mgmt
  1843. }
  1844. func decodeDot11MgmtActionNoAck(data []byte, p gopacket.PacketBuilder) error {
  1845. d := &Dot11MgmtActionNoAck{}
  1846. return decodingLayerDecoder(d, data, p)
  1847. }
  1848. func (m *Dot11MgmtActionNoAck) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtActionNoAck }
  1849. func (m *Dot11MgmtActionNoAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtActionNoAck }
  1850. type Dot11MgmtArubaWLAN struct {
  1851. Dot11Mgmt
  1852. }
  1853. func decodeDot11MgmtArubaWLAN(data []byte, p gopacket.PacketBuilder) error {
  1854. d := &Dot11MgmtArubaWLAN{}
  1855. return decodingLayerDecoder(d, data, p)
  1856. }
  1857. func (m *Dot11MgmtArubaWLAN) LayerType() gopacket.LayerType { return LayerTypeDot11MgmtArubaWLAN }
  1858. func (m *Dot11MgmtArubaWLAN) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtArubaWLAN }