Skip to content

Commit 5e7ef7f

Browse files
krish2718rado17
authored andcommitted
[nrf noup] net: l2: wifi: Fix getopt handling
gettopt now has its own namespace in upstream, but the full POSIX namespacing is not pulled to NCS and is deemed too risky, so, this is a "noup" patch to partially rever the gettop commit [1] and reinstate old behaviour for Wi-Fi shell. [1] - zephyrproject-rtos/zephyr@22f9ef0 Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 137f8dc commit 5e7ef7f

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

subsys/net/l2/wifi/wifi_shell.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3639,19 +3639,19 @@ static int cmd_wifi_p2p_find(const struct shell *sh, size_t argc, char *argv[])
36393639
if (argc > 1) {
36403640
int opt;
36413641
int opt_index = 0;
3642-
struct sys_getopt_state *state;
3643-
static const struct sys_getopt_option long_options[] = {
3644-
{"timeout", sys_getopt_required_argument, 0, 't'},
3645-
{"type", sys_getopt_required_argument, 0, 'T'},
3646-
{"iface", sys_getopt_required_argument, 0, 'i'},
3647-
{"help", sys_getopt_no_argument, 0, 'h'},
3642+
struct getopt_state *state;
3643+
static const struct option long_options[] = {
3644+
{"timeout", required_argument, 0, 't'},
3645+
{"type", required_argument, 0, 'T'},
3646+
{"iface", required_argument, 0, 'i'},
3647+
{"help", no_argument, 0, 'h'},
36483648
{0, 0, 0, 0}
36493649
};
36503650
long val;
36513651

3652-
while ((opt = sys_getopt_long(argc, argv, "t:T:i:h",
3652+
while ((opt = getopt_long(argc, argv, "t:T:i:h",
36533653
long_options, &opt_index)) != -1) {
3654-
state = sys_getopt_state_get();
3654+
state = getopt_state_get();
36553655
switch (opt) {
36563656
case 't':
36573657
if (!parse_number(sh, &val, state->optarg, "timeout", 0, 65535)) {
@@ -3723,12 +3723,12 @@ static int cmd_wifi_p2p_connect(const struct shell *sh, size_t argc, char *argv[
37233723
const char *method_arg = NULL;
37243724
int opt;
37253725
int opt_index = 0;
3726-
struct sys_getopt_state *state;
3727-
static const struct sys_getopt_option long_options[] = {
3728-
{"go-intent", sys_getopt_required_argument, 0, 'g'},
3729-
{"freq", sys_getopt_required_argument, 0, 'f'},
3730-
{"iface", sys_getopt_required_argument, 0, 'i'},
3731-
{"help", sys_getopt_no_argument, 0, 'h'},
3726+
struct getopt_state *state;
3727+
static const struct option long_options[] = {
3728+
{"go-intent", required_argument, 0, 'g'},
3729+
{"freq", required_argument, 0, 'f'},
3730+
{"iface", required_argument, 0, 'i'},
3731+
{"help", no_argument, 0, 'h'},
37323732
{0, 0, 0, 0}
37333733
};
37343734
long val;
@@ -3772,8 +3772,8 @@ static int cmd_wifi_p2p_connect(const struct shell *sh, size_t argc, char *argv[
37723772
/* Set default frequency to 2462 MHz (channel 11, 2.4 GHz) */
37733773
params.connect.freq = 2462;
37743774

3775-
while ((opt = sys_getopt_long(argc, argv, "g:f:i:h", long_options, &opt_index)) != -1) {
3776-
state = sys_getopt_state_get();
3775+
while ((opt = getopt_long(argc, argv, "g:f:i:h", long_options, &opt_index)) != -1) {
3776+
state = getopt_state_get();
37773777
switch (opt) {
37783778
case 'g':
37793779
if (!parse_number(sh, &val, state->optarg, "go-intent", 0, 15)) {
@@ -3821,17 +3821,17 @@ static int cmd_wifi_p2p_group_add(const struct shell *sh, size_t argc, char *arg
38213821
struct wifi_p2p_params params = {0};
38223822
int opt;
38233823
int opt_index = 0;
3824-
struct sys_getopt_state *state;
3825-
static const struct sys_getopt_option long_options[] = {
3826-
{"freq", sys_getopt_required_argument, 0, 'f'},
3827-
{"persistent", sys_getopt_required_argument, 0, 'p'},
3828-
{"ht40", sys_getopt_no_argument, 0, 'h'},
3829-
{"vht", sys_getopt_no_argument, 0, 'v'},
3830-
{"he", sys_getopt_no_argument, 0, 'H'},
3831-
{"edmg", sys_getopt_no_argument, 0, 'e'},
3832-
{"go-bssid", sys_getopt_required_argument, 0, 'b'},
3833-
{"iface", sys_getopt_required_argument, 0, 'i'},
3834-
{"help", sys_getopt_no_argument, 0, '?'},
3824+
struct getopt_state *state;
3825+
static const struct option long_options[] = {
3826+
{"freq", required_argument, 0, 'f'},
3827+
{"persistent", required_argument, 0, 'p'},
3828+
{"ht40", no_argument, 0, 'h'},
3829+
{"vht", no_argument, 0, 'v'},
3830+
{"he", no_argument, 0, 'H'},
3831+
{"edmg", no_argument, 0, 'e'},
3832+
{"go-bssid", required_argument, 0, 'b'},
3833+
{"iface", required_argument, 0, 'i'},
3834+
{"help", no_argument, 0, '?'},
38353835
{0, 0, 0, 0}
38363836
};
38373837
long val;
@@ -3848,9 +3848,9 @@ static int cmd_wifi_p2p_group_add(const struct shell *sh, size_t argc, char *arg
38483848
params.group_add.edmg = false;
38493849
params.group_add.go_bssid_length = 0;
38503850

3851-
while ((opt = sys_getopt_long(argc, argv, "f:p:hvHeb:i:?", long_options,
3851+
while ((opt = getopt_long(argc, argv, "f:p:hvHeb:i:?", long_options,
38523852
&opt_index)) != -1) {
3853-
state = sys_getopt_state_get();
3853+
state = getopt_state_get();
38543854
switch (opt) {
38553855
case 'f':
38563856
if (!parse_number(sh, &val, state->optarg, "freq", 0, 6000)) {
@@ -3939,15 +3939,15 @@ static int cmd_wifi_p2p_invite(const struct shell *sh, size_t argc, char *argv[]
39393939
uint8_t mac_addr[WIFI_MAC_ADDR_LEN];
39403940
int opt;
39413941
int opt_index = 0;
3942-
struct sys_getopt_state *state;
3943-
static const struct sys_getopt_option long_options[] = {
3944-
{"persistent", sys_getopt_required_argument, 0, 'p'},
3945-
{"group", sys_getopt_required_argument, 0, 'g'},
3946-
{"peer", sys_getopt_required_argument, 0, 'P'},
3947-
{"freq", sys_getopt_required_argument, 0, 'f'},
3948-
{"go-dev-addr", sys_getopt_required_argument, 0, 'd'},
3949-
{"iface", sys_getopt_required_argument, 0, 'i'},
3950-
{"help", sys_getopt_no_argument, 0, 'h'},
3942+
struct getopt_state *state;
3943+
static const struct option long_options[] = {
3944+
{"persistent", required_argument, 0, 'p'},
3945+
{"group", required_argument, 0, 'g'},
3946+
{"peer", required_argument, 0, 'P'},
3947+
{"freq", required_argument, 0, 'f'},
3948+
{"go-dev-addr", required_argument, 0, 'd'},
3949+
{"iface", required_argument, 0, 'i'},
3950+
{"help", no_argument, 0, 'h'},
39513951
{0, 0, 0, 0}
39523952
};
39533953
long val;
@@ -3968,9 +3968,9 @@ static int cmd_wifi_p2p_invite(const struct shell *sh, size_t argc, char *argv[]
39683968
return -EINVAL;
39693969
}
39703970

3971-
while ((opt = sys_getopt_long(argc, argv, "p:g:P:f:d:i:h", long_options,
3971+
while ((opt = getopt_long(argc, argv, "p:g:P:f:d:i:h", long_options,
39723972
&opt_index)) != -1) {
3973-
state = sys_getopt_state_get();
3973+
state = getopt_state_get();
39743974
switch (opt) {
39753975
case 'p':
39763976
if (!parse_number(sh, &val, state->optarg, "persistent", 0, 255)) {
@@ -4022,7 +4022,7 @@ static int cmd_wifi_p2p_invite(const struct shell *sh, size_t argc, char *argv[]
40224022
}
40234023
}
40244024

4025-
state = sys_getopt_state_get();
4025+
state = getopt_state_get();
40264026

40274027
if (params.invite.type == WIFI_P2P_INVITE_PERSISTENT &&
40284028
params.invite.persistent_id >= 0 &&

0 commit comments

Comments
 (0)