steering on probes

This commit is contained in:
Martin/Geno 2018-07-17 22:52:29 +02:00
parent c723c8c182
commit 63e16dd756
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
4 changed files with 55 additions and 16 deletions

View File

@ -7,8 +7,6 @@
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
client_probe_learning = 1;
int ret = 0; int ret = 0;
#ifdef MINI #ifdef MINI

View File

@ -7,7 +7,9 @@
#include "log.h" #include "log.h"
#include "wifi_clients.h" #include "wifi_clients.h"
int client_probe_learning = 0; bool client_probe_steering = true;
// steering contains learning already
bool client_probe_learning = false;
static struct blob_buf b; static struct blob_buf b;
@ -100,28 +102,37 @@ static int receive_notify(struct ubus_context *ctx, struct ubus_object *obj, str
// handle // handle
log_debug("ubus_events.receive_notify(): handle\n"); log_verbose("%s["MACSTR"] freq: %d signal %d", method, MAC2STR(addr), freq, ssi_signal);
if (!strcmp(method, "auth")) { if (!strcmp(method, "auth")) {
if (wifi_clients_try(addr, freq, ssi_signal)) { if (wifi_clients_try(addr, freq, ssi_signal)) {
log_debug("auth["MACSTR"] freq: %d signal %d -> reject\n", MAC2STR(addr), freq, ssi_signal); log_debug(" -> reject\n");
return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY; return WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY;
} }
log_debug("auth["MACSTR"] freq: %d signal %d -> accept\n", MAC2STR(addr), freq, ssi_signal); log_debug(" -> accept\n");
return WLAN_STATUS_SUCCESS; return WLAN_STATUS_SUCCESS;
} }
if (!strcmp(method, "probe")) {
log_verbose("%s["MACSTR"] freq: %d signal %d", method, MAC2STR(addr), freq, ssi_signal); if(client_probe_steering) {
if (!strcmp(method, "deauth")) { if (wifi_clients_try(addr, freq, ssi_signal)) {
log_verbose(" disconnect"); log_debug(" -> reject\n");
wifi_clients_disconnect(addr, freq, ssi_signal); return WLAN_STATUS_UNSPECIFIED_FAILURE;
} else if (!strcmp(method, "probe") && client_probe_learning) { }
log_verbose(" learn"); log_debug(" -> accept\n");
return WLAN_STATUS_SUCCESS;
}
if(client_probe_learning) {
log_verbose(" learn");
wifi_clients_learn(addr, freq, ssi_signal); wifi_clients_learn(addr, freq, ssi_signal);
}
}
if (!strcmp(method, "deauth")) {
wifi_clients_disconnect(addr, freq, ssi_signal);
log_verbose(" -> disconnect\n");
return WLAN_STATUS_SUCCESS;
} }
log_verbose("\n"); log_verbose("\n");
return WLAN_STATUS_SUCCESS; return WLAN_STATUS_SUCCESS;
} }

View File

@ -3,7 +3,13 @@
#include <libubus.h> #include <libubus.h>
extern int client_probe_learning; extern bool client_probe_steering;
/*
steering contains learning already:
when client_probe_steering is set,
client_probe_learning is ignored
*/
extern bool client_probe_learning;
int wifictld_ubus_bind_events(struct ubus_context *ctx); int wifictld_ubus_bind_events(struct ubus_context *ctx);

View File

@ -136,6 +136,26 @@ static int ubus_set_clean_values(struct ubus_context *ctx, struct ubus_object *o
return 0; return 0;
} }
static int ubus_is_client_probe_steering(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
{
blob_buf_init(&b, 0);
blobmsg_add_u32(&b, "current", client_probe_steering);
ubus_send_reply(ctx, req, b.head);
return 0;
}
static int ubus_toggle_client_probe_steering(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg)
{
blob_buf_init(&b, 0);
blobmsg_add_u32(&b, "before", client_probe_steering);
client_probe_steering = !client_probe_steering;
blobmsg_add_u32(&b, "current", client_probe_steering);
ubus_send_reply(ctx, req, b.head);
return 0;
}
static int ubus_is_client_probe_learning(struct ubus_context *ctx, struct ubus_object *obj, static int ubus_is_client_probe_learning(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method, struct blob_attr *msg) struct ubus_request_data *req, const char *method, struct blob_attr *msg)
{ {
@ -170,6 +190,10 @@ static const struct ubus_method wifictld_ubus_methods[] = {
UBUS_METHOD_NOARG("get_clean_values", ubus_get_clean_values), UBUS_METHOD_NOARG("get_clean_values", ubus_get_clean_values),
UBUS_METHOD("set_clean_values", ubus_set_clean_values, ubus_set_clean_values_policy), UBUS_METHOD("set_clean_values", ubus_set_clean_values, ubus_set_clean_values_policy),
// steering by probe (or only auth)
UBUS_METHOD_NOARG("is_client_probe_steering", ubus_is_client_probe_steering),
UBUS_METHOD_NOARG("toggle_client_probe_steering", ubus_toggle_client_probe_steering),
// learn by probe (or only auth) // learn by probe (or only auth)
UBUS_METHOD_NOARG("is_client_probe_learning", ubus_is_client_probe_learning), UBUS_METHOD_NOARG("is_client_probe_learning", ubus_is_client_probe_learning),
UBUS_METHOD_NOARG("toggle_client_probe_learning", ubus_toggle_client_probe_learning), UBUS_METHOD_NOARG("toggle_client_probe_learning", ubus_toggle_client_probe_learning),