source: mainline/uspace/lib/ieee80211/include/ieee80211.h@ 053fc2b

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

Locking, correctly disconnecting device, sending DHCP address discover after connecting to WiFi network

  • Property mode set to 100644
File size: 7.0 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 authentication password length. */
63#define IEEE80211_MAX_PASSW_LEN 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 * @param connected True if connected to new BSSID, otherwise false.
142 *
143 * @return EOK if succeed, negative error code otherwise.
144 */
145 int (*bssid_change)(struct ieee80211_dev *, bool);
146
147 /**
148 * Callback to setup encryption key in IEEE 802.11 device.
149 *
150 * @param ieee80211_dev Pointer to IEEE 802.11 device structure.
151 * @param key_conf Key config structure.
152 * @param insert True to insert this key to device, false to remove it.
153 *
154 * @return EOK if succeed, negative error code otherwise.
155 */
156 int (*key_config)(struct ieee80211_dev *,
157 ieee80211_key_config_t *key_conf, bool);
158} ieee80211_ops_t;
159
160/* Initialization functions. */
161extern ieee80211_dev_t *ieee80211_device_create(void);
162extern int ieee80211_device_init(ieee80211_dev_t *ieee80211_dev,
163 ddf_dev_t *ddf_dev);
164extern int ieee80211_init(ieee80211_dev_t *ieee80211_dev,
165 ieee80211_ops_t *ieee80211_ops, ieee80211_iface_t *ieee80211_iface,
166 nic_iface_t *ieee80211_nic_iface, ddf_dev_ops_t *ieee80211_dev_ops);
167
168/* Getters & setters, queries & reports. */
169extern void *ieee80211_get_specific(ieee80211_dev_t *ieee80211_dev);
170extern void ieee80211_set_specific(ieee80211_dev_t *ieee80211_dev,
171 void *specific);
172extern ddf_dev_t *ieee80211_get_ddf_dev(ieee80211_dev_t* ieee80211_dev);
173extern ieee80211_operating_mode_t
174 ieee80211_query_current_op_mode(ieee80211_dev_t *ieee80211_dev);
175extern uint16_t ieee80211_query_current_freq(ieee80211_dev_t *ieee80211_dev);
176extern void ieee80211_query_bssid(ieee80211_dev_t* ieee80211_dev,
177 nic_address_t *bssid);
178extern bool ieee80211_is_connected(ieee80211_dev_t* ieee80211_dev);
179extern void ieee80211_report_current_op_mode(ieee80211_dev_t *ieee80211_dev,
180 ieee80211_operating_mode_t op_mode);
181extern void ieee80211_report_current_freq(ieee80211_dev_t *ieee80211_dev,
182 uint16_t freq);
183extern uint16_t ieee80211_get_aid(ieee80211_dev_t* ieee80211_dev);
184extern int ieee80211_get_pairwise_security(ieee80211_dev_t* ieee80211_dev);
185extern bool ieee80211_is_ready(ieee80211_dev_t* ieee80211_dev);
186extern void ieee80211_set_ready(ieee80211_dev_t* ieee80211_dev, bool ready);
187extern bool ieee80211_query_using_key(ieee80211_dev_t* ieee80211_dev);
188extern void ieee80211_setup_key_confirm(ieee80211_dev_t* ieee80211_dev,
189 bool using_key);
190
191extern bool ieee80211_is_data_frame(uint16_t frame_ctrl);
192extern bool ieee80211_is_mgmt_frame(uint16_t frame_ctrl);
193extern bool ieee80211_is_beacon_frame(uint16_t frame_ctrl);
194extern bool ieee80211_is_probe_response_frame(uint16_t frame_ctrl);
195extern bool ieee80211_is_auth_frame(uint16_t frame_ctrl);
196extern bool ieee80211_is_assoc_response_frame(uint16_t frame_ctrl);
197
198/* Worker functions. */
199extern int ieee80211_rx_handler(ieee80211_dev_t *ieee80211_dev, void *buffer,
200 size_t buffer_size);
201
202#endif // LIB_IEEE80211_H
203
204/** @}
205 */
Note: See TracBrowser for help on using the repository browser.