mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Merge branch 'master' into feature/use_notify
This commit is contained in:
commit
966619612e
6 changed files with 82 additions and 11 deletions
|
@ -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'
|
||||
|
@ -24,7 +24,7 @@ config metric
|
|||
option no_ht_support '0'
|
||||
option no_vht_support '0'
|
||||
option rssi '0'
|
||||
option low_rssi '0'
|
||||
option low_rssi '-500'
|
||||
option freq '100'
|
||||
option chan_util '0'
|
||||
option max_chan_util '0'
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
a4:2b:b0:de:f1:fd
|
||||
f0:79:60:1c:26:f0
|
|
@ -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 -------------------
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -190,6 +190,7 @@ int build_network_overview(struct blob_buf *b)
|
|||
int k;
|
||||
sprintf(ap_mac_buf, MACSTR, MAC2STR(client_array[i].bssid_addr));
|
||||
ap_list = blobmsg_open_table(b, ap_mac_buf);
|
||||
printf("AP MAC BUF: %s\n", ap_mac_buf);
|
||||
for (k = i; i <= client_entry_last; k++){
|
||||
if(!mac_is_equal(client_array[k].bssid_addr, client_array[i].bssid_addr))
|
||||
{
|
||||
|
@ -232,6 +233,9 @@ int eval_probe_metric(struct probe_entry_s probe_entry) {
|
|||
score += (probe_entry.signal >= dawn_metric.rssi_val) ? dawn_metric.rssi : 0;
|
||||
score += (probe_entry.signal <= dawn_metric.low_rssi_val) ? dawn_metric.low_rssi : 0;
|
||||
|
||||
if(score < 0)
|
||||
score = 0;
|
||||
|
||||
printf("SCORE: %d of:\n", score);
|
||||
print_probe_entry(probe_entry);
|
||||
|
||||
|
@ -427,6 +431,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]);
|
||||
|
||||
|
@ -542,7 +551,7 @@ client *client_array_delete(client entry) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int j = i; j <= client_entry_last; j++) {
|
||||
for (int j = i; j < client_entry_last; j++) {
|
||||
client_array[j] = client_array[j + 1];
|
||||
}
|
||||
|
||||
|
@ -596,7 +605,7 @@ probe_entry probe_array_delete(probe_entry entry) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int j = i; j <= probe_entry_last; j++) {
|
||||
for (int j = i; j < probe_entry_last; j++) {
|
||||
probe_array[j] = probe_array[j + 1];
|
||||
}
|
||||
|
||||
|
@ -606,6 +615,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;
|
||||
|
@ -765,7 +798,7 @@ ap ap_array_delete(ap entry) {
|
|||
}
|
||||
}
|
||||
|
||||
for (int j = i; j <= ap_entry_last; j++) {
|
||||
for (int j = i; j < ap_entry_last; j++) {
|
||||
ap_array[j] = ap_array[j + 1];
|
||||
}
|
||||
|
||||
|
@ -776,7 +809,7 @@ ap ap_array_delete(ap entry) {
|
|||
}
|
||||
|
||||
void remove_old_client_entries(time_t current_time, long long int threshold) {
|
||||
for (int i = 0; i < client_entry_last; i++) {
|
||||
for (int i = 0; i <= client_entry_last; i++) {
|
||||
if (client_array[i].time < current_time - threshold) {
|
||||
client_array_delete(client_array[i]);
|
||||
}
|
||||
|
@ -784,7 +817,7 @@ void remove_old_client_entries(time_t current_time, long long int threshold) {
|
|||
}
|
||||
|
||||
void remove_old_probe_entries(time_t current_time, long long int threshold) {
|
||||
for (int i = 0; i < probe_entry_last; i++) {
|
||||
for (int i = 0; i <= probe_entry_last; i++) {
|
||||
if (probe_array[i].time < current_time - threshold) {
|
||||
if (!is_connected(probe_array[i].bssid_addr, probe_array[i].client_addr))
|
||||
probe_array_delete(probe_array[i]);
|
||||
|
@ -793,7 +826,7 @@ void remove_old_probe_entries(time_t current_time, long long int threshold) {
|
|||
}
|
||||
|
||||
void remove_old_ap_entries(time_t current_time, long long int threshold) {
|
||||
for (int i = 0; i < ap_entry_last; i++) {
|
||||
for (int i = 0; i <= ap_entry_last; i++) {
|
||||
if (ap_array[i].time < current_time - threshold) {
|
||||
ap_array_delete(ap_array[i]);
|
||||
}
|
||||
|
|
|
@ -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, ¬ify_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");
|
||||
|
@ -891,6 +913,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue