Line data Source code
1 1 : /*
2 : * Copyright (c) 2017 Intel Corporation.
3 : * Copyright 2024 NXP
4 : * Copyright (c) 2024 Nordic Semiconductor ASA
5 : *
6 : * SPDX-License-Identifier: Apache-2.0
7 : */
8 :
9 : /**
10 : * @file
11 : * @brief WiFi L2 stack public header
12 : */
13 :
14 : #ifndef ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_
15 : #define ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_
16 :
17 : #include <zephyr/net/net_mgmt.h>
18 : #include <zephyr/net/wifi.h>
19 : #include <zephyr/net/ethernet.h>
20 : #include <zephyr/net/offloaded_netdev.h>
21 :
22 : #ifdef __cplusplus
23 : extern "C" {
24 : #endif
25 :
26 : /**
27 : * @addtogroup wifi_mgmt
28 : * @{
29 : */
30 :
31 : /* Management part definitions */
32 :
33 : /** @cond INTERNAL_HIDDEN */
34 :
35 : #define NET_WIFI_LAYER NET_MGMT_LAYER_L2
36 : #define NET_WIFI_CODE NET_MGMT_LAYER_CODE_WIFI
37 : #define NET_WIFI_BASE (NET_MGMT_IFACE_BIT | \
38 : NET_MGMT_LAYER(NET_WIFI_LAYER) | \
39 : NET_MGMT_LAYER_CODE(NET_WIFI_CODE))
40 : #define NET_WIFI_EVENT (NET_WIFI_BASE | NET_MGMT_EVENT_BIT)
41 :
42 : #ifdef CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX
43 : #define WIFI_MGMT_SCAN_SSID_FILT_MAX CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX
44 : #else
45 : #define WIFI_MGMT_SCAN_SSID_FILT_MAX 1
46 : #endif /* CONFIG_WIFI_MGMT_SCAN_SSID_FILT_MAX */
47 :
48 : #ifdef CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL
49 : #define WIFI_MGMT_SCAN_CHAN_MAX_MANUAL CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL
50 : #else
51 : #define WIFI_MGMT_SCAN_CHAN_MAX_MANUAL 1
52 : #endif /* CONFIG_WIFI_MGMT_SCAN_CHAN_MAX_MANUAL */
53 :
54 : #ifdef CONFIG_WIFI_ENT_IDENTITY_MAX_USERS
55 : #define WIFI_ENT_IDENTITY_MAX_USERS CONFIG_WIFI_ENT_IDENTITY_MAX_USERS
56 : #else
57 : #define WIFI_ENT_IDENTITY_MAX_USERS 1
58 : #endif /* CONFIG_WIFI_ENT_IDENTITY_MAX_USERS */
59 :
60 : #define WIFI_MGMT_BAND_STR_SIZE_MAX 8
61 : #define WIFI_MGMT_SCAN_MAX_BSS_CNT 65535
62 :
63 : #define WIFI_MGMT_SKIP_INACTIVITY_POLL IS_ENABLED(CONFIG_WIFI_MGMT_AP_STA_SKIP_INACTIVITY_POLL)
64 : /** @endcond */
65 :
66 : /** @brief Wi-Fi management commands */
67 1 : enum net_request_wifi_cmd {
68 : /** Scan for Wi-Fi networks */
69 : NET_REQUEST_WIFI_CMD_SCAN = 1,
70 : /** Connect to a Wi-Fi network */
71 : NET_REQUEST_WIFI_CMD_CONNECT,
72 : /** Disconnect from a Wi-Fi network */
73 : NET_REQUEST_WIFI_CMD_DISCONNECT,
74 : /** Enable AP mode */
75 : NET_REQUEST_WIFI_CMD_AP_ENABLE,
76 : /** Disable AP mode */
77 : NET_REQUEST_WIFI_CMD_AP_DISABLE,
78 : /** Set AP RTS threshold */
79 : NET_REQUEST_WIFI_CMD_AP_RTS_THRESHOLD,
80 : /** Get interface status */
81 : NET_REQUEST_WIFI_CMD_IFACE_STATUS,
82 : /** Set or get 11k status */
83 : NET_REQUEST_WIFI_CMD_11K_CONFIG,
84 : /** Send 11k neighbor request */
85 : NET_REQUEST_WIFI_CMD_11K_NEIGHBOR_REQUEST,
86 : /** Set power save status */
87 : NET_REQUEST_WIFI_CMD_PS,
88 : /** Setup or teardown TWT flow */
89 : NET_REQUEST_WIFI_CMD_TWT,
90 : /** Setup BTWT flow */
91 : NET_REQUEST_WIFI_CMD_BTWT,
92 : /** Get power save config */
93 : NET_REQUEST_WIFI_CMD_PS_CONFIG,
94 : /** Set or get regulatory domain */
95 : NET_REQUEST_WIFI_CMD_REG_DOMAIN,
96 : /** Set or get Mode of operation */
97 : NET_REQUEST_WIFI_CMD_MODE,
98 : /** Set or get packet filter setting for current mode */
99 : NET_REQUEST_WIFI_CMD_PACKET_FILTER,
100 : /** Set or get Wi-Fi channel for Monitor or TX-Injection mode */
101 : NET_REQUEST_WIFI_CMD_CHANNEL,
102 : /** Disconnect a STA from AP */
103 : NET_REQUEST_WIFI_CMD_AP_STA_DISCONNECT,
104 : /** Get Wi-Fi driver and Firmware versions */
105 : NET_REQUEST_WIFI_CMD_VERSION,
106 : /** Get Wi-Fi latest connection parameters */
107 : NET_REQUEST_WIFI_CMD_CONN_PARAMS,
108 : /** Set RTS threshold */
109 : NET_REQUEST_WIFI_CMD_RTS_THRESHOLD,
110 : /** Configure AP parameter */
111 : NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM,
112 : /** Configure STA parameter */
113 : NET_REQUEST_WIFI_CMD_CONFIG_PARAM,
114 : /** DPP actions */
115 : NET_REQUEST_WIFI_CMD_DPP,
116 : /** BSS transition management query */
117 : NET_REQUEST_WIFI_CMD_BTM_QUERY,
118 : /** Flush PMKSA cache entries */
119 : NET_REQUEST_WIFI_CMD_PMKSA_FLUSH,
120 : /** Set enterprise mode credential */
121 : NET_REQUEST_WIFI_CMD_ENTERPRISE_CREDS,
122 : /** Get RTS threshold */
123 : NET_REQUEST_WIFI_CMD_RTS_THRESHOLD_CONFIG,
124 : /** WPS config */
125 : NET_REQUEST_WIFI_CMD_WPS_CONFIG,
126 : #ifdef CONFIG_WIFI_CREDENTIALS_CONNECT_STORED
127 : /** Connect to APs stored using wifi_credentials library. */
128 : NET_REQUEST_WIFI_CMD_CONNECT_STORED,
129 : #endif
130 : /** Start roaming */
131 : NET_REQUEST_WIFI_CMD_START_ROAMING,
132 : /** Neighbor report complete */
133 : NET_REQUEST_WIFI_CMD_NEIGHBOR_REP_COMPLETE,
134 : /** Specific scan */
135 : NET_REQUEST_WIFI_CMD_CANDIDATE_SCAN,
136 : /** AP WPS config */
137 : NET_REQUEST_WIFI_CMD_AP_WPS_CONFIG,
138 : /** Configure BSS maximum idle period */
139 : NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD,
140 : /** Configure background scanning */
141 : NET_REQUEST_WIFI_CMD_BGSCAN,
142 : /** @cond INTERNAL_HIDDEN */
143 : NET_REQUEST_WIFI_CMD_MAX
144 : /** @endcond */
145 : };
146 :
147 : /** Request a Wi-Fi scan */
148 1 : #define NET_REQUEST_WIFI_SCAN \
149 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_SCAN)
150 :
151 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_SCAN);
152 :
153 : /** Request a Wi-Fi connect */
154 1 : #define NET_REQUEST_WIFI_CONNECT \
155 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONNECT)
156 :
157 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_CONNECT);
158 :
159 : /** Request a Wi-Fi disconnect */
160 1 : #define NET_REQUEST_WIFI_DISCONNECT \
161 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_DISCONNECT)
162 :
163 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_DISCONNECT);
164 :
165 : /** Request a Wi-Fi access point enable */
166 1 : #define NET_REQUEST_WIFI_AP_ENABLE \
167 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_ENABLE)
168 :
169 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_ENABLE);
170 :
171 : /** Request a Wi-Fi access point disable */
172 1 : #define NET_REQUEST_WIFI_AP_DISABLE \
173 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_DISABLE)
174 :
175 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_DISABLE);
176 :
177 : /** Request a Wi-Fi RTS threshold */
178 1 : #define NET_REQUEST_WIFI_AP_RTS_THRESHOLD \
179 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_RTS_THRESHOLD)
180 :
181 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_RTS_THRESHOLD);
182 :
183 : /** Request a Wi-Fi network interface status */
184 1 : #define NET_REQUEST_WIFI_IFACE_STATUS \
185 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_IFACE_STATUS)
186 :
187 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_IFACE_STATUS);
188 :
189 0 : #define NET_REQUEST_WIFI_11K_CONFIG \
190 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_11K_CONFIG)
191 :
192 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_11K_CONFIG);
193 :
194 0 : #define NET_REQUEST_WIFI_11K_NEIGHBOR_REQUEST \
195 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_11K_NEIGHBOR_REQUEST)
196 :
197 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_11K_NEIGHBOR_REQUEST);
198 :
199 : /** Request a Wi-Fi power save */
200 1 : #define NET_REQUEST_WIFI_PS \
201 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS)
202 :
203 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PS);
204 :
205 : /** Request a Wi-Fi TWT */
206 1 : #define NET_REQUEST_WIFI_TWT \
207 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_TWT)
208 :
209 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_TWT);
210 :
211 0 : #define NET_REQUEST_WIFI_BTWT \
212 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_BTWT)
213 :
214 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BTWT);
215 :
216 : /** Request a Wi-Fi power save configuration */
217 1 : #define NET_REQUEST_WIFI_PS_CONFIG \
218 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PS_CONFIG)
219 :
220 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PS_CONFIG);
221 :
222 : /** Request a Wi-Fi regulatory domain */
223 1 : #define NET_REQUEST_WIFI_REG_DOMAIN \
224 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_REG_DOMAIN)
225 :
226 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_REG_DOMAIN);
227 :
228 : /** Request current Wi-Fi mode */
229 1 : #define NET_REQUEST_WIFI_MODE \
230 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_MODE)
231 :
232 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_MODE);
233 :
234 : /** Request Wi-Fi packet filter */
235 1 : #define NET_REQUEST_WIFI_PACKET_FILTER \
236 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PACKET_FILTER)
237 :
238 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PACKET_FILTER);
239 :
240 : /** Request a Wi-Fi channel */
241 1 : #define NET_REQUEST_WIFI_CHANNEL \
242 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CHANNEL)
243 :
244 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_CHANNEL);
245 :
246 : /** Request a Wi-Fi access point to disconnect a station */
247 1 : #define NET_REQUEST_WIFI_AP_STA_DISCONNECT \
248 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_STA_DISCONNECT)
249 :
250 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_STA_DISCONNECT);
251 :
252 : /** Request a Wi-Fi version */
253 1 : #define NET_REQUEST_WIFI_VERSION \
254 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_VERSION)
255 :
256 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_VERSION);
257 :
258 : /** Request a Wi-Fi connection parameters */
259 1 : #define NET_REQUEST_WIFI_CONN_PARAMS \
260 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONN_PARAMS)
261 :
262 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_CONN_PARAMS);
263 :
264 : /** Request a Wi-Fi RTS threshold */
265 1 : #define NET_REQUEST_WIFI_RTS_THRESHOLD \
266 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD)
267 :
268 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD);
269 :
270 : /** Request a Wi-Fi AP parameters configuration */
271 1 : #define NET_REQUEST_WIFI_AP_CONFIG_PARAM \
272 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM)
273 :
274 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM);
275 :
276 : /** Request a Wi-Fi STA parameters configuration */
277 1 : #define NET_REQUEST_WIFI_CONFIG_PARAM \
278 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONFIG_PARAM)
279 :
280 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_CONFIG_PARAM);
281 :
282 : #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
283 : /** Request a Wi-Fi DPP operation */
284 : #define NET_REQUEST_WIFI_DPP \
285 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_DPP)
286 :
287 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_DPP);
288 : #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
289 :
290 : /** Request a Wi-Fi BTM query */
291 1 : #define NET_REQUEST_WIFI_BTM_QUERY (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_BTM_QUERY)
292 :
293 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BTM_QUERY);
294 :
295 : /** Request a Wi-Fi PMKSA cache entries flush */
296 1 : #define NET_REQUEST_WIFI_PMKSA_FLUSH \
297 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_PMKSA_FLUSH)
298 :
299 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_PMKSA_FLUSH);
300 :
301 : /** Set Wi-Fi enterprise mode CA/client Cert and key */
302 1 : #define NET_REQUEST_WIFI_ENTERPRISE_CREDS \
303 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_ENTERPRISE_CREDS)
304 :
305 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_ENTERPRISE_CREDS);
306 :
307 : /** Request a Wi-Fi RTS threshold configuration */
308 1 : #define NET_REQUEST_WIFI_RTS_THRESHOLD_CONFIG \
309 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD_CONFIG)
310 :
311 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD_CONFIG);
312 :
313 0 : #define NET_REQUEST_WIFI_WPS_CONFIG (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_WPS_CONFIG)
314 :
315 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_WPS_CONFIG);
316 : #ifdef CONFIG_WIFI_CREDENTIALS_CONNECT_STORED
317 : #define NET_REQUEST_WIFI_CONNECT_STORED (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_CONNECT_STORED)
318 :
319 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_CONNECT_STORED);
320 : #endif
321 :
322 0 : #define NET_REQUEST_WIFI_START_ROAMING \
323 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_START_ROAMING)
324 :
325 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_START_ROAMING);
326 :
327 0 : #define NET_REQUEST_WIFI_NEIGHBOR_REP_COMPLETE \
328 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_NEIGHBOR_REP_COMPLETE)
329 :
330 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_NEIGHBOR_REP_COMPLETE);
331 :
332 0 : #define NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD \
333 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_BSS_MAX_IDLE_PERIOD)
334 :
335 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BSS_MAX_IDLE_PERIOD);
336 :
337 0 : #define NET_REQUEST_WIFI_BGSCAN \
338 : (NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_BGSCAN)
339 :
340 : NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_BGSCAN);
341 :
342 : /** @cond INTERNAL_HIDDEN */
343 :
344 : enum {
345 : NET_EVENT_WIFI_CMD_SCAN_RESULT_VAL,
346 : NET_EVENT_WIFI_CMD_SCAN_DONE_VAL,
347 : NET_EVENT_WIFI_CMD_CONNECT_RESULT_VAL,
348 : NET_EVENT_WIFI_CMD_DISCONNECT_RESULT_VAL,
349 : NET_EVENT_WIFI_CMD_IFACE_STATUS_VAL,
350 : NET_EVENT_WIFI_CMD_TWT_VAL,
351 : NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE_VAL,
352 : NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT_VAL,
353 : NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE_VAL,
354 : NET_EVENT_WIFI_CMD_SIGNAL_CHANGE_VAL,
355 : NET_EVENT_WIFI_CMD_NEIGHBOR_REP_RECEIVED_VAL,
356 : NET_EVENT_WIFI_CMD_NEIGHBOR_REP_COMPLETE_VAL,
357 : NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT_VAL,
358 : NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT_VAL,
359 : NET_EVENT_WIFI_CMD_AP_STA_CONNECTED_VAL,
360 : NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED_VAL,
361 : NET_EVENT_WIFI_CMD_SUPPLICANT_VAL,
362 :
363 : NET_EVENT_WIFI_CMD_MAX,
364 : };
365 :
366 : BUILD_ASSERT(NET_EVENT_WIFI_CMD_MAX <= NET_MGMT_MAX_COMMANDS,
367 : "Number of events in net_event_wifi_cmd exceeds the limit");
368 :
369 : /** @endcond */
370 :
371 : /** @brief Wi-Fi management events */
372 1 : enum net_event_wifi_cmd {
373 : /** Scan results available */
374 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SCAN_RESULT),
375 : /** Scan done */
376 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SCAN_DONE),
377 : /** Connect result */
378 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_CONNECT_RESULT),
379 : /** Disconnect result */
380 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_DISCONNECT_RESULT),
381 : /** Interface status */
382 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_IFACE_STATUS),
383 : /** TWT events */
384 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_TWT),
385 : /** TWT sleep status: awake or sleeping, can be used by application
386 : * to determine if it can send data or not.
387 : */
388 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE),
389 : /** Raw scan results available */
390 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT),
391 : /** Disconnect complete */
392 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE),
393 : /** Signal change event */
394 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SIGNAL_CHANGE),
395 : /** Neighbor Report */
396 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_NEIGHBOR_REP_RECEIVED),
397 : /** Neighbor Report complete */
398 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_NEIGHBOR_REP_COMPLETE),
399 : /** AP mode enable result */
400 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT),
401 : /** AP mode disable result */
402 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT),
403 : /** STA connected to AP */
404 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_STA_CONNECTED),
405 : /** STA disconnected from AP */
406 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED),
407 : /** Supplicant specific event */
408 : NET_MGMT_CMD(NET_EVENT_WIFI_CMD_SUPPLICANT),
409 : };
410 :
411 : /** Event emitted for Wi-Fi scan result */
412 1 : #define NET_EVENT_WIFI_SCAN_RESULT \
413 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SCAN_RESULT)
414 :
415 : /** Event emitted when Wi-Fi scan is done */
416 1 : #define NET_EVENT_WIFI_SCAN_DONE \
417 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SCAN_DONE)
418 :
419 : /** Event emitted for Wi-Fi connect result */
420 1 : #define NET_EVENT_WIFI_CONNECT_RESULT \
421 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_CONNECT_RESULT)
422 :
423 : /** Event emitted for Wi-Fi disconnect result */
424 1 : #define NET_EVENT_WIFI_DISCONNECT_RESULT \
425 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_DISCONNECT_RESULT)
426 :
427 : /** Event emitted for Wi-Fi network interface status */
428 1 : #define NET_EVENT_WIFI_IFACE_STATUS \
429 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_IFACE_STATUS)
430 :
431 : /** Event emitted for Wi-Fi TWT information */
432 1 : #define NET_EVENT_WIFI_TWT \
433 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_TWT)
434 :
435 : /** Event emitted for Wi-Fi TWT sleep state */
436 1 : #define NET_EVENT_WIFI_TWT_SLEEP_STATE \
437 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_TWT_SLEEP_STATE)
438 :
439 : /** Event emitted for Wi-Fi raw scan result */
440 1 : #define NET_EVENT_WIFI_RAW_SCAN_RESULT \
441 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_RAW_SCAN_RESULT)
442 :
443 : /** Event emitted Wi-Fi disconnect is completed */
444 1 : #define NET_EVENT_WIFI_DISCONNECT_COMPLETE \
445 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_DISCONNECT_COMPLETE)
446 :
447 : /** Event signal change of connected AP */
448 1 : #define NET_EVENT_WIFI_SIGNAL_CHANGE \
449 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_SIGNAL_CHANGE)
450 :
451 : /** Event Neighbor Report Completed */
452 1 : #define NET_EVENT_WIFI_NEIGHBOR_REP_COMP \
453 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_NEIGHBOR_REP_COMPLETE)
454 :
455 : /** Event emitted for Wi-Fi access point enable result */
456 1 : #define NET_EVENT_WIFI_AP_ENABLE_RESULT \
457 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_AP_ENABLE_RESULT)
458 :
459 : /** Event emitted for Wi-Fi access point disable result */
460 1 : #define NET_EVENT_WIFI_AP_DISABLE_RESULT \
461 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_AP_DISABLE_RESULT)
462 :
463 : /** Event emitted when Wi-Fi station is connected in AP mode */
464 1 : #define NET_EVENT_WIFI_AP_STA_CONNECTED \
465 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_AP_STA_CONNECTED)
466 :
467 : /** Event emitted Wi-Fi station is disconnected from AP */
468 1 : #define NET_EVENT_WIFI_AP_STA_DISCONNECTED \
469 : (NET_WIFI_EVENT | NET_EVENT_WIFI_CMD_AP_STA_DISCONNECTED)
470 :
471 : /** @brief Wi-Fi version */
472 1 : struct wifi_version {
473 : /** Driver version */
474 1 : const char *drv_version;
475 : /** Firmware version */
476 1 : const char *fw_version;
477 : };
478 :
479 : /**
480 : * @brief Wi-Fi structure to uniquely identify a band-channel pair
481 : */
482 1 : struct wifi_band_channel {
483 : /** Frequency band */
484 1 : uint8_t band;
485 : /** Channel */
486 1 : uint8_t channel;
487 : };
488 :
489 : /**
490 : * @brief Wi-Fi scan parameters structure.
491 : * Used to specify parameters which can control how the Wi-Fi scan
492 : * is performed.
493 : */
494 1 : struct wifi_scan_params {
495 : /** Scan type, see enum wifi_scan_type.
496 : *
497 : * The scan_type is only a hint to the underlying Wi-Fi chip for the
498 : * preferred mode of scan. The actual mode of scan can depend on factors
499 : * such as the Wi-Fi chip implementation support, regulatory domain
500 : * restrictions etc.
501 : */
502 1 : enum wifi_scan_type scan_type;
503 : /** Bitmap of bands to be scanned.
504 : * Refer to ::wifi_frequency_bands for bit position of each band.
505 : */
506 1 : uint8_t bands;
507 : /** Active scan dwell time (in ms) on a channel.
508 : */
509 1 : uint16_t dwell_time_active;
510 : /** Passive scan dwell time (in ms) on a channel.
511 : */
512 1 : uint16_t dwell_time_passive;
513 : /** Array of SSID strings to scan.
514 : */
515 1 : const char *ssids[WIFI_MGMT_SCAN_SSID_FILT_MAX];
516 : /** Specifies the maximum number of scan results to return. These results would be the
517 : * BSSIDS with the best RSSI values, in all the scanned channels. This should only be
518 : * used to limit the number of returned scan results, and cannot be counted upon to limit
519 : * the scan time, since the underlying Wi-Fi chip might have to scan all the channels to
520 : * find the max_bss_cnt number of APs with the best signal strengths. A value of 0
521 : * signifies that there is no restriction on the number of scan results to be returned.
522 : */
523 1 : uint16_t max_bss_cnt;
524 : /** Channel information array indexed on Wi-Fi frequency bands and channels within that
525 : * band.
526 : * E.g. to scan channel 6 and 11 on the 2.4 GHz band, channel 36 on the 5 GHz band:
527 : * @code{.c}
528 : * chan[0] = {WIFI_FREQ_BAND_2_4_GHZ, 6};
529 : * chan[1] = {WIFI_FREQ_BAND_2_4_GHZ, 11};
530 : * chan[2] = {WIFI_FREQ_BAND_5_GHZ, 36};
531 : * @endcode
532 : *
533 : * This list specifies the channels to be __considered for scan__. The underlying
534 : * Wi-Fi chip can silently omit some channels due to various reasons such as channels
535 : * not conforming to regulatory restrictions etc. The invoker of the API should
536 : * ensure that the channels specified follow regulatory rules.
537 : */
538 1 : struct wifi_band_channel band_chan[WIFI_MGMT_SCAN_CHAN_MAX_MANUAL];
539 : };
540 :
541 : /** @brief Wi-Fi scan result, each result is provided to the net_mgmt_event_callback
542 : * via its info attribute (see net_mgmt.h)
543 : */
544 1 : struct wifi_scan_result {
545 : /** SSID */
546 1 : uint8_t ssid[WIFI_SSID_MAX_LEN + 1];
547 : /** SSID length */
548 1 : uint8_t ssid_length;
549 : /** Frequency band */
550 1 : uint8_t band;
551 : /** Channel */
552 1 : uint8_t channel;
553 : /** Security type */
554 1 : enum wifi_security_type security;
555 : /** WPA3 enterprise type */
556 1 : enum wifi_wpa3_enterprise_type wpa3_ent_type;
557 : /** MFP options */
558 1 : enum wifi_mfp_options mfp;
559 : /** RSSI */
560 1 : int8_t rssi;
561 : /** BSSID */
562 1 : uint8_t mac[WIFI_MAC_ADDR_LEN];
563 : /** BSSID length */
564 1 : uint8_t mac_length;
565 : };
566 :
567 : /** @brief Wi-Fi connect request parameters */
568 1 : struct wifi_connect_req_params {
569 : /** SSID */
570 1 : const uint8_t *ssid;
571 : /** SSID length */
572 1 : uint8_t ssid_length; /* Max 32 */
573 : /** Pre-shared key */
574 1 : const uint8_t *psk;
575 : /** Pre-shared key length */
576 1 : uint8_t psk_length; /* Min 8 - Max 64 */
577 : /** SAE password (same as PSK but with no length restrictions), optional */
578 1 : const uint8_t *sae_password;
579 : /** SAE password length */
580 1 : uint8_t sae_password_length; /* No length restrictions */
581 : /** Frequency band */
582 1 : uint8_t band;
583 : /** Channel */
584 1 : uint8_t channel;
585 : /** Security type */
586 1 : enum wifi_security_type security;
587 : /** MFP options */
588 1 : enum wifi_mfp_options mfp;
589 : /** BSSID */
590 1 : uint8_t bssid[WIFI_MAC_ADDR_LEN];
591 : /** Connect timeout in seconds, SYS_FOREVER_MS for no timeout */
592 1 : int timeout;
593 : /**
594 : * Anonymous identity used in EAP authentication (Phase 1) for Wi-Fi Enterprise networks.
595 : * In EAP methods such as PEAP or TTLS, the anonymous identity is sent in the initial
596 : * outer authentication exchange to protect the user's real identity (eap_identity).
597 : * This value is not always required; if not set, the real identity may be exposed.
598 : * Only used in Phase 1 (outer authentication).
599 : */
600 1 : const uint8_t *anon_id;
601 :
602 : /** Length of the anonymous identity, maximum 64 bytes. */
603 1 : uint8_t aid_length;
604 :
605 : /**
606 : * Private key password for Wi-Fi Enterprise authentication.
607 : * Used when a client certificate and private key are required (e.g., EAP-TLS).
608 : * This is the password protecting the private key file.
609 : * Applies to Phase 1 (outer authentication) when client certificates are used.
610 : */
611 1 : const uint8_t *key_passwd;
612 :
613 : /** Length of the private key password, maximum 128 bytes. */
614 1 : uint8_t key_passwd_length;
615 :
616 : /**
617 : * Password for a secondary private key, if required by the authentication method.
618 : * Rarely used; typically only needed for advanced enterprise setups.
619 : * Applies to Phase 1 (outer authentication) if a second private key is used.
620 : */
621 1 : const uint8_t *key2_passwd;
622 :
623 : /** Length of the secondary private key password, maximum 128 bytes. */
624 1 : uint8_t key2_passwd_length;
625 :
626 : /**
627 : * WPA3 Enterprise mode type.
628 : * Selects the WPA3 Enterprise authentication variant to use.
629 : * WPA3 Enterprise is a security protocol for Wi-Fi networks, often used in organizations,
630 : * that provides enhanced security over WPA2. This field is only relevant for enterprise
631 : * networks.
632 : * Applies to Phase 1 (outer authentication).
633 : */
634 1 : enum wifi_wpa3_enterprise_type wpa3_ent_mode;
635 :
636 : /**
637 : * TLS cipher suite to use for EAP-TLS authentication.
638 : * This selects the cryptographic algorithms used for the secure connection.
639 : * Only relevant for enterprise networks using EAP-TLS or similar methods.
640 : * Applies to Phase 1 (outer authentication).
641 : */
642 1 : uint8_t TLS_cipher;
643 :
644 : /**
645 : * EAP (Extensible Authentication Protocol) version to use.
646 : * EAP is a framework for network authentication, commonly used in enterprise Wi-Fi.
647 : * This field allows specifying the protocol version if required by the network.
648 : * Applies to Phase 1 (outer authentication).
649 : */
650 1 : int eap_ver;
651 :
652 : /**
653 : * Identity string for EAP authentication (Phase 2, inner authentication).
654 : * This is the real username or identity presented to the authentication server
655 : * after the secure tunnel is established (e.g., inside PEAP or TTLS).
656 : * Required for most enterprise Wi-Fi networks (e.g., WPA2/WPA3 Enterprise).
657 : * Applies to Phase 2 (inner authentication).
658 : */
659 1 : const uint8_t *eap_identity;
660 :
661 : /** Length of the EAP identity, maximum 64 bytes. */
662 1 : uint8_t eap_id_length;
663 :
664 : /**
665 : * Password string for EAP authentication (Phase 2, inner authentication).
666 : * Used in EAP methods that require a password (e.g., PEAP, TTLS, EAP-FAST).
667 : * This is the user's password for the enterprise Wi-Fi network.
668 : * Applies to Phase 2 (inner authentication).
669 : */
670 1 : const uint8_t *eap_password;
671 :
672 : /** Length of the EAP password, maximum 128 bytes. */
673 1 : uint8_t eap_passwd_length;
674 :
675 : /**
676 : * Whether to verify the server's certificate authority (CA) during authentication.
677 : * Set to true to require validation of the server's certificate (recommended for security).
678 : * Set to false to skip CA verification (not recommended, but sometimes used for testing).
679 : * Applies to Phase 1 (outer authentication).
680 : */
681 1 : bool verify_peer_cert;
682 :
683 : /**
684 : * Indicates if Fast BSS Transition (802.11r) is used.
685 : * Fast BSS Transition allows seamless roaming between access points in enterprise networks.
686 : * Applies to the overall connection, not specific to EAP phases.
687 : */
688 1 : bool ft_used;
689 :
690 : /**
691 : * Number of EAP user identities provided.
692 : * Used for advanced enterprise authentication scenarios where multiple user credentials
693 : * are needed.
694 : * Applies to Phase 2 (inner authentication).
695 : */
696 1 : int nusers;
697 :
698 : /**
699 : * Number of EAP passwords provided.
700 : * Used in conjunction with multiple user identities for enterprise authentication.
701 : * Applies to Phase 2 (inner authentication).
702 : */
703 1 : uint8_t passwds;
704 :
705 : /**
706 : * Array of pointers to user identity strings for EAP authentication.
707 : * Used for enterprise Wi-Fi networks that require multiple user identities.
708 : * Applies to Phase 2 (inner authentication).
709 : */
710 1 : const uint8_t *identities[WIFI_ENT_IDENTITY_MAX_USERS];
711 :
712 : /**
713 : * Array of pointers to user password strings for EAP authentication.
714 : * Used for enterprise Wi-Fi networks that require multiple user passwords.
715 : * Applies to Phase 2 (inner authentication).
716 : */
717 1 : const uint8_t *passwords[WIFI_ENT_IDENTITY_MAX_USERS];
718 : /** Hidden SSID configure
719 : * 0: disabled (default)
720 : * 1: send empty (length=0) SSID in beacon and ignore probe request for broadcast SSID
721 : * 2: clear SSID, but keep the original length and ignore probe request for broadcast SSID
722 : */
723 1 : uint8_t ignore_broadcast_ssid;
724 : /** Parameter used for frequency band */
725 1 : enum wifi_frequency_bandwidths bandwidth;
726 : };
727 :
728 : /** @brief Wi-Fi disconnect reason codes. To be overlaid on top of \ref wifi_status
729 : * in the disconnect result event for detailed reason.
730 : */
731 1 : enum wifi_disconn_reason {
732 : /** Success, overload status as reason */
733 : WIFI_REASON_DISCONN_SUCCESS = 0,
734 : /** Unspecified reason */
735 : WIFI_REASON_DISCONN_UNSPECIFIED,
736 : /** Disconnected due to user request */
737 : WIFI_REASON_DISCONN_USER_REQUEST,
738 : /** Disconnected due to AP leaving */
739 : WIFI_REASON_DISCONN_AP_LEAVING,
740 : /** Disconnected due to inactivity */
741 : WIFI_REASON_DISCONN_INACTIVITY,
742 : };
743 :
744 : /** @brief Wi-Fi AP mode result codes. To be overlaid on top of \ref wifi_status
745 : * in the AP mode enable or disable result event for detailed status.
746 : */
747 1 : enum wifi_ap_status {
748 : /** AP mode enable or disable successful */
749 : WIFI_STATUS_AP_SUCCESS = 0,
750 : /** AP mode enable or disable failed - generic failure */
751 : WIFI_STATUS_AP_FAIL,
752 : /** AP mode enable failed - channel not supported */
753 : WIFI_STATUS_AP_CHANNEL_NOT_SUPPORTED,
754 : /** AP mode enable failed - channel not allowed */
755 : WIFI_STATUS_AP_CHANNEL_NOT_ALLOWED,
756 : /** AP mode enable failed - SSID not allowed */
757 : WIFI_STATUS_AP_SSID_NOT_ALLOWED,
758 : /** AP mode enable failed - authentication type not supported */
759 : WIFI_STATUS_AP_AUTH_TYPE_NOT_SUPPORTED,
760 : /** AP mode enable failed - operation not supported */
761 : WIFI_STATUS_AP_OP_NOT_SUPPORTED,
762 : /** AP mode enable failed - operation not permitted */
763 : WIFI_STATUS_AP_OP_NOT_PERMITTED,
764 : };
765 :
766 : /** @brief Generic Wi-Fi status for commands and events */
767 1 : struct wifi_status {
768 : union {
769 : /** Status value */
770 1 : int status;
771 : /** Connection status */
772 1 : enum wifi_conn_status conn_status;
773 : /** Disconnection reason status */
774 1 : enum wifi_disconn_reason disconn_reason;
775 : /** Access point status */
776 1 : enum wifi_ap_status ap_status;
777 0 : };
778 : };
779 :
780 : /** @brief Wi-Fi interface status */
781 1 : struct wifi_iface_status {
782 : /** Interface state, see enum wifi_iface_state */
783 1 : int state;
784 : /** SSID length */
785 1 : unsigned int ssid_len;
786 : /** SSID */
787 1 : char ssid[WIFI_SSID_MAX_LEN + 1];
788 : /** BSSID */
789 1 : char bssid[WIFI_MAC_ADDR_LEN];
790 : /** Frequency band */
791 1 : enum wifi_frequency_bands band;
792 : /** Channel */
793 1 : unsigned int channel;
794 : /** Interface mode, see enum wifi_iface_mode */
795 1 : enum wifi_iface_mode iface_mode;
796 : /** Link mode, see enum wifi_link_mode */
797 1 : enum wifi_link_mode link_mode;
798 : /** WPA3 enterprise type */
799 1 : enum wifi_wpa3_enterprise_type wpa3_ent_type;
800 : /** Security type, see enum wifi_security_type */
801 1 : enum wifi_security_type security;
802 : /** MFP options, see enum wifi_mfp_options */
803 1 : enum wifi_mfp_options mfp;
804 : /** RSSI */
805 1 : int rssi;
806 : /** DTIM period */
807 1 : unsigned char dtim_period;
808 : /** Beacon interval */
809 1 : unsigned short beacon_interval;
810 : /** is TWT capable? */
811 1 : bool twt_capable;
812 : /** The current 802.11 PHY TX data rate (in Mbps) */
813 1 : float current_phy_tx_rate;
814 : };
815 :
816 : /** @brief Wi-Fi power save parameters */
817 1 : struct wifi_ps_params {
818 : /** Power save state */
819 1 : enum wifi_ps enabled;
820 : /** Listen interval */
821 1 : unsigned short listen_interval;
822 : /** Wi-Fi power save wakeup mode */
823 1 : enum wifi_ps_wakeup_mode wakeup_mode;
824 : /** Wi-Fi power save mode */
825 1 : enum wifi_ps_mode mode;
826 : /** Wi-Fi power save timeout
827 : *
828 : * This is the time out to wait after sending a TX packet
829 : * before going back to power save (in ms) to receive any replies
830 : * from the AP. Zero means this feature is disabled.
831 : *
832 : * It's a tradeoff between power consumption and latency.
833 : */
834 1 : unsigned int timeout_ms;
835 : /** Wi-Fi power save type */
836 1 : enum wifi_ps_param_type type;
837 : /** Wi-Fi power save fail reason */
838 1 : enum wifi_config_ps_param_fail_reason fail_reason;
839 : /** Wi-Fi power save exit strategy */
840 1 : enum wifi_ps_exit_strategy exit_strategy;
841 : };
842 :
843 0 : #define WIFI_BTWT_AGREEMENT_MAX 5
844 :
845 : /** @brief Wi-Fi broadcast TWT parameters */
846 1 : struct wifi_btwt_params {
847 : /** Broadcast TWT ID */
848 1 : uint8_t btwt_id;
849 : /** Broadcast TWT mantissa */
850 1 : uint16_t btwt_mantissa;
851 : /** Broadcast TWT exponent */
852 1 : uint8_t btwt_exponent;
853 : /** Broadcast TWT range */
854 1 : uint8_t btwt_nominal_wake;
855 : };
856 :
857 : /** @brief Wi-Fi TWT parameters */
858 1 : struct wifi_twt_params {
859 : /** TWT operation, see enum wifi_twt_operation */
860 1 : enum wifi_twt_operation operation;
861 : /** TWT negotiation type, see enum wifi_twt_negotiation_type */
862 1 : enum wifi_twt_negotiation_type negotiation_type;
863 : /** TWT setup command, see enum wifi_twt_setup_cmd */
864 1 : enum wifi_twt_setup_cmd setup_cmd;
865 : /** TWT setup response status, see enum wifi_twt_setup_resp_status */
866 1 : enum wifi_twt_setup_resp_status resp_status;
867 : /** TWT teardown cmd status, see enum wifi_twt_teardown_status */
868 1 : enum wifi_twt_teardown_status teardown_status;
869 : /** Dialog token, used to map requests to responses */
870 1 : uint8_t dialog_token;
871 : /** Flow ID, used to map setup with teardown */
872 1 : uint8_t flow_id;
873 : union {
874 : /** Setup specific parameters */
875 : struct {
876 : /**Interval = Wake up time + Sleeping time */
877 1 : uint64_t twt_interval;
878 : /** Requestor or responder */
879 1 : bool responder;
880 : /** Trigger enabled or disabled */
881 1 : bool trigger;
882 : /** Implicit or explicit */
883 1 : bool implicit;
884 : /** Announced or unannounced */
885 1 : bool announce;
886 : /** Wake up time */
887 1 : uint32_t twt_wake_interval;
888 : /** Wake ahead notification is sent earlier than
889 : * TWT Service period (SP) start based on this duration.
890 : * This should give applications ample time to
891 : * prepare the data before TWT SP starts.
892 : */
893 1 : uint32_t twt_wake_ahead_duration;
894 : /** TWT info enabled or disable */
895 1 : bool twt_info_disable;
896 : /** TWT exponent */
897 1 : uint8_t twt_exponent;
898 : /** TWT Mantissa Range: [0-sizeof(UINT16)] */
899 1 : uint16_t twt_mantissa;
900 1 : } setup;
901 : /** Setup specific parameters */
902 : struct {
903 : /** Broadcast TWT station wait time */
904 1 : uint8_t btwt_sta_wait;
905 : /** Broadcast TWT offset */
906 1 : uint16_t btwt_offset;
907 : /** In multiple of 4 beacon interval */
908 1 : uint8_t btwt_li;
909 : /** Broadcast TWT agreement count */
910 1 : uint8_t btwt_count;
911 : /** Broadcast TWT agreement sets */
912 1 : struct wifi_btwt_params btwt_set_cfg[WIFI_BTWT_AGREEMENT_MAX];
913 1 : } btwt;
914 : /** Teardown specific parameters */
915 : struct {
916 : /** Teardown all flows */
917 1 : bool teardown_all;
918 1 : } teardown;
919 0 : };
920 : /** TWT fail reason, see enum wifi_twt_fail_reason */
921 1 : enum wifi_twt_fail_reason fail_reason;
922 : };
923 :
924 : /** @cond INTERNAL_HIDDEN */
925 :
926 : /* Flow ID is only 3 bits */
927 : #define WIFI_MAX_TWT_FLOWS 8
928 : #define WIFI_MAX_TWT_INTERVAL_US (LONG_MAX - 1)
929 : /* 256 (u8) * 1TU */
930 : #define WIFI_MAX_TWT_WAKE_INTERVAL_US 262144
931 : #define WIFI_MAX_TWT_WAKE_AHEAD_DURATION_US (LONG_MAX - 1)
932 : #define WIFI_MAX_TWT_EXPONENT 31
933 :
934 : /** @endcond */
935 :
936 : /** @brief Wi-Fi TWT flow information */
937 1 : struct wifi_twt_flow_info {
938 : /** Interval = Wake up time + Sleeping time */
939 1 : uint64_t twt_interval;
940 : /** Dialog token, used to map requests to responses */
941 1 : uint8_t dialog_token;
942 : /** Flow ID, used to map setup with teardown */
943 1 : uint8_t flow_id;
944 : /** TWT negotiation type, see enum wifi_twt_negotiation_type */
945 1 : enum wifi_twt_negotiation_type negotiation_type;
946 : /** Requestor or responder */
947 1 : bool responder;
948 : /** Trigger enabled or disabled */
949 1 : bool trigger;
950 : /** Implicit or explicit */
951 1 : bool implicit;
952 : /** Announced or unannounced */
953 1 : bool announce;
954 : /** Wake up time */
955 1 : uint32_t twt_wake_interval;
956 : /** Wake ahead duration */
957 1 : uint32_t twt_wake_ahead_duration;
958 : };
959 :
960 : /** Wi-Fi enterprise mode credentials */
961 1 : struct wifi_enterprise_creds_params {
962 : /** CA certification */
963 1 : uint8_t *ca_cert;
964 : /** CA certification length */
965 1 : uint32_t ca_cert_len;
966 : /** Client certification */
967 1 : uint8_t *client_cert;
968 : /** Client certification length */
969 1 : uint32_t client_cert_len;
970 : /** Client key */
971 1 : uint8_t *client_key;
972 : /** Client key length */
973 1 : uint32_t client_key_len;
974 : /** CA certification of phase2*/
975 1 : uint8_t *ca_cert2;
976 : /** Phase2 CA certification length */
977 1 : uint32_t ca_cert2_len;
978 : /** Client certification of phase2*/
979 1 : uint8_t *client_cert2;
980 : /** Phase2 Client certification length */
981 1 : uint32_t client_cert2_len;
982 : /** Client key of phase2*/
983 1 : uint8_t *client_key2;
984 : /** Phase2 Client key length */
985 1 : uint32_t client_key2_len;
986 : /** Server certification */
987 1 : uint8_t *server_cert;
988 : /** Server certification length */
989 1 : uint32_t server_cert_len;
990 : /** Server key */
991 1 : uint8_t *server_key;
992 : /** Server key length */
993 1 : uint32_t server_key_len;
994 : /** Diffie–Hellman parameter */
995 1 : uint8_t *dh_param;
996 : /** Diffie–Hellman parameter length */
997 1 : uint32_t dh_param_len;
998 : };
999 :
1000 : /** @brief Wi-Fi power save configuration */
1001 1 : struct wifi_ps_config {
1002 : /** Number of TWT flows */
1003 1 : char num_twt_flows;
1004 : /** TWT flow details */
1005 1 : struct wifi_twt_flow_info twt_flows[WIFI_MAX_TWT_FLOWS];
1006 : /** Power save configuration */
1007 1 : struct wifi_ps_params ps_params;
1008 : };
1009 :
1010 : /** @brief Generic get/set operation for any command*/
1011 1 : enum wifi_mgmt_op {
1012 : /** Get operation */
1013 : WIFI_MGMT_GET = 0,
1014 : /** Set operation */
1015 : WIFI_MGMT_SET = 1,
1016 : };
1017 :
1018 : /** Wi-Fi 11k parameters */
1019 1 : struct wifi_11k_params {
1020 : /** 11k command operation */
1021 1 : enum wifi_mgmt_op oper;
1022 : /** 11k enable/disable */
1023 1 : bool enable_11k;
1024 : /** SSID */
1025 1 : uint8_t ssid[WIFI_SSID_MAX_LEN + 1];
1026 : };
1027 :
1028 : /** Max regulatory channel number */
1029 1 : #define MAX_REG_CHAN_NUM 42
1030 :
1031 : /** @brief Per-channel regulatory attributes */
1032 1 : struct wifi_reg_chan_info {
1033 : /** Center frequency in MHz */
1034 1 : unsigned short center_frequency;
1035 : /** Maximum transmission power (in dBm) */
1036 1 : unsigned short max_power:8;
1037 : /** Is channel supported or not */
1038 1 : unsigned short supported:1;
1039 : /** Passive transmissions only */
1040 1 : unsigned short passive_only:1;
1041 : /** Is a DFS channel */
1042 1 : unsigned short dfs:1;
1043 : } __packed;
1044 :
1045 : /** @brief Regulatory domain information or configuration */
1046 1 : struct wifi_reg_domain {
1047 : /** Regulatory domain operation */
1048 1 : enum wifi_mgmt_op oper;
1049 : /** Ignore all other regulatory hints over this one, the behavior is
1050 : * implementation specific.
1051 : */
1052 1 : bool force;
1053 : /** Country code: ISO/IEC 3166-1 alpha-2 */
1054 1 : uint8_t country_code[WIFI_COUNTRY_CODE_LEN];
1055 : /** Number of channels supported */
1056 1 : unsigned int num_channels;
1057 : /** Channels information */
1058 1 : struct wifi_reg_chan_info *chan_info;
1059 : };
1060 :
1061 : /** @brief Wi-Fi TWT sleep states */
1062 1 : enum wifi_twt_sleep_state {
1063 : /** TWT sleep state: sleeping */
1064 : WIFI_TWT_STATE_SLEEP = 0,
1065 : /** TWT sleep state: awake */
1066 : WIFI_TWT_STATE_AWAKE = 1,
1067 : };
1068 :
1069 : #if defined(CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS) || defined(__DOXYGEN__)
1070 : /** @brief Wi-Fi raw scan result */
1071 1 : struct wifi_raw_scan_result {
1072 : /** RSSI */
1073 1 : int8_t rssi;
1074 : /** Frame length */
1075 1 : int frame_length;
1076 : /** Frequency */
1077 1 : unsigned short frequency;
1078 : /** Raw scan data */
1079 1 : uint8_t data[CONFIG_WIFI_MGMT_RAW_SCAN_RESULT_LENGTH];
1080 : };
1081 : #endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */
1082 :
1083 : /** @brief AP mode - connected STA details */
1084 1 : struct wifi_ap_sta_info {
1085 : /** Link mode, see enum wifi_link_mode */
1086 1 : enum wifi_link_mode link_mode;
1087 : /** MAC address */
1088 1 : uint8_t mac[WIFI_MAC_ADDR_LEN];
1089 : /** MAC address length */
1090 1 : uint8_t mac_length;
1091 : /** is TWT capable ? */
1092 1 : bool twt_capable;
1093 : };
1094 :
1095 : /** @cond INTERNAL_HIDDEN */
1096 :
1097 : /* for use in max info size calculations */
1098 : union wifi_mgmt_events {
1099 : struct wifi_scan_result scan_result;
1100 : struct wifi_status connect_status;
1101 : struct wifi_iface_status iface_status;
1102 : #ifdef CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS
1103 : struct wifi_raw_scan_result raw_scan_result;
1104 : #endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */
1105 : struct wifi_twt_params twt_params;
1106 : struct wifi_ap_sta_info ap_sta_info;
1107 : };
1108 :
1109 : /** @endcond */
1110 :
1111 : /** @brief Wi-Fi mode setup */
1112 1 : struct wifi_mode_info {
1113 : /** Mode setting for a specific mode of operation */
1114 1 : uint8_t mode;
1115 : /** Interface index */
1116 1 : uint8_t if_index;
1117 : /** Get or set operation */
1118 1 : enum wifi_mgmt_op oper;
1119 : };
1120 :
1121 : /** @brief Wi-Fi filter setting for monitor, prmoiscuous, TX-injection modes */
1122 1 : struct wifi_filter_info {
1123 : /** Filter setting */
1124 1 : uint8_t filter;
1125 : /** Interface index */
1126 1 : uint8_t if_index;
1127 : /** Filter buffer size */
1128 1 : uint16_t buffer_size;
1129 : /** Get or set operation */
1130 1 : enum wifi_mgmt_op oper;
1131 : };
1132 :
1133 : /** @brief Wi-Fi channel setting for monitor and TX-injection modes */
1134 1 : struct wifi_channel_info {
1135 : /** Channel value to set */
1136 1 : uint16_t channel;
1137 : /** Interface index */
1138 1 : uint8_t if_index;
1139 : /** Get or set operation */
1140 1 : enum wifi_mgmt_op oper;
1141 : };
1142 :
1143 : /** @cond INTERNAL_HIDDEN */
1144 : #define WIFI_AP_STA_MAX_INACTIVITY (LONG_MAX - 1)
1145 : #define WIFI_AP_IEEE_80211_CAPAB_MAX_LEN 64
1146 : /** @endcond */
1147 :
1148 : /** @brief Wi-Fi AP configuration parameter */
1149 1 : struct wifi_ap_config_params {
1150 : /** Parameter used to identify the different AP parameters */
1151 1 : enum wifi_ap_config_param type;
1152 : /** Parameter used for setting maximum inactivity duration for stations */
1153 1 : uint32_t max_inactivity;
1154 : /** Parameter used for setting maximum number of stations */
1155 1 : uint32_t max_num_sta;
1156 : /** Parameter used for frequency band */
1157 1 : enum wifi_frequency_bandwidths bandwidth;
1158 : #if defined(CONFIG_WIFI_NM_HOSTAPD_AP)
1159 : /** Parameter used for setting HT capabilities */
1160 : char ht_capab[WIFI_AP_IEEE_80211_CAPAB_MAX_LEN + 1];
1161 : /** Parameter used for setting VHT capabilities */
1162 : char vht_capab[WIFI_AP_IEEE_80211_CAPAB_MAX_LEN + 1];
1163 : #endif
1164 : };
1165 :
1166 : /** @brief Wi-Fi STA configuration parameter */
1167 1 : struct wifi_config_params {
1168 : /** Parameter used to identify the different STA parameters */
1169 1 : enum wifi_config_param type;
1170 : /** Parameter used for opportunistic key caching */
1171 1 : int okc;
1172 : };
1173 :
1174 : #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
1175 : /** @brief Wi-Fi DPP configuration parameter */
1176 : /** Wi-Fi DPP QR-CODE in string max len for SHA512 */
1177 : #define WIFI_DPP_QRCODE_MAX_LEN 255
1178 :
1179 : /** Wi-Fi DPP operations */
1180 : enum wifi_dpp_op {
1181 : /** Unset invalid operation */
1182 : WIFI_DPP_OP_INVALID = 0,
1183 : /** Add configurator */
1184 : WIFI_DPP_CONFIGURATOR_ADD,
1185 : /** Start DPP auth as configurator or enrollee */
1186 : WIFI_DPP_AUTH_INIT,
1187 : /** Scan qr_code as parameter */
1188 : WIFI_DPP_QR_CODE,
1189 : /** Start DPP chirp to send DPP announcement */
1190 : WIFI_DPP_CHIRP,
1191 : /** Listen on specific frequency */
1192 : WIFI_DPP_LISTEN,
1193 : /** Generate a bootstrap like qrcode */
1194 : WIFI_DPP_BOOTSTRAP_GEN,
1195 : /** Get a bootstrap uri for external device to scan */
1196 : WIFI_DPP_BOOTSTRAP_GET_URI,
1197 : /** Set configurator parameters */
1198 : WIFI_DPP_SET_CONF_PARAM,
1199 : /** Set DPP rx response wait timeout */
1200 : WIFI_DPP_SET_WAIT_RESP_TIME,
1201 : /** Reconfigure DPP network */
1202 : WIFI_DPP_RECONFIG
1203 : };
1204 :
1205 : /** Wi-Fi DPP crypto Elliptic Curves */
1206 : enum wifi_dpp_curves {
1207 : /** Unset default use P-256 */
1208 : WIFI_DPP_CURVES_DEFAULT = 0,
1209 : /** prime256v1 */
1210 : WIFI_DPP_CURVES_P_256,
1211 : /** secp384r1 */
1212 : WIFI_DPP_CURVES_P_384,
1213 : /** secp521r1 */
1214 : WIFI_DPP_CURVES_P_512,
1215 : /** brainpoolP256r1 */
1216 : WIFI_DPP_CURVES_BP_256,
1217 : /** brainpoolP384r1 */
1218 : WIFI_DPP_CURVES_BP_384,
1219 : /** brainpoolP512r1 */
1220 : WIFI_DPP_CURVES_BP_512
1221 : };
1222 :
1223 : /** Wi-Fi DPP role */
1224 : enum wifi_dpp_role {
1225 : /** Unset role */
1226 : WIFI_DPP_ROLE_UNSET = 0,
1227 : /** Configurator passes AP config to enrollee */
1228 : WIFI_DPP_ROLE_CONFIGURATOR,
1229 : /** Enrollee gets AP config and connect to AP */
1230 : WIFI_DPP_ROLE_ENROLLEE,
1231 : /** Both configurator and enrollee might be chosen */
1232 : WIFI_DPP_ROLE_EITHER
1233 : };
1234 :
1235 : /** Wi-Fi DPP security type
1236 : *
1237 : * current only support DPP only AKM
1238 : */
1239 : enum wifi_dpp_conf {
1240 : /** Unset conf */
1241 : WIFI_DPP_CONF_UNSET = 0,
1242 : /** conf=sta-dpp, AKM DPP only for sta */
1243 : WIFI_DPP_CONF_STA,
1244 : /** conf=ap-dpp, AKM DPP only for ap */
1245 : WIFI_DPP_CONF_AP,
1246 : /** conf=query, query for AKM */
1247 : WIFI_DPP_CONF_QUERY
1248 : };
1249 :
1250 : /** Wi-Fi DPP bootstrap type
1251 : *
1252 : * current default and only support QR-CODE
1253 : */
1254 : enum wifi_dpp_bootstrap_type {
1255 : /** Unset type */
1256 : WIFI_DPP_BOOTSTRAP_TYPE_UNSET = 0,
1257 : /** qrcode */
1258 : WIFI_DPP_BOOTSTRAP_TYPE_QRCODE,
1259 : /** pkex */
1260 : WIFI_DPP_BOOTSTRAP_TYPE_PKEX,
1261 : /** nfc */
1262 : WIFI_DPP_BOOTSTRAP_TYPE_NFC_URI
1263 : };
1264 :
1265 : /** Params to add DPP configurator */
1266 : struct wifi_dpp_configurator_add_params {
1267 : /** ECP curves for private key */
1268 : int curve;
1269 : /** ECP curves for net access key */
1270 : int net_access_key_curve;
1271 : };
1272 :
1273 : /** Params to initiate a DPP auth procedure */
1274 : struct wifi_dpp_auth_init_params {
1275 : /** Peer bootstrap id */
1276 : int peer;
1277 : /** Configuration parameter id */
1278 : int configurator;
1279 : /** Role configurator or enrollee */
1280 : int role;
1281 : /** Security type */
1282 : int conf;
1283 : /** SSID in string */
1284 : char ssid[WIFI_SSID_MAX_LEN + 1];
1285 : };
1286 :
1287 : /** Params to do DPP chirp */
1288 : struct wifi_dpp_chirp_params {
1289 : /** Own bootstrap id */
1290 : int id;
1291 : /** Chirp on frequency */
1292 : int freq;
1293 : };
1294 :
1295 : /** Params to do DPP listen */
1296 : struct wifi_dpp_listen_params {
1297 : /** Listen on frequency */
1298 : int freq;
1299 : /** Role configurator or enrollee */
1300 : int role;
1301 : };
1302 :
1303 : /** Params to generate a DPP bootstrap */
1304 : struct wifi_dpp_bootstrap_gen_params {
1305 : /** Bootstrap type */
1306 : int type;
1307 : /** Own operating class */
1308 : int op_class;
1309 : /** Own working channel */
1310 : int chan;
1311 : /** ECP curves */
1312 : int curve;
1313 : /** Own mac address */
1314 : uint8_t mac[WIFI_MAC_ADDR_LEN];
1315 : };
1316 :
1317 : /** Params to set specific DPP configurator */
1318 : struct wifi_dpp_configurator_set_params {
1319 : /** Peer bootstrap id */
1320 : int peer;
1321 : /** Configuration parameter id */
1322 : int configurator;
1323 : /** Role configurator or enrollee */
1324 : int role;
1325 : /** Security type */
1326 : int conf;
1327 : /** ECP curves for private key */
1328 : int curve;
1329 : /** ECP curves for net access key */
1330 : int net_access_key_curve;
1331 : /** Own mac address */
1332 : char ssid[WIFI_SSID_MAX_LEN + 1];
1333 : };
1334 :
1335 : /** Wi-Fi DPP params for various operations
1336 : */
1337 : struct wifi_dpp_params {
1338 : /** Operation enum */
1339 : int action;
1340 : union {
1341 : /** Params to add DPP configurator */
1342 : struct wifi_dpp_configurator_add_params configurator_add;
1343 : /** Params to initiate a DPP auth procedure */
1344 : struct wifi_dpp_auth_init_params auth_init;
1345 : /** Params to do DPP chirp */
1346 : struct wifi_dpp_chirp_params chirp;
1347 : /** Params to do DPP listen */
1348 : struct wifi_dpp_listen_params listen;
1349 : /** Params to generate a DPP bootstrap */
1350 : struct wifi_dpp_bootstrap_gen_params bootstrap_gen;
1351 : /** Params to set specific DPP configurator */
1352 : struct wifi_dpp_configurator_set_params configurator_set;
1353 : /** Bootstrap get uri id */
1354 : int id;
1355 : /** Timeout for DPP frame response rx */
1356 : int dpp_resp_wait_time;
1357 : /** network id for reconfig */
1358 : int network_id;
1359 : /** DPP QR-CODE, max for SHA512 */
1360 : uint8_t dpp_qr_code[WIFI_DPP_QRCODE_MAX_LEN + 1];
1361 : /** Request response reusing request buffer.
1362 : * So once a request is sent, buffer will be
1363 : * fulfilled by response
1364 : */
1365 : char resp[WIFI_DPP_QRCODE_MAX_LEN + 1];
1366 : };
1367 : };
1368 : #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
1369 :
1370 0 : #define WIFI_WPS_PIN_MAX_LEN 8
1371 :
1372 : /** Operation for WPS */
1373 1 : enum wifi_wps_op {
1374 : /** WPS pbc */
1375 : WIFI_WPS_PBC = 0,
1376 : /** Get WPS pin number */
1377 : WIFI_WPS_PIN_GET = 1,
1378 : /** Set WPS pin number */
1379 : WIFI_WPS_PIN_SET = 2,
1380 : };
1381 :
1382 : /** Wi-Fi wps setup */
1383 1 : struct wifi_wps_config_params {
1384 : /** wps operation */
1385 1 : enum wifi_wps_op oper;
1386 : /** pin value*/
1387 1 : char pin[WIFI_WPS_PIN_MAX_LEN + 1];
1388 : };
1389 :
1390 : /** Wi-Fi AP status
1391 : */
1392 0 : enum wifi_sap_iface_state {
1393 : WIFI_SAP_IFACE_UNINITIALIZED,
1394 : WIFI_SAP_IFACE_DISABLED,
1395 : WIFI_SAP_IFACE_COUNTRY_UPDATE,
1396 : WIFI_SAP_IFACE_ACS,
1397 : WIFI_SAP_IFACE_HT_SCAN,
1398 : WIFI_SAP_IFACE_DFS,
1399 : WIFI_SAP_IFACE_NO_IR,
1400 : WIFI_SAP_IFACE_ENABLED
1401 : };
1402 :
1403 : #if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT_BGSCAN) || defined(__DOXYGEN__)
1404 : /** @brief Wi-Fi background scan implementation */
1405 1 : enum wifi_bgscan_type {
1406 : /** None, background scan is disabled */
1407 : WIFI_BGSCAN_NONE = 0,
1408 : /** Simple, periodic scan based on signal strength */
1409 : WIFI_BGSCAN_SIMPLE,
1410 : /** Learn channels used by the network (experimental) */
1411 : WIFI_BGSCAN_LEARN,
1412 : };
1413 :
1414 : /** @brief Wi-Fi background scan parameters */
1415 1 : struct wifi_bgscan_params {
1416 : /** The type of background scanning */
1417 1 : enum wifi_bgscan_type type;
1418 : /** Short scan interval in seconds */
1419 1 : uint16_t short_interval;
1420 : /** Long scan interval in seconds */
1421 1 : uint16_t long_interval;
1422 : /** Signal strength threshold in dBm */
1423 1 : int8_t rssi_threshold;
1424 : /** Number of BSS Transition Management (BTM) queries */
1425 1 : uint16_t btm_queries;
1426 : };
1427 : #endif
1428 :
1429 : /* Extended Capabilities */
1430 0 : enum wifi_ext_capab {
1431 : WIFI_EXT_CAPAB_20_40_COEX = 0,
1432 : WIFI_EXT_CAPAB_GLK = 1,
1433 : WIFI_EXT_CAPAB_EXT_CHAN_SWITCH = 2,
1434 : WIFI_EXT_CAPAB_TIM_BROADCAST = 18,
1435 : WIFI_EXT_CAPAB_BSS_TRANSITION = 19,
1436 : };
1437 :
1438 : #include <zephyr/net/net_if.h>
1439 :
1440 : /** Scan result callback
1441 : *
1442 : * @param iface Network interface
1443 : * @param status Scan result status
1444 : * @param entry Scan result entry
1445 : */
1446 1 : typedef void (*scan_result_cb_t)(struct net_if *iface, int status,
1447 : struct wifi_scan_result *entry);
1448 :
1449 : #ifdef CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS
1450 : /** Raw scan result callback
1451 : *
1452 : * @param iface Network interface
1453 : * @param status Raw scan result status
1454 : * @param entry Raw scan result entry
1455 : */
1456 : typedef void (*raw_scan_result_cb_t)(struct net_if *iface, int status,
1457 : struct wifi_raw_scan_result *entry);
1458 : #endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */
1459 :
1460 : /** Wi-Fi management API */
1461 1 : struct wifi_mgmt_ops {
1462 : /** Scan for Wi-Fi networks
1463 : *
1464 : * @param dev Pointer to the device structure for the driver instance.
1465 : * @param params Scan parameters
1466 : * @param cb Callback to be called for each result
1467 : * cb parameter is the cb that should be called for each
1468 : * result by the driver. The wifi mgmt part will take care of
1469 : * raising the necessary event etc.
1470 : *
1471 : * @return 0 if ok, < 0 if error
1472 : */
1473 1 : int (*scan)(const struct device *dev,
1474 : struct wifi_scan_params *params,
1475 : scan_result_cb_t cb);
1476 : /** Connect to a Wi-Fi network
1477 : *
1478 : * @param dev Pointer to the device structure for the driver instance.
1479 : * @param params Connect parameters
1480 : *
1481 : * @return 0 if ok, < 0 if error
1482 : */
1483 1 : int (*connect)(const struct device *dev,
1484 : struct wifi_connect_req_params *params);
1485 : /** Disconnect from a Wi-Fi network
1486 : *
1487 : * @param dev Pointer to the device structure for the driver instance.
1488 : *
1489 : * @return 0 if ok, < 0 if error
1490 : */
1491 1 : int (*disconnect)(const struct device *dev);
1492 : /** Enable AP mode
1493 : *
1494 : * @param dev Pointer to the device structure for the driver instance.
1495 : * @param params AP mode parameters
1496 : *
1497 : * @return 0 if ok, < 0 if error
1498 : */
1499 1 : int (*ap_enable)(const struct device *dev,
1500 : struct wifi_connect_req_params *params);
1501 : /** Disable AP mode
1502 : *
1503 : * @param dev Pointer to the device structure for the driver instance.
1504 : *
1505 : * @return 0 if ok, < 0 if error
1506 : */
1507 1 : int (*ap_disable)(const struct device *dev);
1508 : /** Disconnect a STA from AP
1509 : *
1510 : * @param dev Pointer to the device structure for the driver instance.
1511 : * @param mac MAC address of the STA to disconnect
1512 : *
1513 : * @return 0 if ok, < 0 if error
1514 : */
1515 1 : int (*ap_sta_disconnect)(const struct device *dev, const uint8_t *mac);
1516 : /** Get interface status
1517 : *
1518 : * @param dev Pointer to the device structure for the driver instance.
1519 : * @param status Interface status
1520 : *
1521 : * @return 0 if ok, < 0 if error
1522 : */
1523 1 : int (*iface_status)(const struct device *dev, struct wifi_iface_status *status);
1524 : #if defined(CONFIG_NET_STATISTICS_WIFI) || defined(__DOXYGEN__)
1525 : /** Get Wi-Fi statistics
1526 : *
1527 : * @param dev Pointer to the device structure for the driver instance.
1528 : * @param stats Wi-Fi statistics
1529 : *
1530 : * @return 0 if ok, < 0 if error
1531 : */
1532 1 : int (*get_stats)(const struct device *dev, struct net_stats_wifi *stats);
1533 : /** Reset Wi-Fi statistics
1534 : *
1535 : * @param dev Pointer to the device structure for the driver instance.
1536 : *
1537 : * @return 0 if ok, < 0 if error
1538 : */
1539 1 : int (*reset_stats)(const struct device *dev);
1540 : #endif /* CONFIG_NET_STATISTICS_WIFI */
1541 : /** Set or get 11K status
1542 : *
1543 : * @param dev Pointer to the device structure for the driver instance.
1544 : * @param params 11k parameters
1545 : *
1546 : * @return 0 if ok, < 0 if error
1547 : */
1548 1 : int (*cfg_11k)(const struct device *dev, struct wifi_11k_params *params);
1549 : /** Send 11k neighbor request
1550 : *
1551 : * @param dev Pointer to the device structure for the driver instance.
1552 : * @param params 11k parameters
1553 : *
1554 : * @return 0 if ok, < 0 if error
1555 : */
1556 1 : int (*send_11k_neighbor_request)(const struct device *dev, struct wifi_11k_params *params);
1557 : /** Set power save status
1558 : *
1559 : * @param dev Pointer to the device structure for the driver instance.
1560 : * @param params Power save parameters
1561 : *
1562 : * @return 0 if ok, < 0 if error
1563 : */
1564 1 : int (*set_power_save)(const struct device *dev, struct wifi_ps_params *params);
1565 : /** Setup or teardown TWT flow
1566 : *
1567 : * @param dev Pointer to the device structure for the driver instance.
1568 : * @param params TWT parameters
1569 : *
1570 : * @return 0 if ok, < 0 if error
1571 : */
1572 1 : int (*set_twt)(const struct device *dev, struct wifi_twt_params *params);
1573 : /** Setup BTWT flow
1574 : *
1575 : * @param dev Pointer to the device structure for the driver instance.
1576 : * @param params BTWT parameters
1577 : *
1578 : * @return 0 if ok, < 0 if error
1579 : */
1580 1 : int (*set_btwt)(const struct device *dev, struct wifi_twt_params *params);
1581 : /** Get power save config
1582 : *
1583 : * @param dev Pointer to the device structure for the driver instance.
1584 : * @param config Power save config
1585 : *
1586 : * @return 0 if ok, < 0 if error
1587 : */
1588 1 : int (*get_power_save_config)(const struct device *dev, struct wifi_ps_config *config);
1589 : /** Set or get regulatory domain
1590 : *
1591 : * @param dev Pointer to the device structure for the driver instance.
1592 : * @param reg_domain Regulatory domain
1593 : *
1594 : * @return 0 if ok, < 0 if error
1595 : */
1596 1 : int (*reg_domain)(const struct device *dev, struct wifi_reg_domain *reg_domain);
1597 : /** Set or get packet filter settings for monitor and promiscuous modes
1598 : *
1599 : * @param dev Pointer to the device structure for the driver instance.
1600 : * @param packet filter settings
1601 : *
1602 : * @return 0 if ok, < 0 if error
1603 : */
1604 1 : int (*filter)(const struct device *dev, struct wifi_filter_info *filter);
1605 : /** Set or get mode of operation
1606 : *
1607 : * @param dev Pointer to the device structure for the driver instance.
1608 : * @param mode settings
1609 : *
1610 : * @return 0 if ok, < 0 if error
1611 : */
1612 1 : int (*mode)(const struct device *dev, struct wifi_mode_info *mode);
1613 : /** Set or get current channel of operation
1614 : *
1615 : * @param dev Pointer to the device structure for the driver instance.
1616 : * @param channel settings
1617 : *
1618 : * @return 0 if ok, < 0 if error
1619 : */
1620 1 : int (*channel)(const struct device *dev, struct wifi_channel_info *channel);
1621 :
1622 : /** Send BTM query
1623 : *
1624 : * @param dev Pointer to the device structure for the driver instance.
1625 : * @param reason query reason
1626 : *
1627 : * @return 0 if ok, < 0 if error
1628 : */
1629 1 : int (*btm_query)(const struct device *dev, uint8_t reason);
1630 :
1631 : /** Check if ap support Neighbor Report or not.
1632 : * @param dev Pointer to the device structure for the driver instance.
1633 : *
1634 : * @return true if support, false if not support
1635 : */
1636 1 : bool (*bss_support_neighbor_rep)(const struct device *dev);
1637 :
1638 : /** Judge ap whether support the capability
1639 : *
1640 : * @param dev Pointer to the device structure for the driver instance.
1641 : * @param capab is the capability to judge
1642 : *
1643 : * @return 1 if support, 0 if not support
1644 : */
1645 1 : int (*bss_ext_capab)(const struct device *dev, int capab);
1646 :
1647 : /** Send legacy scan
1648 : *
1649 : * @param dev Pointer to the device structure for the driver instance.
1650 : *
1651 : * @return 0 if ok, < 0 if error
1652 : */
1653 1 : int (*legacy_roam)(const struct device *dev);
1654 :
1655 : /** Get Version of WiFi driver and Firmware
1656 : *
1657 : * The driver that implements the get_version function must not use stack to allocate the
1658 : * version information pointers that are returned as params struct members.
1659 : * The version pointer parameters should point to a static memory either in ROM (preferred)
1660 : * or in RAM.
1661 : *
1662 : * @param dev Pointer to the device structure for the driver instance
1663 : * @param params Version parameters
1664 : *
1665 : * @return 0 if ok, < 0 if error
1666 : */
1667 1 : int (*get_version)(const struct device *dev, struct wifi_version *params);
1668 : /** Get Wi-Fi connection parameters recently used
1669 : *
1670 : * @param dev Pointer to the device structure for the driver instance
1671 : * @param params the Wi-Fi connection parameters recently used
1672 : *
1673 : * @return 0 if ok, < 0 if error
1674 : */
1675 1 : int (*get_conn_params)(const struct device *dev, struct wifi_connect_req_params *params);
1676 : /** Set RTS threshold value
1677 : *
1678 : * @param dev Pointer to the device structure for the driver instance.
1679 : * @param RTS threshold value
1680 : *
1681 : * @return 0 if ok, < 0 if error
1682 : */
1683 1 : int (*set_rts_threshold)(const struct device *dev, unsigned int rts_threshold);
1684 : /** Configure AP parameter
1685 : *
1686 : * @param dev Pointer to the device structure for the driver instance.
1687 : * @param params AP mode parameter configuration parameter info
1688 : *
1689 : * @return 0 if ok, < 0 if error
1690 : */
1691 1 : int (*ap_config_params)(const struct device *dev, struct wifi_ap_config_params *params);
1692 : /** Configure STA parameter
1693 : *
1694 : * @param dev Pointer to the device structure for the driver instance.
1695 : * @param params STA mode parameter configuration parameter info
1696 : *
1697 : * @return 0 if ok, < 0 if error
1698 : */
1699 1 : int (*config_params)(const struct device *dev, struct wifi_config_params *params);
1700 : #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP
1701 : /** Dispatch DPP operations by action enum, with or without arguments in string format
1702 : *
1703 : * @param dev Pointer to the device structure for the driver instance
1704 : * @param params DPP action enum and parameters in string
1705 : *
1706 : * @return 0 if ok, < 0 if error
1707 : */
1708 : int (*dpp_dispatch)(const struct device *dev, struct wifi_dpp_params *params);
1709 : #endif /* CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP */
1710 : /** Flush PMKSA cache entries
1711 : *
1712 : * @param dev Pointer to the device structure for the driver instance.
1713 : *
1714 : * @return 0 if ok, < 0 if error
1715 : */
1716 1 : int (*pmksa_flush)(const struct device *dev);
1717 : /** Set Wi-Fi enterprise mode CA/client Cert and key
1718 : *
1719 : * @param dev Pointer to the device structure for the driver instance.
1720 : * @param creds Pointer to the CA/client Cert and key.
1721 : *
1722 : * @return 0 if ok, < 0 if error
1723 : */
1724 : #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_CRYPTO_ENTERPRISE
1725 : int (*enterprise_creds)(const struct device *dev,
1726 : struct wifi_enterprise_creds_params *creds);
1727 : #endif
1728 : /** Get RTS threshold value
1729 : *
1730 : * @param dev Pointer to the device structure for the driver instance.
1731 : * @param rts_threshold Pointer to the RTS threshold value.
1732 : *
1733 : * @return 0 if ok, < 0 if error
1734 : */
1735 1 : int (*get_rts_threshold)(const struct device *dev, unsigned int *rts_threshold);
1736 : /** Start a WPS PBC/PIN connection
1737 : *
1738 : * @param dev Pointer to the device structure for the driver instance
1739 : * @param params wps operarion parameters
1740 : *
1741 : * @return 0 if ok, < 0 if error
1742 : */
1743 1 : int (*wps_config)(const struct device *dev, struct wifi_wps_config_params *params);
1744 : /** Trigger candidate scan
1745 : *
1746 : * @param dev Pointer to the device structure for the driver instance
1747 : * @param params Scan parameters
1748 : *
1749 : * @return 0 if ok, < 0 if error
1750 : */
1751 1 : int (*candidate_scan)(const struct device *dev, struct wifi_scan_params *params);
1752 : /** Start 11r roaming
1753 : *
1754 : * @param dev Pointer to the device structure for the driver instance
1755 : *
1756 : * @return 0 if ok, < 0 if error
1757 : */
1758 1 : int (*start_11r_roaming)(const struct device *dev);
1759 : /** Set BSS max idle period
1760 : *
1761 : * @param dev Pointer to the device structure for the driver instance.
1762 : * @param BSS max idle period value
1763 : *
1764 : * @return 0 if ok, < 0 if error
1765 : */
1766 1 : int (*set_bss_max_idle_period)(const struct device *dev,
1767 : unsigned short bss_max_idle_period);
1768 : #if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT_BGSCAN) || defined(__DOXYGEN__)
1769 : /** Configure background scanning
1770 : *
1771 : * @param dev Pointer to the device structure for the driver instance.
1772 : * @param params Background scanning configuration parameters
1773 : *
1774 : * @return 0 if ok, < 0 if error
1775 : */
1776 1 : int (*set_bgscan)(const struct device *dev, struct wifi_bgscan_params *params);
1777 : #endif
1778 : };
1779 :
1780 : /** Wi-Fi management offload API */
1781 1 : struct net_wifi_mgmt_offload {
1782 : /**
1783 : * Mandatory to get in first position.
1784 : * A network device should indeed provide a pointer on such
1785 : * net_if_api structure. So we make current structure pointer
1786 : * that can be casted to a net_if_api structure pointer.
1787 : */
1788 : #if defined(CONFIG_WIFI_USE_NATIVE_NETWORKING) || defined(__DOXYGEN__)
1789 : /** Ethernet API */
1790 1 : struct ethernet_api wifi_iface;
1791 : #else
1792 : /** Offloaded network device API */
1793 : struct offloaded_if_api wifi_iface;
1794 : #endif
1795 : /** Wi-Fi management API */
1796 1 : const struct wifi_mgmt_ops *const wifi_mgmt_api;
1797 :
1798 : #if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT) || defined(__DOXYGEN__)
1799 : /** Wi-Fi supplicant driver API */
1800 1 : const void *wifi_drv_ops;
1801 : #endif
1802 : };
1803 :
1804 : #if defined(CONFIG_WIFI_NM_WPA_SUPPLICANT)
1805 : /* Make sure wifi_drv_ops is after wifi_mgmt_api */
1806 : BUILD_ASSERT(offsetof(struct net_wifi_mgmt_offload, wifi_mgmt_api) <
1807 : offsetof(struct net_wifi_mgmt_offload, wifi_drv_ops));
1808 : #endif
1809 :
1810 : /* Make sure that the network interface API is properly setup inside
1811 : * Wifi mgmt offload API struct (it is the first one).
1812 : */
1813 : BUILD_ASSERT(offsetof(struct net_wifi_mgmt_offload, wifi_iface) == 0);
1814 :
1815 : /** Wi-Fi management connect result event
1816 : *
1817 : * @param iface Network interface
1818 : * @param status Connect result status
1819 : */
1820 1 : void wifi_mgmt_raise_connect_result_event(struct net_if *iface, int status);
1821 :
1822 : /** Wi-Fi management disconnect result event
1823 : *
1824 : * @param iface Network interface
1825 : * @param status Disconnect result status
1826 : */
1827 1 : void wifi_mgmt_raise_disconnect_result_event(struct net_if *iface, int status);
1828 :
1829 : /** Wi-Fi management interface status event
1830 : *
1831 : * @param iface Network interface
1832 : * @param iface_status Interface status
1833 : */
1834 1 : void wifi_mgmt_raise_iface_status_event(struct net_if *iface,
1835 : struct wifi_iface_status *iface_status);
1836 :
1837 : /** Wi-Fi management TWT event
1838 : *
1839 : * @param iface Network interface
1840 : * @param twt_params TWT parameters
1841 : */
1842 1 : void wifi_mgmt_raise_twt_event(struct net_if *iface,
1843 : struct wifi_twt_params *twt_params);
1844 :
1845 : /** Wi-Fi management TWT sleep state event
1846 : *
1847 : * @param iface Network interface
1848 : * @param twt_sleep_state TWT sleep state
1849 : */
1850 1 : void wifi_mgmt_raise_twt_sleep_state(struct net_if *iface, int twt_sleep_state);
1851 :
1852 : #if defined(CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS) || defined(__DOXYGEN__)
1853 : /** Wi-Fi management raw scan result event
1854 : *
1855 : * @param iface Network interface
1856 : * @param raw_scan_info Raw scan result
1857 : */
1858 1 : void wifi_mgmt_raise_raw_scan_result_event(struct net_if *iface,
1859 : struct wifi_raw_scan_result *raw_scan_info);
1860 : #endif /* CONFIG_WIFI_MGMT_RAW_SCAN_RESULTS */
1861 :
1862 : /** Wi-Fi management disconnect complete event
1863 : *
1864 : * @param iface Network interface
1865 : * @param status Disconnect complete status
1866 : */
1867 1 : void wifi_mgmt_raise_disconnect_complete_event(struct net_if *iface, int status);
1868 :
1869 : #ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_ROAMING
1870 : /** Wi-Fi management neighbor reports event
1871 : *
1872 : * @param iface Network interface
1873 : * @param inbuf Input buffer of neighbor reports
1874 : * @param buf_len Lenghth of input buffer
1875 : */
1876 : void wifi_mgmt_raise_neighbor_rep_recv_event(struct net_if *iface,
1877 : char *inbuf, size_t buf_len);
1878 : #endif
1879 :
1880 : /** Wi-Fi management AP mode enable result event
1881 : *
1882 : * @param iface Network interface
1883 : * @param status AP mode enable result status
1884 : */
1885 1 : void wifi_mgmt_raise_ap_enable_result_event(struct net_if *iface, enum wifi_ap_status status);
1886 :
1887 : /** Wi-Fi management AP mode disable result event
1888 : *
1889 : * @param iface Network interface
1890 : * @param status AP mode disable result status
1891 : */
1892 1 : void wifi_mgmt_raise_ap_disable_result_event(struct net_if *iface, enum wifi_ap_status status);
1893 :
1894 : /** Wi-Fi management AP mode STA connected event
1895 : *
1896 : * @param iface Network interface
1897 : * @param sta_info STA information
1898 : */
1899 1 : void wifi_mgmt_raise_ap_sta_connected_event(struct net_if *iface,
1900 : struct wifi_ap_sta_info *sta_info);
1901 :
1902 : /** Wi-Fi management AP mode STA disconnected event
1903 : * @param iface Network interface
1904 : * @param sta_info STA information
1905 : */
1906 1 : void wifi_mgmt_raise_ap_sta_disconnected_event(struct net_if *iface,
1907 : struct wifi_ap_sta_info *sta_info);
1908 :
1909 : /**
1910 : * @}
1911 : */
1912 : #ifdef __cplusplus
1913 : }
1914 : #endif
1915 :
1916 : #endif /* ZEPHYR_INCLUDE_NET_WIFI_MGMT_H_ */
|