imrove probe steering (fix log + do not reset try)

This commit is contained in:
Martin/Geno 2018-07-17 23:12:07 +02:00
parent ef40400d12
commit b9cc6b0c3e
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
4 changed files with 39 additions and 14 deletions

View File

@ -108,7 +108,7 @@ static int receive_notify(struct ubus_context *ctx, struct ubus_object *obj, str
// handle
log_verbose("%s["MACSTR"] freq: %d signal %d", method, MAC2STR(addr), freq, ssi_signal);
if (!strcmp(method, "auth")) {
if (wifi_clients_try(addr, freq, ssi_signal)) {
if (wifi_clients_try(true, addr, freq, ssi_signal)) {
log_debug(" -> reject\n");
return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
}
@ -118,7 +118,7 @@ static int receive_notify(struct ubus_context *ctx, struct ubus_object *obj, str
if (!strcmp(method, "probe")) {
if(client_probe_steering) {
if (wifi_clients_try(addr, freq, ssi_signal)) {
if (wifi_clients_try(false, addr, freq, ssi_signal)) {
log_debug(" -> reject\n");
return WLAN_STATUS_UNSPECIFIED_FAILURE;
}

View File

@ -20,7 +20,8 @@ static int ubus_get_clients(struct ubus_context *ctx, struct ubus_object *obj,
sprintf(mac_buf, MACSTR, MAC2STR(el->addr));
c = blobmsg_open_table(&b, mac_buf);
blobmsg_add_u32(&b, "try", el->try);
blobmsg_add_u32(&b, "try_probe", el->try_probe);
blobmsg_add_u32(&b, "try_auth", el->try_auth);
blobmsg_add_u32(&b, "time", el->time);
blobmsg_add_u32(&b, "authed", el->authed);
blobmsg_add_u32(&b, "connected", el->connected);

View File

@ -72,7 +72,8 @@ struct wifi_client *__get_client(const u8 *address){
log_debug("wifi_clients.__get_client("MACSTR"): gen new client\n", MAC2STR(address));
client = calloc(sizeof(*client), 1);
memcpy(client->addr, address, sizeof(client->addr));
client->try = 0;
client->try_probe = 0;
client->try_auth = 0;
time(&client->time);
client->authed = 0;
client->connected = 0;
@ -107,17 +108,27 @@ void wifi_clients_learn(const u8 *address, uint32_t freq, uint32_t ssi_signal) {
__client_learn(client, freq, ssi_signal);
}
int wifi_clients_try(const u8 *address, uint32_t freq, uint32_t ssi_signal) {
int wifi_clients_try(bool auth, const u8 *address, uint32_t freq, uint32_t ssi_signal) {
struct wifi_client *client;
client = __get_client(address);
__client_learn(client, freq, ssi_signal);
client->try++;
log_info("auth(mac="MACSTR" freq=%d ssi=%d try=%d): ", MAC2STR(address), freq, ssi_signal, client->try);
if (auth) {
log_info("auth(try=%d", client->try_auth);
client->try_auth++;
client->try_probe = 0;
}else{
log_info("probe(try=%d", client->try_probe);
client->try_probe++;
}
log_info(" mac="MACSTR" freq=%d ssi=%d): ", MAC2STR(address), freq, ssi_signal);
if (freq > WIFI_CLIENT_FREQ_THREASHOLD) {
log_info("accept\n");
client->try = 0;
if(!auth){
client->try_probe = 0;
return 0;
}
client->try_auth = 0;
client->authed = 1;
client->connected = 1;
return 0;
@ -126,18 +137,30 @@ int wifi_clients_try(const u8 *address, uint32_t freq, uint32_t ssi_signal) {
if (client->freq_highest > WIFI_CLIENT_FREQ_THREASHOLD &&
ssi_signal > client_signal_threashold
) {
log_info("reject - learned higher freq + ssi is high enough\n");
return -1;
}
if(client->try > client_try_threashold) {
if(auth && client->try_auth > client_try_threashold ||
!auth && client->try_probe > client_try_threashold
) {
log_info("accept - threashold\n");
client->try = 0;
if(!auth){
client->try_probe = 0;
return 0;
}
client->try_auth = 0;
client->authed = 1;
client->connected = 1;
return 0;
}
log_info("reject\n");
return client->try;
if(auth){
return client->try_auth;
}
return client->try_probe;
}
void wifi_clients_disconnect(const u8 *address, uint32_t freq, uint32_t ssi_signal) {

View File

@ -17,7 +17,8 @@ struct wifi_client {
struct avl_node avl;
u8 addr[ETH_ALEN];
time_t time;
int try;
int try_probe;
int try_auth;
bool connected;
bool authed;
uint32_t freq_highest;
@ -31,7 +32,7 @@ int wifi_clients_init();
void wifi_clients_close();
void wifi_clients_learn(const uint8_t *address, uint32_t freq, uint32_t ssi_signal);
int wifi_clients_try(const uint8_t *address, uint32_t freq, uint32_t ssi_signal);
int wifi_clients_try(bool auth, const uint8_t *address, uint32_t freq, uint32_t ssi_signal);
void wifi_clients_disconnect(const uint8_t *address, uint32_t freq, uint32_t ssi_signal);
void wifi_clients_del(const u8 *addr);