mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Fix remove function
This commit is contained in:
parent
0ea12984a8
commit
5aadda49c9
1 changed files with 25 additions and 7 deletions
|
@ -11,6 +11,7 @@ node* delete_probe_req(node* head, uint8_t bssid_addr[], uint8_t client_addr[]);
|
||||||
int mac_is_first_in_list(node* head, uint8_t bssid_addr[], uint8_t client_addr[]);
|
int mac_is_first_in_list(node* head, uint8_t bssid_addr[], uint8_t client_addr[]);
|
||||||
node* remove_node(node* head, node* curr, node* prev);
|
node* remove_node(node* head, node* curr, node* prev);
|
||||||
node* remove_old_entries(node* head, time_t current_time, long long int threshold);
|
node* remove_old_entries(node* head, time_t current_time, long long int threshold);
|
||||||
|
void print_list_with_head(node* head);
|
||||||
|
|
||||||
void insert_to_list(probe_entry entry)
|
void insert_to_list(probe_entry entry)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +20,7 @@ void insert_to_list(probe_entry entry)
|
||||||
entry.time = time(0);
|
entry.time = time(0);
|
||||||
|
|
||||||
// first delete probe request
|
// first delete probe request
|
||||||
//probe_list_head = remove_old_entries(probe_list_head, time(0), TIME_THRESHOLD);
|
probe_list_head = remove_old_entries(probe_list_head, time(0), TIME_THRESHOLD);
|
||||||
probe_list_head = delete_probe_req(probe_list_head, entry.bssid_addr, entry.client_addr);
|
probe_list_head = delete_probe_req(probe_list_head, entry.bssid_addr, entry.client_addr);
|
||||||
probe_list_head = insert(probe_list_head, entry);
|
probe_list_head = insert(probe_list_head, entry);
|
||||||
|
|
||||||
|
@ -178,18 +179,17 @@ node* remove_old_entries(node* head, time_t current_time, long long int threshol
|
||||||
node *next = head;
|
node *next = head;
|
||||||
while(next)
|
while(next)
|
||||||
{
|
{
|
||||||
//printf("Going next...\n");
|
|
||||||
//printf("Entry Time: %ld, Curr Time: %lld\n", next->data.time, current_time - threshold);
|
|
||||||
if(next->data.time < current_time - threshold)
|
if(next->data.time < current_time - threshold)
|
||||||
{
|
{
|
||||||
//printf("Removing node!\n");
|
|
||||||
head = remove_node(head, next, prev);
|
head = remove_node(head, next, prev);
|
||||||
|
print_list_with_head(head);
|
||||||
|
next = prev->ptr;
|
||||||
|
} else {
|
||||||
|
prev = next;
|
||||||
|
next = next->ptr;
|
||||||
}
|
}
|
||||||
prev = next;
|
|
||||||
next = next->ptr;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +277,24 @@ int mac_is_greater(uint8_t addr1[], uint8_t addr2[])
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_list_with_head(node* head)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&list_mutex);
|
||||||
|
printf("------------------\n");
|
||||||
|
if(head)
|
||||||
|
{
|
||||||
|
node* next;
|
||||||
|
next = head;
|
||||||
|
while(next)
|
||||||
|
{
|
||||||
|
print_probe_entry(next->data);
|
||||||
|
next = next->ptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("------------------\n");
|
||||||
|
pthread_mutex_unlock(&list_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
void print_list()
|
void print_list()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock(&list_mutex);
|
pthread_mutex_lock(&list_mutex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue