aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/services
diff options
context:
space:
mode:
authorDavid Bauer <mail@david-bauer.net>2020-11-02 00:53:41 +0100
committerDavid Bauer <mail@david-bauer.net>2020-11-17 17:05:06 +0100
commit0ce5f15f9c51926bc56aa8f9d8d848f803f9f251 (patch)
treea19c73833627fe7ea42792657ac956008f23a7dd /package/network/services
parent80b531614beab477c642cfdfef8dc6238c58f007 (diff)
downloadupstream-0ce5f15f9c51926bc56aa8f9d8d848f803f9f251.tar.gz
upstream-0ce5f15f9c51926bc56aa8f9d8d848f803f9f251.tar.bz2
upstream-0ce5f15f9c51926bc56aa8f9d8d848f803f9f251.zip
hostapd: ubus: add get_status method
This adds a new get_status method to a hostapd interface, which provides information about the current interface status. Signed-off-by: David Bauer <mail@david-bauer.net>
Diffstat (limited to 'package/network/services')
-rw-r--r--package/network/services/hostapd/src/src/ap/ubus.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/package/network/services/hostapd/src/src/ap/ubus.c b/package/network/services/hostapd/src/src/ap/ubus.c
index f864d586ab..aae9f91a20 100644
--- a/package/network/services/hostapd/src/src/ap/ubus.c
+++ b/package/network/services/hostapd/src/src/ap/ubus.c
@@ -372,6 +372,45 @@ hostapd_bss_get_features(struct ubus_context *ctx, struct ubus_object *obj,
return 0;
}
+static int
+hostapd_bss_get_status(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct hostapd_data *hapd = container_of(obj, struct hostapd_data, ubus.obj);
+ void *airtime_table, *dfs_table;
+ struct os_reltime now;
+ char phy_name[17];
+ char mac_buf[20];
+
+ blob_buf_init(&b, 0);
+ blobmsg_add_string(&b, "status", hostapd_state_text(hapd->iface->state));
+ blobmsg_add_u32(&b, "freq", hapd->iface->freq);
+
+ snprintf(phy_name, 17, "%s", hapd->iface->phy);
+ blobmsg_add_string(&b, "phy", phy_name);
+
+ /* Airtime */
+ airtime_table = blobmsg_open_table(&b, "airtime");
+ blobmsg_add_u64(&b, "time", hapd->iface->last_channel_time);
+ blobmsg_add_u64(&b, "time_busy", hapd->iface->last_channel_time_busy);
+ blobmsg_add_u16(&b, "utilization", hapd->iface->channel_utilization);
+ blobmsg_close_table(&b, airtime_table);
+
+ /* DFS */
+ dfs_table = blobmsg_open_table(&b, "dfs");
+ blobmsg_add_u32(&b, "cac_seconds", hapd->iface->dfs_cac_ms / 1000);
+ blobmsg_add_u8(&b, "cac_active", !!(hapd->iface->cac_started));
+ os_reltime_age(&hapd->iface->dfs_cac_start, &now);
+ blobmsg_add_u32(&b, "cac_seconds_left",
+ hapd->iface->cac_started ? hapd->iface->dfs_cac_ms / 1000 - now.sec : 0);
+ blobmsg_close_table(&b, dfs_table);
+
+ ubus_send_reply(ctx, req, b.head);
+
+ return 0;
+}
+
enum {
NOTIFY_RESPONSE,
__NOTIFY_MAX
@@ -1242,6 +1281,7 @@ hostapd_wnm_disassoc_imminent(struct ubus_context *ctx, struct ubus_object *obj,
static const struct ubus_method bss_methods[] = {
UBUS_METHOD_NOARG("reload", hostapd_bss_reload),
UBUS_METHOD_NOARG("get_clients", hostapd_bss_get_clients),
+ UBUS_METHOD_NOARG("get_status", hostapd_bss_get_status),
UBUS_METHOD("del_client", hostapd_bss_del_client, del_policy),
UBUS_METHOD_NOARG("list_bans", hostapd_bss_list_bans),
#ifdef CONFIG_WPS