WiFi: use the correct ifname when getting Access Point Status

This commit is contained in:
Amin Ben Romdhane 2023-06-16 07:26:22 +00:00
parent 8d4298b537
commit 08f31df314
3 changed files with 9 additions and 40 deletions

View file

@ -831,40 +831,6 @@ char *get_l3_device(char *interface_name)
return dmjson_get_value(res, 1, "l3_device");
}
char *get_device_from_wifi_iface(const char *wifi_iface, const char *wifi_section)
{
json_object *jobj;
array_list *jarr;
unsigned n = 0, i;
const char *ifname = "";
if (!wifi_iface || wifi_iface[0] == 0 || !wifi_section || wifi_section[0] == 0)
return "";
dmubus_call("network.wireless", "status", UBUS_ARGS{{}}, 0, &jobj);
if (jobj == NULL)
return "";
json_object_object_get_ex(jobj, wifi_iface, &jobj);
json_object_object_get_ex(jobj, "interfaces", &jobj);
jarr = json_object_get_array(jobj);
if (jarr)
n = array_list_length(jarr);
for (i = 0; i < n; i++) {
json_object *j_e = jarr->array[i];
const char *sect;
sect = dmjson_get_value(j_e, 1, "section");
if (!strcmp(sect, wifi_section)) {
ifname = dmjson_get_value(j_e, 2, "config", "ifname");
break;
}
}
return (char *)ifname;
}
bool value_exists_in_uci_list(struct uci_list *list, const char *value)
{
struct uci_element *e = NULL;

View file

@ -258,7 +258,6 @@ int dm_read_sysfs_file(const char *file, char *dst, unsigned len);
int get_net_iface_sysfs(const char *uci_iface, const char *name, char **value);
int get_net_device_sysfs(const char *device, const char *name, char **value);
int get_net_device_status(const char *device, char **value);
char *get_device_from_wifi_iface(const char *wifi_iface, const char *wifi_section);
int dm_time_utc_format(time_t ts, char **dst);
int dm_time_format(time_t ts, char **dst);
void convert_string_to_hex(const char *str, char *hex, size_t size);

View file

@ -789,7 +789,12 @@ static int set_radio_enable(char *refparam, struct dmctx *ctx, void *data, char
static int get_radio_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
char *isup = get_radio_option_nocache(section_name((((struct wifi_radio_args *)data)->sections)->config_section), "isup");
json_object *res = NULL;
dmubus_call("network.wireless", "status", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "Down");
char *isup = dmjson_get_value(res, 2, section_name((((struct wifi_radio_args *)data)->sections)->config_section), "up");
*value = (DM_STRCMP(isup, "false") == 0) ? "Down" : "Up";
return 0;
}
@ -3105,12 +3110,11 @@ static int get_access_point_associative_device_statistics_retrans_count(char *re
static int get_wifi_access_point_status(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value)
{
json_object *res = NULL;
char object[32], *status = NULL, *iface;
char object[32], *status = NULL;
dmuci_get_value_by_section_string((((struct wifi_ssid_args *)data)->sections)->config_section, "device", &iface);
snprintf(object, sizeof(object), "wifi.ap.%s", iface);
snprintf(object, sizeof(object), "wifi.ap.%s", ((struct wifi_acp_args *)data)->ifname);
dmubus_call(object, "status", UBUS_ARGS{0}, 0, &res);
DM_ASSERT(res, *value = "Error_Misconfigured");
DM_ASSERT(res, *value = "Disabled");
status = dmjson_get_value(res, 1, "status");
if (DM_LSTRCMP(status, "running") == 0 || DM_LSTRCMP(status, "up") == 0)