From 9e93c33be48e8f20c6451d763d61f56c8e43a819 Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Sun, 26 Apr 2015 12:46:28 +0000 Subject: [PATCH] Strict capwap added to ac.conf FossilOrigin-Name: 9b86298087cb4c758124a8b6afb9939c149ced4f8ea9abc7166a58deee417ef7 --- src/ac/ac.default.conf | 18 ++++++++++++++++++ src/ac/conf.c | 9 +++++++++ src/ac/conf.h | 2 ++ src/ac/wtpman.c | 8 +++----- src/wtp/cfg.c | 14 +++++++------- src/wtp/cfg.json | 4 ++-- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/ac/ac.default.conf b/src/ac/ac.default.conf index 524b3b40..4d703995 100644 --- a/src/ac/ac.default.conf +++ b/src/ac/ac.default.conf @@ -54,6 +54,24 @@ # cisco_software_version = +# strict_capwap +# +# Strict CAPWAP protocol +# If set to YES, AC-Tube for example complains about any message +# with missing mandatory elements. +# +# Default: +# strict_capwap = 1 + +# strict_headers +# +# If set to 1, any malformed packets wil b thrown away. +# +# Default: +# strict_headers = 1 + + + # image_dir # Directorie where firmware images are stored diff --git a/src/ac/conf.c b/src/ac/conf.c index e9ba4c55..32119797 100644 --- a/src/ac/conf.c +++ b/src/ac/conf.c @@ -34,6 +34,11 @@ uint8_t conf_macaddress[12]; uint8_t conf_macaddress_len=0; +int conf_strict_capwap=1; +int conf_strict_headers=1; + + + const char * conf_acname = NULL; int conf_acname_len = 0; @@ -585,6 +590,10 @@ int read_config(const char * filename){ CFG_STR_LIST("bcast_addrs", "{}", CFGF_NONE), CFG_STR_LIST("ac_ips","{}",CFGF_NONE), CFG_SIMPLE_STR("control_port",&conf_control_port), + + CFG_SIMPLE_BOOL("strict_capwap",&conf_strict_capwap), + CFG_SIMPLE_BOOL("strict_headers",&conf_strict_headers), + #ifdef WITH_LWAPP CFG_SIMPLE_STR("lw_control_port",&conf_lw_control_port), diff --git a/src/ac/conf.h b/src/ac/conf.h index 0c515ed0..1ae7387a 100644 --- a/src/ac/conf.h +++ b/src/ac/conf.h @@ -125,6 +125,8 @@ extern long conf_debug_level; extern uint8_t conf_macaddress[12]; extern uint8_t conf_macaddress_len; +extern int conf_strict_capwap; +extern int conf_strict_headers; #endif diff --git a/src/ac/wtpman.c b/src/ac/wtpman.c index 371cdf3c..57f2a4d0 100644 --- a/src/ac/wtpman.c +++ b/src/ac/wtpman.c @@ -18,7 +18,6 @@ #include "capwap/timer.h" -#include "conf.h" #include "capwap/lwmsg.h" #include "capwap/lwapp.h" @@ -110,8 +109,6 @@ static void wtpman_run_discovery(void *arg) struct conn * conn = wtpman->conn; -conn->strict_capwap=0; -conn->strict_hdr=1; conn->capwap_mode=CW_MODE_CIPWAP; conn->config = mbag_create(); @@ -242,8 +239,6 @@ static int wtpman_join(void *arg, time_t timer) struct conn * conn = wtpman->conn; -conn->strict_capwap=1; -conn->strict_hdr=1; conn->capwap_mode=CW_MODE_CIPWAP; @@ -482,6 +477,9 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr) return NULL; } + wtpman->conn->strict_capwap = conf_strict_capwap; + wtpman->conn->strict_hdr = conf_strict_headers; + return wtpman; } diff --git a/src/wtp/cfg.c b/src/wtp/cfg.c index 9e822a85..9b9a65c3 100644 --- a/src/wtp/cfg.c +++ b/src/wtp/cfg.c @@ -146,7 +146,7 @@ int cfg_json_get_ac_ip_list(struct mbag_itemdef *idef, char *js, jsmntok_t * t, mbag_t mbag) { - printf("Get AC IP List len = %d\n", t->size); +// printf("Get AC IP List len = %d\n", t->size); if (t->type != JSMN_ARRAY) { printf("ac_ip_list is not a list\n"); exit(0); @@ -330,7 +330,7 @@ int bstr16_local(struct mbag_itemdef *idef, char *js, jsmntok_t * t) } // *(js+t->end)=0; - printf("Set str: %d %s\n", item_id, str); +// printf("Set str: %d %s\n", item_id, str); mbag_set_bstr16n(conn->local, item_id, (uint8_t *) js + t->start, t->end - t->start); return 0; @@ -349,7 +349,7 @@ int bstr_local(struct mbag_itemdef *idef, char *js, jsmntok_t * t) } // *(js+t->end)=0; - printf("Set str: %d %s\n", item_id, str); +// printf("Set str: %d %s\n", item_id, str); bstr16_t v = bstr16cfgstr(str); @@ -793,8 +793,8 @@ static int cfg_json_get_ac_name_with_priority_cb(char *js, jsmntok_t * t, // printf("ACNAMEKEY: %s\n",key); - printf("Key: %s\n", key); - printf("Val: %s\n", val); +// printf("Key: %s\n", key); +// printf("Val: %s\n", val); mavl_replace(mbag, ac); return skip(t + 1); @@ -835,8 +835,8 @@ static int cfg_json_get_radios_cb(char *js, jsmntok_t * t, *(js + (t + 1)->end) = 0; const char *val = js + (t + 1)->start; - printf("Key: %s\n",key); - printf("Val: %s\n",val); +// printf("Key: %s\n",key); +// printf("Val: %s\n",val); diff --git a/src/wtp/cfg.json b/src/wtp/cfg.json index ee100edc..cfb12b1f 100644 --- a/src/wtp/cfg.json +++ b/src/wtp/cfg.json @@ -28,11 +28,11 @@ "radios":{ "0":{ "admin_state":"2", - "radio_type":"0" + "radio_type":"7" }, "1":{ "admin_state":"2", - "radio_type":"0" + "radio_type":"8" } }, "bssid":""