source: mainline/uspace/lib/ieee80211/include/ieee80211.h@ d7dadcb4

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d7dadcb4 was 1dcc0b9, checked in by Jan Kolarik <kolarik@…>, 10 years ago

Scanning whole 2.4GHz spectrum, created supplicant for managing connection between device STA and AP, finished association process between STA and AP, handling 4way handshake protocol used for key management, written needed cryptographic algorithms (AES, SHA1, HMAC, PBKDF2) for CCMP protocol, data communication on OPEN/CCMP networks.

  • Property mode set to 100644
File size: 6.9 KB
Line 
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
29/**
30 * @addtogroup libieee80211
31 * @{
32 */
33/**
34 * @file ieee80211.h
35 * @brief Public header exposing IEEE 802.11 to drivers.
36 */
37
38#ifndef LIB_IEEE80211_H
39#define LIB_IEEE80211_H
40
41#include <ddf/driver.h>
42#include <nic.h>
43#include <ops/ieee80211.h>
44
45#define DEVICE_CATEGORY_IEEE80211 "ieee80211"
46
47struct ieee80211_dev;
48typedef struct ieee80211_dev ieee80211_dev_t;
49
50/** Initial channel frequency. */
51#define IEEE80211_FIRST_FREQ 2412
52
53/** Max supported channel frequency. */
54#define IEEE80211_MAX_FREQ 2472
55
56/* Gap between IEEE80211 channels in MHz. */
57#define IEEE80211_CHANNEL_GAP 5
58
59/* Max AMPDU factor. */
60#define IEEE80211_MAX_AMPDU_FACTOR 13
61
62/* Max passphrase length in WPA/WPA2 protocols. */
63#define IEEE80211_WPA_MAX_PASSWORD_LENGTH 64
64
65/** IEEE 802.11 b/g supported data rates in units of 500 kb/s. */
66static const uint8_t ieee80211bg_data_rates[] = {
67 2, 4, 11, 12, 18, 22, 24, 36, 48, 72, 96, 108
68};
69
70/** Device operating modes. */
71typedef enum {
72 IEEE80211_OPMODE_ADHOC,
73 IEEE80211_OPMODE_MESH,
74 IEEE80211_OPMODE_AP,
75 IEEE80211_OPMODE_STATION
76} ieee80211_operating_mode_t;
77
78/** Key flags. */
79typedef enum {
80 IEEE80211_KEY_FLAG_TYPE_PAIRWISE = 0x01,
81 IEEE80211_KEY_FLAG_TYPE_GROUP = 0x02
82} ieee80211_key_flags_t;
83
84/** Key config structure. */
85typedef struct {
86 uint8_t id;
87 uint8_t flags;
88 ieee80211_security_suite_t suite;
89 uint8_t data[32];
90} ieee80211_key_config_t;
91
92/** IEEE 802.11 callback functions. */
93typedef struct {
94 /**
95 * Function that is called at device initalization. This should
96 * get device into running state.
97 *
98 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
99 *
100 * @return EOK if succeed, negative error code otherwise.
101 */
102 int (*start)(struct ieee80211_dev *);
103
104 /**
105 * Scan neighborhood for networks. There should be implemented
106 * scanning of whole bandwidth. Incoming results are processed by
107 * IEEE 802.11 framework itself.
108 *
109 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
110 *
111 * @return EOK if succeed, negative error code otherwise.
112 */
113 int (*scan)(struct ieee80211_dev *);
114
115 /**
116 * Handler for TX frames to be send from device. This should be
117 * called for every frame that has to be send from IEEE 802.11 device.
118 *
119 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
120 * @param buffer Buffer with data to be send.
121 * @param buffer_size Size of buffer.
122 *
123 * @return EOK if succeed, negative error code otherwise.
124 */
125 int (*tx_handler)(struct ieee80211_dev *, void *, size_t);
126
127 /**
128 * Set device operating frequency to given value.
129 *
130 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
131 * @param freq New device operating frequency.
132 *
133 * @return EOK if succeed, negative error code otherwise.
134 */
135 int (*set_freq)(struct ieee80211_dev *, uint16_t);
136
137 /**
138 * Callback to inform device about BSSID change.
139 *
140 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
141 *
142 * @return EOK if succeed, negative error code otherwise.
143 */
144 int (*bssid_change)(struct ieee80211_dev *);
145
146 /**
147 * Callback to setup encryption key in IEEE 802.11 device.
148 *
149 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
150 * @param key_conf Key config structure.
151 * @param insert True to insert this key to device, false to remove it.
152 *
153 * @return EOK if succeed, negative error code otherwise.
154 */
155 int (*key_config)(struct ieee80211_dev *,
156 ieee80211_key_config_t *key_conf, bool);
157} ieee80211_ops_t;
158
159/* Initialization functions. */
160extern ieee80211_dev_t *ieee80211_device_create(void);
161extern int ieee80211_device_init(ieee80211_dev_t *ieee80211_dev,
162 ddf_dev_t *ddf_dev);
163extern int ieee80211_init(ieee80211_dev_t *ieee80211_dev,
164 ieee80211_ops_t *ieee80211_ops, ieee80211_iface_t *ieee80211_iface,
165 nic_iface_t *ieee80211_nic_iface, ddf_dev_ops_t *ieee80211_dev_ops);
166
167/* Getters & setters, queries & reports. */
168extern void *ieee80211_get_specific(ieee80211_dev_t *ieee80211_dev);
169extern void ieee80211_set_specific(ieee80211_dev_t *ieee80211_dev,
170 void *specific);
171extern ddf_dev_t *ieee80211_get_ddf_dev(ieee80211_dev_t* ieee80211_dev);
172extern ieee80211_operating_mode_t
173 ieee80211_query_current_op_mode(ieee80211_dev_t *ieee80211_dev);
174extern uint16_t ieee80211_query_current_freq(ieee80211_dev_t *ieee80211_dev);
175extern void ieee80211_query_bssid(ieee80211_dev_t* ieee80211_dev,
176 nic_address_t *bssid);
177extern bool ieee80211_is_connected(ieee80211_dev_t* ieee80211_dev);
178extern void ieee80211_report_current_op_mode(ieee80211_dev_t *ieee80211_dev,
179 ieee80211_operating_mode_t op_mode);
180extern void ieee80211_report_current_freq(ieee80211_dev_t *ieee80211_dev,
181 uint16_t freq);
182extern uint16_t ieee80211_get_aid(ieee80211_dev_t* ieee80211_dev);
183extern int ieee80211_get_security_suite(ieee80211_dev_t* ieee80211_dev);
184extern bool ieee80211_is_ready(ieee80211_dev_t* ieee80211_dev);
185extern void ieee80211_set_ready(ieee80211_dev_t* ieee80211_dev, bool ready);
186extern bool ieee80211_query_using_key(ieee80211_dev_t* ieee80211_dev);
187extern void ieee80211_setup_key_confirm(ieee80211_dev_t* ieee80211_dev,
188 bool using_key);
189
190extern bool ieee80211_is_data_frame(uint16_t frame_ctrl);
191extern bool ieee80211_is_mgmt_frame(uint16_t frame_ctrl);
192extern bool ieee80211_is_beacon_frame(uint16_t frame_ctrl);
193extern bool ieee80211_is_probe_response_frame(uint16_t frame_ctrl);
194extern bool ieee80211_is_auth_frame(uint16_t frame_ctrl);
195extern bool ieee80211_is_assoc_response_frame(uint16_t frame_ctrl);
196
197/* Worker functions. */
198extern int ieee80211_rx_handler(ieee80211_dev_t *ieee80211_dev, void *buffer,
199 size_t buffer_size);
200
201#endif // LIB_IEEE80211_H
202
203/** @}
204 */
Note: See TracBrowser for help on using the repository browser.