gluon-respondd: expose OWE clients in nodeinfo

Provide the number of OWE stations in addition to the number of all
connected wireless clients.
This commit is contained in:
David Bauer 2020-03-26 00:28:27 +01:00 committed by Martin Weinelt
parent b7ac32efbc
commit 59a4cd63b8

View File

@ -239,7 +239,7 @@ static void count_iface_stations(size_t *wifi24, size_t *wifi5, const char *ifna
} }
} }
static void count_stations(size_t *wifi24, size_t *wifi5) { static void count_stations(size_t *wifi24, size_t *wifi5, size_t *owe24, size_t owe5) {
struct uci_context *ctx = uci_alloc_context(); struct uci_context *ctx = uci_alloc_context();
if (!ctx) if (!ctx)
return; return;
@ -269,6 +269,9 @@ static void count_stations(size_t *wifi24, size_t *wifi5) {
if (!ifname) if (!ifname)
continue; continue;
if (strstr(ifname, "owe") == ifname)
count_iface_stations(owe24, owe5, ifname);
count_iface_stations(wifi24, wifi5, ifname); count_iface_stations(wifi24, wifi5, ifname);
} }
@ -277,9 +280,9 @@ static void count_stations(size_t *wifi24, size_t *wifi5) {
} }
static struct json_object * get_clients(void) { static struct json_object * get_clients(void) {
size_t wifi24 = 0, wifi5 = 0; size_t wifi24 = 0, wifi5 = 0, owe24 = 0, owe5 = 0;
count_stations(&wifi24, &wifi5); count_stations(&wifi24, &wifi5, &owe24, &owe5);
struct json_object *ret = json_object_new_object(); struct json_object *ret = json_object_new_object();
@ -287,6 +290,10 @@ static struct json_object * get_clients(void) {
json_object_object_add(ret, "wifi24", json_object_new_int(wifi24)); json_object_object_add(ret, "wifi24", json_object_new_int(wifi24));
json_object_object_add(ret, "wifi5", json_object_new_int(wifi5)); json_object_object_add(ret, "wifi5", json_object_new_int(wifi5));
json_object_object_add(ret, "owe", json_object_new_int(owe24 + owe5));
json_object_object_add(ret, "owe24", json_object_new_int(owe24));
json_object_object_add(ret, "owe5", json_object_new_int(owe5));
return ret; return ret;
} }