[AUTO00218054] [rdkb][common][app][modify wps
state and pushbutton]
[Description]
modify wps state from 0/1 to 0/2, and remove wps pushbutton cmd after createVAP; support adding multi mac address to acl.
[Release-log]
N/A
Change-Id: I18d3c28cf80ddd8b33f7cee7113716615a2bbb85
diff --git a/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c b/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c
index 77b23cf..df1f102 100644
--- a/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c
+++ b/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.c
@@ -182,12 +182,9 @@
intf_param->igmpsn_enable = FALSE;
}
-void set_wps_state(wifi_intf_param *intf_param, char *enable)
+void set_wps_state(wifi_intf_param *intf_param, char *wps_state)
{
- if (strcmp(enable, "1") == 0)
- intf_param->wps_state = TRUE;
- else
- intf_param->wps_state = FALSE;
+ intf_param->wps_state = strtol(wps_state, NULL, 10);
}
void set_wps_cancel(wifi_intf_param *intf_param, char *enable)
@@ -460,6 +457,7 @@
int key_len = 0;
wifi_vap_info_t vap_info = {0};
BOOL radio_enable = FALSE;
+ char *maclist;
if(ap_param.radio_index == -1)
return;
@@ -525,30 +523,16 @@
// wps_state
fprintf(stderr, "Set wps_state: %d \n", ap_param.wps_state);
- ret = wifi_setApWpsEnable(ap_param.ap_index, ap_param.wps_state);
+ if (ap_param.wps_state == 2)
+ ret = wifi_setApWpsEnable(ap_param.ap_index, 1);
+ else
+ ret = wifi_setApWpsEnable(ap_param.ap_index, 0);
if (ret != RETURN_OK)
fprintf(stderr, "[Set wps_state failed!!!]\n");
ret = 0;
- // wps_cancel
- fprintf(stderr, "Set wps_cancel: %d \n", ap_param.wps_cancel);
- if (ap_param.wps_cancel){
- ret = wifi_cancelApWPS(ap_param.ap_index);
- if (ret != RETURN_OK)
- fprintf(stderr, "[Set wps_cancel failed!!!]\n");
- ret = 0;
- }
-
- // wps_pushbutton
- fprintf(stderr, "Set wps_pushbutton: %d \n", ap_param.wps_pushbutton);
- if (ap_param.wps_pushbutton){
- ret = wifi_setApWpsButtonPush(ap_param.ap_index);
- if (ret != RETURN_OK)
- fprintf(stderr, "[Set wps_pushbutton failed!!!]\n");
- ret = 0;
- }
-
// macfilter
+ fprintf(stderr, "Set macfilter: %s \n", ap_param.macfilter);
if ((strcmp(ap_param.macfilter, "disable") == 0) || (strcmp(ap_param.macfilter, "\0") == 0) )
vap_info.u.bss_info.mac_filter_enable = false;
else if (strcmp(ap_param.macfilter, "deny") == 0){
@@ -561,28 +545,37 @@
}
else
fprintf(stderr, "The macfilter tpye: %s is invalid!!!\n", ap_param.macfilter);
- fprintf(stderr, "Set macfilter: %s \n", ap_param.macfilter);
// maclist
- if ((strlen(ap_param.macfilter) == 0)){
+ fprintf(stderr, "Set maclist: %s \n", ap_param.maclist);
+ if ((strlen(ap_param.maclist) == 0)){
ret = wifi_delApAclDevices(ap_param.ap_index);
if (ret != RETURN_OK)
fprintf(stderr, "[Del all maclist failed!!!]\n");
ret = 0;
- }
+ }
else if (strcmp(ap_param.macfilter, "allow") == 0) {
- ret = wifi_addApAclDevice(ap_param.ap_index, ap_param.maclist);
- if (ret != RETURN_OK)
- fprintf(stderr, "[Add maclist failed!!!]\n");
- ret = 0;
+ maclist = strtok(ap_param.maclist, ";");
+ while (maclist != NULL)
+ {
+ ret = wifi_addApAclDevice(ap_param.ap_index, maclist);
+ if (ret != RETURN_OK)
+ fprintf(stderr, "[Add maclist failed!!!]\n");
+ ret = 0;
+ maclist = strtok(NULL, ";");
}
+ }
else if (strcmp(ap_param.macfilter, "deny") == 0) {
- ret = wifi_addApDenyAclDevice(ap_param.ap_index, ap_param.maclist);
- if (ret != RETURN_OK)
- fprintf(stderr, "[Add maclist failed!!!]\n");
- ret = 0;
+ maclist = strtok(ap_param.maclist, ";");
+ while (maclist != NULL)
+ {
+ ret = wifi_addApDenyAclDevice(ap_param.ap_index, maclist);
+ if (ret != RETURN_OK)
+ fprintf(stderr, "[Add maclist failed!!!]\n");
+ ret = 0;
+ maclist = strtok(NULL, ";");
}
- fprintf(stderr, "Set maclist: %s \n", ap_param.maclist);
+ }
ret = 0;
// Replace the setting with uci config
@@ -684,7 +677,7 @@
// SSID
printf("wifi%d ssid: %s\n", ap_param.ap_index, vap_info.u.bss_info.ssid);
- // igmpsn_enableS
+ // igmpsn_enable
ret = wifi_getRadioIGMPSnoopingEnable(ap_param.radio_index, &igmpsn_state);
if (ret != RETURN_OK)
fprintf(stderr, "[Get igmpsn_state failed!!!]\n");
@@ -850,10 +843,6 @@
set_igmpsn_enable(&intf_param, op->v.string);
}else if (strcmp(op->e.name, "wps_state") == 0){
set_wps_state(&intf_param, op->v.string);
- }else if (strcmp(op->e.name, "wps_cancel") == 0){
- set_wps_cancel(&intf_param, op->v.string);
- }else if (strcmp(op->e.name, "wps_pushbutton") == 0){
- set_wps_pushbutton(&intf_param, op->v.string);
}else if (strcmp(op->e.name, "macfilter") == 0){
set_macfilter(&intf_param, op->v.string);
}else if (strcmp(op->e.name, "maclist") == 0){
@@ -897,6 +886,70 @@
fprintf(stderr, "[Apply vap setting failed!!!]\n");
}
+ for (i = 0; i < 3 ;i++ ){
+ apCount[i] = 0;
+ staCount[i] = 0;
+ }
+
+ uci_foreach_element(&uci_pkg->sections, e) {
+
+ struct uci_section *s = uci_to_section(e);
+ struct uci_element *option = NULL;
+ wifi_radio_param radio_param = {0};
+ wifi_intf_param intf_param = {0};
+ int phyId = 0;
+ radio_param.radio_index = -1;
+ intf_param.ap_index = -1;
+
+ if (strcmp(s->type, "wifi-iface") == 0) {
+ uci_foreach_element(&s->options, option) {
+
+ struct uci_option *op = uci_to_option(option);
+ {
+ // parsing iface
+ if (strcmp(op->e.name, "device") == 0){
+ set_radionum(&intf_param, op->v.string);
+ }else if (strcmp(op->e.name, "mode") == 0){
+ intf_param.mac_offset = staCount[intf_param.radio_index] + apCount[intf_param.radio_index];
+ if (strncmp(op->v.string, "sta", 3) == 0) {
+ intf_param.sta_mode = TRUE;
+ intf_param.sta_index = intf_param.radio_index + staCount[intf_param.radio_index]*max_radio_num;
+ staCount[intf_param.radio_index] ++ ;
+ fprintf(stderr, "\n----- Start parsing sta %d config. -----\n", intf_param.sta_index);
+ } else if (strncmp(op->v.string, "ap", 2) == 0) {
+ intf_param.sta_mode = FALSE;
+ intf_param.ap_index = intf_param.radio_index + apCount[intf_param.radio_index]*max_radio_num;
+ apCount[intf_param.radio_index] ++ ;
+ fprintf(stderr, "\n----- Start parsing ap %d config. -----\n", intf_param.ap_index);
+ }
+ }else if (strcmp(op->e.name, "wps_cancel") == 0){
+ set_wps_cancel(&intf_param, op->v.string);
+ }else if (strcmp(op->e.name, "wps_pushbutton") == 0){
+ set_wps_pushbutton(&intf_param, op->v.string);
+ }
+ }
+ }
+
+ // wps_cancel
+ fprintf(stderr, "Set wps_cancel: %d \n", intf_param.wps_cancel);
+ if (intf_param.wps_cancel){
+ ret = wifi_cancelApWPS(intf_param.ap_index);
+ if (ret != RETURN_OK)
+ fprintf(stderr, "[Set wps_cancel failed!!!]\n");
+ ret = 0;
+ }
+
+ // wps_pushbutton
+ fprintf(stderr, "Set wps_pushbutton: %d \n", intf_param.wps_pushbutton);
+ if (intf_param.wps_pushbutton){
+ ret = wifi_setApWpsButtonPush(intf_param.ap_index);
+ if (ret != RETURN_OK)
+ fprintf(stderr, "[Set wps_pushbutton failed!!!]\n");
+ ret = 0;
+ }
+ }
+ }
+
uci_unload(uci_ctx, uci_pkg);
uci_free_context(uci_ctx);
return RETURN_OK;
diff --git a/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.h b/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.h
index a235ed0..034ae4c 100644
--- a/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.h
+++ b/recipes-wifi/wifi-test-tool/files/src/wifi-test-tool.h
@@ -62,7 +62,7 @@
char ifname[16];
bool hidden;
bool igmpsn_enable;
- bool wps_state;
+ int wps_state;
bool wps_cancel;
bool wps_pushbutton;
char macfilter[10];