From 1375b7a736b8a54e79f7132fab56554c401578cf Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 19 Dec 2017 18:56:12 +0100 Subject: [PATCH 1/2] check probe requests --- src/utils/ubus.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 5017262..a5b311c 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -337,7 +337,7 @@ static int handle_probe_req(struct blob_attr *msg) { parse_to_probe_req(msg, &prob_req); //insert_to_list(prob_req, 1); //probe_entry tmp_probe = - insert_to_array(prob_req, 1); + probe_entry tmp_prob_req = insert_to_array(prob_req, 1); // send probe via network @@ -348,12 +348,12 @@ static int handle_probe_req(struct blob_attr *msg) { printf("[WC] Hostapd-Probe: %s : %s\n", "probe", str); //print_probe_array(); - /* + // deny access - if (!decide_function(&tmp_probe)) { + if (!decide_function(&tmp_prob_req)) { //printf("MAC WILL BE DECLINED!!!\n"); return UBUS_STATUS_UNKNOWN_ERROR; - }*/ + } //printf("MAC WILL BE ACCEPDTED!!!\n"); return 0; } From bd1c38c0ea80b524c3abce04588f625031af3dd9 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 19 Dec 2017 19:07:41 +0100 Subject: [PATCH 2/2] add option to deny on probe requests --- files/dawn.config | 1 + src/include/datastorage.h | 1 + src/utils/dawn_uci.c | 8 ++++++++ src/utils/ubus.c | 6 ++++++ 4 files changed, 16 insertions(+) diff --git a/files/dawn.config b/files/dawn.config index a204eb8..bcd4a52 100644 --- a/files/dawn.config +++ b/files/dawn.config @@ -35,3 +35,4 @@ config settings metric option min_probe_count '4' option bandwith_threshold '6' option use_station_count '1' + option eval_probe_req '1' \ No newline at end of file diff --git a/src/include/datastorage.h b/src/include/datastorage.h index 6d7a6fd..2c1c65e 100644 --- a/src/include/datastorage.h +++ b/src/include/datastorage.h @@ -34,6 +34,7 @@ struct probe_metric_s { int min_probe_count; int bandwith_threshold; int use_station_count; + int eval_probe_req; }; struct time_config_s { diff --git a/src/utils/dawn_uci.c b/src/utils/dawn_uci.c index 05401a6..150e995 100644 --- a/src/utils/dawn_uci.c +++ b/src/utils/dawn_uci.c @@ -217,6 +217,14 @@ struct probe_metric_s uci_get_dawn_metric() { if (ptr.o->type == UCI_TYPE_STRING) ret.use_station_count = atoi(ptr.o->v.string); + char tmp_eval_probe_req[] = "dawn.metric.eval_probe_req"; + if (uci_lookup_ptr(c, &ptr, tmp_eval_probe_req, 1) != UCI_OK) { + uci_perror(c, "uci_get_daw_metric Error"); + return ret; + } + if (ptr.o->type == UCI_TYPE_STRING) + ret.eval_probe_req = atoi(ptr.o->v.string); + printf("Loaded metric: %d\n", ret.min_probe_count); uci_free_context(c); diff --git a/src/utils/ubus.c b/src/utils/ubus.c index a5b311c..9d28ec2 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -350,6 +350,12 @@ static int handle_probe_req(struct blob_attr *msg) { //print_probe_array(); // deny access + + if(!dawn_metric.eval_probe_req) + { + return 0; + } + if (!decide_function(&tmp_prob_req)) { //printf("MAC WILL BE DECLINED!!!\n"); return UBUS_STATUS_UNKNOWN_ERROR;