mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Merge pull request #8 from berlin-open-wireless-lab/feature/tidy_stuff
tidy up datastorage header
This commit is contained in:
commit
640b4b8a2b
4 changed files with 64 additions and 48 deletions
|
@ -13,8 +13,10 @@
|
||||||
#define ETH_ALEN 6
|
#define ETH_ALEN 6
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct probe_metric_s dawn_metric;
|
|
||||||
|
|
||||||
|
/* Metric */
|
||||||
|
|
||||||
|
// ---------------- Structs ----------------
|
||||||
struct probe_metric_s {
|
struct probe_metric_s {
|
||||||
int ht_support;
|
int ht_support;
|
||||||
int vht_support;
|
int vht_support;
|
||||||
|
@ -34,10 +36,13 @@ struct time_config_s {
|
||||||
time_t remove_probe;
|
time_t remove_probe;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SORT_NUM 5
|
// ---------------- Global variables ----------------
|
||||||
#define TIME_THRESHOLD 120 // every minute
|
struct probe_metric_s dawn_metric;
|
||||||
|
|
||||||
// Probe entrys
|
|
||||||
|
/* Probe, Auth, Assoc */
|
||||||
|
|
||||||
|
// ---------------- Structs ----------------
|
||||||
typedef struct probe_entry_s {
|
typedef struct probe_entry_s {
|
||||||
uint8_t bssid_addr[ETH_ALEN];
|
uint8_t bssid_addr[ETH_ALEN];
|
||||||
uint8_t client_addr[ETH_ALEN];
|
uint8_t client_addr[ETH_ALEN];
|
||||||
|
@ -60,11 +65,33 @@ typedef struct auth_entry_s {
|
||||||
|
|
||||||
typedef struct auth_entry_s assoc_entry;
|
typedef struct auth_entry_s assoc_entry;
|
||||||
|
|
||||||
|
// ---------------- Defines ----------------
|
||||||
|
#define PROBE_ARRAY_LEN 1000
|
||||||
|
|
||||||
typedef struct {
|
// ---------------- Global variables ----------------
|
||||||
uint32_t freq;
|
struct probe_entry_s probe_array[PROBE_ARRAY_LEN];
|
||||||
} client_request;
|
pthread_mutex_t probe_array_mutex;
|
||||||
|
|
||||||
|
// ---------------- Functions ----------------
|
||||||
|
probe_entry insert_to_array(probe_entry entry, int inc_counter);
|
||||||
|
|
||||||
|
void probe_array_insert(probe_entry entry);
|
||||||
|
|
||||||
|
probe_entry probe_array_delete(probe_entry entry);
|
||||||
|
|
||||||
|
probe_entry probe_array_get_entry(uint8_t bssid_addr[], uint8_t client_addr[]);
|
||||||
|
|
||||||
|
void print_probe_array();
|
||||||
|
|
||||||
|
void print_probe_entry(probe_entry entry);
|
||||||
|
|
||||||
|
void print_auth_entry(auth_entry entry);
|
||||||
|
|
||||||
|
void *remove_probe_array_thread(void *arg);
|
||||||
|
|
||||||
|
/* AP, Client */
|
||||||
|
|
||||||
|
// ---------------- Structs ----------------
|
||||||
typedef struct client_s {
|
typedef struct client_s {
|
||||||
uint8_t bssid_addr[ETH_ALEN];
|
uint8_t bssid_addr[ETH_ALEN];
|
||||||
uint8_t client_addr[ETH_ALEN];
|
uint8_t client_addr[ETH_ALEN];
|
||||||
|
@ -94,34 +121,21 @@ typedef struct ap_s {
|
||||||
time_t time;
|
time_t time;
|
||||||
} ap;
|
} ap;
|
||||||
|
|
||||||
// Array
|
// ---------------- Defines ----------------
|
||||||
#define ARRAY_AP_LEN 50
|
#define ARRAY_AP_LEN 50
|
||||||
#define TIME_THRESHOLD_AP 30
|
#define TIME_THRESHOLD_AP 30
|
||||||
struct ap_s ap_array[ARRAY_AP_LEN];
|
|
||||||
pthread_mutex_t ap_array_mutex;
|
|
||||||
|
|
||||||
ap insert_to_ap_array(ap entry);
|
|
||||||
|
|
||||||
void print_ap_array();
|
|
||||||
|
|
||||||
void *remove_ap_array_thread(void *arg);
|
|
||||||
|
|
||||||
ap ap_array_get_ap(uint8_t bssid_addr[]);
|
|
||||||
|
|
||||||
// Array
|
|
||||||
#define ARRAY_CLIENT_LEN 1000
|
#define ARRAY_CLIENT_LEN 1000
|
||||||
#define TIME_THRESHOLD_CLIENT 30
|
#define TIME_THRESHOLD_CLIENT 30
|
||||||
#define TIME_THRESHOLD_CLIENT_UPDATE 10
|
#define TIME_THRESHOLD_CLIENT_UPDATE 10
|
||||||
#define TIME_THRESHOLD_CLIENT_KICK 60
|
#define TIME_THRESHOLD_CLIENT_KICK 60
|
||||||
|
|
||||||
|
// ---------------- Global variables ----------------
|
||||||
struct client_s client_array[ARRAY_CLIENT_LEN];
|
struct client_s client_array[ARRAY_CLIENT_LEN];
|
||||||
pthread_mutex_t client_array_mutex;
|
pthread_mutex_t client_array_mutex;
|
||||||
|
struct ap_s ap_array[ARRAY_AP_LEN];
|
||||||
|
pthread_mutex_t ap_array_mutex;
|
||||||
|
|
||||||
int mac_is_equal(uint8_t addr1[], uint8_t addr2[]);
|
// ---------------- Functions ----------------
|
||||||
|
|
||||||
int mac_is_greater(uint8_t addr1[], uint8_t addr2[]);
|
|
||||||
|
|
||||||
void insert_client_to_array(client entry);
|
void insert_client_to_array(client entry);
|
||||||
|
|
||||||
void kick_clients(uint8_t bssid[], uint32_t id);
|
void kick_clients(uint8_t bssid[], uint32_t id);
|
||||||
|
@ -136,31 +150,33 @@ void print_client_entry(client entry);
|
||||||
|
|
||||||
void *remove_client_array_thread(void *arg);
|
void *remove_client_array_thread(void *arg);
|
||||||
|
|
||||||
#define ARRAY_LEN 1000
|
ap insert_to_ap_array(ap entry);
|
||||||
|
|
||||||
struct probe_entry_s probe_array[ARRAY_LEN];
|
void print_ap_array();
|
||||||
pthread_mutex_t probe_array_mutex;
|
|
||||||
|
|
||||||
probe_entry insert_to_array(probe_entry entry, int inc_counter);
|
void *remove_ap_array_thread(void *arg);
|
||||||
|
|
||||||
void probe_array_insert(probe_entry entry);
|
ap ap_array_get_ap(uint8_t bssid_addr[]);
|
||||||
|
|
||||||
probe_entry probe_array_delete(probe_entry entry);
|
/* Utils */
|
||||||
|
|
||||||
probe_entry probe_array_get_entry(uint8_t bssid_addr[], uint8_t client_addr[]);
|
// ---------------- Defines -------------------
|
||||||
|
#define SORT_NUM 5
|
||||||
|
#define TIME_THRESHOLD 120 // every minute
|
||||||
|
|
||||||
|
// ---------------- Global variables ----------------
|
||||||
|
char sort_string[SORT_NUM];
|
||||||
|
|
||||||
|
// ---------------- Functions -------------------
|
||||||
|
int mac_is_equal(uint8_t addr1[], uint8_t addr2[]);
|
||||||
|
|
||||||
|
int mac_is_greater(uint8_t addr1[], uint8_t addr2[]);
|
||||||
|
|
||||||
int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[]);
|
int better_ap_available(uint8_t bssid_addr[], uint8_t client_addr[]);
|
||||||
|
|
||||||
void print_array();
|
|
||||||
|
|
||||||
void print_probe_entry(probe_entry entry);
|
/* List stuff */
|
||||||
|
|
||||||
void print_auth_entry(auth_entry entry);
|
|
||||||
|
|
||||||
void *remove_array_thread(void *arg);
|
|
||||||
|
|
||||||
|
|
||||||
// List
|
|
||||||
typedef struct node {
|
typedef struct node {
|
||||||
probe_entry data;
|
probe_entry data;
|
||||||
struct node *ptr;
|
struct node *ptr;
|
||||||
|
@ -180,6 +196,6 @@ void *remove_thread(void *arg);
|
||||||
|
|
||||||
pthread_mutex_t list_mutex;
|
pthread_mutex_t list_mutex;
|
||||||
node *probe_list_head;
|
node *probe_list_head;
|
||||||
char sort_string[SORT_NUM];
|
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -211,7 +211,7 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
init_socket_runopts(opt_broadcast_ip, opt_broadcast_port, 1);
|
init_socket_runopts(opt_broadcast_ip, opt_broadcast_port, 1);
|
||||||
|
|
||||||
pthread_create(&tid_probe, NULL, &remove_array_thread, (void *) &time_config.remove_probe);
|
pthread_create(&tid_probe, NULL, &remove_probe_array_thread, (void *) &time_config.remove_probe);
|
||||||
pthread_create(&tid_client, NULL, &remove_client_array_thread, (void *) &time_config.remove_client);
|
pthread_create(&tid_client, NULL, &remove_client_array_thread, (void *) &time_config.remove_client);
|
||||||
pthread_create(&tid_get_client, NULL, &update_clients_thread, (void *) &time_config.update_client);
|
pthread_create(&tid_get_client, NULL, &update_clients_thread, (void *) &time_config.update_client);
|
||||||
//pthread_create(&tid_kick_clients, NULL, &kick_clients_thread, NULL);
|
//pthread_create(&tid_kick_clients, NULL, &kick_clients_thread, NULL);
|
||||||
|
|
|
@ -306,13 +306,13 @@ void probe_array_insert(probe_entry entry) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int j = probe_entry_last; j >= i; j--) {
|
for (int j = probe_entry_last; j >= i; j--) {
|
||||||
if (j + 1 <= ARRAY_LEN) {
|
if (j + 1 <= PROBE_ARRAY_LEN) {
|
||||||
probe_array[j + 1] = probe_array[j];
|
probe_array[j + 1] = probe_array[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
probe_array[i] = entry;
|
probe_array[i] = entry;
|
||||||
|
|
||||||
if (probe_entry_last < ARRAY_LEN) {
|
if (probe_entry_last < PROBE_ARRAY_LEN) {
|
||||||
probe_entry_last++;
|
probe_entry_last++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ probe_entry probe_array_get_entry(uint8_t bssid_addr[], uint8_t client_addr[]) {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_array() {
|
void print_probe_array() {
|
||||||
printf("------------------\n");
|
printf("------------------\n");
|
||||||
printf("Probe Entry Last: %d\n", probe_entry_last);
|
printf("Probe Entry Last: %d\n", probe_entry_last);
|
||||||
for (int i = 0; i <= probe_entry_last; i++) {
|
for (int i = 0; i <= probe_entry_last; i++) {
|
||||||
|
@ -539,7 +539,7 @@ void remove_old_ap_entries(time_t current_time, long long int threshold) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *remove_array_thread(void *arg) {
|
void *remove_probe_array_thread(void *arg) {
|
||||||
printf("Removing thread with time: %lu\n", *(long int *) arg);
|
printf("Removing thread with time: %lu\n", *(long int *) arg);
|
||||||
time_t time_treshold = *(time_t *) arg;
|
time_t time_treshold = *(time_t *) arg;
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
|
@ -216,7 +216,7 @@ int parse_to_probe_req(struct blob_attr *msg, probe_entry *prob_req) {
|
||||||
|
|
||||||
static int handle_auth_req(struct blob_attr *msg) {
|
static int handle_auth_req(struct blob_attr *msg) {
|
||||||
|
|
||||||
print_array();
|
print_probe_array();
|
||||||
auth_entry auth_req;
|
auth_entry auth_req;
|
||||||
parse_to_auth_req(msg, &auth_req);
|
parse_to_auth_req(msg, &auth_req);
|
||||||
printf("AUTH Entry: ");
|
printf("AUTH Entry: ");
|
||||||
|
@ -266,7 +266,7 @@ static int handle_probe_req(struct blob_attr *msg) {
|
||||||
|
|
||||||
printf("[WC] Hostapd-Probe: %s : %s\n", "probe", str);
|
printf("[WC] Hostapd-Probe: %s : %s\n", "probe", str);
|
||||||
|
|
||||||
print_array();
|
print_probe_array();
|
||||||
/*
|
/*
|
||||||
// deny access
|
// deny access
|
||||||
if (!decide_function(&tmp_probe)) {
|
if (!decide_function(&tmp_probe)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue