parse from ubus call

This commit is contained in:
PolynomialDivision 2017-12-23 19:59:46 +01:00
parent fe5e6849b8
commit 5e6c0ed78f
3 changed files with 8 additions and 3 deletions

View file

@ -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 ----------------

View file

@ -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() {

View file

@ -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]);