Merge pull request #35 from berlin-open-wireless-lab/feature/when_kicking_set_probe_count_to_min_probe_count_for_all_aps

Feature/when kicking set probe count to min probe count for all aps
This commit is contained in:
Polynomdivision 2017-12-30 13:17:06 +01:00 committed by GitHub
commit 2a4cbce855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 3 deletions

View file

@ -13,7 +13,7 @@ config hostapd
config times
option update_client '10'
option remove_client '120'
option remove_client '15'
option remove_probe '120'
option remove_ap '460'
option update_hostapd '10'
@ -32,7 +32,7 @@ config metric
option low_rssi_val '-80'
option chan_util_val '140'
option max_chan_util_val '170'
option min_probe_count '4'
option min_probe_count '0'
option bandwith_threshold '6'
option use_station_count '1'
option eval_probe_req '1'

View file

@ -203,6 +203,8 @@ int build_hearing_map_sort_client(struct blob_buf *b);
int build_network_overview(struct blob_buf *b);
int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count);
/* Utils */
// ---------------- Defines -------------------

View file

@ -40,4 +40,6 @@ int send_blob_attr_via_network(struct blob_attr *msg, char* method);
void blobmsg_add_macaddr(struct blob_buf *buf, const char *name, const uint8_t *addr);
int send_set_probe(uint8_t client_addr[]);
#endif

View file

@ -427,6 +427,11 @@ void kick_clients(uint8_t bssid[], uint32_t id) {
}
printf("Client is probably NOT in active transmisison. KICK! RxRate is: %f\n", rx_rate);
// here we should send a messsage to set the probe.count for all aps to the min that there is no delay between switching
// the hearing map is full...
send_set_probe(client_array[j].client_addr);
del_client_interface(id, client_array[j].client_addr, 5, 1, 1000);
client_array_delete(client_array[j]);
@ -606,6 +611,30 @@ probe_entry probe_array_delete(probe_entry entry) {
return tmp;
}
int probe_array_set_all_probe_count(uint8_t client_addr[], uint32_t probe_count) {
int updated = 0;
if (probe_entry_last == -1) {
return 0;
}
pthread_mutex_lock(&probe_array_mutex);
for (int i = 0; i <= probe_entry_last; i++) {
if (mac_is_equal(client_addr, probe_array[i].client_addr)) {
printf("SETTING MAC!!!\n");
probe_array[i].counter = probe_count;
}else if(!mac_is_greater(client_addr, probe_array[i].client_addr))
{
printf("MAC NOT FOUND!!!\n");
break;
}
}
pthread_mutex_unlock(&probe_array_mutex);
return updated;
}
int probe_array_update_rssi(uint8_t bssid_addr[], uint8_t client_addr[], uint32_t rssi) {
int updated = 0;

View file

@ -181,6 +181,8 @@ static int get_network(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg);
static int handle_set_probe(struct blob_attr *msg);
int hostapd_array_check_id(uint32_t id);
void hostapd_array_insert(uint32_t id);
@ -425,6 +427,20 @@ static int handle_deauth_req(struct blob_attr *msg) {
return 0;
}
static int handle_set_probe(struct blob_attr *msg) {
hostapd_notify_entry notify_req;
parse_to_hostapd_notify(msg, &notify_req);
client client_entry;
memcpy(client_entry.bssid_addr, notify_req.bssid_addr, sizeof(uint8_t) * ETH_ALEN );
memcpy(client_entry.client_addr, notify_req.client_addr, sizeof(uint8_t) * ETH_ALEN );
probe_array_set_all_probe_count(client_entry.client_addr, dawn_metric.min_probe_count);
return 0;
}
int handle_network_msg(char* msg)
{
//printf("HANDLING NETWORK MSG: %s\n", msg);
@ -485,6 +501,12 @@ int handle_network_msg(char* msg)
} else if (strncmp(method, "deauth", 5) == 0) {
printf("METHOD DEAUTH\n");
handle_deauth_req(data_buf.head);
} else if (strncmp(method, "setprobe", 5) == 0) {
printf("HANDLING SET PROBE!\n");
handle_set_probe(data_buf.head);
}
/*
hostapd_notify_entry entry;
parse_to_hostapd_notify(data_buf.head, &entry);
@ -496,7 +518,7 @@ int handle_network_msg(char* msg)
pthread_mutex_lock(&client_array_mutex);
client_array_delete(client_entry);
pthread_mutex_unlock(&client_array_mutex);*/
}
//}
//free(method);
//free(data);
//printf("HANDLING FINISHED NETWORK MSG!\n");
@ -889,6 +911,20 @@ int ubus_send_probe_via_network(struct probe_entry_s probe_entry) {
return 0;
}
int send_set_probe(uint8_t client_addr[])
{
printf("SENDING SET PROBE VIA NETWORK!\n");
blob_buf_init(&b_probe, 0);
blobmsg_add_macaddr(&b_probe, "bssid", client_addr);
blobmsg_add_macaddr(&b_probe, "address", client_addr);
send_blob_attr_via_network(b_probe.head, "setprobe");
return 0;
}
enum {
MAC_ADDR,
__ADD_DEL_MAC_MAX