Skip to content

Commit 1640826

Browse files
fengming-yenashif
authored andcommitted
net: wifi_mgmt: add hostap DPP support
Add wifi l2 mgmt dpp handlers. Add wifi subcommand dpp to call l2 mgmt dpp handlers. DPP l2 handlers will parse params to hostap wpa_cli format args and send wpa_cli commands to hostap. Signed-off-by: Fengming Ye <[email protected]>
1 parent 37491cb commit 1640826

File tree

5 files changed

+486
-0
lines changed

5 files changed

+486
-0
lines changed

include/zephyr/net/wifi_mgmt.h

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/*
22
* Copyright (c) 2017 Intel Corporation.
3+
* Copyright 2024 NXP
34
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
@@ -91,6 +92,8 @@ enum net_request_wifi_cmd {
9192
NET_REQUEST_WIFI_CMD_RTS_THRESHOLD,
9293
/** Configure AP parameter */
9394
NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM,
95+
/** DPP actions */
96+
NET_REQUEST_WIFI_CMD_DPP,
9497
/** @cond INTERNAL_HIDDEN */
9598
NET_REQUEST_WIFI_CMD_MAX
9699
/** @endcond */
@@ -198,6 +201,12 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD);
198201

199202
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM);
200203

204+
/** Request a Wi-Fi DPP operation */
205+
#define NET_REQUEST_WIFI_DPP \
206+
(_NET_WIFI_BASE | NET_REQUEST_WIFI_CMD_DPP)
207+
208+
NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_DPP);
209+
201210
/** @brief Wi-Fi management events */
202211
enum net_event_wifi_cmd {
203212
/** Scan results available */
@@ -768,6 +777,178 @@ struct wifi_ap_config_params {
768777
uint32_t max_num_sta;
769778
};
770779

780+
/** @brief Wi-Fi DPP configuration parameter */
781+
/** Wi-Fi DPP QR-CODE in string max len for SHA512 */
782+
#define WIFI_DPP_QRCODE_MAX_LEN 255
783+
784+
/** Wi-Fi DPP operations */
785+
enum wifi_dpp_op {
786+
/** Unset invalid operation */
787+
WIFI_DPP_OP_INVALID = 0,
788+
/** Add configurator */
789+
WIFI_DPP_CONFIGURATOR_ADD,
790+
/** Start DPP auth as configurator or enrollee */
791+
WIFI_DPP_AUTH_INIT,
792+
/** Scan qr_code as parameter */
793+
WIFI_DPP_QR_CODE,
794+
/** Start DPP chirp to send DPP announcement */
795+
WIFI_DPP_CHIRP,
796+
/** Listen on specific frequency */
797+
WIFI_DPP_LISTEN,
798+
/** Generate a bootstrap like qrcode */
799+
WIFI_DPP_BOOTSTRAP_GEN,
800+
/** Get a bootstrap uri for external device to scan */
801+
WIFI_DPP_BOOTSTRAP_GET_URI,
802+
/** Set configurator parameters */
803+
WIFI_DPP_SET_CONF_PARAM,
804+
/** Set DPP rx response wait timeout */
805+
WIFI_DPP_SET_WAIT_RESP_TIME
806+
};
807+
808+
/** Wi-Fi DPP crypto Elliptic Curves */
809+
enum wifi_dpp_curves {
810+
/** Unset default use P-256 */
811+
WIFI_DPP_CURVES_DEFAULT = 0,
812+
/** prime256v1 */
813+
WIFI_DPP_CURVES_P_256,
814+
/** secp384r1 */
815+
WIFI_DPP_CURVES_P_384,
816+
/** secp521r1 */
817+
WIFI_DPP_CURVES_P_512,
818+
/** brainpoolP256r1 */
819+
WIFI_DPP_CURVES_BP_256,
820+
/** brainpoolP384r1 */
821+
WIFI_DPP_CURVES_BP_384,
822+
/** brainpoolP512r1 */
823+
WIFI_DPP_CURVES_BP_512
824+
};
825+
826+
/** Wi-Fi DPP role */
827+
enum wifi_dpp_role {
828+
/** Unset role */
829+
WIFI_DPP_ROLE_UNSET = 0,
830+
/** Configurator passes AP config to enrollee */
831+
WIFI_DPP_ROLE_CONFIGURATOR,
832+
/** Enrollee gets AP config and connect to AP */
833+
WIFI_DPP_ROLE_ENROLLEE,
834+
/** Both configurator and enrollee might be chosen */
835+
WIFI_DPP_ROLE_EITHER
836+
};
837+
838+
/** Wi-Fi DPP security type
839+
*
840+
* current only support DPP only AKM
841+
*/
842+
enum wifi_dpp_conf {
843+
/** Unset conf */
844+
WIFI_DPP_CONF_UNSET = 0,
845+
/** conf=sta-dpp, AKM DPP only for sta */
846+
WIFI_DPP_CONF_STA,
847+
/** conf=ap-dpp, AKM DPP only for ap */
848+
WIFI_DPP_CONF_AP,
849+
/** conf=query, query for AKM */
850+
WIFI_DPP_CONF_QUERY
851+
};
852+
853+
/** Wi-Fi DPP bootstrap type
854+
*
855+
* current default and only support QR-CODE
856+
*/
857+
enum wifi_dpp_bootstrap_type {
858+
/** Unset type */
859+
WIFI_DPP_BOOTSTRAP_TYPE_UNSET = 0,
860+
/** qrcode */
861+
WIFI_DPP_BOOTSTRAP_TYPE_QRCODE,
862+
/** pkex */
863+
WIFI_DPP_BOOTSTRAP_TYPE_PKEX,
864+
/** nfc */
865+
WIFI_DPP_BOOTSTRAP_TYPE_NFC_URI
866+
};
867+
868+
/** Wi-Fi DPP params for various operations
869+
*/
870+
struct wifi_dpp_params {
871+
/** Operation enum */
872+
int action;
873+
union {
874+
/** Params to add DPP configurator */
875+
struct wifi_dpp_configurator_add_params {
876+
/** ECP curves for private key */
877+
int curve;
878+
/** ECP curves for net access key */
879+
int net_access_key_curve;
880+
} configurator_add;
881+
/** Params to initiate a DPP auth procedure */
882+
struct wifi_dpp_auth_init_params {
883+
/** Peer bootstrap id */
884+
int peer;
885+
/** Configuration parameter id */
886+
int configurator;
887+
/** Role configurator or enrollee */
888+
int role;
889+
/** Security type */
890+
int conf;
891+
/** SSID in string */
892+
char ssid[WIFI_SSID_MAX_LEN + 1];
893+
} auth_init;
894+
/** Params to do DPP chirp */
895+
struct wifi_dpp_chirp_params {
896+
/** Own bootstrap id */
897+
int id;
898+
/** Chirp on frequency */
899+
int freq;
900+
} chirp;
901+
/** Params to do DPP listen */
902+
struct wifi_dpp_listen_params {
903+
/** Listen on frequency */
904+
int freq;
905+
/** Role configurator or enrollee */
906+
int role;
907+
} listen;
908+
/** Params to generate a DPP bootstrap */
909+
struct wifi_dpp_bootstrap_gen_params {
910+
/** Bootstrap type */
911+
int type;
912+
/** Own operating class */
913+
int op_class;
914+
/** Own working channel */
915+
int chan;
916+
/** ECP curves */
917+
int curve;
918+
/** Own mac address */
919+
uint8_t mac[WIFI_MAC_ADDR_LEN];
920+
} bootstrap_gen;
921+
/** Params to set specific DPP configurator */
922+
struct wifi_dpp_configurator_set_params {
923+
/** Peer bootstrap id */
924+
int peer;
925+
/** Configuration parameter id */
926+
int configurator;
927+
/** Role configurator or enrollee */
928+
int role;
929+
/** Security type */
930+
int conf;
931+
/** ECP curves for private key */
932+
int curve;
933+
/** ECP curves for net access key */
934+
int net_access_key_curve;
935+
/** Own mac address */
936+
char ssid[WIFI_SSID_MAX_LEN + 1];
937+
} configurator_set;
938+
/** Bootstrap get uri id */
939+
int id;
940+
/** Timeout for DPP frame response rx */
941+
int dpp_resp_wait_time;
942+
/** DPP QR-CODE, max for SHA512 */
943+
uint8_t dpp_qr_code[WIFI_DPP_QRCODE_MAX_LEN + 1];
944+
/** Request response reusing request buffer.
945+
* So once a request is sent, buffer will be
946+
* fulfilled by response
947+
*/
948+
char resp[WIFI_DPP_QRCODE_MAX_LEN + 1];
949+
};
950+
};
951+
771952
#include <zephyr/net/net_if.h>
772953

773954
/** Scan result callback
@@ -956,6 +1137,14 @@ struct wifi_mgmt_ops {
9561137
* @return 0 if ok, < 0 if error
9571138
*/
9581139
int (*ap_config_params)(const struct device *dev, struct wifi_ap_config_params *params);
1140+
/** Dispatch DPP operations by action enum, with or without arguments in string format
1141+
*
1142+
* @param dev Pointer to the device structure for the driver instance
1143+
* @param params DPP action enum and parameters in string
1144+
*
1145+
* @return 0 if ok, < 0 if error
1146+
*/
1147+
int (*dpp_dispatch)(const struct device *dev, struct wifi_dpp_params *params);
9591148
};
9601149

9611150
/** Wi-Fi management offload API */

0 commit comments

Comments
 (0)