diff --git a/actube.workspace b/actube.workspace deleted file mode 100644 index c63c2d68..00000000 --- a/actube.workspace +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/cw/cfg.c b/src/cw/cfg.c index aa5401c0..3bf217ef 100644 --- a/src/cw/cfg.c +++ b/src/cw/cfg.c @@ -154,7 +154,6 @@ const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def) int i; struct cw_Cfg_entry e, *r; for(i=0; cfg[i]!=NULL; i++){ -// cw_dbg(DBG_X,"GET_L IN: %p",cfg[i]); e.key = key; r = mavl_get(cfg[i]->cfg, &e); if (r!=NULL) @@ -177,11 +176,29 @@ bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def) s = cw_cfg_get(cfg,key,def); if(s==NULL) + s=def; + if (s==NULL) return NULL; return bstr16_create_from_str(s); } +bstr16_t cw_cfg_get_bstr16_l(cw_Cfg_t **cfgs, const char * key, const char *def) +{ + bstr16_t s; + int i; + + for(i=0; cfgs[i]!=NULL; i++){ + s = cw_cfg_get_bstr16(cfgs[i],key,NULL); + if (s!=NULL) + return s; + } + if (def == NULL) + return NULL; + return bstr16_create_from_str(def); + +} + int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str) { CW_TYPE_BSTR16->read(cfg,key,bstr16_data(str),bstr16_len(str),NULL); diff --git a/src/cw/cfg.h b/src/cw/cfg.h index ea381956..ff96c246 100644 --- a/src/cw/cfg.h +++ b/src/cw/cfg.h @@ -93,6 +93,7 @@ int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n); int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len); +bstr16_t cw_cfg_get_bstr16_l(cw_Cfg_t **cfgs, const char * key, const char *def); #define cw_cfg_get_word2(cfg1,cfg2,key,def) \ cw_cfg_get_word(cfg1,key,cw_cfg_get_word(cfg2,key,def)) diff --git a/src/cw/cw_write_descriptor_subelem.c b/src/cw/cw_write_descriptor_subelem.c index 841ffb86..a5c19f99 100644 --- a/src/cw/cw_write_descriptor_subelem.c +++ b/src/cw/cw_write_descriptor_subelem.c @@ -8,24 +8,19 @@ int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list, int subelem_id, const char * parent_key ) { - char key[256]; + char key[CW_CFG_MAX_KEY_LEN]; uint32_t vendor; - //bstr16_t version; + bstr16_t version; const char *vendor_s; uint8_t *d; - - /* d += cw_put_dword(d, bstrv_get_vendor_id(v)); - d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v)); - d += cw_put_data(d, bstrv_data(v), bstrv_len(v)); - */ sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR); vendor_s = cw_cfg_get_l (cfg_list, key, NULL); if (vendor_s == NULL) { - cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key); - return 0; + cw_log (LOG_ERR, "Can't put subelem %s, no value of type found.", key); + vendor_s = "0"; } vendor = atoi(vendor_s); @@ -33,12 +28,13 @@ int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list, sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION); - cw_Val_t * val = cw_cfg_get_val_l(cfg_list, key, CW_TYPE_BSTR16); +// cw_Val_t * val = cw_cfg_get_val_l(cfg_list, key, CW_TYPE_BSTR16); + version = cw_cfg_get_bstr16_l(cfg_list,key,NULL); //version = cw_cfg_get_bstr16 (cfg, key, NULL); - if (val == NULL) { + if (version == NULL) { cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key); return 0; } @@ -49,14 +45,10 @@ int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list, d += cw_put_dword(d, vendor); //->type->put (vendor, d); /* put version */ - - d += cw_put_dword (d, (subelem_id << 16) | val->type->len(val)); -// d += cw_put_bstr16(d, version); - d += val->type->put(val,d); + d += cw_put_dword (d, (subelem_id << 16) | bstr16_len(version)); + d += cw_put_bstr16(d, version); - cw_val_destroy(val); - -// free(version); + free(version); return d-dst; } diff --git a/src/wtp/conf_uci.c b/src/wtp/conf_uci.c deleted file mode 100644 index f3191473..00000000 --- a/src/wtp/conf_uci.c +++ /dev/null @@ -1,242 +0,0 @@ - -#include -#include - -#include -#include -#include -#include -#include - - -#include - -#include "cw/capwap.h" -#include "cw/log.h" -#include "wtp_conf.h" - -#include "cw/log.h" -#include "cw/dbg.h" - -#include "cw/bstr.h" - - -static struct uci_section * get_anon_section(struct uci_package * pkg, const char *type) -{ - - struct uci_element * e; - struct uci_list * l = &pkg->sections; - - uci_foreach_element(l,e){ - struct uci_section *s = (struct uci_section*)e; - if (!s->anonymous) - continue; - - if (strcmp(s->type,type)==0){ - return s; - } - } - return NULL; - -} - - -static void set_dbg_opt(struct uci_context *ctx,struct uci_section * section,int opt,const char * optstr) -{ - - const char *str = uci_lookup_option_string(ctx,section,optstr); - if (!str){ - return; - } - - if ((strcmp(str,"1")==0) || (strcmp(str,"true")==0)) - //conf_dbg_level |= opt; - cw_dbg_set_level(opt,1); - - if ((strcmp(str,"0")==0) || (strcmp(str,"false")==0)) - cw_dbg_set_level(opt,0); - - -} - - -static void read_dbg_options(struct uci_context *ctx, struct uci_section *section) -{ - - int i; - for (i=0; cw_dbg_strings[i].id!=CW_STR_STOP; i++) { - - set_dbg_opt(ctx,section,cw_dbg_strings[i].id,cw_dbg_strings[i].str); - - } -} - -static void read_timers(struct uci_context *ctx,struct uci_section *section) -{ - int i; - for (i=0; conf_timer_cfgstrs[i].name; i++) { - - const char *str = uci_lookup_option_string(ctx,section,conf_timer_cfgstrs[i].name); - if ( str ) { - *(conf_timer_cfgstrs[i].value)=atol(str); - - } - - } - -} - -int read_config(const char * filename){ - - - struct uci_context * ctx; - - ctx = uci_alloc_context(); - if (!ctx){ - cw_log(LOG_ERR,"Fatal: Can't create uci ctx, can't read config file"); - return 0; - } - - struct uci_package * pkg; - - if (filename == NULL){ - filename = "wtp_uci.conf"; - } - cw_dbg(DBG_INFO,"Reading config file %s",filename); - - - int rc = uci_load(ctx, filename, &pkg ); - - if (rc == UCI_ERR_NOTFOUND){ - cw_log(LOG_INFO,"Config file '%s' not found, running without config",filename); - return 1; - } - - if (rc) { - char * errstr; - uci_get_errorstr(ctx, &errstr, ""); - cw_log(LOG_ERR,"Fatal: Can't read config file: %s",errstr); - return 0; - - } - - - struct uci_section * section; - - section = get_anon_section(pkg,"dbg"); - read_dbg_options(ctx,section); - - - - - - section = get_anon_section(pkg,"wtp"); - if (!section) { - cw_dbg(DBG_INFO,"No 'wtp' section found, running without config"); - return 1; - } - - read_timers(ctx,section); - - const char *str; - str = uci_lookup_option_string(ctx,section,"name"); - if (str) - conf_wtpname = strdup(str); - - str = uci_lookup_option_string(ctx,section,"mtu"); - if (str) - conf_mtu = atoi(str); - - str = uci_lookup_option_string(ctx,section,"mtu_discovery"); - if (str) - conf_mtu_discovery = atoi(str); - - str = uci_lookup_option_string(ctx,section,"interface"); - if (str) - conf_primary_if=strdup(str); - - str = uci_lookup_option_string(ctx,section,"ip"); - if (str) - conf_ip=strdup(str); - - str = uci_lookup_option_string(ctx,section,"ssl_key"); - if (str) - conf_sslkeyfilename=strdup(str); - - str = uci_lookup_option_string(ctx,section,"ssl_cert"); - if (str) - conf_sslcertfilename=strdup(str); - - str = uci_lookup_option_string(ctx,section,"dtls_psk"); - if (str) - conf_dtls_psk=strdup(str); - - str = uci_lookup_option_string(ctx,section,"ssl_cipher"); - if (str) - conf_dtls_cipher=strdup(str); - - - str = uci_lookup_option_string(ctx,section,"vendor_id"); - if (str) - conf_vendor_id=atoi(str); - - str = uci_lookup_option_string(ctx,section,"echo_interval"); - if (str) - conf_echo_interval=atoi(str); - - - str = uci_lookup_option_string(ctx,section,"software_version"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_software_version,s); - } - - str = uci_lookup_option_string(ctx,section,"hardware_version"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_hardware_version,s); - } - - str = uci_lookup_option_string(ctx,section,"bootloader_version"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_bootloader_version,s); - } - - - str = uci_lookup_option_string(ctx,section,"board_id"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_board_id,s); - } - - str = uci_lookup_option_string(ctx,section,"board_revision"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_board_revision,s); - } - - - str = uci_lookup_option_string(ctx,section,"serial_no"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_serial_no,s); - } - - - str = uci_lookup_option_string(ctx,section,"model_no"); - if (str){ - uint8_t * s = bstr16_create_from_cfgstr(str); - bstr16_replace(&conf_model_no,s); - } - - - - - - return 1; - -} - - - diff --git a/src/wtp/wtp_uci.default.conf b/src/wtp/wtp_uci.default.conf deleted file mode 100644 index 82f5116b..00000000 --- a/src/wtp/wtp_uci.default.conf +++ /dev/null @@ -1,75 +0,0 @@ -#default configuration file for wpt - -config 'wtp' - # WTP name - # (default is empty, the WTP will - # create a random name) - option name - - # MTU - option mtu 1500 - - # Do MTU discovery (means append mtu discovery - # padding msg element when sendig discovery requests) - option mtu_discovery 1 - - # SSL certificate and key - # (default is empty, you have to specify one) - option ssl_cert - option ssl_key - - # DTSL pre-shared key - option dtls_psk - - # ciphers - # - option ssl_cipher - - # vendor id - # set the vendor id as integer value - # default is gnu - option vendor_id - - option max_discovery_interval 30 - option discovery_interval 5 - - - # capwap mode - # possible values: capwap, cisco - # default is "capwap" - option capwap_mode "capwap" - - # bindings mode - # possible values: capwpa80211, cisco - - - # interface - # Interface to use as primary interface - # Default: wtp tries to determine the primary interface - # by itself. - option interface - - # ip - # IP address to use as - option ip - - - -config 'dbg' - # debug options - option info 0 - option dtls 0 - option dtls_detail 0 - option dtls_bio 0 - option dtls_bio_dmp 0 - option pkt_in 0 - option pkt_out 0 - option pkt_err 0 - option msg_in 0 - option msg_out 0 - option msg_err 0 - option elem 0 - option elem_err 0 - option elem_dmp 0 - option rfc 0 -