|
1 | 1 | /* |
2 | 2 | * Copyright (c) 2017 Intel Corporation. |
| 3 | + * Copyright 2024 NXP |
3 | 4 | * |
4 | 5 | * SPDX-License-Identifier: Apache-2.0 |
5 | 6 | */ |
@@ -91,6 +92,8 @@ enum net_request_wifi_cmd { |
91 | 92 | NET_REQUEST_WIFI_CMD_RTS_THRESHOLD, |
92 | 93 | /** Configure AP parameter */ |
93 | 94 | NET_REQUEST_WIFI_CMD_AP_CONFIG_PARAM, |
| 95 | + /** DPP actions */ |
| 96 | + NET_REQUEST_WIFI_CMD_DPP, |
94 | 97 | /** @cond INTERNAL_HIDDEN */ |
95 | 98 | NET_REQUEST_WIFI_CMD_MAX |
96 | 99 | /** @endcond */ |
@@ -198,6 +201,12 @@ NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_RTS_THRESHOLD); |
198 | 201 |
|
199 | 202 | NET_MGMT_DEFINE_REQUEST_HANDLER(NET_REQUEST_WIFI_AP_CONFIG_PARAM); |
200 | 203 |
|
| 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 | + |
201 | 210 | /** @brief Wi-Fi management events */ |
202 | 211 | enum net_event_wifi_cmd { |
203 | 212 | /** Scan results available */ |
@@ -768,6 +777,178 @@ struct wifi_ap_config_params { |
768 | 777 | uint32_t max_num_sta; |
769 | 778 | }; |
770 | 779 |
|
| 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 | + |
771 | 952 | #include <zephyr/net/net_if.h> |
772 | 953 |
|
773 | 954 | /** Scan result callback |
@@ -956,6 +1137,14 @@ struct wifi_mgmt_ops { |
956 | 1137 | * @return 0 if ok, < 0 if error |
957 | 1138 | */ |
958 | 1139 | 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); |
959 | 1148 | }; |
960 | 1149 |
|
961 | 1150 | /** Wi-Fi management offload API */ |
|
0 commit comments