mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Get value of WiFi.AccessPoint.Status WiFi.Radio.OperatingStandards from ubus
This commit is contained in:
parent
21af510617
commit
c4d65b917a
3 changed files with 59 additions and 33 deletions
|
|
@ -100,6 +100,8 @@ int os__browse_wifi_associated_device(struct dmctx *dmctx, DMNODE *parent_node,
|
|||
char * os__get_radio_frequency_nocache(const struct wifi_radio_args *args);
|
||||
char * os__get_radio_channel_nocache(const struct wifi_radio_args *args);
|
||||
void os__wifi_start_scan(const char *radio);
|
||||
int os_get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
int os_get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value);
|
||||
|
||||
/* IOPSYS-WRT only
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -265,6 +265,28 @@ int os__get_access_point_associative_device_statistics_retrans_count(char *refpa
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*#Device.WiFi.AccessPoint.{i}.Status!UBUS:wifi.ap.@Name/status//status*/
|
||||
int os_get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
char object[32], *status = NULL, *iface;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "device", &iface);
|
||||
snprintf(object, sizeof(object), "wifi.ap.%s", iface);
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
|
||||
DM_ASSERT(res, status = "");
|
||||
status = dmjson_get_value(res, 1, "status");
|
||||
|
||||
|
||||
if (strcmp(status, "running") == 0 || strcmp(status, "up") == 0)
|
||||
*value = "Enabled";
|
||||
else
|
||||
*value = "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.WiFi.Radio.{i}.MaxBitRate!UBUS:wifi.radio.@Name/status//maxrate*/
|
||||
int os__get_radio_max_bit_rate (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
|
|
@ -509,6 +531,37 @@ int os__get_radio_supported_standard(char *refparam, struct dmctx *ctx, void *da
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.WiFi.Radio.{i}.OperatingStandards!UBUS:wifi.radio.@Name/status//standard*/
|
||||
int os_get_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res;
|
||||
char object[32], *standard = NULL, *iface = NULL;
|
||||
char **standards = NULL;
|
||||
int i;
|
||||
size_t length;
|
||||
|
||||
*value = "";
|
||||
dmuci_get_value_by_section_string(((struct wifi_radio_args *)data)->wifi_radio_sec, "device", &iface);
|
||||
snprintf(object, sizeof(object), "wifi.radio.%s", iface);
|
||||
dmubus_call(object, "status", UBUS_ARGS{}, 0, &res);
|
||||
|
||||
DM_ASSERT(res, standard = "");
|
||||
standard = dmjson_get_value(res, 1, "standard");
|
||||
standards = strsplit(standard, "/", &length);
|
||||
|
||||
for (i=0; i<length;i++) {
|
||||
if (strcmp(standards[i], "802.11") == 0)
|
||||
continue;
|
||||
if (strlen(*value) == 0){
|
||||
dmasprintf(value, "%s", standards[i]);
|
||||
continue;
|
||||
}
|
||||
dmasprintf(value, "%s,%s", *value, standards[i]);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
int os__get_access_point_total_associations(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
json_object *res = NULL, *assoclist = NULL, *arrobj = NULL;
|
||||
|
|
|
|||
|
|
@ -205,17 +205,6 @@ static int get_wifi_status (char *refparam, struct dmctx *ctx, void *data, char
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*#Device.WiFi.SSID.{i}.Status!UCI:wireless/wifi-iface,@i-1/disabled*/
|
||||
static int get_wifi_access_point_status (char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
{
|
||||
dmuci_get_value_by_section_string(((struct wifi_ssid_args *)data)->wifi_ssid_sec, "disabled", value);
|
||||
if (*value[0] == '\0' || *value[0] == '0')
|
||||
*value = "Enabled";
|
||||
else
|
||||
*value = "Disabled";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*#Device.WiFi.SSID.{i}.SSID!UCI:wireless/wifi-iface,@i-1/ssid*/
|
||||
static int get_wlan_ssid(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
|
||||
|
|
@ -243,6 +232,7 @@ static int get_WiFiSSID_MACAddress(char *refparam, struct dmctx *ctx, void *data
|
|||
{
|
||||
json_object *res;
|
||||
dmubus_call("network.device", "status", UBUS_ARGS{{"name", ((struct wifi_ssid_args *)data)->ifname, String}}, 1, &res);
|
||||
|
||||
DM_ASSERT(res, *value = "");
|
||||
*value = dmjson_get_value(res, 1, "macaddr");
|
||||
return 0;
|
||||
|
|
@ -367,25 +357,6 @@ static int set_radio_dfsenable(char *refparam, struct dmctx *ctx, void *data, ch
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*#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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static int set_radio_operating_standard(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action)
|
||||
{
|
||||
char *freq;
|
||||
|
|
@ -833,7 +804,7 @@ static int get_access_point_control_enable(char *refparam, struct dmctx *ctx, vo
|
|||
char *macfilter;
|
||||
|
||||
dmuci_get_value_by_section_string(((struct wifi_acp_args *)data)->wifi_acp_sec, "macfilter", &macfilter);
|
||||
if (!*value || *value[0] == 0 || strcmp(macfilter, "deny") == 0 || strcmp(macfilter, "disable") == 0)
|
||||
if (macfilter[0] == 0 || strcmp(macfilter, "deny") == 0 || strcmp(macfilter, "disable") == 0)
|
||||
*value = "false";
|
||||
else
|
||||
*value = "true";
|
||||
|
|
@ -2475,7 +2446,7 @@ DMLEAF tWiFiRadioParams[] = {
|
|||
{CUSTOM_PREFIX"MaxAssociations", &DMWRITE, DMT_STRING, get_radio_maxassoc, set_radio_maxassoc, NULL, NULL, BBFDM_BOTH},
|
||||
{CUSTOM_PREFIX"DFSEnable", &DMWRITE, DMT_BOOL, get_radio_dfsenable, set_radio_dfsenable, NULL, NULL, BBFDM_BOTH},
|
||||
{"SupportedStandards", &DMREAD, DMT_STRING, os__get_radio_supported_standard, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"OperatingStandards", &DMWRITE, DMT_STRING, get_radio_operating_standard, set_radio_operating_standard, NULL, NULL, BBFDM_BOTH},
|
||||
{"OperatingStandards", &DMWRITE, DMT_STRING, os_get_radio_operating_standard, set_radio_operating_standard, NULL, NULL, BBFDM_BOTH},
|
||||
{"ChannelsInUse", &DMREAD, DMT_STRING, os__get_radio_channel, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"Channel", &DMWRITE, DMT_UNINT, os__get_radio_channel, set_radio_channel, NULL, NULL, BBFDM_BOTH},
|
||||
{"AutoChannelEnable", &DMWRITE, DMT_BOOL, get_radio_auto_channel_enable, set_radio_auto_channel_enable, NULL, NULL, BBFDM_BOTH},
|
||||
|
|
@ -2601,7 +2572,7 @@ DMLEAF tWiFiAccessPointParams[] = {
|
|||
/* PARAM, permission, type, getvalue, setvalue, forced_inform, notification, bbfdm_type*/
|
||||
{"Alias", &DMWRITE, DMT_STRING, get_access_point_alias, set_access_point_alias, NULL, NULL, BBFDM_BOTH},
|
||||
{"Enable", &DMWRITE, DMT_BOOL, get_wifi_enable, set_wifi_enable, NULL, NULL, BBFDM_BOTH},
|
||||
{"Status", &DMREAD, DMT_STRING, get_wifi_access_point_status, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"Status", &DMREAD, DMT_STRING, os_get_wifi_access_point_status, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"SSIDReference", &DMREAD, DMT_STRING, get_ap_ssid_ref, NULL, NULL, NULL, BBFDM_BOTH},
|
||||
{"SSIDAdvertisementEnabled", &DMWRITE, DMT_BOOL, get_wlan_ssid_advertisement_enable, set_wlan_ssid_advertisement_enable, NULL, NULL, BBFDM_BOTH},
|
||||
{"WMMEnable", &DMWRITE, DMT_BOOL, get_wmm_enabled, set_wmm_enabled, NULL, NULL, BBFDM_BOTH},
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue