Zephyr Project API  3.3.0
A Scalable Open Source RTOS
wifi_mgmt.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_
13#define ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_
14
15#include <zephyr/net/net_mgmt.h>
16#include <zephyr/net/wifi.h>
17#include <zephyr/net/ethernet.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23/* Management part definitions */
24
25#define _NET_WIFI_LAYER NET_MGMT_LAYER_L2
26#define _NET_WIFI_CODE 0x156
27#define _NET_WIFI_BASE (NET_MGMT_IFACE_BIT | \
28 NET_MGMT_LAYER(_NET_WIFI_LAYER) | \
29 NET_MGMT_LAYER_CODE(_NET_WIFI_CODE))
30#define _NET_WIFI_EVENT (_NET_WIFI_BASE | NET_MGMT_EVENT_BIT)
31
45};
46
47#define NET_REQUEST_WIFI_SCAN \
48 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_SCAN)
49
51
52#define NET_REQUEST_WIFI_CONNECT \
53 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONNECT)
54
56
57#define NET_REQUEST_WIFI_DISCONNECT \
58 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_DISCONNECT)
59
61
62#define NET_REQUEST_WIFI_AP_ENABLE \
63 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_ENABLE)
64
66
67#define NET_REQUEST_WIFI_AP_DISABLE \
68 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_DISABLE)
69
71
72#define NET_REQUEST_WIFI_IFACE_STATUS \
73 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_IFACE_STATUS)
74
76
77#define NET_REQUEST_WIFI_PS \
78 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS)
79
81
82#define NET_REQUEST_WIFI_PS_MODE \
83 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS_MODE)
84
86
87#define NET_REQUEST_WIFI_TWT \
88 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_TWT)
89
91
92#define NET_REQUEST_WIFI_PS_CONFIG \
93 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS_CONFIG)
94
96#define NET_REQUEST_WIFI_REG_DOMAIN \
97 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_REG_DOMAIN)
98
100
101#define NET_REQUEST_WIFI_PS_TIMEOUT \
102 (_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS_TIMEOUT)
103
105
113};
114
115#define NET_EVENT_WIFI_SCAN_RESULT \
116 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SCAN_RESULT)
117
118#define NET_EVENT_WIFI_SCAN_DONE \
119 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SCAN_DONE)
120
121#define NET_EVENT_WIFI_CONNECT_RESULT \
122 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_CONNECT_RESULT)
123
124#define NET_EVENT_WIFI_DISCONNECT_RESULT \
125 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_DISCONNECT_RESULT)
126
127#define NET_EVENT_WIFI_IFACE_STATUS \
128 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_IFACE_STATUS)
129
130#define NET_EVENT_WIFI_TWT \
131 (_NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_TWT)
132
133/* Each result is provided to the net_mgmt_event_callback
134 * via its info attribute (see net_mgmt.h)
135 */
139
145
148};
149
151 const uint8_t *ssid;
152 uint8_t ssid_length; /* Max 32 */
153
155 uint8_t psk_length; /* Min 8 - Max 64 */
156
157 uint8_t *sae_password; /* Optional with fallback to psk */
158 uint8_t sae_password_length; /* No length restrictions */
159
164 int timeout; /* SYS_FOREVER_MS for no timeout */
165};
166
169};
170
172 int state; /* enum wifi_iface_state */
173 unsigned int ssid_len;
177 unsigned int channel;
182 int rssi;
183};
184
187};
188
191};
192
195};
196
201 /* Map requests to responses */
203 /* Map setup with teardown */
205 union {
206 struct {
207 /* Interval = Wake up time + Sleeping time */
213 /* Wake up time */
216 struct {
217 /* Only for Teardown */
220 };
221};
222
223/* Flow ID is only 3 bits */
224#define WIFI_MAX_TWT_FLOWS 8
225#define WIFI_MAX_TWT_INTERVAL_MS 0x7FFFFFFF
227 /* Interval = Wake up time + Sleeping time */
229 /* Map requests to responses */
231 /* Map setup with teardown */
238 /* Wake up time */
240};
241
247};
248
249/* Generic get/set operation for any command*/
253};
254
257 /* Ignore all other regulatory hints */
258 bool force;
260};
261
262#include <zephyr/net/net_if.h>
263
264typedef void (*scan_result_cb_t)(struct net_if *iface, int status,
265 struct wifi_scan_result *entry);
266
274#ifdef CONFIG_WIFI_USE_NATIVE_NETWORKING
276#else
277 struct net_if_api wifi_iface;
278#endif
279
280 /* cb parameter is the cb that should be called for each
281 * result by the driver. The wifi mgmt part will take care of
282 * raising the necessary event etc...
283 */
284 int (*scan)(const struct device *dev, scan_result_cb_t cb);
285 int (*connect)(const struct device *dev,
286 struct wifi_connect_req_params *params);
287 int (*disconnect)(const struct device *dev);
288 int (*ap_enable)(const struct device *dev,
289 struct wifi_connect_req_params *params);
290 int (*ap_disable)(const struct device *dev);
291 int (*iface_status)(const struct device *dev, struct wifi_iface_status *status);
292#ifdef CONFIG_NET_STATISTICS_WIFI
293 int (*get_stats)(const struct device *dev, struct net_stats_wifi *stats);
294#endif /* CONFIG_NET_STATISTICS_WIFI */
295 int (*set_power_save)(const struct device *dev, struct wifi_ps_params *params);
296 int (*set_power_save_mode)(const struct device *dev, struct wifi_ps_mode_params *params);
297 int (*set_twt)(const struct device *dev, struct wifi_twt_params *params);
298 int (*get_power_save_config)(const struct device *dev, struct wifi_ps_config *config);
299 int (*reg_domain)(const struct device *dev, struct wifi_reg_domain *reg_domain);
300 int (*set_power_save_timeout)(const struct device *dev,
301 struct wifi_ps_timeout_params *ps_timeout);
302};
303
304/* Make sure that the network interface API is properly setup inside
305 * Wifi mgmt offload API struct (it is the first one).
306 */
307BUILD_ASSERT(offsetof(struct net_wifi_mgmt_offload, wifi_iface) == 0);
308
309void wifi_mgmt_raise_connect_result_event(struct net_if *iface, int status);
310void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status);
312 struct wifi_iface_status *iface_status);
314 struct wifi_twt_params *twt_params);
315#ifdef __cplusplus
316}
317#endif
318
319#endif /* ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_ */
Ethernet.
#define NET_MGMT_DEFINE_REQUEST_HANDLER(_mgmt_request)
Definition: net_mgmt.h:95
Public API for network interface.
Network Management API public header.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__INT8_TYPE__ int8_t
Definition: stdint.h:72
Runtime device structure (in ROM) per driver instance.
Definition: device.h:378
Definition: ethernet.h:404
Network Interface structure.
Definition: net_if.h:510
All Wi-Fi specific statistics.
Definition: net_stats.h:490
Definition: wifi_mgmt.h:267
int(* set_twt)(const struct device *dev, struct wifi_twt_params *params)
Definition: wifi_mgmt.h:297
struct net_if_api wifi_iface
Definition: wifi_mgmt.h:277
int(* set_power_save_mode)(const struct device *dev, struct wifi_ps_mode_params *params)
Definition: wifi_mgmt.h:296
int(* get_power_save_config)(const struct device *dev, struct wifi_ps_config *config)
Definition: wifi_mgmt.h:298
int(* set_power_save)(const struct device *dev, struct wifi_ps_params *params)
Definition: wifi_mgmt.h:295
int(* scan)(const struct device *dev, scan_result_cb_t cb)
Definition: wifi_mgmt.h:284
int(* disconnect)(const struct device *dev)
Definition: wifi_mgmt.h:287
int(* set_power_save_timeout)(const struct device *dev, struct wifi_ps_timeout_params *ps_timeout)
Definition: wifi_mgmt.h:300
int(* reg_domain)(const struct device *dev, struct wifi_reg_domain *reg_domain)
Definition: wifi_mgmt.h:299
int(* ap_disable)(const struct device *dev)
Definition: wifi_mgmt.h:290
int(* ap_enable)(const struct device *dev, struct wifi_connect_req_params *params)
Definition: wifi_mgmt.h:288
int(* connect)(const struct device *dev, struct wifi_connect_req_params *params)
Definition: wifi_mgmt.h:285
int(* iface_status)(const struct device *dev, struct wifi_iface_status *status)
Definition: wifi_mgmt.h:291
Definition: wifi_mgmt.h:150
enum wifi_security_type security
Definition: wifi_mgmt.h:162
uint8_t * psk
Definition: wifi_mgmt.h:154
uint8_t channel
Definition: wifi_mgmt.h:161
uint8_t ssid_length
Definition: wifi_mgmt.h:152
int timeout
Definition: wifi_mgmt.h:164
enum wifi_mfp_options mfp
Definition: wifi_mgmt.h:163
uint8_t sae_password_length
Definition: wifi_mgmt.h:158
uint8_t band
Definition: wifi_mgmt.h:160
uint8_t * sae_password
Definition: wifi_mgmt.h:157
uint8_t psk_length
Definition: wifi_mgmt.h:155
const uint8_t * ssid
Definition: wifi_mgmt.h:151
Definition: wifi_mgmt.h:171
char ssid[WIFI_SSID_MAX_LEN]
Definition: wifi_mgmt.h:174
int rssi
Definition: wifi_mgmt.h:182
char bssid[WIFI_MAC_ADDR_LEN]
Definition: wifi_mgmt.h:175
enum wifi_security_type security
Definition: wifi_mgmt.h:180
unsigned int channel
Definition: wifi_mgmt.h:177
enum wifi_mfp_options mfp
Definition: wifi_mgmt.h:181
int state
Definition: wifi_mgmt.h:172
enum wifi_iface_mode iface_mode
Definition: wifi_mgmt.h:178
unsigned int ssid_len
Definition: wifi_mgmt.h:173
enum wifi_frequency_bands band
Definition: wifi_mgmt.h:176
enum wifi_link_mode link_mode
Definition: wifi_mgmt.h:179
Definition: wifi_mgmt.h:242
bool enabled
Definition: wifi_mgmt.h:244
char num_twt_flows
Definition: wifi_mgmt.h:246
struct wifi_twt_flow_info twt_flows[8]
Definition: wifi_mgmt.h:243
enum wifi_ps_mode mode
Definition: wifi_mgmt.h:245
Definition: wifi_mgmt.h:189
enum wifi_ps_mode mode
Definition: wifi_mgmt.h:190
Definition: wifi_mgmt.h:185
enum wifi_ps enabled
Definition: wifi_mgmt.h:186
Definition: wifi_mgmt.h:193
int timeout_ms
Definition: wifi_mgmt.h:194
Definition: wifi_mgmt.h:255
enum wifi_mgmt_op oper
Definition: wifi_mgmt.h:256
bool force
Definition: wifi_mgmt.h:258
uint8_t country_code[WIFI_COUNTRY_CODE_LEN]
Definition: wifi_mgmt.h:259
Definition: wifi_mgmt.h:136
uint8_t ssid_length
Definition: wifi_mgmt.h:138
uint8_t band
Definition: wifi_mgmt.h:140
uint8_t mac[WIFI_MAC_ADDR_LEN]
Definition: wifi_mgmt.h:146
int8_t rssi
Definition: wifi_mgmt.h:144
uint8_t mac_length
Definition: wifi_mgmt.h:147
enum wifi_mfp_options mfp
Definition: wifi_mgmt.h:143
uint8_t channel
Definition: wifi_mgmt.h:141
uint8_t ssid[WIFI_SSID_MAX_LEN]
Definition: wifi_mgmt.h:137
enum wifi_security_type security
Definition: wifi_mgmt.h:142
Definition: wifi_mgmt.h:167
int status
Definition: wifi_mgmt.h:168
Definition: wifi_mgmt.h:226
uint8_t dialog_token
Definition: wifi_mgmt.h:230
uint8_t twt_wake_interval_ms
Definition: wifi_mgmt.h:239
uint32_t twt_interval_ms
Definition: wifi_mgmt.h:228
enum wifi_twt_negotiation_type negotiation_type
Definition: wifi_mgmt.h:233
bool trigger
Definition: wifi_mgmt.h:235
bool responder
Definition: wifi_mgmt.h:234
uint8_t flow_id
Definition: wifi_mgmt.h:232
bool implicit
Definition: wifi_mgmt.h:236
bool announce
Definition: wifi_mgmt.h:237
Definition: wifi_mgmt.h:197
bool announce
Definition: wifi_mgmt.h:212
bool teardown_all
Definition: wifi_mgmt.h:218
uint8_t twt_wake_interval_ms
Definition: wifi_mgmt.h:214
uint32_t twt_interval_ms
Definition: wifi_mgmt.h:208
enum wifi_twt_setup_cmd setup_cmd
Definition: wifi_mgmt.h:200
bool trigger
Definition: wifi_mgmt.h:210
enum wifi_twt_negotiation_type negotiation_type
Definition: wifi_mgmt.h:199
enum wifi_twt_operation operation
Definition: wifi_mgmt.h:198
struct wifi_twt_params::@262::@265 teardown
bool implicit
Definition: wifi_mgmt.h:211
uint8_t flow_id
Definition: wifi_mgmt.h:204
struct wifi_twt_params::@262::@264 setup
uint8_t dialog_token
Definition: wifi_mgmt.h:202
bool responder
Definition: wifi_mgmt.h:209
General WiFi Definitions.
wifi_ps
Definition: wifi.h:250
wifi_frequency_bands
Definition: wifi.h:80
wifi_mfp_options
Definition: wifi.h:52
#define WIFI_MAC_ADDR_LEN
Definition: wifi.h:110
wifi_twt_setup_cmd
Definition: wifi.h:295
wifi_iface_mode
Definition: wifi.h:166
#define WIFI_COUNTRY_CODE_LEN
Definition: wifi.h:15
wifi_twt_negotiation_type
Definition: wifi.h:283
wifi_link_mode
Definition: wifi.h:204
wifi_twt_operation
Definition: wifi.h:273
#define WIFI_SSID_MAX_LEN
Definition: wifi.h:108
wifi_security_type
Definition: wifi.h:20
wifi_ps_mode
Definition: wifi.h:260
void wifi_mgmt_raise_connect_result_event(struct net_if *iface, int status)
#define NET_REQUEST_WIFI_PS_CONFIG
Definition: wifi_mgmt.h:92
#define NET_REQUEST_WIFI_SCAN
Definition: wifi_mgmt.h:47
#define NET_REQUEST_WIFI_REG_DOMAIN
Definition: wifi_mgmt.h:96
void wifi_mgmt_raise_twt_event(struct net_if *iface, struct wifi_twt_params *twt_params)
void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status)
#define NET_REQUEST_WIFI_IFACE_STATUS
Definition: wifi_mgmt.h:72
#define NET_REQUEST_WIFI_PS_MODE
Definition: wifi_mgmt.h:82
#define NET_REQUEST_WIFI_PS_TIMEOUT
Definition: wifi_mgmt.h:101
#define WIFI_MAX_TWT_FLOWS
Definition: wifi_mgmt.h:224
#define NET_REQUEST_WIFI_AP_ENABLE
Definition: wifi_mgmt.h:62
#define NET_REQUEST_WIFI_PS
Definition: wifi_mgmt.h:77
void wifi_mgmt_raise_iface_status_event(struct net_if *iface, struct wifi_iface_status *iface_status)
#define NET_REQUEST_WIFI_DISCONNECT
Definition: wifi_mgmt.h:57
net_request_wifi_cmd
Definition: wifi_mgmt.h:32
@ NET_REQUEST_WIFI_CMD_TWT
Definition: wifi_mgmt.h:41
@ NET_REQUEST_WIFI_CMD_AP_ENABLE
Definition: wifi_mgmt.h:36
@ NET_REQUEST_WIFI_CMD_REG_DOMAIN
Definition: wifi_mgmt.h:43
@ NET_REQUEST_WIFI_CMD_SCAN
Definition: wifi_mgmt.h:33
@ NET_REQUEST_WIFI_CMD_IFACE_STATUS
Definition: wifi_mgmt.h:38
@ NET_REQUEST_WIFI_CMD_AP_DISABLE
Definition: wifi_mgmt.h:37
@ NET_REQUEST_WIFI_CMD_CONNECT
Definition: wifi_mgmt.h:34
@ NET_REQUEST_WIFI_CMD_PS_MODE
Definition: wifi_mgmt.h:40
@ NET_REQUEST_WIFI_CMD_PS
Definition: wifi_mgmt.h:39
@ NET_REQUEST_WIFI_CMD_DISCONNECT
Definition: wifi_mgmt.h:35
@ NET_REQUEST_WIFI_CMD_PS_CONFIG
Definition: wifi_mgmt.h:42
@ NET_REQUEST_WIFI_CMD_PS_TIMEOUT
Definition: wifi_mgmt.h:44
#define NET_REQUEST_WIFI_CONNECT
Definition: wifi_mgmt.h:52
#define NET_REQUEST_WIFI_TWT
Definition: wifi_mgmt.h:87
net_event_wifi_cmd
Definition: wifi_mgmt.h:106
@ NET_EVENT_WIFI_CMD_SCAN_RESULT
Definition: wifi_mgmt.h:107
@ NET_EVENT_WIFI_CMD_DISCONNECT_RESULT
Definition: wifi_mgmt.h:110
@ NET_EVENT_WIFI_CMD_SCAN_DONE
Definition: wifi_mgmt.h:108
@ NET_EVENT_WIFI_CMD_TWT
Definition: wifi_mgmt.h:112
@ NET_EVENT_WIFI_CMD_IFACE_STATUS
Definition: wifi_mgmt.h:111
@ NET_EVENT_WIFI_CMD_CONNECT_RESULT
Definition: wifi_mgmt.h:109
void(* scan_result_cb_t)(struct net_if *iface, int status, struct wifi_scan_result *entry)
Definition: wifi_mgmt.h:264
wifi_mgmt_op
Definition: wifi_mgmt.h:250
@ WIFI_MGMT_GET
Definition: wifi_mgmt.h:251
@ WIFI_MGMT_SET
Definition: wifi_mgmt.h:252
#define NET_REQUEST_WIFI_AP_DISABLE
Definition: wifi_mgmt.h:67