mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Insert client to array
This commit is contained in:
parent
0030119350
commit
8531beee52
4 changed files with 26 additions and 1 deletions
|
@ -45,6 +45,7 @@ typedef struct client_s {
|
||||||
uint8_t vht;
|
uint8_t vht;
|
||||||
uint8_t wps;
|
uint8_t wps;
|
||||||
uint8_t mfp;
|
uint8_t mfp;
|
||||||
|
time_t time;
|
||||||
uint32_t aid;
|
uint32_t aid;
|
||||||
} client;
|
} client;
|
||||||
|
|
||||||
|
@ -57,6 +58,8 @@ typedef struct client_s {
|
||||||
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;
|
||||||
|
|
||||||
|
void insert_client_to_array(client entry);
|
||||||
|
|
||||||
void client_array_insert(client entry);
|
void client_array_insert(client entry);
|
||||||
client* client_array_delete(client entry);
|
client* client_array_delete(client entry);
|
||||||
void print_client_array();
|
void print_client_array();
|
||||||
|
|
|
@ -53,10 +53,17 @@ int main(int argc, char **argv) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pthread_mutex_init(&client_array_mutex, NULL) != 0) {
|
||||||
|
printf("\n mutex init failed\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
init_socket_runopts(opt_broadcast_ip, opt_broadcast_port, 0);
|
init_socket_runopts(opt_broadcast_ip, opt_broadcast_port, 0);
|
||||||
|
|
||||||
pthread_t tid;
|
pthread_t tid;
|
||||||
pthread_create(&tid, NULL, &remove_array_thread, NULL);
|
pthread_create(&tid, NULL, &remove_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);
|
||||||
|
|
|
@ -76,7 +76,7 @@ void client_array_insert(client entry)
|
||||||
int i;
|
int i;
|
||||||
for(i = 0; i <= client_entry_last; i++)
|
for(i = 0; i <= client_entry_last; i++)
|
||||||
{
|
{
|
||||||
if(!client_array_go_next("bs", 2, entry, client_array[i]))
|
if(!client_array_go_next("bc", 2, entry, client_array[i]))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,20 @@ void *remove_array_thread(void *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void insert_client_to_array(client entry)
|
||||||
|
{
|
||||||
|
pthread_mutex_lock(&client_array_mutex);
|
||||||
|
entry.time = time(0);
|
||||||
|
|
||||||
|
printf("Deleting Client:\n");
|
||||||
|
client_array_delete(entry);
|
||||||
|
printf("Inserting Client:\n");
|
||||||
|
client_array_insert(entry);
|
||||||
|
printf("Inseted Client\n");
|
||||||
|
|
||||||
|
|
||||||
|
pthread_mutex_unlock(&client_array_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -287,6 +287,8 @@ dump_client(struct blob_attr **tb, uint8_t client_addr[], const char* bssid_addr
|
||||||
client_entry.aid = blobmsg_get_u32(tb[CLIENT_AID]);
|
client_entry.aid = blobmsg_get_u32(tb[CLIENT_AID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insert_client_to_array(client_entry);
|
||||||
|
|
||||||
printf("Dumped Client!\n");
|
printf("Dumped Client!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue