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