Skip to content

Commit 5a38391

Browse files
gangli02kartben
authored andcommitted
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 <[email protected]>
1 parent 20409ca commit 5a38391

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ static int wifi_scan_args_to_params(const struct shell *sh,
10561056

10571057
static int cmd_wifi_scan(const struct shell *sh, size_t argc, char *argv[])
10581058
{
1059-
struct net_if *iface = net_if_get_first_wifi();
1059+
struct net_if *iface = net_if_get_wifi_sta();
10601060
struct wifi_scan_params params = { 0 };
10611061
bool do_scan = true;
10621062
int opt_num;
@@ -1092,7 +1092,7 @@ static int cmd_wifi_scan(const struct shell *sh, size_t argc, char *argv[])
10921092

10931093
static int cmd_wifi_status(const struct shell *sh, size_t argc, char *argv[])
10941094
{
1095-
struct net_if *iface = net_if_get_first_wifi();
1095+
struct net_if *iface = net_if_get_wifi_sta();
10961096
struct wifi_iface_status status = { 0 };
10971097

10981098
context.sh = sh;
@@ -1226,7 +1226,7 @@ static int cmd_wifi_stats(const struct shell *sh, size_t argc, char *argv[])
12261226
{
12271227
#if defined(CONFIG_NET_STATISTICS_WIFI) && \
12281228
defined(CONFIG_NET_STATISTICS_USER_API)
1229-
struct net_if *iface = net_if_get_first_wifi();
1229+
struct net_if *iface = net_if_get_wifi_sta();
12301230
struct net_stats_wifi stats = { 0 };
12311231
int ret;
12321232

@@ -1269,7 +1269,7 @@ static int cmd_wifi_stats(const struct shell *sh, size_t argc, char *argv[])
12691269

12701270
static int cmd_wifi_11k(const struct shell *sh, size_t argc, char *argv[])
12711271
{
1272-
struct net_if *iface = net_if_get_first_wifi();
1272+
struct net_if *iface = net_if_get_wifi_sta();
12731273
struct wifi_11k_params params = { 0 };
12741274

12751275
context.sh = sh;
@@ -1310,7 +1310,7 @@ static int cmd_wifi_11k(const struct shell *sh, size_t argc, char *argv[])
13101310

13111311
static int cmd_wifi_11k_neighbor_request(const struct shell *sh, size_t argc, char *argv[])
13121312
{
1313-
struct net_if *iface = net_if_get_first_wifi();
1313+
struct net_if *iface = net_if_get_wifi_sta();
13141314
struct wifi_11k_params params = { 0 };
13151315

13161316
context.sh = sh;
@@ -1347,7 +1347,7 @@ static int cmd_wifi_11k_neighbor_request(const struct shell *sh, size_t argc, ch
13471347

13481348
static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
13491349
{
1350-
struct net_if *iface = net_if_get_first_wifi();
1350+
struct net_if *iface = net_if_get_wifi_sta();
13511351
struct wifi_ps_params params = { 0 };
13521352

13531353
context.sh = sh;
@@ -1435,7 +1435,7 @@ static int cmd_wifi_ps(const struct shell *sh, size_t argc, char *argv[])
14351435

14361436
static int cmd_wifi_ps_mode(const struct shell *sh, size_t argc, char *argv[])
14371437
{
1438-
struct net_if *iface = net_if_get_first_wifi();
1438+
struct net_if *iface = net_if_get_wifi_sta();
14391439
struct wifi_ps_params params = { 0 };
14401440

14411441
context.sh = sh;
@@ -1465,7 +1465,7 @@ static int cmd_wifi_ps_mode(const struct shell *sh, size_t argc, char *argv[])
14651465

14661466
static int cmd_wifi_ps_timeout(const struct shell *sh, size_t argc, char *argv[])
14671467
{
1468-
struct net_if *iface = net_if_get_first_wifi();
1468+
struct net_if *iface = net_if_get_wifi_sta();
14691469
struct wifi_ps_params params = { 0 };
14701470
long timeout_ms = 0;
14711471
int err = 0;
@@ -1500,7 +1500,7 @@ static int cmd_wifi_ps_timeout(const struct shell *sh, size_t argc, char *argv[]
15001500
static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
15011501
char *argv[])
15021502
{
1503-
struct net_if *iface = net_if_get_first_wifi();
1503+
struct net_if *iface = net_if_get_wifi_sta();
15041504
struct wifi_twt_params params = { 0 };
15051505
int idx = 1;
15061506
long value;
@@ -1547,7 +1547,7 @@ static int cmd_wifi_twt_setup_quick(const struct shell *sh, size_t argc,
15471547
static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
15481548
char *argv[])
15491549
{
1550-
struct net_if *iface = net_if_get_first_wifi();
1550+
struct net_if *iface = net_if_get_wifi_sta();
15511551
struct wifi_twt_params params = { 0 };
15521552
int idx = 1;
15531553
long value;
@@ -1632,7 +1632,7 @@ static int cmd_wifi_twt_setup(const struct shell *sh, size_t argc,
16321632
static int cmd_wifi_twt_teardown(const struct shell *sh, size_t argc,
16331633
char *argv[])
16341634
{
1635-
struct net_if *iface = net_if_get_first_wifi();
1635+
struct net_if *iface = net_if_get_wifi_sta();
16361636
struct wifi_twt_params params = { 0 };
16371637
long value;
16381638

@@ -1682,7 +1682,7 @@ static int cmd_wifi_twt_teardown(const struct shell *sh, size_t argc,
16821682
static int cmd_wifi_twt_teardown_all(const struct shell *sh, size_t argc,
16831683
char *argv[])
16841684
{
1685-
struct net_if *iface = net_if_get_first_wifi();
1685+
struct net_if *iface = net_if_get_wifi_sta();
16861686
struct wifi_twt_params params = { 0 };
16871687

16881688
context.sh = sh;
@@ -1806,11 +1806,7 @@ static int cmd_wifi_ap_stations(const struct shell *sh, size_t argc,
18061806
static int cmd_wifi_ap_sta_disconnect(const struct shell *sh, size_t argc,
18071807
char *argv[])
18081808
{
1809-
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
18101809
struct net_if *iface = net_if_get_wifi_sap();
1811-
#else
1812-
struct net_if *iface = net_if_get_first_wifi();
1813-
#endif
18141810
uint8_t mac[6];
18151811
int ret;
18161812

@@ -1879,11 +1875,7 @@ static int wifi_ap_config_args_to_params(const struct shell *sh, size_t argc, ch
18791875
static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc,
18801876
char *argv[])
18811877
{
1882-
#ifdef CONFIG_WIFI_NM_HOSTAPD_AP
18831878
struct net_if *iface = net_if_get_wifi_sap();
1884-
#else
1885-
struct net_if *iface = net_if_get_first_wifi();
1886-
#endif
18871879
struct wifi_ap_config_params ap_config_params = { 0 };
18881880
int ret = -1;
18891881

@@ -1907,7 +1899,7 @@ static int cmd_wifi_ap_config_params(const struct shell *sh, size_t argc,
19071899
static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
19081900
char *argv[])
19091901
{
1910-
struct net_if *iface = net_if_get_first_wifi();
1902+
struct net_if *iface = net_if_get_wifi_sta();
19111903
struct wifi_reg_domain regd = {0};
19121904
int ret, chan_idx = 0;
19131905

@@ -1976,7 +1968,7 @@ static int cmd_wifi_reg_domain(const struct shell *sh, size_t argc,
19761968

19771969
static int cmd_wifi_listen_interval(const struct shell *sh, size_t argc, char *argv[])
19781970
{
1979-
struct net_if *iface = net_if_get_first_wifi();
1971+
struct net_if *iface = net_if_get_wifi_sta();
19801972
struct wifi_ps_params params = { 0 };
19811973
long interval;
19821974

@@ -2011,7 +2003,7 @@ static int cmd_wifi_listen_interval(const struct shell *sh, size_t argc, char *a
20112003
#ifdef CONFIG_WIFI_NM_WPA_SUPPLICANT_WNM
20122004
static int cmd_wifi_btm_query(const struct shell *sh, size_t argc, char *argv[])
20132005
{
2014-
struct net_if *iface = net_if_get_first_wifi();
2006+
struct net_if *iface = net_if_get_wifi_sta();
20152007
uint8_t query_reason = 0;
20162008
long tmp = 0;
20172009

@@ -2139,7 +2131,7 @@ static int cmd_wifi_ap_wps_pin(const struct shell *sh, size_t argc, char *argv[]
21392131

21402132
static int cmd_wifi_ps_wakeup_mode(const struct shell *sh, size_t argc, char *argv[])
21412133
{
2142-
struct net_if *iface = net_if_get_first_wifi();
2134+
struct net_if *iface = net_if_get_wifi_sta();
21432135
struct wifi_ps_params params = { 0 };
21442136

21452137
context.sh = sh;
@@ -2170,7 +2162,7 @@ static int cmd_wifi_ps_wakeup_mode(const struct shell *sh, size_t argc, char *ar
21702162

21712163
static int cmd_wifi_set_rts_threshold(const struct shell *sh, size_t argc, char *argv[])
21722164
{
2173-
struct net_if *iface = net_if_get_first_wifi();
2165+
struct net_if *iface = net_if_get_wifi_sta();
21742166
unsigned int rts_threshold = -1; /* Default value if user supplies "off" argument */
21752167
int err = 0;
21762168

@@ -2227,7 +2219,7 @@ static int cmd_wifi_set_rts_threshold(const struct shell *sh, size_t argc, char
22272219
static int cmd_wifi_ps_exit_strategy(const struct shell *sh, size_t argc,
22282220
char *argv[])
22292221
{
2230-
struct net_if *iface = net_if_get_first_wifi();
2222+
struct net_if *iface = net_if_get_wifi_sta();
22312223
struct wifi_ps_params params = { 0 };
22322224

22332225
context.sh = sh;
@@ -2328,7 +2320,7 @@ static int cmd_wifi_mode(const struct shell *sh, size_t argc, char *argv[])
23282320
* lower layer
23292321
*/
23302322
if (mode_info.if_index == 0) {
2331-
iface = net_if_get_first_wifi();
2323+
iface = net_if_get_wifi_sta();
23322324
if (iface == NULL) {
23332325
PR_ERROR("Cannot find the default wifi interface\n");
23342326
return -ENOEXEC;
@@ -2417,7 +2409,7 @@ static int cmd_wifi_channel(const struct shell *sh, size_t argc, char *argv[])
24172409
*/
24182410

24192411
if (channel_info.if_index == 0) {
2420-
iface = net_if_get_first_wifi();
2412+
iface = net_if_get_wifi_sta();
24212413
if (iface == NULL) {
24222414
PR_ERROR("Cannot find the default wifi interface\n");
24232415
return -ENOEXEC;
@@ -2531,7 +2523,7 @@ static int cmd_wifi_packet_filter(const struct shell *sh, size_t argc, char *arg
25312523
* value to be verified by the lower layer.
25322524
*/
25332525
if (packet_filter.if_index == 0) {
2534-
iface = net_if_get_first_wifi();
2526+
iface = net_if_get_wifi_sta();
25352527
if (iface == NULL) {
25362528
PR_ERROR("Cannot find the default wifi interface\n");
25372529
return -ENOEXEC;
@@ -2568,7 +2560,7 @@ static int cmd_wifi_packet_filter(const struct shell *sh, size_t argc, char *arg
25682560

25692561
static int cmd_wifi_version(const struct shell *sh, size_t argc, char *argv[])
25702562
{
2571-
struct net_if *iface = net_if_get_first_wifi();
2563+
struct net_if *iface = net_if_get_wifi_sta();
25722564
struct wifi_version version = {0};
25732565

25742566
if (argc > 1) {
@@ -2813,7 +2805,7 @@ static int parse_dpp_args_set_config_param(const struct shell *sh, size_t argc,
28132805

28142806
static int cmd_wifi_dpp_configurator_add(const struct shell *sh, size_t argc, char *argv[])
28152807
{
2816-
struct net_if *iface = net_if_get_first_wifi();
2808+
struct net_if *iface = net_if_get_wifi_sta();
28172809
struct wifi_dpp_params params = {0};
28182810

28192811
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
28282820
static int cmd_wifi_dpp_auth_init(const struct shell *sh, size_t argc, char *argv[])
28292821
{
28302822
int ret;
2831-
struct net_if *iface = net_if_get_first_wifi();
2823+
struct net_if *iface = net_if_get_wifi_sta();
28322824
struct wifi_dpp_params params = {0};
28332825

28342826
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
28482840

28492841
static int cmd_wifi_dpp_qr_code(const struct shell *sh, size_t argc, char *argv[])
28502842
{
2851-
struct net_if *iface = net_if_get_first_wifi();
2843+
struct net_if *iface = net_if_get_wifi_sta();
28522844
struct wifi_dpp_params params = {0};
28532845

28542846
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[
28672859
static int cmd_wifi_dpp_chirp(const struct shell *sh, size_t argc, char *argv[])
28682860
{
28692861
int ret;
2870-
struct net_if *iface = net_if_get_first_wifi();
2862+
struct net_if *iface = net_if_get_wifi_sta();
28712863
struct wifi_dpp_params params = {0};
28722864

28732865
params.action = WIFI_DPP_CHIRP;
@@ -2888,7 +2880,7 @@ static int cmd_wifi_dpp_chirp(const struct shell *sh, size_t argc, char *argv[])
28882880
static int cmd_wifi_dpp_listen(const struct shell *sh, size_t argc, char *argv[])
28892881
{
28902882
int ret;
2891-
struct net_if *iface = net_if_get_first_wifi();
2883+
struct net_if *iface = net_if_get_wifi_sta();
28922884
struct wifi_dpp_params params = {0};
28932885

28942886
params.action = WIFI_DPP_LISTEN;
@@ -2909,7 +2901,7 @@ static int cmd_wifi_dpp_listen(const struct shell *sh, size_t argc, char *argv[]
29092901
static int cmd_wifi_dpp_btstrap_gen(const struct shell *sh, size_t argc, char *argv[])
29102902
{
29112903
int ret;
2912-
struct net_if *iface = net_if_get_first_wifi();
2904+
struct net_if *iface = net_if_get_wifi_sta();
29132905
struct wifi_dpp_params params = {0};
29142906

29152907
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
29302922
static int cmd_wifi_dpp_btstrap_get_uri(const struct shell *sh, size_t argc, char *argv[])
29312923
{
29322924
int ret = 0;
2933-
struct net_if *iface = net_if_get_first_wifi();
2925+
struct net_if *iface = net_if_get_wifi_sta();
29342926
struct wifi_dpp_params params = {0};
29352927

29362928
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
29542946
static int cmd_wifi_dpp_configurator_set(const struct shell *sh, size_t argc, char *argv[])
29552947
{
29562948
int ret;
2957-
struct net_if *iface = net_if_get_first_wifi();
2949+
struct net_if *iface = net_if_get_wifi_sta();
29582950
struct wifi_dpp_params params = {0};
29592951

29602952
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
29752967
static int cmd_wifi_dpp_resp_timeout_set(const struct shell *sh, size_t argc, char *argv[])
29762968
{
29772969
int ret = 0;
2978-
struct net_if *iface = net_if_get_first_wifi();
2970+
struct net_if *iface = net_if_get_wifi_sta();
29792971
struct wifi_dpp_params params = {0};
29802972

29812973
params.action = WIFI_DPP_SET_WAIT_RESP_TIME;

0 commit comments

Comments
 (0)