From 5e6c0ed78f4fe0475d0eb64062b760ae467a2c47 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Sat, 23 Dec 2017 19:59:46 +0100 Subject: [PATCH] parse from ubus call --- src/include/datastorage.h | 4 +++- src/storage/datastorage.c | 4 ++-- src/utils/ubus.c | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/include/datastorage.h b/src/include/datastorage.h index a1f4fca..58d83c4 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -109,6 +109,8 @@ typedef struct auth_entry_s assoc_entry; // ---------------- Defines ---------------- #define PROBE_ARRAY_LEN 1000 +#define SSID_MAX_LEN 32 + // ---------------- Global variables ---------------- struct probe_entry_s probe_array[PROBE_ARRAY_LEN]; pthread_mutex_t probe_array_mutex; @@ -161,7 +163,7 @@ typedef struct ap_s { uint32_t channel_utilization; time_t time; uint32_t station_count; - // essid + uint8_t ssid[SSID_MAX_LEN]; } ap; // ---------------- Defines ---------------- diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index ba75903..f5980c8 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -1189,8 +1189,8 @@ void print_ap_entry(ap entry) { char mac_buf_ap[20]; sprintf(mac_buf_ap, MACSTR, MAC2STR(entry.bssid_addr)); - printf("bssid_addr: %s, freq: %d, ht: %d, vht: %d, chan_utilz: %d\n", - mac_buf_ap, entry.freq, entry.ht, entry.vht, entry.channel_utilization); + printf("ssid: %s, bssid_addr: %s, freq: %d, ht: %d, vht: %d, chan_utilz: %d\n", + entry.ssid, mac_buf_ap, entry.freq, entry.ht, entry.vht, entry.channel_utilization); } void print_ap_array() { diff --git a/src/utils/ubus.c b/src/utils/ubus.c index fe013f2..d2b198e 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -105,6 +105,7 @@ static const struct blobmsg_policy prob_policy[__PROB_MAX] = { enum { CLIENT_TABLE, CLIENT_TABLE_BSSID, + CLIENT_TABLE_SSID, CLIENT_TABLE_FREQ, CLIENT_TABLE_HT, CLIENT_TABLE_VHT, @@ -116,6 +117,7 @@ enum { static const struct blobmsg_policy client_table_policy[__CLIENT_TABLE_MAX] = { [CLIENT_TABLE] = {.name = "clients", .type = BLOBMSG_TYPE_TABLE}, [CLIENT_TABLE_BSSID] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING}, + [CLIENT_TABLE_SSID] = {.name = "ssid", .type = BLOBMSG_TYPE_STRING}, [CLIENT_TABLE_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32}, [CLIENT_TABLE_HT] = {.name = "ht_supported", .type = BLOBMSG_TYPE_INT8}, [CLIENT_TABLE_VHT] = {.name = "vht_supported", .type = BLOBMSG_TYPE_INT8}, @@ -766,6 +768,7 @@ int parse_to_clients(struct blob_attr *msg, int do_kick, uint32_t id) { ap_entry.ht = blobmsg_get_u8(tb[CLIENT_TABLE_HT]); ap_entry.vht = blobmsg_get_u8(tb[CLIENT_TABLE_VHT]); ap_entry.channel_utilization = blobmsg_get_u32(tb[CLIENT_TABLE_CHAN_UTIL]); + strcpy((char*)ap_entry.ssid, blobmsg_get_string(tb[CLIENT_TABLE_SSID])); if (tb[CLIENT_TABLE_NUM_STA]) { ap_entry.station_count = blobmsg_get_u32(tb[CLIENT_TABLE_NUM_STA]);