mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Add remove ap thread
This commit is contained in:
parent
67fcaba74c
commit
61cc5c1939
3 changed files with 24 additions and 0 deletions
|
@ -91,6 +91,7 @@ pthread_mutex_t ap_array_mutex;
|
||||||
|
|
||||||
ap insert_to_ap_array(ap entry);
|
ap insert_to_ap_array(ap entry);
|
||||||
void print_ap_array();
|
void print_ap_array();
|
||||||
|
void *remove_ap_array_thread(void *arg);
|
||||||
|
|
||||||
// Array
|
// Array
|
||||||
#define ARRAY_CLIENT_LEN 1000
|
#define ARRAY_CLIENT_LEN 1000
|
||||||
|
|
|
@ -98,6 +98,9 @@ int main(int argc, char **argv) {
|
||||||
pthread_t tid_kick_clients;
|
pthread_t tid_kick_clients;
|
||||||
pthread_create(&tid_kick_clients, NULL, &kick_clients_thread, NULL);
|
pthread_create(&tid_kick_clients, NULL, &kick_clients_thread, NULL);
|
||||||
|
|
||||||
|
pthread_t tid_ap;
|
||||||
|
pthread_create(&tid_ap, NULL, &remove_ap_array_thread, NULL);
|
||||||
|
|
||||||
//pthread_create(&tid, NULL, &remove_thread, NULL);
|
//pthread_create(&tid, NULL, &remove_thread, NULL);
|
||||||
|
|
||||||
dawn_init_ubus(ubus_socket, opt_hostapd_dir);
|
dawn_init_ubus(ubus_socket, opt_hostapd_dir);
|
||||||
|
|
|
@ -28,6 +28,8 @@ void ap_array_insert(ap entry);
|
||||||
|
|
||||||
ap ap_array_delete(ap entry);
|
ap ap_array_delete(ap entry);
|
||||||
|
|
||||||
|
void remove_old_ap_entries(time_t current_time, long long int threshold);
|
||||||
|
|
||||||
void print_ap_entry(ap entry);
|
void print_ap_entry(ap entry);
|
||||||
|
|
||||||
int probe_entry_last = -1;
|
int probe_entry_last = -1;
|
||||||
|
@ -425,6 +427,14 @@ 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 < probe_entry_last; i++) {
|
||||||
|
if (ap_array[i].time < current_time - threshold) {
|
||||||
|
ap_array_delete(ap_array[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void *remove_array_thread(void *arg) {
|
void *remove_array_thread(void *arg) {
|
||||||
while (1) {
|
while (1) {
|
||||||
sleep(TIME_THRESHOLD);
|
sleep(TIME_THRESHOLD);
|
||||||
|
@ -447,6 +457,16 @@ void *remove_client_array_thread(void *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *remove_ap_array_thread(void *arg) {
|
||||||
|
while (1) {
|
||||||
|
sleep(TIME_THRESHOLD_AP);
|
||||||
|
pthread_mutex_lock(&ap_array_mutex);
|
||||||
|
printf("[Thread] : Removing old ap entries!\n");
|
||||||
|
remove_old_ap_entries(time(0), TIME_THRESHOLD_AP);
|
||||||
|
pthread_mutex_unlock(&ap_array_mutex);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void insert_client_to_array(client entry) {
|
void insert_client_to_array(client entry) {
|
||||||
pthread_mutex_lock(&client_array_mutex);
|
pthread_mutex_lock(&client_array_mutex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue