From 07f02708bb6cc0a9a105d744ab776d23462eabba Mon Sep 17 00:00:00 2001 From: "7u83@mail.ru" <7u83@mail.ru@noemail.net> Date: Thu, 26 Apr 2018 04:50:32 +0000 Subject: [PATCH] Byte valguards fully implemented FossilOrigin-Name: 06e14f6c3efc2ff16b87540ca719639accadd9c919e47ab08b2768fd87482722 --- actube.workspace | 4 +-- src/ac/ac.conf | 1 + src/ac/config.ktv | 6 ++--- src/cw/cw_ktv_write_struct.c | 17 +++++++++++- src/cw/cw_type_byte.c | 39 +++++++++++++++++++++++++++- src/cw/cw_write_descriptor_subelem.c | 4 +-- src/mod/cisco/cisco_actions_ac.c | 4 +-- src/wtp/cisco.ktv | 6 ++--- src/wtp/wtp_main.c | 4 +-- 9 files changed, 69 insertions(+), 16 deletions(-) diff --git a/actube.workspace b/actube.workspace index c63c2d68..07586c53 100644 --- a/actube.workspace +++ b/actube.workspace @@ -1,10 +1,10 @@ - + - + diff --git a/src/ac/ac.conf b/src/ac/ac.conf index 9d207757..6036b395 100644 --- a/src/ac/ac.conf +++ b/src/ac/ac.conf @@ -136,6 +136,7 @@ strict_capwap = off # # Defalut: #listen = 192.168.0.14:1027 +listen = 192.168.56.1 # broadcast_listen - Broadcast listen address # If ommited, the boraadcast listen adresses a determined automatically diff --git a/src/ac/config.ktv b/src/ac/config.ktv index 89d92cde..62055c56 100644 --- a/src/ac/config.ktv +++ b/src/ac/config.ktv @@ -29,7 +29,7 @@ ac-descriptor/software/vendor :Dword: 4232704 ac-descriptor/software/version :Bstr16: .x07036500 ac-descriptor/station-limit :Word: 1000 ac-descriptor/stations :Word: 0 -capwap-control-ip-address/address.0 :IPAddress: 192.168.0.14 +capwap-control-ip-address/address.0 :IPAddress: 192.168.56.1 capwap-control-ip-address/wtps.0 :Word: 2 cisco/mwar-type :Byte: 0 maximum-message-length :Word: 4096 @@ -48,8 +48,8 @@ capwap-control-ip-address/wtps.0:Word:0 #capwap-control-ip-address/wtps.1:Word:11 -cisco/ssl-keyfile:Str:"../../ssl/certs/ac-cisco.key" -cisco/ssl-certfile:Str:"../../ssl/certs/ac-cisco.pem" +cisco/ssl-keyfile:Str:"../../ssl/certs/cisco-ac.key" +cisco/ssl-certfile:Str:"../../ssl/certs/cisco-ac.pem" cisco/ssl-cipher:Str:NORMAL #+DHE-RSA:+AES-256-CBC:+AES-128-CBC:+SHA1:+PSK cisco/ssl-dhbits:Word:2048 diff --git a/src/cw/cw_ktv_write_struct.c b/src/cw/cw_ktv_write_struct.c index fcd8bebc..7924e942 100644 --- a/src/cw/cw_ktv_write_struct.c +++ b/src/cw/cw_ktv_write_struct.c @@ -19,13 +19,28 @@ int cw_ktv_write_struct(mavl_t ktv, const cw_KTVStruct_t * stru, const char *pke memset(dst+pos,0,stru[i].len); sprintf(key,"%s/%s",pkey,stru[i].key); - result = cw_ktv_get(ktv,key,stru[i].type); + result = cw_ktv_get(ktv,key,NULL); + + if (result == NULL){ cw_log(LOG_ERR,"Can't put %s, no value found, filling zero.",key); memset(dst+pos,0,stru[i].len); } else{ + result->valguard=stru[i].valguard; + if (strcmp(stru[i].type->name,result->type->name)){ + printf("Type mismatch: %s != %s\n",stru[i].type->name,result->type->name); + if (stru[i].type->cast != NULL){ + if (!stru[i].type->cast(result)){ + cw_log(LOG_ERR,"Can't cast from %s to %s",result->type->name,stru[i].type->name); + exit(0); + } + } + + + } + result->type->put(result,dst+pos); } if (stru[i].len!=-1) diff --git a/src/cw/cw_type_byte.c b/src/cw/cw_type_byte.c index 7b33de9f..eb654473 100644 --- a/src/cw/cw_type_byte.c +++ b/src/cw/cw_type_byte.c @@ -61,9 +61,31 @@ static int to_str(const cw_KTV_t *data, char *dst, int max_len) } +static int get_guardval(const char *str, const cw_KTVValRange_t * valrange) +{ + while(valrange->name!=NULL){ + if(strcmp(str,valrange->name)==0) + return valrange->min; + valrange++; + } + return -1; +} + + static cw_KTV_t *from_str(cw_KTV_t * data, const char *src) { data->type = &cw_type_byte; + if (data->valguard != NULL){ + int rc; + rc = get_guardval(src,data->valguard); + if (rc != -1){ + data->val.byte = rc; + return data; + } + + } + + data->val.byte = atoi(src); return data; } @@ -86,6 +108,20 @@ static const char * get_type_name(cw_KTV_t *data) return CW_TYPE_BYTE->name; } +static int cast(cw_KTV_t * data) +{ + if (strcmp(data->type->name,CW_TYPE_BYTE->name)==0) + return 1; + if (strcmp(data->type->name,CW_TYPE_STR->name)==0){ + char *src = data->val.ptr; + CW_TYPE_BYTE->from_str(data,src); + free(src); + return 1; + } + return 0; +} + + const struct cw_Type cw_type_byte = { "Byte", /* name */ NULL, /* del */ @@ -95,5 +131,6 @@ const struct cw_Type cw_type_byte = { from_str, /* from_str */ len, /* len */ data, /* data */ - get_type_name /* get_type_name */ + get_type_name, /* get_type_name */ + cast }; diff --git a/src/cw/cw_write_descriptor_subelem.c b/src/cw/cw_write_descriptor_subelem.c index b9ebca34..3c0bae86 100644 --- a/src/cw/cw_write_descriptor_subelem.c +++ b/src/cw/cw_write_descriptor_subelem.c @@ -20,7 +20,7 @@ int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore, vendor = cw_ktv_get (ktvstore, key, CW_TYPE_DWORD); if (vendor == NULL) { - cw_log (LOG_ERR, "Can't put subelem %s, no value found.", key); + cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key); return 0; } @@ -29,7 +29,7 @@ int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore, version = cw_ktv_get (ktvstore, key, CW_TYPE_BSTR16); if (version == NULL) { - cw_log (LOG_ERR, "Can't put subelem %s, no value found.", key); + cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key); return 0; } diff --git a/src/mod/cisco/cisco_actions_ac.c b/src/mod/cisco/cisco_actions_ac.c index a6ffb0fb..61622326 100644 --- a/src/mod/cisco/cisco_actions_ac.c +++ b/src/mod/cisco/cisco_actions_ac.c @@ -1200,7 +1200,7 @@ static struct cw_ElemHandler handlers73[] = { cisco_radio_oper_state, /* type */ "operational-state", /* Key */ cw_in_radio_generic_struct, /* get */ - NULL, /* put */ + cw_out_radio_generic_struct, /* put */ NULL /* mkkey */ } , @@ -1258,7 +1258,7 @@ static struct cw_ElemDef join_request_elements[] ={ {0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 1, 0}, {0,CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_GROUP_NAME, 1, 0}, {0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_ADDR, 1, 0}, - {0,CW_VENDOR_ID_CISCO, CISCO_ELEM_SPAM_VENDOR_SPECIFIC,1, CW_IGNORE}, + {0,CW_VENDOR_ID_CISCO, CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE}, {CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_PATH_MTU, 0, 0}, diff --git a/src/wtp/cisco.ktv b/src/wtp/cisco.ktv index 629f61c1..0ea72fec 100644 --- a/src/wtp/cisco.ktv +++ b/src/wtp/cisco.ktv @@ -146,8 +146,8 @@ radio.0/cisco/wtp-radio-config/occupancy-limit :Word: 100 radio.0/cisco/wtp-radio-config/reg :Dword: 65536 radio.0/cisco/wtp-radio-config/unknown75 :Byte: 0 radio.0/decryption-error-report-period :Word: 120 -radio.0/operational-state/cause :Byte: 0 -radio.0/operational-state/state :Byte: 2 +radio.0/operational-state/cause :Str: 0 +radio.0/operational-state/state :Str: enabled radio.0/rate_set :Bstr16: .x82848b960c1218243048606c radio.0/wlan.0/allow-aaa-override :Byte: 1 radio.0/wlan.0/broadcast-ssid :Bool: true @@ -212,7 +212,7 @@ radio/wlan/radio-od :Byte: 1 radio/wlan/wlan-capability :Word: 17 radio/wlan/wlan-id :Byte: 0 result-code :Dword: 0 -session-id: .x00006215 +session-id:Bstr16: .x00006215 statistics-timer :Word: 60 tube.0/main :Byte: 12 tube.0/zumsel :Byte: 12 diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c index e44a1f7d..623bb7f0 100644 --- a/src/wtp/wtp_main.c +++ b/src/wtp/wtp_main.c @@ -192,8 +192,8 @@ exit(0); cw_discovery_init_results(&dis); - /*cw_run_discovery(conn, "255.255.255.255","192.168.56.1", &dis);*/ - cw_run_discovery(conn, "255.255.255.255",NULL, &dis); +cw_run_discovery(conn, "255.255.255.255","192.168.56.1", &dis); +/* cw_run_discovery(conn, "255.255.255.255",NULL, &dis);*/ cw_dbg_ktv_dump(dis.prio_ip, DBG_INFO, "=== IP list ===", "IP", "=== END IP List ==="); /*