Fix bugs: Device.WiFi.Radio

This commit is contained in:
Omar Kallel 2020-03-19 09:45:26 +01:00
parent e3777371b1
commit a25b8584cb
3 changed files with 24 additions and 7 deletions

View file

@ -5,6 +5,7 @@
* it under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation
*
* Author: Omar Kallel <omar.kallel@pivasoftware.com>
* Author: Anis Ellouze <anis.ellouze@pivasoftware.com>
* Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
*
@ -357,9 +358,19 @@ static int set_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, ch
/*#Device.WiFi.Radio.{i}.OperatingStandards!UCI:wireless/wifi-device,@i-1/hwmode*/
static int get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "hwmode", value);
if (strcmp(*value, "auto") == 0)
char *supst = NULL;
dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "hwmode", &supst);
if(strcmp(supst, "11n") == 0 || strcmp(supst, "auto") == 0) {
*value = "n";
} else if (strcmp(supst, "11g") == 0) {
*value = "g";
} else if (strcmp(supst, "11ac") == 0) {
*value = "ac";
} else if (strcmp(supst, "11b") == 0) {
*value = "b";
} else if (strcmp(supst, "11ax") == 0) {
*value = "ax";
}
return 0;
}
@ -369,7 +380,7 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void
switch (action) {
case VALUECHECK:
if (dm_validate_string_list(value, -1, -1, -1, -1, -1, NULL, 0, NULL, 0))
if (dm_validate_string_list(value, -1, -1, -1, -1, -1, SupportedStandards, 6, NULL, 0))
return FAULT_9007;
return 0;
case VALUESET:
@ -382,7 +393,7 @@ static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void
} else {
if (strcmp(value, "b") == 0)
value = "11b";
else if (strcmp(value, "b,g") == 0 || strcmp(value, "g,b") == 0)
else if (strcmp(value, "b,g") == 0 || strcmp(value, "g,b") == 0) //TODO: Not supported in TR181 (to check)
value = "11bg";
else if (strcmp(value, "g") == 0)
value = "11g";
@ -527,13 +538,15 @@ static int get_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx
static int set_WiFiRadio_OperatingChannelBandwidth(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
{
char buf[6];
switch (action) {
case VALUECHECK:
if (dm_validate_string(value, -1, -1, NULL, 0, NULL, 0))
if (dm_validate_string(value, -1, -1, SupportedOperatingChannelBandwidth, 6, NULL, 0))
return FAULT_9007;
break;
case VALUESET:
dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "bandwidth", value);
sscanf(value,"%[^M]", buf);
dmuci_set_value_by_section(((struct wifi_radio_args *)data)->wifi_radio_sec, "bandwidth", buf);
break;
}
return 0;
@ -628,7 +641,7 @@ static int get_WiFiRadio_RegulatoryDomain(char *refparam, struct dmctx *ctx, voi
dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "country", &country);
arr = strsplit(country, "/", &length);
if(arr && arr[0])
dmasprintf(value, "%s", arr[0]);
dmasprintf(value, "%s ", arr[0]);
else
*value= "";

View file

@ -55,6 +55,8 @@ char *DropAlgorithm[] = {"RED", "DT", "WRED", "BLUE"};
char *SchedulerAlgorithm[] = {"WFQ", "WRR", "SP"};
char *DTMFMethod[] = {"InBand", "RFC2833", "SIPInfo"};
char *ProfileEnable[] = {"Disabled", "Quiescent", "Enabled"};
char *SupportedOperatingChannelBandwidth[] = {"20MHz", "40MHz", "80MHz", "160MHZ", "80+80MHz", "Auto"};
char *SupportedStandards[] = {"a", "b", "g", "n", "ac", "ax"};
char *PIN[] = {"^\\d{4}|\\d{8}$"};
char *DestinationAddress[] = {"^\\d+/\\d+$"};

View file

@ -96,6 +96,8 @@ extern char *MACAddress[];
extern char *IPPrefix[];
extern char *IPv4Prefix[];
extern char *IPv6Prefix[];
extern char *SupportedOperatingChannelBandwidth[];
extern char *SupportedStandards[];
#define NVRAM_FILE "/proc/nvram/WpaKey"
#define MAX_DHCP_LEASES 256