Fix unit tests
[govpp.git] / vendor / github.com / google / gopacket / layers / dot11.go
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 // TODO: Verify these element ids, and append more ids if more.
244
245 const (
246         Dot11InformationElementIDSSID          Dot11InformationElementID = 0
247         Dot11InformationElementIDRates         Dot11InformationElementID = 1
248         Dot11InformationElementIDFHSet         Dot11InformationElementID = 2
249         Dot11InformationElementIDDSSet         Dot11InformationElementID = 3
250         Dot11InformationElementIDCFSet         Dot11InformationElementID = 4
251         Dot11InformationElementIDTIM           Dot11InformationElementID = 5
252         Dot11InformationElementIDIBSSSet       Dot11InformationElementID = 6
253         Dot11InformationElementIDChallenge     Dot11InformationElementID = 16
254         Dot11InformationElementIDERPInfo       Dot11InformationElementID = 42
255         Dot11InformationElementIDQOSCapability Dot11InformationElementID = 46
256         Dot11InformationElementIDERPInfo2      Dot11InformationElementID = 47
257         Dot11InformationElementIDRSNInfo       Dot11InformationElementID = 48
258         Dot11InformationElementIDESRates       Dot11InformationElementID = 50
259         Dot11InformationElementIDVendor        Dot11InformationElementID = 221
260         Dot11InformationElementIDReserved      Dot11InformationElementID = 68
261 )
262
263 // String provides a human readable string for Dot11InformationElementID.
264 // This string is possibly subject to change over time; if you're storing this
265 // persistently, you should probably store the Dot11InformationElementID value,
266 // not its string.
267 func (a Dot11InformationElementID) String() string {
268         switch a {
269         case Dot11InformationElementIDSSID:
270                 return "SSID"
271         case Dot11InformationElementIDRates:
272                 return "Rates"
273         case Dot11InformationElementIDFHSet:
274                 return "FHset"
275         case Dot11InformationElementIDDSSet:
276                 return "DSset"
277         case Dot11InformationElementIDCFSet:
278                 return "CFset"
279         case Dot11InformationElementIDTIM:
280                 return "TIM"
281         case Dot11InformationElementIDIBSSSet:
282                 return "IBSSset"
283         case Dot11InformationElementIDChallenge:
284                 return "Challenge"
285         case Dot11InformationElementIDERPInfo:
286                 return "ERPinfo"
287         case Dot11InformationElementIDQOSCapability:
288                 return "QOS capability"
289         case Dot11InformationElementIDERPInfo2:
290                 return "ERPinfo2"
291         case Dot11InformationElementIDRSNInfo:
292                 return "RSNinfo"
293         case Dot11InformationElementIDESRates:
294                 return "ESrates"
295         case Dot11InformationElementIDVendor:
296                 return "Vendor"
297         case Dot11InformationElementIDReserved:
298                 return "Reserved"
299         default:
300                 return "Unknown information element id"
301         }
302 }
303
304 // Dot11 provides an IEEE 802.11 base packet header.
305 // See http://standards.ieee.org/findstds/standard/802.11-2012.html
306 // for excrutiating detail.
307 type Dot11 struct {
308         BaseLayer
309         Type           Dot11Type
310         Proto          uint8
311         Flags          Dot11Flags
312         DurationID     uint16
313         Address1       net.HardwareAddr
314         Address2       net.HardwareAddr
315         Address3       net.HardwareAddr
316         Address4       net.HardwareAddr
317         SequenceNumber uint16
318         FragmentNumber uint16
319         Checksum       uint32
320 }
321
322 func decodeDot11(data []byte, p gopacket.PacketBuilder) error {
323         d := &Dot11{}
324         return decodingLayerDecoder(d, data, p)
325 }
326
327 func (m *Dot11) LayerType() gopacket.LayerType  { return LayerTypeDot11 }
328 func (m *Dot11) CanDecode() gopacket.LayerClass { return LayerTypeDot11 }
329 func (m *Dot11) NextLayerType() gopacket.LayerType {
330         if m.Flags.WEP() {
331                 return (LayerTypeDot11WEP)
332         }
333
334         return m.Type.LayerType()
335 }
336
337 func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
338         if len(data) < 10 {
339                 df.SetTruncated()
340                 return fmt.Errorf("Dot11 length %v too short, %v required", len(data), 10)
341         }
342         m.Type = Dot11Type((data[0])&0xFC) >> 2
343
344         m.Proto = uint8(data[0]) & 0x0003
345         m.Flags = Dot11Flags(data[1])
346         m.DurationID = binary.LittleEndian.Uint16(data[2:4])
347         m.Address1 = net.HardwareAddr(data[4:10])
348
349         offset := 10
350
351         mainType := m.Type.MainType()
352
353         switch mainType {
354         case Dot11TypeCtrl:
355                 switch m.Type {
356                 case Dot11TypeCtrlRTS, Dot11TypeCtrlPowersavePoll, Dot11TypeCtrlCFEnd, Dot11TypeCtrlCFEndAck:
357                         if len(data) < offset+6 {
358                                 df.SetTruncated()
359                                 return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
360                         }
361                         m.Address2 = net.HardwareAddr(data[offset : offset+6])
362                         offset += 6
363                 }
364         case Dot11TypeMgmt, Dot11TypeData:
365                 if len(data) < offset+14 {
366                         df.SetTruncated()
367                         return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+14)
368                 }
369                 m.Address2 = net.HardwareAddr(data[offset : offset+6])
370                 offset += 6
371                 m.Address3 = net.HardwareAddr(data[offset : offset+6])
372                 offset += 6
373
374                 m.SequenceNumber = (binary.LittleEndian.Uint16(data[offset:offset+2]) & 0xFFF0) >> 4
375                 m.FragmentNumber = (binary.LittleEndian.Uint16(data[offset:offset+2]) & 0x000F)
376                 offset += 2
377         }
378
379         if mainType == Dot11TypeData && m.Flags.FromDS() && m.Flags.ToDS() {
380                 if len(data) < offset+6 {
381                         df.SetTruncated()
382                         return fmt.Errorf("Dot11 length %v too short, %v required", len(data), offset+6)
383                 }
384                 m.Address4 = net.HardwareAddr(data[offset : offset+6])
385                 offset += 6
386         }
387
388         m.BaseLayer = BaseLayer{Contents: data[0:offset], Payload: data[offset : len(data)-4]}
389         m.Checksum = binary.LittleEndian.Uint32(data[len(data)-4 : len(data)])
390         return nil
391 }
392
393 func (m *Dot11) ChecksumValid() bool {
394         // only for CTRL and MGMT frames
395         h := crc32.NewIEEE()
396         h.Write(m.Contents)
397         h.Write(m.Payload)
398         return m.Checksum == h.Sum32()
399 }
400
401 func (m Dot11) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
402         buf, err := b.PrependBytes(24)
403
404         if err != nil {
405                 return err
406         }
407
408         buf[0] = (uint8(m.Type) << 2) | m.Proto
409         buf[1] = uint8(m.Flags)
410
411         binary.LittleEndian.PutUint16(buf[2:4], m.DurationID)
412
413         copy(buf[4:10], m.Address1)
414
415         offset := 10
416
417         switch m.Type.MainType() {
418         case Dot11TypeCtrl:
419                 switch m.Type {
420                 case Dot11TypeCtrlRTS, Dot11TypeCtrlPowersavePoll, Dot11TypeCtrlCFEnd, Dot11TypeCtrlCFEndAck:
421                         copy(buf[offset:offset+6], m.Address2)
422                         offset += 6
423                 }
424         case Dot11TypeMgmt, Dot11TypeData:
425                 copy(buf[offset:offset+6], m.Address2)
426                 offset += 6
427                 copy(buf[offset:offset+6], m.Address3)
428                 offset += 6
429
430                 binary.LittleEndian.PutUint16(buf[offset:offset+2], (m.SequenceNumber<<4)|m.FragmentNumber)
431                 offset += 2
432         }
433
434         if m.Type.MainType() == Dot11TypeData && m.Flags.FromDS() && m.Flags.ToDS() {
435                 copy(buf[offset:offset+6], m.Address4)
436                 offset += 6
437         }
438
439         return nil
440 }
441
442 // Dot11Mgmt is a base for all IEEE 802.11 management layers.
443 type Dot11Mgmt struct {
444         BaseLayer
445 }
446
447 func (m *Dot11Mgmt) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload }
448 func (m *Dot11Mgmt) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
449         m.Contents = data
450         return nil
451 }
452
453 // Dot11Ctrl is a base for all IEEE 802.11 control layers.
454 type Dot11Ctrl struct {
455         BaseLayer
456 }
457
458 func (m *Dot11Ctrl) NextLayerType() gopacket.LayerType { return gopacket.LayerTypePayload }
459
460 func (m *Dot11Ctrl) LayerType() gopacket.LayerType  { return LayerTypeDot11Ctrl }
461 func (m *Dot11Ctrl) CanDecode() gopacket.LayerClass { return LayerTypeDot11Ctrl }
462 func (m *Dot11Ctrl) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
463         m.Contents = data
464         return nil
465 }
466
467 func decodeDot11Ctrl(data []byte, p gopacket.PacketBuilder) error {
468         d := &Dot11Ctrl{}
469         return decodingLayerDecoder(d, data, p)
470 }
471
472 // Dot11WEP contains WEP encrpted IEEE 802.11 data.
473 type Dot11WEP struct {
474         BaseLayer
475 }
476
477 func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return LayerTypeLLC }
478
479 func (m *Dot11WEP) LayerType() gopacket.LayerType  { return LayerTypeDot11WEP }
480 func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeDot11WEP }
481 func (m *Dot11WEP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
482         m.Contents = data
483         return nil
484 }
485
486 func decodeDot11WEP(data []byte, p gopacket.PacketBuilder) error {
487         d := &Dot11WEP{}
488         return decodingLayerDecoder(d, data, p)
489 }
490
491 // Dot11Data is a base for all IEEE 802.11 data layers.
492 type Dot11Data struct {
493         BaseLayer
494 }
495
496 func (m *Dot11Data) NextLayerType() gopacket.LayerType { return LayerTypeLLC }
497
498 func (m *Dot11Data) LayerType() gopacket.LayerType  { return LayerTypeDot11Data }
499 func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerTypeDot11Data }
500 func (m *Dot11Data) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
501         m.Payload = data
502         return nil
503 }
504
505 func decodeDot11Data(data []byte, p gopacket.PacketBuilder) error {
506         d := &Dot11Data{}
507         return decodingLayerDecoder(d, data, p)
508 }
509
510 type Dot11DataCFAck struct {
511         Dot11Data
512 }
513
514 func decodeDot11DataCFAck(data []byte, p gopacket.PacketBuilder) error {
515         d := &Dot11DataCFAck{}
516         return decodingLayerDecoder(d, data, p)
517 }
518
519 func (m *Dot11DataCFAck) LayerType() gopacket.LayerType  { return LayerTypeDot11DataCFAck }
520 func (m *Dot11DataCFAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAck }
521 func (m *Dot11DataCFAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
522         return m.Dot11Data.DecodeFromBytes(data, df)
523 }
524
525 type Dot11DataCFPoll struct {
526         Dot11Data
527 }
528
529 func decodeDot11DataCFPoll(data []byte, p gopacket.PacketBuilder) error {
530         d := &Dot11DataCFPoll{}
531         return decodingLayerDecoder(d, data, p)
532 }
533
534 func (m *Dot11DataCFPoll) LayerType() gopacket.LayerType  { return LayerTypeDot11DataCFPoll }
535 func (m *Dot11DataCFPoll) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFPoll }
536 func (m *Dot11DataCFPoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
537         return m.Dot11Data.DecodeFromBytes(data, df)
538 }
539
540 type Dot11DataCFAckPoll struct {
541         Dot11Data
542 }
543
544 func decodeDot11DataCFAckPoll(data []byte, p gopacket.PacketBuilder) error {
545         d := &Dot11DataCFAckPoll{}
546         return decodingLayerDecoder(d, data, p)
547 }
548
549 func (m *Dot11DataCFAckPoll) LayerType() gopacket.LayerType  { return LayerTypeDot11DataCFAckPoll }
550 func (m *Dot11DataCFAckPoll) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAckPoll }
551 func (m *Dot11DataCFAckPoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
552         return m.Dot11Data.DecodeFromBytes(data, df)
553 }
554
555 type Dot11DataNull struct {
556         Dot11Data
557 }
558
559 func decodeDot11DataNull(data []byte, p gopacket.PacketBuilder) error {
560         d := &Dot11DataNull{}
561         return decodingLayerDecoder(d, data, p)
562 }
563
564 func (m *Dot11DataNull) LayerType() gopacket.LayerType  { return LayerTypeDot11DataNull }
565 func (m *Dot11DataNull) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataNull }
566 func (m *Dot11DataNull) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
567         return m.Dot11Data.DecodeFromBytes(data, df)
568 }
569
570 type Dot11DataCFAckNoData struct {
571         Dot11Data
572 }
573
574 func decodeDot11DataCFAckNoData(data []byte, p gopacket.PacketBuilder) error {
575         d := &Dot11DataCFAckNoData{}
576         return decodingLayerDecoder(d, data, p)
577 }
578
579 func (m *Dot11DataCFAckNoData) LayerType() gopacket.LayerType  { return LayerTypeDot11DataCFAckNoData }
580 func (m *Dot11DataCFAckNoData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFAckNoData }
581 func (m *Dot11DataCFAckNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
582         return m.Dot11Data.DecodeFromBytes(data, df)
583 }
584
585 type Dot11DataCFPollNoData struct {
586         Dot11Data
587 }
588
589 func decodeDot11DataCFPollNoData(data []byte, p gopacket.PacketBuilder) error {
590         d := &Dot11DataCFPollNoData{}
591         return decodingLayerDecoder(d, data, p)
592 }
593
594 func (m *Dot11DataCFPollNoData) LayerType() gopacket.LayerType  { return LayerTypeDot11DataCFPollNoData }
595 func (m *Dot11DataCFPollNoData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataCFPollNoData }
596 func (m *Dot11DataCFPollNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
597         return m.Dot11Data.DecodeFromBytes(data, df)
598 }
599
600 type Dot11DataCFAckPollNoData struct {
601         Dot11Data
602 }
603
604 func decodeDot11DataCFAckPollNoData(data []byte, p gopacket.PacketBuilder) error {
605         d := &Dot11DataCFAckPollNoData{}
606         return decodingLayerDecoder(d, data, p)
607 }
608
609 func (m *Dot11DataCFAckPollNoData) LayerType() gopacket.LayerType {
610         return LayerTypeDot11DataCFAckPollNoData
611 }
612 func (m *Dot11DataCFAckPollNoData) CanDecode() gopacket.LayerClass {
613         return LayerTypeDot11DataCFAckPollNoData
614 }
615 func (m *Dot11DataCFAckPollNoData) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
616         return m.Dot11Data.DecodeFromBytes(data, df)
617 }
618
619 type Dot11DataQOS struct {
620         Dot11Ctrl
621         TID       uint8 /* Traffic IDentifier */
622         EOSP      bool  /* End of service period */
623         AckPolicy Dot11AckPolicy
624         TXOP      uint8
625 }
626
627 func (m *Dot11DataQOS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
628         if len(data) < 4 {
629                 df.SetTruncated()
630                 return fmt.Errorf("Dot11DataQOS length %v too short, %v required", len(data), 4)
631         }
632         m.TID = (uint8(data[0]) & 0x0F)
633         m.EOSP = (uint8(data[0]) & 0x10) == 0x10
634         m.AckPolicy = Dot11AckPolicy((uint8(data[0]) & 0x60) >> 5)
635         m.TXOP = uint8(data[1])
636         // TODO: Mesh Control bytes 2:4
637         m.BaseLayer = BaseLayer{Contents: data[0:4], Payload: data[4:]}
638         return nil
639 }
640
641 type Dot11DataQOSData struct {
642         Dot11DataQOS
643 }
644
645 func decodeDot11DataQOSData(data []byte, p gopacket.PacketBuilder) error {
646         d := &Dot11DataQOSData{}
647         return decodingLayerDecoder(d, data, p)
648 }
649
650 func (m *Dot11DataQOSData) LayerType() gopacket.LayerType  { return LayerTypeDot11DataQOSData }
651 func (m *Dot11DataQOSData) CanDecode() gopacket.LayerClass { return LayerTypeDot11DataQOSData }
652
653 func (m *Dot11DataQOSData) NextLayerType() gopacket.LayerType {
654         return LayerTypeDot11Data
655 }
656
657 type Dot11DataQOSDataCFAck struct {
658         Dot11DataQOS
659 }
660
661 func decodeDot11DataQOSDataCFAck(data []byte, p gopacket.PacketBuilder) error {
662         d := &Dot11DataQOSDataCFAck{}
663         return decodingLayerDecoder(d, data, p)
664 }
665
666 func (m *Dot11DataQOSDataCFAck) LayerType() gopacket.LayerType     { return LayerTypeDot11DataQOSDataCFAck }
667 func (m *Dot11DataQOSDataCFAck) CanDecode() gopacket.LayerClass    { return LayerTypeDot11DataQOSDataCFAck }
668 func (m *Dot11DataQOSDataCFAck) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataCFAck }
669
670 type Dot11DataQOSDataCFPoll struct {
671         Dot11DataQOS
672 }
673
674 func decodeDot11DataQOSDataCFPoll(data []byte, p gopacket.PacketBuilder) error {
675         d := &Dot11DataQOSDataCFPoll{}
676         return decodingLayerDecoder(d, data, p)
677 }
678
679 func (m *Dot11DataQOSDataCFPoll) LayerType() gopacket.LayerType {
680         return LayerTypeDot11DataQOSDataCFPoll
681 }
682 func (m *Dot11DataQOSDataCFPoll) CanDecode() gopacket.LayerClass {
683         return LayerTypeDot11DataQOSDataCFPoll
684 }
685 func (m *Dot11DataQOSDataCFPoll) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataCFPoll }
686
687 type Dot11DataQOSDataCFAckPoll struct {
688         Dot11DataQOS
689 }
690
691 func decodeDot11DataQOSDataCFAckPoll(data []byte, p gopacket.PacketBuilder) error {
692         d := &Dot11DataQOSDataCFAckPoll{}
693         return decodingLayerDecoder(d, data, p)
694 }
695
696 func (m *Dot11DataQOSDataCFAckPoll) LayerType() gopacket.LayerType {
697         return LayerTypeDot11DataQOSDataCFAckPoll
698 }
699 func (m *Dot11DataQOSDataCFAckPoll) CanDecode() gopacket.LayerClass {
700         return LayerTypeDot11DataQOSDataCFAckPoll
701 }
702 func (m *Dot11DataQOSDataCFAckPoll) NextLayerType() gopacket.LayerType {
703         return LayerTypeDot11DataCFAckPoll
704 }
705
706 type Dot11DataQOSNull struct {
707         Dot11DataQOS
708 }
709
710 func decodeDot11DataQOSNull(data []byte, p gopacket.PacketBuilder) error {
711         d := &Dot11DataQOSNull{}
712         return decodingLayerDecoder(d, data, p)
713 }
714
715 func (m *Dot11DataQOSNull) LayerType() gopacket.LayerType     { return LayerTypeDot11DataQOSNull }
716 func (m *Dot11DataQOSNull) CanDecode() gopacket.LayerClass    { return LayerTypeDot11DataQOSNull }
717 func (m *Dot11DataQOSNull) NextLayerType() gopacket.LayerType { return LayerTypeDot11DataNull }
718
719 type Dot11DataQOSCFPollNoData struct {
720         Dot11DataQOS
721 }
722
723 func decodeDot11DataQOSCFPollNoData(data []byte, p gopacket.PacketBuilder) error {
724         d := &Dot11DataQOSCFPollNoData{}
725         return decodingLayerDecoder(d, data, p)
726 }
727
728 func (m *Dot11DataQOSCFPollNoData) LayerType() gopacket.LayerType {
729         return LayerTypeDot11DataQOSCFPollNoData
730 }
731 func (m *Dot11DataQOSCFPollNoData) CanDecode() gopacket.LayerClass {
732         return LayerTypeDot11DataQOSCFPollNoData
733 }
734 func (m *Dot11DataQOSCFPollNoData) NextLayerType() gopacket.LayerType {
735         return LayerTypeDot11DataCFPollNoData
736 }
737
738 type Dot11DataQOSCFAckPollNoData struct {
739         Dot11DataQOS
740 }
741
742 func decodeDot11DataQOSCFAckPollNoData(data []byte, p gopacket.PacketBuilder) error {
743         d := &Dot11DataQOSCFAckPollNoData{}
744         return decodingLayerDecoder(d, data, p)
745 }
746
747 func (m *Dot11DataQOSCFAckPollNoData) LayerType() gopacket.LayerType {
748         return LayerTypeDot11DataQOSCFAckPollNoData
749 }
750 func (m *Dot11DataQOSCFAckPollNoData) CanDecode() gopacket.LayerClass {
751         return LayerTypeDot11DataQOSCFAckPollNoData
752 }
753 func (m *Dot11DataQOSCFAckPollNoData) NextLayerType() gopacket.LayerType {
754         return LayerTypeDot11DataCFAckPollNoData
755 }
756
757 type Dot11InformationElement struct {
758         BaseLayer
759         ID     Dot11InformationElementID
760         Length uint8
761         OUI    []byte
762         Info   []byte
763 }
764
765 func (m *Dot11InformationElement) LayerType() gopacket.LayerType {
766         return LayerTypeDot11InformationElement
767 }
768 func (m *Dot11InformationElement) CanDecode() gopacket.LayerClass {
769         return LayerTypeDot11InformationElement
770 }
771
772 func (m *Dot11InformationElement) NextLayerType() gopacket.LayerType {
773         return LayerTypeDot11InformationElement
774 }
775
776 func (m *Dot11InformationElement) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
777         if len(data) < 2 {
778                 df.SetTruncated()
779                 return fmt.Errorf("Dot11InformationElement length %v too short, %v required", len(data), 2)
780         }
781         m.ID = Dot11InformationElementID(data[0])
782         m.Length = data[1]
783         offset := int(2)
784
785         if len(data) < offset+int(m.Length) {
786                 df.SetTruncated()
787                 return fmt.Errorf("Dot11InformationElement length %v too short, %v required", len(data), offset+int(m.Length))
788         }
789         if m.ID == 221 {
790                 // Vendor extension
791                 m.OUI = data[offset : offset+4]
792                 m.Info = data[offset+4 : offset+int(m.Length)]
793         } else {
794                 m.Info = data[offset : offset+int(m.Length)]
795         }
796
797         offset += int(m.Length)
798
799         m.BaseLayer = BaseLayer{Contents: data[:offset], Payload: data[offset:]}
800         return nil
801 }
802
803 func (d *Dot11InformationElement) String() string {
804         if d.ID == 0 {
805                 return fmt.Sprintf("802.11 Information Element (SSID: %v)", string(d.Info))
806         } else if d.ID == 1 {
807                 rates := ""
808                 for i := 0; i < len(d.Info); i++ {
809                         if d.Info[i]&0x80 == 0 {
810                                 rates += fmt.Sprintf("%.1f ", float32(d.Info[i])*0.5)
811                         } else {
812                                 rates += fmt.Sprintf("%.1f* ", float32(d.Info[i]&0x7F)*0.5)
813                         }
814                 }
815                 return fmt.Sprintf("802.11 Information Element (Rates: %s Mbit)", rates)
816         } else if d.ID == 221 {
817                 return fmt.Sprintf("802.11 Information Element (Vendor: ID: %v, Length: %v, OUI: %X, Info: %X)", d.ID, d.Length, d.OUI, d.Info)
818         } else {
819                 return fmt.Sprintf("802.11 Information Element (ID: %v, Length: %v, Info: %X)", d.ID, d.Length, d.Info)
820         }
821 }
822
823 func (m Dot11InformationElement) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
824         length := len(m.Info) + len(m.OUI)
825         if buf, err := b.PrependBytes(2 + length); err != nil {
826                 return err
827         } else {
828                 buf[0] = uint8(m.ID)
829                 buf[1] = uint8(length)
830                 copy(buf[2:], m.OUI)
831                 copy(buf[2+len(m.OUI):], m.Info)
832         }
833         return nil
834 }
835
836 func decodeDot11InformationElement(data []byte, p gopacket.PacketBuilder) error {
837         d := &Dot11InformationElement{}
838         return decodingLayerDecoder(d, data, p)
839 }
840
841 type Dot11CtrlCTS struct {
842         Dot11Ctrl
843 }
844
845 func decodeDot11CtrlCTS(data []byte, p gopacket.PacketBuilder) error {
846         d := &Dot11CtrlCTS{}
847         return decodingLayerDecoder(d, data, p)
848 }
849
850 func (m *Dot11CtrlCTS) LayerType() gopacket.LayerType {
851         return LayerTypeDot11CtrlCTS
852 }
853 func (m *Dot11CtrlCTS) CanDecode() gopacket.LayerClass {
854         return LayerTypeDot11CtrlCTS
855 }
856 func (m *Dot11CtrlCTS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
857         return m.Dot11Ctrl.DecodeFromBytes(data, df)
858 }
859
860 type Dot11CtrlRTS struct {
861         Dot11Ctrl
862 }
863
864 func decodeDot11CtrlRTS(data []byte, p gopacket.PacketBuilder) error {
865         d := &Dot11CtrlRTS{}
866         return decodingLayerDecoder(d, data, p)
867 }
868
869 func (m *Dot11CtrlRTS) LayerType() gopacket.LayerType {
870         return LayerTypeDot11CtrlRTS
871 }
872 func (m *Dot11CtrlRTS) CanDecode() gopacket.LayerClass {
873         return LayerTypeDot11CtrlRTS
874 }
875 func (m *Dot11CtrlRTS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
876         return m.Dot11Ctrl.DecodeFromBytes(data, df)
877 }
878
879 type Dot11CtrlBlockAckReq struct {
880         Dot11Ctrl
881 }
882
883 func decodeDot11CtrlBlockAckReq(data []byte, p gopacket.PacketBuilder) error {
884         d := &Dot11CtrlBlockAckReq{}
885         return decodingLayerDecoder(d, data, p)
886 }
887
888 func (m *Dot11CtrlBlockAckReq) LayerType() gopacket.LayerType {
889         return LayerTypeDot11CtrlBlockAckReq
890 }
891 func (m *Dot11CtrlBlockAckReq) CanDecode() gopacket.LayerClass {
892         return LayerTypeDot11CtrlBlockAckReq
893 }
894 func (m *Dot11CtrlBlockAckReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
895         return m.Dot11Ctrl.DecodeFromBytes(data, df)
896 }
897
898 type Dot11CtrlBlockAck struct {
899         Dot11Ctrl
900 }
901
902 func decodeDot11CtrlBlockAck(data []byte, p gopacket.PacketBuilder) error {
903         d := &Dot11CtrlBlockAck{}
904         return decodingLayerDecoder(d, data, p)
905 }
906
907 func (m *Dot11CtrlBlockAck) LayerType() gopacket.LayerType  { return LayerTypeDot11CtrlBlockAck }
908 func (m *Dot11CtrlBlockAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11CtrlBlockAck }
909 func (m *Dot11CtrlBlockAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
910         return m.Dot11Ctrl.DecodeFromBytes(data, df)
911 }
912
913 type Dot11CtrlPowersavePoll struct {
914         Dot11Ctrl
915 }
916
917 func decodeDot11CtrlPowersavePoll(data []byte, p gopacket.PacketBuilder) error {
918         d := &Dot11CtrlPowersavePoll{}
919         return decodingLayerDecoder(d, data, p)
920 }
921
922 func (m *Dot11CtrlPowersavePoll) LayerType() gopacket.LayerType {
923         return LayerTypeDot11CtrlPowersavePoll
924 }
925 func (m *Dot11CtrlPowersavePoll) CanDecode() gopacket.LayerClass {
926         return LayerTypeDot11CtrlPowersavePoll
927 }
928 func (m *Dot11CtrlPowersavePoll) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
929         return m.Dot11Ctrl.DecodeFromBytes(data, df)
930 }
931
932 type Dot11CtrlAck struct {
933         Dot11Ctrl
934 }
935
936 func decodeDot11CtrlAck(data []byte, p gopacket.PacketBuilder) error {
937         d := &Dot11CtrlAck{}
938         return decodingLayerDecoder(d, data, p)
939 }
940
941 func (m *Dot11CtrlAck) LayerType() gopacket.LayerType  { return LayerTypeDot11CtrlAck }
942 func (m *Dot11CtrlAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11CtrlAck }
943 func (m *Dot11CtrlAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
944         return m.Dot11Ctrl.DecodeFromBytes(data, df)
945 }
946
947 type Dot11CtrlCFEnd struct {
948         Dot11Ctrl
949 }
950
951 func decodeDot11CtrlCFEnd(data []byte, p gopacket.PacketBuilder) error {
952         d := &Dot11CtrlCFEnd{}
953         return decodingLayerDecoder(d, data, p)
954 }
955
956 func (m *Dot11CtrlCFEnd) LayerType() gopacket.LayerType {
957         return LayerTypeDot11CtrlCFEnd
958 }
959 func (m *Dot11CtrlCFEnd) CanDecode() gopacket.LayerClass {
960         return LayerTypeDot11CtrlCFEnd
961 }
962 func (m *Dot11CtrlCFEnd) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
963         return m.Dot11Ctrl.DecodeFromBytes(data, df)
964 }
965
966 type Dot11CtrlCFEndAck struct {
967         Dot11Ctrl
968 }
969
970 func decodeDot11CtrlCFEndAck(data []byte, p gopacket.PacketBuilder) error {
971         d := &Dot11CtrlCFEndAck{}
972         return decodingLayerDecoder(d, data, p)
973 }
974
975 func (m *Dot11CtrlCFEndAck) LayerType() gopacket.LayerType {
976         return LayerTypeDot11CtrlCFEndAck
977 }
978 func (m *Dot11CtrlCFEndAck) CanDecode() gopacket.LayerClass {
979         return LayerTypeDot11CtrlCFEndAck
980 }
981 func (m *Dot11CtrlCFEndAck) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
982         return m.Dot11Ctrl.DecodeFromBytes(data, df)
983 }
984
985 type Dot11MgmtAssociationReq struct {
986         Dot11Mgmt
987         CapabilityInfo uint16
988         ListenInterval uint16
989 }
990
991 func decodeDot11MgmtAssociationReq(data []byte, p gopacket.PacketBuilder) error {
992         d := &Dot11MgmtAssociationReq{}
993         return decodingLayerDecoder(d, data, p)
994 }
995
996 func (m *Dot11MgmtAssociationReq) LayerType() gopacket.LayerType {
997         return LayerTypeDot11MgmtAssociationReq
998 }
999 func (m *Dot11MgmtAssociationReq) CanDecode() gopacket.LayerClass {
1000         return LayerTypeDot11MgmtAssociationReq
1001 }
1002 func (m *Dot11MgmtAssociationReq) NextLayerType() gopacket.LayerType {
1003         return LayerTypeDot11InformationElement
1004 }
1005 func (m *Dot11MgmtAssociationReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1006         if len(data) < 4 {
1007                 df.SetTruncated()
1008                 return fmt.Errorf("Dot11MgmtAssociationReq length %v too short, %v required", len(data), 4)
1009         }
1010         m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2])
1011         m.ListenInterval = binary.LittleEndian.Uint16(data[2:4])
1012         m.Payload = data[4:]
1013         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1014 }
1015
1016 func (m Dot11MgmtAssociationReq) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1017         buf, err := b.PrependBytes(4)
1018
1019         if err != nil {
1020                 return err
1021         }
1022
1023         binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo)
1024         binary.LittleEndian.PutUint16(buf[2:4], m.ListenInterval)
1025
1026         return nil
1027 }
1028
1029 type Dot11MgmtAssociationResp struct {
1030         Dot11Mgmt
1031         CapabilityInfo uint16
1032         Status         Dot11Status
1033         AID            uint16
1034 }
1035
1036 func decodeDot11MgmtAssociationResp(data []byte, p gopacket.PacketBuilder) error {
1037         d := &Dot11MgmtAssociationResp{}
1038         return decodingLayerDecoder(d, data, p)
1039 }
1040
1041 func (m *Dot11MgmtAssociationResp) CanDecode() gopacket.LayerClass {
1042         return LayerTypeDot11MgmtAssociationResp
1043 }
1044 func (m *Dot11MgmtAssociationResp) LayerType() gopacket.LayerType {
1045         return LayerTypeDot11MgmtAssociationResp
1046 }
1047 func (m *Dot11MgmtAssociationResp) NextLayerType() gopacket.LayerType {
1048         return LayerTypeDot11InformationElement
1049 }
1050 func (m *Dot11MgmtAssociationResp) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1051         if len(data) < 6 {
1052                 df.SetTruncated()
1053                 return fmt.Errorf("Dot11MgmtAssociationResp length %v too short, %v required", len(data), 6)
1054         }
1055         m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2])
1056         m.Status = Dot11Status(binary.LittleEndian.Uint16(data[2:4]))
1057         m.AID = binary.LittleEndian.Uint16(data[4:6])
1058         m.Payload = data[6:]
1059         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1060 }
1061
1062 func (m Dot11MgmtAssociationResp) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1063         buf, err := b.PrependBytes(6)
1064
1065         if err != nil {
1066                 return err
1067         }
1068
1069         binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo)
1070         binary.LittleEndian.PutUint16(buf[2:4], uint16(m.Status))
1071         binary.LittleEndian.PutUint16(buf[4:6], m.AID)
1072
1073         return nil
1074 }
1075
1076 type Dot11MgmtReassociationReq struct {
1077         Dot11Mgmt
1078         CapabilityInfo   uint16
1079         ListenInterval   uint16
1080         CurrentApAddress net.HardwareAddr
1081 }
1082
1083 func decodeDot11MgmtReassociationReq(data []byte, p gopacket.PacketBuilder) error {
1084         d := &Dot11MgmtReassociationReq{}
1085         return decodingLayerDecoder(d, data, p)
1086 }
1087
1088 func (m *Dot11MgmtReassociationReq) LayerType() gopacket.LayerType {
1089         return LayerTypeDot11MgmtReassociationReq
1090 }
1091 func (m *Dot11MgmtReassociationReq) CanDecode() gopacket.LayerClass {
1092         return LayerTypeDot11MgmtReassociationReq
1093 }
1094 func (m *Dot11MgmtReassociationReq) NextLayerType() gopacket.LayerType {
1095         return LayerTypeDot11InformationElement
1096 }
1097 func (m *Dot11MgmtReassociationReq) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1098         if len(data) < 10 {
1099                 df.SetTruncated()
1100                 return fmt.Errorf("Dot11MgmtReassociationReq length %v too short, %v required", len(data), 10)
1101         }
1102         m.CapabilityInfo = binary.LittleEndian.Uint16(data[0:2])
1103         m.ListenInterval = binary.LittleEndian.Uint16(data[2:4])
1104         m.CurrentApAddress = net.HardwareAddr(data[4:10])
1105         m.Payload = data[10:]
1106         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1107 }
1108
1109 func (m Dot11MgmtReassociationReq) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1110         buf, err := b.PrependBytes(10)
1111
1112         if err != nil {
1113                 return err
1114         }
1115
1116         binary.LittleEndian.PutUint16(buf[0:2], m.CapabilityInfo)
1117         binary.LittleEndian.PutUint16(buf[2:4], m.ListenInterval)
1118
1119         copy(buf[4:10], m.CurrentApAddress)
1120
1121         return nil
1122 }
1123
1124 type Dot11MgmtReassociationResp struct {
1125         Dot11Mgmt
1126 }
1127
1128 func decodeDot11MgmtReassociationResp(data []byte, p gopacket.PacketBuilder) error {
1129         d := &Dot11MgmtReassociationResp{}
1130         return decodingLayerDecoder(d, data, p)
1131 }
1132
1133 func (m *Dot11MgmtReassociationResp) LayerType() gopacket.LayerType {
1134         return LayerTypeDot11MgmtReassociationResp
1135 }
1136 func (m *Dot11MgmtReassociationResp) CanDecode() gopacket.LayerClass {
1137         return LayerTypeDot11MgmtReassociationResp
1138 }
1139 func (m *Dot11MgmtReassociationResp) NextLayerType() gopacket.LayerType {
1140         return LayerTypeDot11InformationElement
1141 }
1142
1143 type Dot11MgmtProbeReq struct {
1144         Dot11Mgmt
1145 }
1146
1147 func decodeDot11MgmtProbeReq(data []byte, p gopacket.PacketBuilder) error {
1148         d := &Dot11MgmtProbeReq{}
1149         return decodingLayerDecoder(d, data, p)
1150 }
1151
1152 func (m *Dot11MgmtProbeReq) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtProbeReq }
1153 func (m *Dot11MgmtProbeReq) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtProbeReq }
1154 func (m *Dot11MgmtProbeReq) NextLayerType() gopacket.LayerType {
1155         return LayerTypeDot11InformationElement
1156 }
1157
1158 type Dot11MgmtProbeResp struct {
1159         Dot11Mgmt
1160         Timestamp uint64
1161         Interval  uint16
1162         Flags     uint16
1163 }
1164
1165 func decodeDot11MgmtProbeResp(data []byte, p gopacket.PacketBuilder) error {
1166         d := &Dot11MgmtProbeResp{}
1167         return decodingLayerDecoder(d, data, p)
1168 }
1169
1170 func (m *Dot11MgmtProbeResp) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtProbeResp }
1171 func (m *Dot11MgmtProbeResp) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtProbeResp }
1172 func (m *Dot11MgmtProbeResp) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1173         if len(data) < 12 {
1174                 df.SetTruncated()
1175
1176                 return fmt.Errorf("Dot11MgmtProbeResp length %v too short, %v required", len(data), 12)
1177         }
1178
1179         m.Timestamp = binary.LittleEndian.Uint64(data[0:8])
1180         m.Interval = binary.LittleEndian.Uint16(data[8:10])
1181         m.Flags = binary.LittleEndian.Uint16(data[10:12])
1182         m.Payload = data[12:]
1183
1184         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1185 }
1186
1187 func (m *Dot11MgmtProbeResp) NextLayerType() gopacket.LayerType {
1188         return LayerTypeDot11InformationElement
1189 }
1190
1191 func (m Dot11MgmtProbeResp) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1192         buf, err := b.PrependBytes(12)
1193
1194         if err != nil {
1195                 return err
1196         }
1197
1198         binary.LittleEndian.PutUint64(buf[0:8], m.Timestamp)
1199         binary.LittleEndian.PutUint16(buf[8:10], m.Interval)
1200         binary.LittleEndian.PutUint16(buf[10:12], m.Flags)
1201
1202         return nil
1203 }
1204
1205 type Dot11MgmtMeasurementPilot struct {
1206         Dot11Mgmt
1207 }
1208
1209 func decodeDot11MgmtMeasurementPilot(data []byte, p gopacket.PacketBuilder) error {
1210         d := &Dot11MgmtMeasurementPilot{}
1211         return decodingLayerDecoder(d, data, p)
1212 }
1213
1214 func (m *Dot11MgmtMeasurementPilot) LayerType() gopacket.LayerType {
1215         return LayerTypeDot11MgmtMeasurementPilot
1216 }
1217 func (m *Dot11MgmtMeasurementPilot) CanDecode() gopacket.LayerClass {
1218         return LayerTypeDot11MgmtMeasurementPilot
1219 }
1220
1221 type Dot11MgmtBeacon struct {
1222         Dot11Mgmt
1223         Timestamp uint64
1224         Interval  uint16
1225         Flags     uint16
1226 }
1227
1228 func decodeDot11MgmtBeacon(data []byte, p gopacket.PacketBuilder) error {
1229         d := &Dot11MgmtBeacon{}
1230         return decodingLayerDecoder(d, data, p)
1231 }
1232
1233 func (m *Dot11MgmtBeacon) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtBeacon }
1234 func (m *Dot11MgmtBeacon) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtBeacon }
1235 func (m *Dot11MgmtBeacon) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1236         if len(data) < 12 {
1237                 df.SetTruncated()
1238                 return fmt.Errorf("Dot11MgmtBeacon length %v too short, %v required", len(data), 12)
1239         }
1240         m.Timestamp = binary.LittleEndian.Uint64(data[0:8])
1241         m.Interval = binary.LittleEndian.Uint16(data[8:10])
1242         m.Flags = binary.LittleEndian.Uint16(data[10:12])
1243         m.Payload = data[12:]
1244         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1245 }
1246
1247 func (m *Dot11MgmtBeacon) NextLayerType() gopacket.LayerType { return LayerTypeDot11InformationElement }
1248
1249 func (m Dot11MgmtBeacon) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1250         buf, err := b.PrependBytes(12)
1251
1252         if err != nil {
1253                 return err
1254         }
1255
1256         binary.LittleEndian.PutUint64(buf[0:8], m.Timestamp)
1257         binary.LittleEndian.PutUint16(buf[8:10], m.Interval)
1258         binary.LittleEndian.PutUint16(buf[10:12], m.Flags)
1259
1260         return nil
1261 }
1262
1263 type Dot11MgmtATIM struct {
1264         Dot11Mgmt
1265 }
1266
1267 func decodeDot11MgmtATIM(data []byte, p gopacket.PacketBuilder) error {
1268         d := &Dot11MgmtATIM{}
1269         return decodingLayerDecoder(d, data, p)
1270 }
1271
1272 func (m *Dot11MgmtATIM) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtATIM }
1273 func (m *Dot11MgmtATIM) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtATIM }
1274
1275 type Dot11MgmtDisassociation struct {
1276         Dot11Mgmt
1277         Reason Dot11Reason
1278 }
1279
1280 func decodeDot11MgmtDisassociation(data []byte, p gopacket.PacketBuilder) error {
1281         d := &Dot11MgmtDisassociation{}
1282         return decodingLayerDecoder(d, data, p)
1283 }
1284
1285 func (m *Dot11MgmtDisassociation) LayerType() gopacket.LayerType {
1286         return LayerTypeDot11MgmtDisassociation
1287 }
1288 func (m *Dot11MgmtDisassociation) CanDecode() gopacket.LayerClass {
1289         return LayerTypeDot11MgmtDisassociation
1290 }
1291 func (m *Dot11MgmtDisassociation) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1292         if len(data) < 2 {
1293                 df.SetTruncated()
1294                 return fmt.Errorf("Dot11MgmtDisassociation length %v too short, %v required", len(data), 2)
1295         }
1296         m.Reason = Dot11Reason(binary.LittleEndian.Uint16(data[0:2]))
1297         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1298 }
1299
1300 func (m Dot11MgmtDisassociation) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1301         buf, err := b.PrependBytes(2)
1302
1303         if err != nil {
1304                 return err
1305         }
1306
1307         binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Reason))
1308
1309         return nil
1310 }
1311
1312 type Dot11MgmtAuthentication struct {
1313         Dot11Mgmt
1314         Algorithm Dot11Algorithm
1315         Sequence  uint16
1316         Status    Dot11Status
1317 }
1318
1319 func decodeDot11MgmtAuthentication(data []byte, p gopacket.PacketBuilder) error {
1320         d := &Dot11MgmtAuthentication{}
1321         return decodingLayerDecoder(d, data, p)
1322 }
1323
1324 func (m *Dot11MgmtAuthentication) LayerType() gopacket.LayerType {
1325         return LayerTypeDot11MgmtAuthentication
1326 }
1327 func (m *Dot11MgmtAuthentication) CanDecode() gopacket.LayerClass {
1328         return LayerTypeDot11MgmtAuthentication
1329 }
1330 func (m *Dot11MgmtAuthentication) NextLayerType() gopacket.LayerType {
1331         return LayerTypeDot11InformationElement
1332 }
1333 func (m *Dot11MgmtAuthentication) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1334         if len(data) < 6 {
1335                 df.SetTruncated()
1336                 return fmt.Errorf("Dot11MgmtAuthentication length %v too short, %v required", len(data), 6)
1337         }
1338         m.Algorithm = Dot11Algorithm(binary.LittleEndian.Uint16(data[0:2]))
1339         m.Sequence = binary.LittleEndian.Uint16(data[2:4])
1340         m.Status = Dot11Status(binary.LittleEndian.Uint16(data[4:6]))
1341         m.Payload = data[6:]
1342         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1343 }
1344
1345 func (m Dot11MgmtAuthentication) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1346         buf, err := b.PrependBytes(6)
1347
1348         if err != nil {
1349                 return err
1350         }
1351
1352         binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Algorithm))
1353         binary.LittleEndian.PutUint16(buf[2:4], m.Sequence)
1354         binary.LittleEndian.PutUint16(buf[4:6], uint16(m.Status))
1355
1356         return nil
1357 }
1358
1359 type Dot11MgmtDeauthentication struct {
1360         Dot11Mgmt
1361         Reason Dot11Reason
1362 }
1363
1364 func decodeDot11MgmtDeauthentication(data []byte, p gopacket.PacketBuilder) error {
1365         d := &Dot11MgmtDeauthentication{}
1366         return decodingLayerDecoder(d, data, p)
1367 }
1368
1369 func (m *Dot11MgmtDeauthentication) LayerType() gopacket.LayerType {
1370         return LayerTypeDot11MgmtDeauthentication
1371 }
1372 func (m *Dot11MgmtDeauthentication) CanDecode() gopacket.LayerClass {
1373         return LayerTypeDot11MgmtDeauthentication
1374 }
1375 func (m *Dot11MgmtDeauthentication) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
1376         if len(data) < 2 {
1377                 df.SetTruncated()
1378                 return fmt.Errorf("Dot11MgmtDeauthentication length %v too short, %v required", len(data), 2)
1379         }
1380         m.Reason = Dot11Reason(binary.LittleEndian.Uint16(data[0:2]))
1381         return m.Dot11Mgmt.DecodeFromBytes(data, df)
1382 }
1383
1384 func (m Dot11MgmtDeauthentication) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.SerializeOptions) error {
1385         buf, err := b.PrependBytes(2)
1386
1387         if err != nil {
1388                 return err
1389         }
1390
1391         binary.LittleEndian.PutUint16(buf[0:2], uint16(m.Reason))
1392
1393         return nil
1394 }
1395
1396 type Dot11MgmtAction struct {
1397         Dot11Mgmt
1398 }
1399
1400 func decodeDot11MgmtAction(data []byte, p gopacket.PacketBuilder) error {
1401         d := &Dot11MgmtAction{}
1402         return decodingLayerDecoder(d, data, p)
1403 }
1404
1405 func (m *Dot11MgmtAction) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtAction }
1406 func (m *Dot11MgmtAction) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtAction }
1407
1408 type Dot11MgmtActionNoAck struct {
1409         Dot11Mgmt
1410 }
1411
1412 func decodeDot11MgmtActionNoAck(data []byte, p gopacket.PacketBuilder) error {
1413         d := &Dot11MgmtActionNoAck{}
1414         return decodingLayerDecoder(d, data, p)
1415 }
1416
1417 func (m *Dot11MgmtActionNoAck) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtActionNoAck }
1418 func (m *Dot11MgmtActionNoAck) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtActionNoAck }
1419
1420 type Dot11MgmtArubaWLAN struct {
1421         Dot11Mgmt
1422 }
1423
1424 func decodeDot11MgmtArubaWLAN(data []byte, p gopacket.PacketBuilder) error {
1425         d := &Dot11MgmtArubaWLAN{}
1426         return decodingLayerDecoder(d, data, p)
1427 }
1428
1429 func (m *Dot11MgmtArubaWLAN) LayerType() gopacket.LayerType  { return LayerTypeDot11MgmtArubaWLAN }
1430 func (m *Dot11MgmtArubaWLAN) CanDecode() gopacket.LayerClass { return LayerTypeDot11MgmtArubaWLAN }