mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-02-12 08:41:51 +00:00
feed hostapd with nr reports
This commit is contained in:
parent
1804d18bf5
commit
a63c723e31
5 changed files with 64 additions and 2 deletions
|
@ -62,6 +62,7 @@ struct probe_metric_s {
|
|||
int use_driver_recog;
|
||||
int min_kick_count;
|
||||
int chan_util_avg_period;
|
||||
int set_hostapd_nr;
|
||||
int kicking;
|
||||
int op_class;
|
||||
int duration;
|
||||
|
@ -267,6 +268,8 @@ int ap_get_collision_count(int col_domain);
|
|||
|
||||
void send_beacon_reports(uint8_t bssid[], int id);
|
||||
|
||||
int ap_get_nr(struct blob_buf *b, uint8_t own_bssid_addr[]);
|
||||
|
||||
/* Utils */
|
||||
|
||||
// ---------------- Defines -------------------
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define STR2MAC(a) &(a)[0], &(a)[1], &(a)[2], &(a)[3], &(a)[4], &(a)[5]
|
||||
|
||||
#define MACSTR "%02X:%02X:%02X:%02X:%02X:%02X"
|
||||
#define MACSTRLOWER "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
|
||||
/**
|
||||
* Convert char to binary.
|
||||
|
|
|
@ -894,6 +894,37 @@ ap insert_to_ap_array(ap entry) {
|
|||
return entry;
|
||||
}
|
||||
|
||||
|
||||
int ap_get_nr(struct blob_buf *b_local, uint8_t own_bssid_addr[]) {
|
||||
|
||||
pthread_mutex_lock(&ap_array_mutex);
|
||||
int i;
|
||||
|
||||
void* nbs = blobmsg_open_array(b_local, "list");
|
||||
|
||||
for (i = 0; i <= ap_entry_last; i++) {
|
||||
if (mac_is_equal(own_bssid_addr, ap_array[i].bssid_addr)) {
|
||||
continue; //TODO: Skip own entry?!
|
||||
}
|
||||
|
||||
void* nr_entry = blobmsg_open_array(b_local, NULL);
|
||||
|
||||
char mac_buf[20];
|
||||
sprintf(mac_buf, MACSTRLOWER, MAC2STR(ap_array[i].bssid_addr));
|
||||
blobmsg_add_string(b_local, NULL, mac_buf);
|
||||
|
||||
blobmsg_add_string(b_local, NULL, (char *) ap_array[i].ssid);
|
||||
blobmsg_add_string(b_local, NULL, ap_array[i].neighbor_report);
|
||||
blobmsg_close_array(b_local, nr_entry);
|
||||
|
||||
}
|
||||
blobmsg_close_array(b_local, nbs);
|
||||
|
||||
pthread_mutex_unlock(&ap_array_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ap_get_collision_count(int col_domain) {
|
||||
|
||||
int ret_sta_count = 0;
|
||||
|
|
|
@ -77,6 +77,7 @@ struct probe_metric_s uci_get_dawn_metric() {
|
|||
ret.use_driver_recog = uci_lookup_option_int(uci_ctx, s, "use_driver_recog");
|
||||
ret.min_kick_count = uci_lookup_option_int(uci_ctx, s, "min_number_to_kick");
|
||||
ret.chan_util_avg_period = uci_lookup_option_int(uci_ctx, s, "chan_util_avg_period");
|
||||
ret.set_hostapd_nr = uci_lookup_option_int(uci_ctx, s, "set_hostapd_nr");
|
||||
ret.op_class = uci_lookup_option_int(uci_ctx, s, "op_class");
|
||||
ret.duration = uci_lookup_option_int(uci_ctx, s, "duration");
|
||||
ret.mode = uci_lookup_option_int(uci_ctx, s, "mode");
|
||||
|
|
|
@ -35,6 +35,7 @@ static struct blob_buf b_notify;
|
|||
static struct blob_buf b_clients;
|
||||
static struct blob_buf b_umdns;
|
||||
static struct blob_buf b_beacon;
|
||||
static struct blob_buf b_nr;
|
||||
|
||||
void update_clients(struct uloop_timeout *t);
|
||||
|
||||
|
@ -325,6 +326,8 @@ bool subscribe(struct hostapd_sock_entry *hostapd_entry);
|
|||
|
||||
int parse_to_beacon_rep(struct blob_attr *msg, probe_entry *beacon_rep);
|
||||
|
||||
void ubus_set_nr();
|
||||
|
||||
void add_client_update_timer(time_t time) {
|
||||
uloop_timeout_set(&client_timer, time);
|
||||
}
|
||||
|
@ -1108,6 +1111,8 @@ static int ubus_get_rrm() {
|
|||
|
||||
void update_clients(struct uloop_timeout *t) {
|
||||
ubus_get_clients();
|
||||
if(dawn_metric.set_hostapd_nr)
|
||||
ubus_set_nr();
|
||||
// maybe to much?! don't set timer again...
|
||||
uloop_timeout_set(&client_timer, timeout_config.update_client * 1000);
|
||||
}
|
||||
|
@ -1187,6 +1192,21 @@ void update_hostapd_sockets(struct uloop_timeout *t) {
|
|||
uloop_timeout_set(&hostapd_timer, timeout_config.update_hostapd * 1000);
|
||||
}
|
||||
|
||||
void ubus_set_nr(){
|
||||
struct hostapd_sock_entry *sub;
|
||||
|
||||
|
||||
list_for_each_entry(sub, &hostapd_sock_list, list)
|
||||
{
|
||||
if (sub->subscribed) {
|
||||
int timeout = 1;
|
||||
blob_buf_init(&b_nr, 0);
|
||||
ap_get_nr(&b_nr, sub->bssid_addr);
|
||||
ubus_invoke(ctx, sub->id, "rrm_nr_set", b_nr.head, NULL, NULL, timeout * 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void del_client_all_interfaces(const uint8_t *client_addr, uint32_t reason, uint8_t deauth, uint32_t ban_time) {
|
||||
struct hostapd_sock_entry *sub;
|
||||
|
||||
|
@ -1226,7 +1246,7 @@ void del_client_interface(uint32_t id, const uint8_t *client_addr, uint32_t reas
|
|||
}
|
||||
|
||||
void wnm_disassoc_imminent(uint32_t id, const uint8_t *client_addr, char* dest_ap, uint32_t duration) {
|
||||
struct hostapd_sock_entry *sub;
|
||||
struct hostapd_sock_entry *sub;
|
||||
|
||||
blob_buf_init(&b, 0);
|
||||
blobmsg_add_macaddr(&b, "addr", client_addr);
|
||||
|
@ -1245,7 +1265,7 @@ void wnm_disassoc_imminent(uint32_t id, const uint8_t *client_addr, char* dest_a
|
|||
list_for_each_entry(sub, &hostapd_sock_list, list)
|
||||
{
|
||||
if (sub->subscribed) {
|
||||
int timeout = 1;
|
||||
int timeout = 1; //TDO: Maybe ID is wrong?! OR CHECK HERE ID
|
||||
ubus_invoke(ctx, id, "wnm_disassoc_imminent", b.head, NULL, NULL, timeout * 1000);
|
||||
}
|
||||
}
|
||||
|
@ -1664,6 +1684,7 @@ int uci_send_via_network()
|
|||
blobmsg_add_u32(&b, "use_driver_recog", dawn_metric.use_driver_recog);
|
||||
blobmsg_add_u32(&b, "min_number_to_kick", dawn_metric.min_kick_count);
|
||||
blobmsg_add_u32(&b, "chan_util_avg_period", dawn_metric.chan_util_avg_period);
|
||||
blobmsg_add_u32(&b, "set_hostapd_nr", dawn_metric.set_hostapd_nr);
|
||||
blobmsg_add_u32(&b, "op_class", dawn_metric.op_class);
|
||||
blobmsg_add_u32(&b, "duration", dawn_metric.duration);
|
||||
blobmsg_add_u32(&b, "mode", dawn_metric.mode);
|
||||
|
@ -1719,6 +1740,7 @@ enum {
|
|||
UCI_USE_DRIVER_RECOG,
|
||||
UCI_MIN_NUMBER_TO_KICK,
|
||||
UCI_CHAN_UTIL_AVG_PERIOD,
|
||||
UCI_SET_HOSTAPD_NR,
|
||||
UCI_OP_CLASS,
|
||||
UCI_DURATION,
|
||||
UCI_MODE,
|
||||
|
@ -1771,6 +1793,7 @@ static const struct blobmsg_policy uci_metric_policy[__UCI_METIC_MAX] = {
|
|||
[UCI_USE_DRIVER_RECOG] = {.name = "use_driver_recog", .type = BLOBMSG_TYPE_INT32},
|
||||
[UCI_MIN_NUMBER_TO_KICK] = {.name = "min_number_to_kick", .type = BLOBMSG_TYPE_INT32},
|
||||
[UCI_CHAN_UTIL_AVG_PERIOD] = {.name = "chan_util_avg_period", .type = BLOBMSG_TYPE_INT32},
|
||||
[UCI_SET_HOSTAPD_NR] = {.name = "set_hostapd_nr", .type = BLOBMSG_TYPE_INT32},
|
||||
[UCI_OP_CLASS] = {.name = "op_class", .type = BLOBMSG_TYPE_INT32},
|
||||
[UCI_DURATION] = {.name = "duration", .type = BLOBMSG_TYPE_INT32},
|
||||
[UCI_MODE] = {.name = "mode", .type = BLOBMSG_TYPE_INT32},
|
||||
|
@ -1876,6 +1899,9 @@ int handle_uci_config(struct blob_attr *msg) {
|
|||
sprintf(cmd_buffer, "dawn.@metric[0].chan_util_avg_period=%d", blobmsg_get_u32(tb_metric[UCI_CHAN_UTIL_AVG_PERIOD]));
|
||||
uci_set_network(cmd_buffer);
|
||||
|
||||
sprintf(cmd_buffer, "dawn.@metric[0].set_hostapd_nr=%d", blobmsg_get_u32(tb_metric[UCI_SET_HOSTAPD_NR]));
|
||||
uci_set_network(cmd_buffer);
|
||||
|
||||
sprintf(cmd_buffer, "dawn.@metric[0].op_class=%d", blobmsg_get_u32(tb_metric[UCI_OP_CLASS]));
|
||||
uci_set_network(cmd_buffer);
|
||||
|
||||
|
|
Loading…
Reference in a new issue