[59fa7ab] | 1 | /*
|
---|
| 2 | * Copyright (c) 2015 Jan Kolarik
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 |
|
---|
[8a64320e] | 29 | /**
|
---|
[59fa7ab] | 30 | * @addtogroup libieee80211
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | /** @file ieee80211.h
|
---|
[8a64320e] | 35 | *
|
---|
[59fa7ab] | 36 | * Internal IEEE 802.11 header that should not be included.
|
---|
| 37 | */
|
---|
| 38 |
|
---|
[8a64320e] | 39 | #ifndef LIB_IEEE80211_PRIVATE_H
|
---|
| 40 | #define LIB_IEEE80211_PRIVATE_H
|
---|
[59fa7ab] | 41 |
|
---|
[1dcc0b9] | 42 | #include <fibril_synch.h>
|
---|
[59fa7ab] | 43 | #include <byteorder.h>
|
---|
| 44 | #include <ddf/driver.h>
|
---|
[8d2dd7f2] | 45 | #include <stddef.h>
|
---|
| 46 | #include <stdint.h>
|
---|
[59fa7ab] | 47 | #include <ieee80211/ieee80211.h>
|
---|
| 48 | #include "ieee80211.h"
|
---|
| 49 |
|
---|
[8a64320e] | 50 | /** Timeout in us for waiting to authentication/association response. */
|
---|
| 51 | #define AUTH_TIMEOUT 200000
|
---|
[1dcc0b9] | 52 |
|
---|
[8a64320e] | 53 | /** Timeout in us for waiting to finish 4-way handshake process. */
|
---|
| 54 | #define HANDSHAKE_TIMEOUT 5000000
|
---|
[1dcc0b9] | 55 |
|
---|
[8a64320e] | 56 | /** Scanning period. */
|
---|
| 57 | #define SCAN_PERIOD_USEC 35000000
|
---|
[053fc2b] | 58 |
|
---|
[8a64320e] | 59 | /** Time to wait for beacons on channel. */
|
---|
| 60 | #define SCAN_CHANNEL_WAIT_USEC 200000
|
---|
[1dcc0b9] | 61 |
|
---|
[8a64320e] | 62 | /** Max time to keep scan result. */
|
---|
| 63 | #define MAX_KEEP_SCAN_SPAN_SEC 120
|
---|
[1dcc0b9] | 64 |
|
---|
[8a64320e] | 65 | /** Security bit in capability info field. */
|
---|
| 66 | #define CAP_SECURITY 0x10
|
---|
[1dcc0b9] | 67 |
|
---|
[8a64320e] | 68 | /** Protocol type used in EAPOL frames. */
|
---|
| 69 | #define ETH_TYPE_PAE 0x888e
|
---|
[1dcc0b9] | 70 |
|
---|
[8a64320e] | 71 | /** WPA OUI used in vendor specific IE. */
|
---|
| 72 | #define WPA_OUI 0x0050f201
|
---|
[1dcc0b9] | 73 |
|
---|
[8a64320e] | 74 | /** GTK OUI used in vendor specific IE. */
|
---|
| 75 | #define GTK_OUI 0x000fac01
|
---|
[1dcc0b9] | 76 |
|
---|
[8a64320e] | 77 | /** Max PTK key length. */
|
---|
| 78 | #define MAX_PTK_LENGTH 64
|
---|
[1dcc0b9] | 79 |
|
---|
[8a64320e] | 80 | /** Max GTK key length. */
|
---|
| 81 | #define MAX_GTK_LENGTH 64
|
---|
[1dcc0b9] | 82 |
|
---|
[8a64320e] | 83 | /** KEK offset inside PTK. */
|
---|
| 84 | #define KEK_OFFSET 16
|
---|
[1dcc0b9] | 85 |
|
---|
[8a64320e] | 86 | /** TK offset inside PTK. */
|
---|
| 87 | #define TK_OFFSET 32
|
---|
[1dcc0b9] | 88 |
|
---|
[8a64320e] | 89 | /** Length of Michael MIC code used in TKIP security suite. */
|
---|
| 90 | #define MIC_LENGTH 8
|
---|
[cc575ef9] | 91 |
|
---|
[8a64320e] | 92 | /** Length of data to be encrypted by PRF function.
|
---|
| 93 | *
|
---|
| 94 | * NONCE + SNONCE (2 * 32) + DEST_MAC + SOURCE_MAC (2 * ETH_ADDR)
|
---|
| 95 | *
|
---|
[1dcc0b9] | 96 | */
|
---|
[8a64320e] | 97 | #define PRF_CRYPT_DATA_LENGTH (2 * 32 + 2 * ETH_ADDR)
|
---|
[1dcc0b9] | 98 |
|
---|
[8a64320e] | 99 | /** Special room in header reserved for encryption. */
|
---|
[a931b7b] | 100 | typedef enum {
|
---|
| 101 | IEEE80211_TKIP_HEADER_LENGTH = 8,
|
---|
| 102 | IEEE80211_CCMP_HEADER_LENGTH = 8
|
---|
| 103 | } ieee80211_encrypt_header_reserve_length_t;
|
---|
| 104 |
|
---|
[1dcc0b9] | 105 | /** IEEE 802.11 PTK key length. */
|
---|
| 106 | typedef enum {
|
---|
| 107 | IEEE80211_PTK_CCMP_LENGTH = 48,
|
---|
| 108 | IEEE80211_PTK_TKIP_LENGTH = 64
|
---|
| 109 | } ieee80211_ptk_length_t;
|
---|
| 110 |
|
---|
| 111 | /** IEEE 802.11 GTK key length. */
|
---|
| 112 | typedef enum {
|
---|
| 113 | IEEE80211_GTK_CCMP_LENGTH = 16,
|
---|
| 114 | IEEE80211_GTK_TKIP_LENGTH = 32
|
---|
| 115 | } ieee80211_gtk_length_t;
|
---|
| 116 |
|
---|
[59fa7ab] | 117 | /** IEEE 802.11 frame types. */
|
---|
| 118 | typedef enum {
|
---|
| 119 | IEEE80211_MGMT_FRAME = 0x0,
|
---|
| 120 | IEEE80211_CTRL_FRAME = 0x4,
|
---|
| 121 | IEEE80211_DATA_FRAME = 0x8,
|
---|
| 122 | IEEE80211_EXT_FRAME = 0xC
|
---|
| 123 | } ieee80211_frame_type_t;
|
---|
| 124 |
|
---|
[1dcc0b9] | 125 | /** IEEE 802.11 management frame subtypes. */
|
---|
[59fa7ab] | 126 | typedef enum {
|
---|
| 127 | IEEE80211_MGMT_ASSOC_REQ_FRAME = 0x00,
|
---|
| 128 | IEEE80211_MGMT_ASSOC_RESP_FRAME = 0x10,
|
---|
| 129 | IEEE80211_MGMT_REASSOC_REQ_FRAME = 0x20,
|
---|
| 130 | IEEE80211_MGMT_REASSOC_RESP_FRAME = 0x30,
|
---|
| 131 | IEEE80211_MGMT_PROBE_REQ_FRAME = 0x40,
|
---|
| 132 | IEEE80211_MGMT_PROBE_RESP_FRAME = 0x50,
|
---|
| 133 | IEEE80211_MGMT_BEACON_FRAME = 0x80,
|
---|
[1dcc0b9] | 134 | IEEE80211_MGMT_DISASSOC_FRAME = 0xA0,
|
---|
[59fa7ab] | 135 | IEEE80211_MGMT_AUTH_FRAME = 0xB0,
|
---|
| 136 | IEEE80211_MGMT_DEAUTH_FRAME = 0xC0,
|
---|
[1dcc0b9] | 137 | } ieee80211_frame_mgmt_subtype_t;
|
---|
| 138 |
|
---|
| 139 | /** IEEE 802.11 data frame subtypes. */
|
---|
| 140 | typedef enum {
|
---|
| 141 | IEEE80211_DATA_DATA_FRAME = 0x0000,
|
---|
| 142 | IEEE80211_DATA_QOS_FRAME = 0x0080
|
---|
| 143 | } ieee80211_frame_data_subtype_t;
|
---|
[59fa7ab] | 144 |
|
---|
| 145 | /** IEEE 802.11 frame control value masks. */
|
---|
| 146 | typedef enum {
|
---|
| 147 | IEEE80211_FRAME_CTRL_FRAME_TYPE = 0x000C,
|
---|
| 148 | IEEE80211_FRAME_CTRL_FRAME_SUBTYPE = 0x00F0,
|
---|
[1dcc0b9] | 149 | IEEE80211_FRAME_CTRL_PROTECTED = 0x4000
|
---|
| 150 | } ieee80211_frame_ctrl_mask_t;
|
---|
| 151 |
|
---|
| 152 | /** IEEE 802.11 frame control DS field values. */
|
---|
| 153 | typedef enum {
|
---|
| 154 | IEEE80211_FRAME_CTRL_TODS = 0x0100,
|
---|
| 155 | IEEE80211_FRAME_CTRL_FROMDS = 0x0200
|
---|
| 156 | } ieee80211_frame_ctrl_ds_t;
|
---|
| 157 |
|
---|
| 158 | /** IEEE 802.11 authentication cipher suites values. */
|
---|
| 159 | typedef enum {
|
---|
| 160 | IEEE80211_AUTH_CIPHER_TKIP = 0x02,
|
---|
| 161 | IEEE80211_AUTH_CIPHER_CCMP = 0x04
|
---|
| 162 | } ieee80211_auth_cipher_type_t;
|
---|
| 163 |
|
---|
| 164 | /** IEEE 802.11 AKM suites values. */
|
---|
| 165 | typedef enum {
|
---|
| 166 | IEEE80211_AUTH_AKM_8021X = 0x01,
|
---|
| 167 | IEEE80211_AUTH_AKM_PSK = 0x02
|
---|
| 168 | } ieee80211_auth_akm_type_t;
|
---|
| 169 |
|
---|
| 170 | typedef enum {
|
---|
| 171 | IEEE80211_EAPOL_START = 0x1,
|
---|
| 172 | IEEE80211_EAPOL_KEY = 0x3
|
---|
| 173 | } ieee80211_eapol_frame_type_t;
|
---|
| 174 |
|
---|
| 175 | typedef enum {
|
---|
| 176 | IEEE80211_EAPOL_KEY_KEYINFO_KEYTYPE = 0x0008,
|
---|
[09044cb] | 177 | IEEE80211_EAPOL_KEY_KEYINFO_KEYID = 0x0010,
|
---|
[1dcc0b9] | 178 | IEEE80211_EAPOL_KEY_KEYINFO_INSTALL = 0x0040,
|
---|
| 179 | IEEE80211_EAPOL_KEY_KEYINFO_ACK = 0x0080,
|
---|
| 180 | IEEE80211_EAPOL_KEY_KEYINFO_MIC = 0x0100,
|
---|
| 181 | IEEE80211_EAPOL_KEY_KEYINFO_SECURE = 0x0200,
|
---|
| 182 | IEEE80211_EAPOL_KEY_KEYINFO_ENCDATA = 0x1000
|
---|
| 183 | } ieee80211_eapol_key_keyinfo_t;
|
---|
[59fa7ab] | 184 |
|
---|
| 185 | /** IEEE 802.11 information element types. */
|
---|
| 186 | typedef enum {
|
---|
[8a64320e] | 187 | IEEE80211_SSID_IE = 0, /**< Target SSID. */
|
---|
| 188 | IEEE80211_RATES_IE = 1, /**< Supported data rates. */
|
---|
| 189 | IEEE80211_CHANNEL_IE = 3, /**< Current channel number. */
|
---|
| 190 | IEEE80211_CHALLENGE_IE = 16, /**< Challenge text. */
|
---|
| 191 | IEEE80211_RSN_IE = 48, /**< RSN. */
|
---|
| 192 | IEEE80211_EXT_RATES_IE = 50, /**< Extended data rates. */
|
---|
| 193 | IEEE80211_VENDOR_IE = 221 /**< Vendor specific IE. */
|
---|
[59fa7ab] | 194 | } ieee80211_ie_type_t;
|
---|
| 195 |
|
---|
[1dcc0b9] | 196 | /** IEEE 802.11 authentication phases. */
|
---|
| 197 | typedef enum {
|
---|
| 198 | IEEE80211_AUTH_DISCONNECTED,
|
---|
| 199 | IEEE80211_AUTH_AUTHENTICATED,
|
---|
[053fc2b] | 200 | IEEE80211_AUTH_ASSOCIATED,
|
---|
| 201 | IEEE80211_AUTH_CONNECTED
|
---|
[1dcc0b9] | 202 | } ieee80211_auth_phase_t;
|
---|
| 203 |
|
---|
| 204 | /** Link with scan result info. */
|
---|
| 205 | typedef struct {
|
---|
| 206 | link_t link;
|
---|
| 207 | time_t last_beacon;
|
---|
| 208 | ieee80211_scan_result_t scan_result;
|
---|
[a931b7b] | 209 | uint8_t auth_ie[256];
|
---|
| 210 | size_t auth_ie_len;
|
---|
[1dcc0b9] | 211 | } ieee80211_scan_result_link_t;
|
---|
| 212 |
|
---|
| 213 | /** List of scan results info. */
|
---|
| 214 | typedef struct {
|
---|
| 215 | list_t list;
|
---|
[053fc2b] | 216 | fibril_mutex_t results_mutex;
|
---|
[1dcc0b9] | 217 | size_t size;
|
---|
| 218 | } ieee80211_scan_result_list_t;
|
---|
| 219 |
|
---|
| 220 | /** BSSID info. */
|
---|
| 221 | typedef struct {
|
---|
| 222 | uint16_t aid;
|
---|
[053fc2b] | 223 | char password[IEEE80211_MAX_PASSW_LEN];
|
---|
[1dcc0b9] | 224 | uint8_t ptk[MAX_PTK_LENGTH];
|
---|
| 225 | uint8_t gtk[MAX_GTK_LENGTH];
|
---|
| 226 | ieee80211_scan_result_link_t *res_link;
|
---|
| 227 | } ieee80211_bssid_info_t;
|
---|
| 228 |
|
---|
[59fa7ab] | 229 | /** IEEE 802.11 WiFi device structure. */
|
---|
| 230 | struct ieee80211_dev {
|
---|
| 231 | /** Backing DDF device. */
|
---|
| 232 | ddf_dev_t *ddf_dev;
|
---|
[a35b458] | 233 |
|
---|
[59fa7ab] | 234 | /** Pointer to implemented IEEE 802.11 device operations. */
|
---|
| 235 | ieee80211_ops_t *ops;
|
---|
[a35b458] | 236 |
|
---|
[59fa7ab] | 237 | /** Pointer to implemented IEEE 802.11 interface operations. */
|
---|
| 238 | ieee80211_iface_t *iface;
|
---|
[a35b458] | 239 |
|
---|
[59fa7ab] | 240 | /** Pointer to driver specific data. */
|
---|
| 241 | void *specific;
|
---|
[a35b458] | 242 |
|
---|
[59fa7ab] | 243 | /** Current operating frequency. */
|
---|
| 244 | uint16_t current_freq;
|
---|
[a35b458] | 245 |
|
---|
[59fa7ab] | 246 | /** Current operating mode. */
|
---|
| 247 | ieee80211_operating_mode_t current_op_mode;
|
---|
[a35b458] | 248 |
|
---|
[1dcc0b9] | 249 | /** Info about BSSID we are connected to. */
|
---|
| 250 | ieee80211_bssid_info_t bssid_info;
|
---|
[a35b458] | 251 |
|
---|
[8a64320e] | 252 | /**
|
---|
[1dcc0b9] | 253 | * Flag indicating that data traffic is encrypted by HW key
|
---|
[8a64320e] | 254 | * that is set up in device.
|
---|
[1dcc0b9] | 255 | */
|
---|
| 256 | bool using_hw_key;
|
---|
[a35b458] | 257 |
|
---|
[59fa7ab] | 258 | /** BSSIDs we listen to. */
|
---|
| 259 | nic_address_t bssid_mask;
|
---|
[a35b458] | 260 |
|
---|
[59fa7ab] | 261 | /** List of APs in neighborhood. */
|
---|
[1dcc0b9] | 262 | ieee80211_scan_result_list_t ap_list;
|
---|
[a35b458] | 263 |
|
---|
[1dcc0b9] | 264 | /** Current sequence number used in data frames. */
|
---|
| 265 | uint16_t sequence_number;
|
---|
[a35b458] | 266 |
|
---|
[1dcc0b9] | 267 | /** Current authentication phase. */
|
---|
| 268 | ieee80211_auth_phase_t current_auth_phase;
|
---|
[a35b458] | 269 |
|
---|
[053fc2b] | 270 | /** Flag indicating whether client wants connect to network. */
|
---|
| 271 | bool pending_conn_req;
|
---|
[a35b458] | 272 |
|
---|
[053fc2b] | 273 | /** Scanning guard. */
|
---|
| 274 | fibril_mutex_t scan_mutex;
|
---|
[a35b458] | 275 |
|
---|
[1dcc0b9] | 276 | /** General purpose guard. */
|
---|
| 277 | fibril_mutex_t gen_mutex;
|
---|
[a35b458] | 278 |
|
---|
[1dcc0b9] | 279 | /** General purpose condition variable. */
|
---|
| 280 | fibril_condvar_t gen_cond;
|
---|
[a35b458] | 281 |
|
---|
[1dcc0b9] | 282 | /** Indicates whether device is fully initialized. */
|
---|
| 283 | bool ready;
|
---|
[a35b458] | 284 |
|
---|
[59fa7ab] | 285 | /** Indicates whether driver has already started. */
|
---|
| 286 | bool started;
|
---|
| 287 | };
|
---|
| 288 |
|
---|
[1dcc0b9] | 289 | /** IEEE 802.3 (ethernet) header. */
|
---|
| 290 | typedef struct {
|
---|
| 291 | uint8_t dest_addr[ETH_ADDR];
|
---|
| 292 | uint8_t src_addr[ETH_ADDR];
|
---|
[8a64320e] | 293 | uint16_t proto; /**< Big Endian value! */
|
---|
| 294 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 295 | eth_header_t;
|
---|
[1dcc0b9] | 296 |
|
---|
[59fa7ab] | 297 | /** IEEE 802.11 management header structure. */
|
---|
| 298 | typedef struct {
|
---|
[8a64320e] | 299 | uint16_t frame_ctrl; /**< Little Endian value! */
|
---|
| 300 | uint16_t duration_id; /**< Little Endian value! */
|
---|
[59fa7ab] | 301 | uint8_t dest_addr[ETH_ADDR];
|
---|
| 302 | uint8_t src_addr[ETH_ADDR];
|
---|
| 303 | uint8_t bssid[ETH_ADDR];
|
---|
[8a64320e] | 304 | uint16_t seq_ctrl; /**< Little Endian value! */
|
---|
| 305 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 306 | ieee80211_mgmt_header_t;
|
---|
[59fa7ab] | 307 |
|
---|
| 308 | /** IEEE 802.11 data header structure. */
|
---|
| 309 | typedef struct {
|
---|
[8a64320e] | 310 | uint16_t frame_ctrl; /**< Little Endian value! */
|
---|
| 311 | uint16_t duration_id; /**< Little Endian value! */
|
---|
[59fa7ab] | 312 | uint8_t address1[ETH_ADDR];
|
---|
| 313 | uint8_t address2[ETH_ADDR];
|
---|
| 314 | uint8_t address3[ETH_ADDR];
|
---|
[8a64320e] | 315 | uint16_t seq_ctrl; /**< Little Endian value! */
|
---|
| 316 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 317 | ieee80211_data_header_t;
|
---|
[59fa7ab] | 318 |
|
---|
| 319 | /** IEEE 802.11 information element header. */
|
---|
| 320 | typedef struct {
|
---|
| 321 | uint8_t element_id;
|
---|
| 322 | uint8_t length;
|
---|
[8a64320e] | 323 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 324 | ieee80211_ie_header_t;
|
---|
[59fa7ab] | 325 |
|
---|
| 326 | /** IEEE 802.11 authentication frame body. */
|
---|
| 327 | typedef struct {
|
---|
[8a64320e] | 328 | uint16_t auth_alg; /**< Little Endian value! */
|
---|
| 329 | uint16_t auth_trans_no; /**< Little Endian value! */
|
---|
| 330 | uint16_t status; /**< Little Endian value! */
|
---|
| 331 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 332 | ieee80211_auth_body_t;
|
---|
[1dcc0b9] | 333 |
|
---|
| 334 | /** IEEE 802.11 deauthentication frame body. */
|
---|
| 335 | typedef struct {
|
---|
[8a64320e] | 336 | uint16_t reason; /**< Little Endian value! */
|
---|
| 337 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 338 | ieee80211_deauth_body_t;
|
---|
[1dcc0b9] | 339 |
|
---|
| 340 | /** IEEE 802.11 association request frame body. */
|
---|
| 341 | typedef struct {
|
---|
[8a64320e] | 342 | uint16_t capability; /**< Little Endian value! */
|
---|
| 343 | uint16_t listen_interval; /**< Little Endian value! */
|
---|
| 344 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 345 | ieee80211_assoc_req_body_t;
|
---|
[1dcc0b9] | 346 |
|
---|
| 347 | /** IEEE 802.11 association response frame body. */
|
---|
| 348 | typedef struct {
|
---|
[8a64320e] | 349 | uint16_t capability; /**< Little Endian value! */
|
---|
| 350 | uint16_t status; /**< Little Endian value! */
|
---|
| 351 | uint16_t aid; /**< Little Endian value! */
|
---|
| 352 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 353 | ieee80211_assoc_resp_body_t;
|
---|
[59fa7ab] | 354 |
|
---|
| 355 | /** IEEE 802.11 beacon frame body start. */
|
---|
| 356 | typedef struct {
|
---|
| 357 | uint8_t timestamp[8];
|
---|
[8a64320e] | 358 | uint16_t beacon_interval; /**< Little Endian value! */
|
---|
| 359 | uint16_t capability; /**< Little Endian value! */
|
---|
| 360 | } __attribute__((packed)) __attribute__((aligned(2)))
|
---|
| 361 | ieee80211_beacon_start_t;
|
---|
[1dcc0b9] | 362 |
|
---|
| 363 | /** IEEE 802.11i EAPOL-Key frame format. */
|
---|
| 364 | typedef struct {
|
---|
| 365 | uint8_t proto_version;
|
---|
| 366 | uint8_t packet_type;
|
---|
[8a64320e] | 367 | uint16_t body_length; /**< Big Endian value! */
|
---|
[1dcc0b9] | 368 | uint8_t descriptor_type;
|
---|
[8a64320e] | 369 | uint16_t key_info; /**< Big Endian value! */
|
---|
| 370 | uint16_t key_length; /**< Big Endian value! */
|
---|
[1dcc0b9] | 371 | uint8_t key_replay_counter[8];
|
---|
| 372 | uint8_t key_nonce[32];
|
---|
| 373 | uint8_t eapol_key_iv[16];
|
---|
| 374 | uint8_t key_rsc[8];
|
---|
| 375 | uint8_t reserved[8];
|
---|
| 376 | uint8_t key_mic[16];
|
---|
[8a64320e] | 377 | uint16_t key_data_length; /**< Big Endian value! */
|
---|
[1dcc0b9] | 378 | } __attribute__((packed)) ieee80211_eapol_key_frame_t;
|
---|
| 379 |
|
---|
| 380 | #define ieee80211_scan_result_list_foreach(results, iter) \
|
---|
[8a64320e] | 381 | list_foreach((results).list, link, ieee80211_scan_result_link_t, (iter))
|
---|
[1dcc0b9] | 382 |
|
---|
[8a64320e] | 383 | static inline void
|
---|
| 384 | ieee80211_scan_result_list_init(ieee80211_scan_result_list_t *results)
|
---|
[1dcc0b9] | 385 | {
|
---|
| 386 | list_initialize(&results->list);
|
---|
[053fc2b] | 387 | fibril_mutex_initialize(&results->results_mutex);
|
---|
[1dcc0b9] | 388 | }
|
---|
| 389 |
|
---|
[8a64320e] | 390 | static inline void
|
---|
| 391 | ieee80211_scan_result_list_remove(ieee80211_scan_result_list_t *results,
|
---|
| 392 | ieee80211_scan_result_link_t *result)
|
---|
[1dcc0b9] | 393 | {
|
---|
| 394 | list_remove(&result->link);
|
---|
| 395 | results->size--;
|
---|
| 396 | }
|
---|
| 397 |
|
---|
[8a64320e] | 398 | static inline void
|
---|
| 399 | ieee80211_scan_result_list_append(ieee80211_scan_result_list_t *results,
|
---|
| 400 | ieee80211_scan_result_link_t *result)
|
---|
[1dcc0b9] | 401 | {
|
---|
| 402 | list_append(&result->link, &results->list);
|
---|
| 403 | results->size++;
|
---|
| 404 | }
|
---|
[59fa7ab] | 405 |
|
---|
[8a64320e] | 406 | extern bool ieee80211_is_fromds_frame(uint16_t);
|
---|
| 407 | extern bool ieee80211_is_tods_frame(uint16_t);
|
---|
| 408 | extern void ieee80211_set_connect_request(ieee80211_dev_t *);
|
---|
| 409 | extern bool ieee80211_pending_connect_request(ieee80211_dev_t *);
|
---|
| 410 | extern ieee80211_auth_phase_t ieee80211_get_auth_phase(ieee80211_dev_t *);
|
---|
| 411 | extern void ieee80211_set_auth_phase(ieee80211_dev_t *, ieee80211_auth_phase_t);
|
---|
[b7fd2a0] | 412 | extern errno_t ieee80211_probe_request(ieee80211_dev_t *, char *);
|
---|
| 413 | extern errno_t ieee80211_authenticate(ieee80211_dev_t *);
|
---|
| 414 | extern errno_t ieee80211_associate(ieee80211_dev_t *, char *);
|
---|
| 415 | extern errno_t ieee80211_deauthenticate(ieee80211_dev_t *);
|
---|
[8a64320e] | 416 |
|
---|
| 417 | #endif
|
---|
[59fa7ab] | 418 |
|
---|
| 419 | /** @}
|
---|
| 420 | */
|
---|