From f8c2b602496f597394a8f15d524c8b2a16565ffa Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Mon, 24 Jul 2017 00:43:58 +0200 Subject: [PATCH] Parse ht and vht information in probe --- src/include/datastorage.h | 2 ++ src/storage/datastorage.c | 6 +++--- src/utils/ubus.c | 29 +++++++++++++++++------------ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/include/datastorage.h b/src/include/datastorage.h index d6aff85..911f86e 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -23,6 +23,8 @@ typedef struct probe_entry_s { uint8_t target_addr[ETH_ALEN]; uint32_t signal; uint32_t freq; + uint8_t ht_support; + uint8_t vht_support; time_t time; int counter; } probe_entry; diff --git a/src/storage/datastorage.c b/src/storage/datastorage.c index a6d9162..c856433 100644 --- a/src/storage/datastorage.c +++ b/src/storage/datastorage.c @@ -661,8 +661,8 @@ void print_probe_entry(probe_entry entry) { printf( "bssid_addr: %s, client_addr: %s, target_addr: %s, signal: %d, freq: " - "%d, counter: %d\n", - mac_buf_ap, mac_buf_client, mac_buf_target, entry.signal, entry.freq, + "%d, ht: %d, vht: %d, counter: %d\n", + mac_buf_ap, mac_buf_client, mac_buf_target, entry.signal, entry.freq, entry.ht_support, entry.vht_support, entry.counter); } @@ -679,7 +679,7 @@ void print_client_entry(client entry) { void print_client_array() { printf("--------Clients------\n"); - printf("Probe Entry Last: %d\n", client_entry_last); + printf("Client Entry Last: %d\n", client_entry_last); for(int i = 0; i <= client_entry_last; i++) { print_client_entry(client_array[i]); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 433d089..bc95f9b 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -23,15 +23,19 @@ enum { PROB_TARGET_ADDR, PROB_SIGNAL, PROB_FREQ, + PROB_HT_SUPPORT, + PROB_VHT_SUPPORT, __PROB_MAX, }; static const struct blobmsg_policy prob_policy[__PROB_MAX] = { - [PROB_BSSID_ADDR] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING}, - [PROB_CLIENT_ADDR] = {.name = "address", .type = BLOBMSG_TYPE_STRING}, - [PROB_TARGET_ADDR] = {.name = "target", .type = BLOBMSG_TYPE_STRING}, - [PROB_SIGNAL] = {.name = "signal", .type = BLOBMSG_TYPE_INT32}, - [PROB_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32}, + [PROB_BSSID_ADDR] = {.name = "bssid", .type = BLOBMSG_TYPE_STRING}, + [PROB_CLIENT_ADDR] = {.name = "address", .type = BLOBMSG_TYPE_STRING}, + [PROB_TARGET_ADDR] = {.name = "target", .type = BLOBMSG_TYPE_STRING}, + [PROB_SIGNAL] = {.name = "signal", .type = BLOBMSG_TYPE_INT32}, + [PROB_FREQ] = {.name = "freq", .type = BLOBMSG_TYPE_INT32}, + [PROB_HT_SUPPORT] = {.name = "ht_support", .type = BLOBMSG_TYPE_INT8}, + [PROB_VHT_SUPPORT] = {.name = "vht_support", .type = BLOBMSG_TYPE_INT8}, }; enum { @@ -127,18 +131,18 @@ int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req) { if (tb[PROB_SIGNAL]) { prob_req->signal = blobmsg_get_u32(tb[PROB_SIGNAL]); - } - else - { - return -1; } if (tb[PROB_FREQ]) { prob_req->freq = blobmsg_get_u32(tb[PROB_FREQ]); } - else - { - return -1; + + if (tb[PROB_HT_SUPPORT]) { + prob_req->ht_support = blobmsg_get_u8(tb[PROB_HT_SUPPORT]); + } + + if (tb[PROB_VHT_SUPPORT]) { + prob_req->vht_support = blobmsg_get_u8(tb[PROB_VHT_SUPPORT]); } return 0; @@ -265,6 +269,7 @@ dump_client(struct blob_attr **tb, uint8_t client_addr[], const char* bssid_addr //sprintf(mac_buf_ap, "%x:%x:%x:%x:%x:%x", MAC2STR(client_entry.bssid_addr)); //sprintf(mac_buf_client, "%x:%x:%x:%x:%x:%x", MAC2STR(client_entry.client_addr)); + //printf("Frequency is: %d\n",freq); client_entry.freq = freq; client_entry.ht_supported = ht_supported;