mirror of
https://github.com/berlin-open-wireless-lab/DAWN.git
synced 2025-03-09 15:40:12 +00:00
Kick if rssi is not strong enough
This commit is contained in:
parent
5110bcfab6
commit
7a1c7e29d4
6 changed files with 62 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
config 'settings' 'dawn'
|
||||
option broadcast_ip '224.0.0.1'
|
||||
option broadcast_ip '10.0.0.255'
|
||||
option broadcast_port '1025'
|
||||
option sort_order 'cfsb'
|
||||
option sort_order 'csfb'
|
||||
option hostapd_dir '/var/run/hostapd'
|
||||
option background '0'
|
|
@ -54,12 +54,13 @@ typedef struct client_s {
|
|||
|
||||
|
||||
#define ARRAY_CLIENT_LEN 1000
|
||||
#define TIME_THRESHOLD_CLIENT 60
|
||||
#define TIME_THRESHOLD_CLIENT 5
|
||||
|
||||
struct client_s client_array[ARRAY_CLIENT_LEN];
|
||||
pthread_mutex_t client_array_mutex;
|
||||
|
||||
void insert_client_to_array(client entry);
|
||||
void kick_clients(uint8_t bssid[]);
|
||||
|
||||
void client_array_insert(client entry);
|
||||
client* client_array_delete(client entry);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef __DAWN_UBUS_H
|
||||
#define __DAWN_UBUS_H
|
||||
|
||||
#include <libubox/blobmsg_json.h>
|
||||
#include "datastorage.h"
|
||||
|
||||
#define MIN_PROBE_REQ 2 // TODO: Parse from config file...
|
||||
|
|
|
@ -59,7 +59,7 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
init_socket_runopts(opt_broadcast_ip, opt_broadcast_port, 0);
|
||||
init_socket_runopts(opt_broadcast_ip, opt_broadcast_port, 1);
|
||||
|
||||
pthread_t tid_probe;
|
||||
pthread_create(&tid_probe, NULL, &remove_array_thread, NULL);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "datastorage.h"
|
||||
|
||||
#include "ubus.h"
|
||||
|
||||
#define MAC2STR(a) (a)[0], (a)[1], (a)[2], (a)[3], (a)[4], (a)[5]
|
||||
|
||||
int go_next_help(char sort_order[], int i, probe_entry entry,
|
||||
|
@ -16,10 +18,59 @@ int client_array_go_next(char sort_order[], int i, client entry,
|
|||
int client_array_go_next_help(char sort_order[], int i, client entry,
|
||||
client next_entry);
|
||||
void remove_old_client_entries(time_t current_time, long long int threshold);
|
||||
int kick_client(uint8_t bssid[], uint8_t client[]);
|
||||
|
||||
int probe_entry_last = -1;
|
||||
int client_entry_last = -1;
|
||||
|
||||
int kick_client(uint8_t bssid[], uint8_t client[])
|
||||
{
|
||||
int i;
|
||||
for(i = 0; i <= client_entry_last; i++)
|
||||
{
|
||||
if(mac_is_equal(probe_array[i].client_addr, client))
|
||||
{
|
||||
// check if bssid is first in list...
|
||||
return (mac_is_equal(bssid, probe_array[i].bssid_addr));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void kick_clients(uint8_t bssid[])
|
||||
{
|
||||
// Seach for BSSID
|
||||
int i;
|
||||
for(i = 0; i <= client_entry_last; i++)
|
||||
{
|
||||
if(mac_is_equal(client_array[i].bssid_addr, bssid))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Go threw clients
|
||||
int j;
|
||||
for(j = i; j <= client_entry_last; j++)
|
||||
{
|
||||
if(!mac_is_equal(client_array[j].bssid_addr, bssid))
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(kick_client(bssid, client_array[j].client_addr))
|
||||
{
|
||||
/*
|
||||
TODO: KICK ONLY FROM ONE BSSID?
|
||||
*/
|
||||
printf("KICKING CLIENT!!!!!!!!!!!!!\n");
|
||||
del_client(client_array[j].client_addr, 5, 1, 60000);
|
||||
} else
|
||||
{
|
||||
printf("STAAAY CLIENT!!!!!!!!!!!!!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int client_array_go_next_help(char sort_order[], int i, client entry,
|
||||
client next_entry) {
|
||||
switch (sort_order[i]) {
|
||||
|
|
|
@ -333,8 +333,13 @@ int parse_to_clients(struct blob_attr *msg) {
|
|||
dump_client_table(blobmsg_data(tb[CLIENT_TABLE]), blobmsg_data_len(tb[CLIENT_TABLE]), blobmsg_data(tb[CLIENT_TABLE_BSSID]), blobmsg_get_u32(tb[CLIENT_TABLE_FREQ]));
|
||||
|
||||
/* BSSID */
|
||||
/*
|
||||
* here i know my bssid to kick the clients
|
||||
* seems a good idea ?!
|
||||
*/
|
||||
uint8_t bssid[ETH_ALEN];
|
||||
hwaddr_aton(blobmsg_data(tb[CLIENT_TABLE_BSSID]), bssid);
|
||||
kick_clients(bssid);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue