net: wifi: change the acquisition of wifi interface

For WiFi interface, uniformly use net_if_get_wifi_sta() and
net_if_get_wifi_sap() APIs to replace net_if_get_first_wifi().

Signed-off-by: Gang Li <gang.li_1@nxp.com>
This commit is contained in:
Gang Li 2024-12-04 05:29:18 +01:00 committed by Benjamin Cabé
commit 5a383919a0

View file

@ -1056,7 +1056,7 @@ static int wifi_scan_args_to_params(const struct shell *sh,
static int cmd_wifi_scan(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_scan_params params = { 0 };
bool do_scan = true;
int opt_num;
@ -1092,7 +1092,7 @@ static int cmd_wifi_scan(const struct shell *sh, size_t argc, char *argv[])
static int cmd_wifi_status(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_iface_status status = { 0 };
context.sh = sh;
@ -1226,7 +1226,7 @@ static int cmd_wifi_stats(const struct shell *sh, size_t argc, char *argv[])
{
#if defined(CONFIG_NET_STATISTICS_WIFI) && \
defined(CONFIG_NET_STATISTICS_USER_API)
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct net_stats_wifi stats = { 0 };
int ret;
@ -1269,7 +1269,7 @@ static int cmd_wifi_stats(const struct shell *sh, size_t argc, char *argv[])
static int cmd_wifi_11k(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_11k_params params = { 0 };
context.sh = sh;
@ -1310,7 +1310,7 @@ static int cmd_wifi_11k(const struct shell *sh, size_t argc, char *argv[])
static int cmd_wifi_11k_neighbor_request(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_11k_params params = { 0 };
context.sh = sh;
@ -1347,7 +1347,7 @@ static int cmd_wifi_11k_neighbor_request(const struct shell *sh, size_t argc, ch
static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_ps_params params = { 0 };
context.sh = sh;
@ -1435,7 +1435,7 @@ static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
static int cmd_wifi_ps_mode(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_ps_params params = { 0 };
context.sh = sh;
@ -1465,7 +1465,7 @@ static int cmd_wifi_ps_mode(const struct shell *sh, size_t argc, char *argv[])
static int cmd_wifi_ps_timeout(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_ps_params params = { 0 };
long timeout_ms = 0;
int err = 0;
@ -1500,7 +1500,7 @@ static int cmd_wifi_ps_timeout(const struct shell *sh, size_t argc, char *argv[]
static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_twt_params params = { 0 };
int idx = 1;
long value;
@ -1547,7 +1547,7 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_twt_params params = { 0 };
int idx = 1;
long value;
@ -1632,7 +1632,7 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
static int cmd_wifi_twt_teardown(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_twt_params params = { 0 };
long value;
@ -1682,7 +1682,7 @@ static int cmd_wifi_twt_teardown(const struct shell *sh, size_t argc,
static int cmd_wifi_twt_teardown_all(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_twt_params params = { 0 };
context.sh = sh;
@ -1806,11 +1806,7 @@ static int cmd_wifi_ap_stations(const struct shell *sh, size_t argc,
static int cmd_wifi_ap_sta_disconnect(const struct shell *sh, size_t argc,
char *argv[])
{
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
struct net_if *iface = net_if_get_wifi_sap();
#else
struct net_if *iface = net_if_get_first_wifi();
#endif
uint8_t mac[6];
int ret;
@ -1879,11 +1875,7 @@ static int wifi_ap_config_args_to_params(const struct shell *sh, size_t argc, ch
static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc,
char *argv[])
{
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
struct net_if *iface = net_if_get_wifi_sap();
#else
struct net_if *iface = net_if_get_first_wifi();
#endif
struct wifi_ap_config_params ap_config_params = { 0 };
int ret = -1;
@ -1907,7 +1899,7 @@ static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc,
static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_reg_domain regd = {0};
int ret, chan_idx = 0;
@ -1976,7 +1968,7 @@ static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
static int cmd_wifi_listen_interval(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_ps_params params = { 0 };
long interval;
@ -2011,7 +2003,7 @@ static int cmd_wifi_listen_interval(const struct shell *sh, size_t argc, char *a
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM
static int cmd_wifi_btm_query(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
uint8_t query_reason = 0;
long tmp = 0;
@ -2139,7 +2131,7 @@ static int cmd_wifi_ap_wps_pin(const struct shell *sh, size_t argc, char *argv[]
static int cmd_wifi_ps_wakeup_mode(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_ps_params params = { 0 };
context.sh = sh;
@ -2170,7 +2162,7 @@ static int cmd_wifi_ps_wakeup_mode(const struct shell *sh, size_t argc, char *ar
static int cmd_wifi_set_rts_threshold(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
unsigned int rts_threshold = -1; /* Default value if user supplies "off" argument */
int err = 0;
@ -2227,7 +2219,7 @@ static int cmd_wifi_set_rts_threshold(const struct shell *sh, size_t argc, char
static int cmd_wifi_ps_exit_strategy(const struct shell *sh, size_t argc,
char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_ps_params params = { 0 };
context.sh = sh;
@ -2328,7 +2320,7 @@ static int cmd_wifi_mode(const struct shell *sh, size_t argc, char *argv[])
* lower layer
*/
if (mode_info.if_index == 0) {
iface = net_if_get_first_wifi();
iface = net_if_get_wifi_sta();
if (iface == NULL) {
PR_ERROR("Cannot find the default wifi interface\n");
return -ENOEXEC;
@ -2417,7 +2409,7 @@ static int cmd_wifi_channel(const struct shell *sh, size_t argc, char *argv[])
*/
if (channel_info.if_index == 0) {
iface = net_if_get_first_wifi();
iface = net_if_get_wifi_sta();
if (iface == NULL) {
PR_ERROR("Cannot find the default wifi interface\n");
return -ENOEXEC;
@ -2531,7 +2523,7 @@ static int cmd_wifi_packet_filter(const struct shell *sh, size_t argc, char *arg
* value to be verified by the lower layer.
*/
if (packet_filter.if_index == 0) {
iface = net_if_get_first_wifi();
iface = net_if_get_wifi_sta();
if (iface == NULL) {
PR_ERROR("Cannot find the default wifi interface\n");
return -ENOEXEC;
@ -2568,7 +2560,7 @@ static int cmd_wifi_packet_filter(const struct shell *sh, size_t argc, char *arg
static int cmd_wifi_version(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_version version = {0};
if (argc > 1) {
@ -2813,7 +2805,7 @@ static int parse_dpp_args_set_config_param(const struct shell *sh, size_t argc,
static int cmd_wifi_dpp_configurator_add(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_CONFIGURATOR_ADD;
@ -2828,7 +2820,7 @@ static int cmd_wifi_dpp_configurator_add(const struct shell *sh, size_t argc, ch
static int cmd_wifi_dpp_auth_init(const struct shell *sh, size_t argc, char *argv[])
{
int ret;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_AUTH_INIT;
@ -2848,7 +2840,7 @@ static int cmd_wifi_dpp_auth_init(const struct shell *sh, size_t argc, char *arg
static int cmd_wifi_dpp_qr_code(const struct shell *sh, size_t argc, char *argv[])
{
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_QR_CODE;
@ -2867,7 +2859,7 @@ static int cmd_wifi_dpp_qr_code(const struct shell *sh, size_t argc, char *argv[
static int cmd_wifi_dpp_chirp(const struct shell *sh, size_t argc, char *argv[])
{
int ret;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_CHIRP;
@ -2888,7 +2880,7 @@ static int cmd_wifi_dpp_chirp(const struct shell *sh, size_t argc, char *argv[])
static int cmd_wifi_dpp_listen(const struct shell *sh, size_t argc, char *argv[])
{
int ret;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_LISTEN;
@ -2909,7 +2901,7 @@ static int cmd_wifi_dpp_listen(const struct shell *sh, size_t argc, char *argv[]
static int cmd_wifi_dpp_btstrap_gen(const struct shell *sh, size_t argc, char *argv[])
{
int ret;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_BOOTSTRAP_GEN;
@ -2930,7 +2922,7 @@ static int cmd_wifi_dpp_btstrap_gen(const struct shell *sh, size_t argc, char *a
static int cmd_wifi_dpp_btstrap_get_uri(const struct shell *sh, size_t argc, char *argv[])
{
int ret = 0;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_BOOTSTRAP_GET_URI;
@ -2954,7 +2946,7 @@ static int cmd_wifi_dpp_btstrap_get_uri(const struct shell *sh, size_t argc, cha
static int cmd_wifi_dpp_configurator_set(const struct shell *sh, size_t argc, char *argv[])
{
int ret;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_SET_CONF_PARAM;
@ -2975,7 +2967,7 @@ static int cmd_wifi_dpp_configurator_set(const struct shell *sh, size_t argc, ch
static int cmd_wifi_dpp_resp_timeout_set(const struct shell *sh, size_t argc, char *argv[])
{
int ret = 0;
struct net_if *iface = net_if_get_first_wifi();
struct net_if *iface = net_if_get_wifi_sta();
struct wifi_dpp_params params = {0};
params.action = WIFI_DPP_SET_WAIT_RESP_TIME;