• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright (C) 2012 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef SHILL_NET_IEEE80211_H_
18 #define SHILL_NET_IEEE80211_H_
19 
20 namespace shill {
21 
22 namespace IEEE_80211 {
23 // Information Element Ids from IEEE 802.11-2012 Section 8.4.2
24 const uint8_t kElemIdChannels = 0x24;
25 const uint8_t kElemIdChallengeText = 0x10;
26 const uint8_t kElemIdCountry = 0x07;
27 const uint8_t kElemIdDSParameterSet = 0x03;
28 const uint8_t kElemIdErp = 0x2a;
29 const uint8_t kElemIdExtendedRates = 0x32;
30 const uint8_t kElemIdHTCap = 0x2d;
31 const uint8_t kElemIdHTInfo = 0x3d;
32 const uint8_t kElemIdPowerCapability = 0x21;
33 const uint8_t kElemIdPowerConstraint = 0x20;
34 const uint8_t kElemIdRequest = 0x0a;
35 const uint8_t kElemIdRSN = 0x30;
36 const uint8_t kElemIdSsid = 0x00;
37 const uint8_t kElemIdSupportedRates = 0x01;
38 const uint8_t kElemIdTpcReport = 0x23;
39 const uint8_t kElemIdVendor = 0xdd;
40 const uint8_t kElemIdVHTCap = 0xbf;
41 const uint8_t kElemIdVHTOperation = 0xc0;
42 
43 const unsigned int kMaxSSIDLen = 32;
44 
45 const unsigned int kWEP40AsciiLen = 5;
46 const unsigned int kWEP40HexLen = 10;
47 const unsigned int kWEP104AsciiLen = 13;
48 const unsigned int kWEP104HexLen = 26;
49 
50 const unsigned int kWPAAsciiMinLen = 8;
51 const unsigned int kWPAAsciiMaxLen = 63;
52 const unsigned int kWPAHexLen = 64;
53 
54 const uint32_t kOUIVendorEpigram = 0x00904c;
55 const uint32_t kOUIVendorMicrosoft = 0x0050f2;
56 
57 const uint8_t kOUIMicrosoftWPA = 1;
58 const uint8_t kOUIMicrosoftWPS = 4;
59 const uint16_t kWPSElementManufacturer = 0x1021;
60 const uint16_t kWPSElementModelName = 0x1023;
61 const uint16_t kWPSElementModelNumber = 0x1024;
62 const uint16_t kWPSElementDeviceName = 0x1011;
63 
64 const int kRSNIEVersionLen = 2;
65 const int kRSNIESelectorLen = 4;
66 const int kRSNIECipherCountOffset = kRSNIEVersionLen + kRSNIESelectorLen;
67 const int kRSNIECipherCountLen = 2;
68 const int kRSNIENumCiphers = 2;
69 const int kRSNIECapabilitiesLen = 2;
70 const uint16_t kRSNCapabilityPreAuth = 0x0001;
71 const uint16_t kRSNCapabilityPairwise = 0x0002;
72 const uint16_t kRSNCapabilityPTKSA = 0x000c;
73 const uint16_t kRSNCapabilityGTKSA = 0x0030;
74 const uint16_t kRSNCapabilityFrameProtectionRequired = 0x0040;
75 const uint16_t kRSNCapabilityFrameProtectionCapable = 0x0080;
76 const uint16_t kRSNCapabilityPeerKey = 0x0200;
77 
78 /* 802.11n HT capabilities masks (for cap_info) */
79 const uint16_t kHTCapMaskLdpcCoding = 0x0001;
80 const uint16_t kHTCapMaskSupWidth2040 = 0x0002;
81 const uint16_t kHTCapMaskSmPs = 0x000c;
82 const uint16_t kHTCapMaskSmPsShift = 2;
83 const uint16_t kHTCapMaskGrnFld = 0x0010;
84 const uint16_t kHTCapMaskSgi20 = 0x0020;
85 const uint16_t kHTCapMaskSgi40 = 0x0040;
86 const uint16_t kHTCapMaskTxStbc = 0x0080;
87 const uint16_t kHTCapMaskRxStbc = 0x0300;
88 const uint16_t kHTCapMaskRxStbcShift = 8;
89 const uint16_t kHTCapMaskDelayBA = 0x0400;
90 const uint16_t kHTCapMaskMaxAmsdu = 0x0800;
91 const uint16_t kHTCapMaskDsssCck40 = 0x1000;
92 const uint16_t kHTCapMask40MHzIntolerant = 0x4000;
93 const uint16_t kHTCapMaskLsigTxopProt = 0x8000;
94 
95 // Beacon and Probe Response Capability Information field masks from
96 // IEEE 802.11-2012 Section 8.4.1.4
97 const uint16_t kWlanCapMaskEss = 0x0001;
98 const uint16_t kWlanCapMaskIbss = 0x0002;
99 const uint16_t kWlanCapMaskContentionFreePollable = 0x0004;
100 const uint16_t kWlanCapMaskContentionFreePollRequest = 0x0008;
101 const uint16_t kWlanCapMaskPrivacy = 0x0010;
102 const uint16_t kWlanCapMaskShortPreamble = 0x0020;
103 const uint16_t kWlanCapMaskPbcc = 0x0040;
104 const uint16_t kWlanCapMaskChannelAgility = 0x0080;
105 const uint16_t kWlanCapMaskSpectrumMgmt = 0x0100;
106 const uint16_t kWlanCapMaskQoS = 0x0200;
107 const uint16_t kWlanCapMaskShortSlotTime = 0x0400;
108 const uint16_t kWlanCapMaskApsd = 0x0800;
109 const uint16_t kWlanCapMaskRadioMeasurement = 0x1000;
110 const uint16_t kWlanCapMaskDsssOfdm = 0x2000;
111 const uint16_t kWlanCapMaskDelayedBlockAck = 0x4000;
112 const uint16_t kWlanCapMaskImmediateBlockAck = 0x8000;
113 
114 
115 // This structure is incomplete.  Fields will be added as necessary.
116 //
117 // NOTE: the uint16_t stuff is in little-endian format so conversions are
118 // required.
119 struct ieee80211_frame {
120   uint16_t frame_control;
121   uint16_t duration_usec;
122   uint8_t destination_mac[6];
123   uint8_t source_mac[6];
124   uint8_t address[6];
125   uint16_t sequence_control;
126   union {
127     struct {
128       uint16_t reserved_1;
129       uint16_t reserved_2;
130       uint16_t status_code;
131     } authentiate_message;
132     struct {
133       uint16_t reason_code;
134     } deauthentiate_message;
135     struct {
136       uint16_t reserved_1;
137       uint16_t status_code;
138     } associate_response;
139   } u;
140 };
141 
142 // Status/reason code returned by nl80211 messages: Authenticate,
143 // Deauthenticate, Associate, and Reassociate.
144 enum WiFiReasonCode {
145   kReasonCodeReserved0 = 0,  // 0 is reserved.
146   kReasonCodeUnspecified = 1,
147   kReasonCodePreviousAuthenticationInvalid = 2,
148   kReasonCodeSenderHasLeft = 3,
149   kReasonCodeInactivity = 4,
150   kReasonCodeTooManySTAs = 5,
151   kReasonCodeNonAuthenticated = 6,
152   kReasonCodeNonAssociated = 7,
153   kReasonCodeDisassociatedHasLeft = 8,
154   kReasonCodeReassociationNotAuthenticated = 9,
155   kReasonCodeUnacceptablePowerCapability = 10,
156   kReasonCodeUnacceptableSupportedChannelInfo = 11,
157   kReasonCodeReserved12 = 12,  // 12 is reserved.
158   kReasonCodeInvalidInfoElement = 13,
159   kReasonCodeMICFailure = 14,
160   kReasonCode4WayTimeout = 15,
161   kReasonCodeGroupKeyHandshakeTimeout = 16,
162   kReasonCodeDifferenIE = 17,
163   kReasonCodeGroupCipherInvalid = 18,
164   kReasonCodePairwiseCipherInvalid = 19,
165   kReasonCodeAkmpInvalid = 20,
166   kReasonCodeUnsupportedRsnIeVersion = 21,
167   kReasonCodeInvalidRsnIeCaps = 22,
168   kReasonCode8021XAuth = 23,
169   kReasonCodeCipherSuiteRejected = 24,
170   kReasonCodeReservedBegin25 = 25,   // 25-31 are reserved.
171   kReasonCodeReservedEnd31 = 31,
172   kReasonCodeUnspecifiedQoS = 32,
173   kReasonCodeQoSBandwidth = 33,
174   kReasonCodeiPoorConditions = 34,
175   kReasonCodeOutsideTxop = 35,
176   kReasonCodeStaLeaving = 36,
177   kReasonCodeUnacceptableMechanism = 37,
178   kReasonCodeSetupRequired = 38,
179   kReasonCodeTimeout = 39,
180   kReasonCodeReservedBegin40 = 40,  // 40-44 are reserved.
181   kReasonCodeReservedEnd44 = 44,
182   kReasonCodeCipherSuiteNotSupported = 45,
183   kReasonCodeMax,
184   kReasonCodeInvalid = UINT16_MAX
185 };
186 
187 enum WiFiStatusCode {
188   kStatusCodeSuccessful = 0,
189   kStatusCodeFailure = 1,
190   // 2-9 are reserved.
191   kStatusCodeAllCapabilitiesNotSupported = 10,
192   kStatusCodeCantConfirmAssociation = 11,
193   kStatusCodeAssociationDenied = 12,
194   kStatusCodeAuthenticationUnsupported = 13,
195   kStatusCodeOutOfSequence = 14,
196   kStatusCodeChallengeFailure = 15,
197   kStatusCodeFrameTimeout = 16,
198   kStatusCodeMaxSta = 17,
199   kStatusCodeDataRateUnsupported = 18,
200   kStatusCodeShortPreambleUnsupported = 19,
201   kStatusCodePbccUnsupported = 20,
202   kStatusCodeChannelAgilityUnsupported = 21,
203   kStatusCodeNeedSpectrumManagement = 22,
204   kStatusCodeUnacceptablePowerCapability = 23,
205   kStatusCodeUnacceptableSupportedChannelInfo = 24,
206   kStatusCodeShortTimeSlotRequired = 25,
207   kStatusCodeDssOfdmRequired = 26,
208   // 27-31 are reserved.
209   kStatusCodeQosFailure = 32,
210   kStatusCodeInsufficientBandwithForQsta = 33,
211   kStatusCodePoorConditions = 34,
212   kStatusCodeQosNotSupported = 35,
213   // 36 is reserved.
214   kStatusCodeDeclined = 37,
215   kStatusCodeInvalidParameterValues = 38,
216   kStatusCodeCannotBeHonored = 39,
217   kStatusCodeInvalidInfoElement = 40,
218   kStatusCodeGroupCipherInvalid = 41,
219   kStatusCodePairwiseCipherInvalid = 42,
220   kStatusCodeAkmpInvalid = 43,
221   kStatusCodeUnsupportedRsnIeVersion = 44,
222   kStatusCodeInvalidRsnIeCaps = 45,
223   kStatusCodeCipherSuiteRejected = 46,
224   kStatusCodeTsDelayNotMet = 47,
225   kStatusCodeDirectLinkIllegal = 48,
226   kStatusCodeStaNotInBss = 49,
227   kStatusCodeStaNotInQsta = 50,
228   kStatusCodeExcessiveListenInterval = 51,
229   kStatusCodeMax,
230   kStatusCodeInvalid = UINT16_MAX
231 };
232 
233 }  // namespace IEEE_80211
234 
235 }  // namespace shill
236 
237 #endif  // SHILL_NET_IEEE80211_H_
238