mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
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>
This commit is contained in:
parent
80b531614b
commit
0ce5f15f9c
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user