cw_Cfg_t is now a structure instead of typedef's mavl

shell
7u83 6 months ago
parent ee16f3794f
commit aa3d83d8a4
  1. 44
      src/cw/cfg.c
  2. 8
      src/cw/cfg.h
  3. 4
      src/cw/conn.h
  4. 2
      src/cw/cw.h
  5. 2
      src/cw/cw_write_radio_element.c
  6. 22
      src/cw/dbg.c
  7. 8
      src/cw/dbg.h
  8. 20
      src/cw/dbg_strings.c
  9. 2
      src/cw/val.h
  10. 0
      src/wtp/cfg.h.olf
  11. 2
      src/wtp/changestate.c
  12. 12
      src/wtp/cisco.ckv
  13. 3
      src/wtp/run.c

@ -83,7 +83,17 @@ static void del(void *ptr)
cw_Cfg_t *cw_cfg_create()
{
return mavl_create(cmp, del, sizeof(struct cw_Cfg_entry));
cw_Cfg_t * cfg;
cfg = malloc(sizeof(cw_Cfg_t));
if (cfg == NULL)
return NULL;
cfg->cfg = mavl_create(cmp, del, sizeof(struct cw_Cfg_entry));
if (cfg->cfg==NULL){
cw_cfg_destroy(cfg);
return NULL;
}
return cfg;
}
int cw_cfg_set(cw_Cfg_t * cfg, const char *key, const char *val)
@ -101,7 +111,7 @@ int cw_cfg_set(cw_Cfg_t * cfg, const char *key, const char *val)
free((void *) e.key);
return 0;
}
void *rc = mavl_replace(cfg, &e, &replaced);
void *rc = mavl_replace(cfg->cfg, &e, &replaced);
if (!rc) {
del(&e);
return 0;
@ -116,7 +126,7 @@ const char *cw_cfg_get(cw_Cfg_t * cfg, const char *key, const char *def)
{
struct cw_Cfg_entry e, *r;
e.key = key;
r = mavl_get(cfg, &e);
r = mavl_get(cfg->cfg, &e);
if (!r)
return def;
return r->val;
@ -129,7 +139,7 @@ const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def)
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], &e);
r = mavl_get(cfg[i]->cfg, &e);
if (r!=NULL)
return r->val;
}
@ -167,7 +177,7 @@ void cw_cfg_dump(cw_Cfg_t * cfg)
{
mavliter_t it;
struct cw_Cfg_entry *e;
mavliter_init(&it, cfg);
mavliter_init(&it, cfg->cfg);
mavliter_foreach(&it) {
e = mavliter_get(&it);
@ -475,7 +485,7 @@ int cw_cfg_write_to_file(FILE *f, cw_Cfg_t * cfg)
{
mavliter_t it;
struct cw_Cfg_entry *e;
mavliter_init(&it, cfg);
mavliter_init(&it, cfg->cfg);
mavliter_foreach(&it) {
int n;
e = mavliter_get(&it);
@ -519,7 +529,7 @@ void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base)
struct cw_Cfg_entry search;
search.key = base;
mavliter_init(&(cfi->it), cfg);
mavliter_init(&(cfi->it), cfg->cfg);
mavliter_seek(&(cfi->it), &search, 0);
cfi->base = base;
}
@ -642,7 +652,7 @@ int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
search.key=ikey;
/*//result = ktvn(ktv,&search);*/
result = mavl_get_last(cfg,&search);
result = mavl_get_last(cfg->cfg,&search);
if (result == NULL){
return 0;
}
@ -687,7 +697,7 @@ int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *type,
void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst)
{
mavliter_t it;
mavliter_init(&it, src);
mavliter_init(&it, src->cfg);
mavliter_foreach(&it) {
int exists;
struct cw_Cfg_entry * old_elem,*e, new_elem;
@ -705,7 +715,7 @@ void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst)
*/
old_elem = mavl_insert(dst,&new_elem,&exists);
old_elem = mavl_insert(dst->cfg,&new_elem,&exists);
/* cw_dbg(DBG_X, "CPY: %s: %s -> %s [%d]",new_elem.key,new_elem.val,old_elem->val,exists);
if (exists){
@ -731,10 +741,10 @@ void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst)
}
cw_dbg(DBG_CFG_SET, "Replace: %s: %s (old: %s)",new_elem.key, new_elem.val, old_elem->val);
if(dst->del){
dst->del(old_elem);
if(dst->cfg->del){
dst->cfg->del(old_elem);
}
memcpy(old_elem,&new_elem,dst->data_size);
memcpy(old_elem,&new_elem,dst->cfg->data_size);
}
}
@ -742,13 +752,15 @@ void cw_cfg_copy(cw_Cfg_t *src, cw_Cfg_t *dst)
void cw_cfg_destroy(cw_Cfg_t *cfg)
{
mavl_destroy(cfg);
if (cfg->cfg)
mavl_destroy(cfg->cfg);
free(cfg);
}
void cw_cfg_clear(cw_Cfg_t *cfg)
{
mavl_del_all(cfg);
mavl_del_all(cfg->cfg);
}
@ -757,7 +769,7 @@ int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key)
struct cw_Cfg_entry e, *result;
//cw_dbg(DBG_X,"LOOX FOR: %s",key);
e.key=key;
result = mavl_get_first(cfg,&e);
result = mavl_get_first(cfg->cfg,&e);
if (result == NULL)
return 0;
//cw_dbg(DBG_X,"BASEXXX: %s",result->key);

@ -7,7 +7,13 @@
#define CW_CFG_MAX_KEY_LEN 1024
typedef struct mavl cw_Cfg_t;
struct cw_Cfg {
struct mavl * cfg;
const char *name;
int dbg_level;
};
typedef struct cw_Cfg cw_Cfg_t;
cw_Cfg_t * cw_cfg_create();
int cw_cfg_set(cw_Cfg_t *cfg,const char *key, const char *val);

@ -78,14 +78,14 @@ struct cw_Conn {
cw_Cfg_t * local_cfg; /**< local_cfg contains overrides for global_cfg
wich are related to this conn object. */
mavl_t remote_cfg; /**< contains the configuration we now from the
cw_Cfg_t * remote_cfg; /**< contains the configuration we now from the
device this conn object ist connected to.
Typically this is what we have got from discovery
response or join response in WTP mode.
And in AC mode this contains date receive from
configuration status request. */
mavl_t update_cfg;
cw_Cfg_t * update_cfg;
bstr16_t session_id;

@ -385,7 +385,7 @@ int cw_read_ac_descriptor(mavl_t store,
struct cw_DescriptorSubelemDef *allowed);
int cw_setup_dtls(struct cw_Conn * conn, mavl_t cfg, const char *prefix, char * default_cipher);
int cw_setup_dtls(struct cw_Conn * conn, cw_Cfg_t * cfg, const char *prefix, char * default_cipher);

@ -9,7 +9,7 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
{
char key[CW_CFG_MAX_KEY_LEN];
cw_Val_t *elem, search;
// cw_Val_t *elem;
int len;
uint8_t * d;

@ -104,7 +104,8 @@ static struct cw_StrListElem * color_on = theme0;
struct cw_StrListElem color_ontext[] = {
/* {DBG_ELEM_DMP, "\x1b[37m"},*/
{DBG_ELEM_DMP, ANSI_BBLACK ANSI_ITALIC},
{DBG_ELEM_DMP_OUT, ANSI_BBLACK ANSI_ITALIC},
{DBG_ELEM_DMP_IN, ANSI_BBLACK},
{CW_STR_STOP, ""}
};
@ -118,7 +119,7 @@ static struct cw_StrListElem color_off[] = {
static struct cw_StrListElem prefix[] = {
{DBG_INFO, "Info -"},
{DBG_PKT_IN, "Pkt IN -"},
{DBG_PKT_IN, "Pkt In -"},
{DBG_PKT_OUT, "Pkt Out -"},
{DBG_MSG_IN, "Msg In - "},
{DBG_MSG_OUT, "Msg Out - "},
@ -130,10 +131,10 @@ static struct cw_StrListElem prefix[] = {
{DBG_MSG_ERR, " Msg Error -"},
{DBG_PKT_ERR, " Pkt Error -"},
{DBG_ELEM_ERR, " Elem Error -"},
{DBG_RFC, " RFC -"},
{DBG_RFC, " RFC -"},
{DBG_DTLS, "DTLS - "},
{DBG_DTLS_DETAIL, "DTLS - "},
{DBG_WARN, " Warning - "},
{DBG_WARN, " Warning - "},
{DBG_MOD, " Mod - "},
{DBG_STATE, " STATEMACHINE - "},
{DBG_CFG_SET, " Cfg Set - "},
@ -272,7 +273,7 @@ void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len,
cw_dbg(level, "%s", buf);
if (cw_dbg_is_level(DBG_PKT_DMP)) {
// if (cw_dbg_is_level(DBG_PKT_DMP)) {
int dlevel;
if (level == DBG_PKT_IN){
dlevel=DBG_PKT_DMP_IN;
@ -281,7 +282,7 @@ void cw_dbg_pkt(int level, struct cw_Conn *conn, uint8_t * packet, int len,
dlevel=DBG_PKT_DMP_OUT;
}
cw_dbg_dmp(dlevel,packet,len,"");
}
// }
}
@ -414,9 +415,12 @@ void cw_dbg_elem(int level, struct cw_Conn *conn, int msg,
handler->name,len);
if (cw_dbg_is_level(DBG_ELEM_DMP)) {
/*dmp = cw_format_dump(msgbuf,len,NULL);*/
cw_dbg_dmp(DBG_ELEM_DMP,msgbuf,len,"");
int dlevel;
if (level == DBG_ELEM_OUT)
cw_dbg_dmp(DBG_ELEM_DMP_OUT,msgbuf,len,"");
else
cw_dbg_dmp(DBG_ELEM_DMP_IN,msgbuf,len,"");
}
return;

@ -56,7 +56,7 @@ enum cw_dbg_levels{
DBG_PKT_ERR = (1<<2),
/** Dump content of packets */
DBG_PKT_DMP = (1<<3),
// DBG_PKT_DMP = (1<<3),
/** Display incomming/outgoing CAPWAP/LWAPP messages */
DBG_MSG_IN = (1<<4),
@ -122,13 +122,17 @@ enum cw_dbg_levels{
DBG_MSG_IN_DMP = (1<<27),
DBG_MSG_OUT_DMP = (1<<29),
DBG_X = (1<<29),
DBG_X = (1<<30),
DBG_ALL = (0xffffffff),
DBG_MSG_PARSING = 3,
DBG_MSG_COMPOSING = 5,
DBG_ELEM_DMP_IN = 7,
DBG_ELEM_DMP_OUT = 9,
};

@ -35,18 +35,21 @@
* Debug strings
*/
struct cw_StrListElem cw_dbg_strings[] = {
{ DBG_INFO, "info", },
{ DBG_PKT_IN, "pkt_in" },
{ DBG_PKT_OUT, "pkt_out" },
{ DBG_PKT_ERR, "pkt_err" },
{ DBG_PKT_DMP, "pkt_dmp" },
{ DBG_MSG_IN, "msg_in" },
{ DBG_MSG_OUT, "msg_out" },
{ DBG_MSG_DMP, "msg_dmp" },
{ DBG_INFO, "info", },
{ DBG_PKT_IN, "pkt_in" },
{ DBG_PKT_OUT, "pkt_out" },
{ DBG_PKT_ERR, "pkt_err" },
// { DBG_PKT_IN_DMP, "pkt_in_dmp" },
// { DBG_PKT_IN_DMP, "pkt_out_dmp" },
{ DBG_MSG_IN, "msg_in" },
{ DBG_MSG_OUT, "msg_out" },
// { DBG_MSG_DMP, "msg_dmp" },
{ DBG_MSG_ERR, "msg_err"},
{ DBG_RFC, "rfc", },
{ DBG_ELEM_IN, "elem_in"},
{ DBG_ELEM_OUT, "elem_out"},
{ DBG_ELEM_DMP, "elem_dmp"},
@ -75,6 +78,7 @@ struct cw_StrListElem cw_dbg_strings[] = {
{ (DBG_MSG_IN | DBG_MSG_OUT), "msg" },
{ (DBG_PKT_IN | DBG_PKT_OUT), "pkt" },
{ (DBG_MSG_IN | DBG_MSG_OUT | DBG_ELEM_IN | DBG_ELEM_OUT ), "std" },
{ DBG_ALL, "all"},

@ -23,7 +23,7 @@
//#define CW_KTV_MAX_KEY_LEN 1024
typedef struct mavl cw_Cfg_t;
typedef struct cw_Cfg cw_Cfg_t;
/**
* @struct cw_Val

@ -7,7 +7,7 @@
#include "wtp_interface.h"
int changestate(struct conn * conn)
int changestate(struct cw_Conn * conn)
{

@ -157,7 +157,7 @@ radio.0/wlan.1/add-wlan/scan-defer-time: 100
radio.0/wlan.1/add-wlan/session-timout: 1800
radio.0/wlan.1/add-wlan/ssid: tubeC
radio.0/wlan.1/add-wlan/wep-encryption: false
radio.0/wlan.1/add-wlan/wep-key: .x68f4ae11b1b5b53d3cba571b50
radio.0/wlan.1/add-wlan/wep-key: .x6ecd3e2d4ada67bc959ff28170
radio.0/wlan.1/add-wlan/wep-key-index: 1
radio.0/wlan.1/add-wlan/wlan-capability: 1073
radio.0/wlan.1/add-wlan/wlan-id: 1
@ -174,7 +174,7 @@ radio.0/wlan.13/add-wlan/scan-defer-time: 100
radio.0/wlan.13/add-wlan/session-timout: 1800
radio.0/wlan.13/add-wlan/ssid: SuperSSID
radio.0/wlan.13/add-wlan/wep-encryption: false
radio.0/wlan.13/add-wlan/wep-key: .x68f4ae11b1b5b53d3cba571b50
radio.0/wlan.13/add-wlan/wep-key: .x6ecd3e2d4ada67bc959ff28170
radio.0/wlan.13/add-wlan/wep-key-index: 1
radio.0/wlan.13/add-wlan/wlan-capability: 1057
radio.0/wlan.13/add-wlan/wlan-id: 13
@ -192,8 +192,8 @@ radio.1/cisco/antenna-payload/unknown: 3
radio.1/cisco/channel-power: .x0808102408221c16100a04fefe2808221c16100a04fefe2c08221c16100a04fefe3008221c16100a04fefe3408221c16100a04fefe3808221c16100a04fefe3c08221c16100a04fefe4008221c16100a04fefe6408221c16100a04fefe6808221c16100a04fefe6c08221c16100a04fefe7008221c16100a04fefe7408221c16100a04fefe8408221c16100a04fefe8808221c16100a04fefe8c08221c16100a04fefe
radio.1/cisco/elem145: .x01
radio.1/cisco/elem15/cfg-type: 1 - global
radio.1/cisco/elem15/channel: 116
radio.1/cisco/elem15/rest: .x07ffffffce010001
radio.1/cisco/elem15/channel: 36
radio.1/cisco/elem15/rest: .x07ffffffce000000
radio.1/cisco/elem153: .x00
radio.1/cisco/elem156: .x020100
radio.1/cisco/elem16: .x0c121824
@ -250,7 +250,7 @@ radio.1/wlan.1/add-wlan/scan-defer-time: 100
radio.1/wlan.1/add-wlan/session-timout: 1800
radio.1/wlan.1/add-wlan/ssid: tubeC
radio.1/wlan.1/add-wlan/wep-encryption: false
radio.1/wlan.1/add-wlan/wep-key: .x47067708e07287af779e30c94a
radio.1/wlan.1/add-wlan/wep-key: .x150728c73ce900b86693fc5e57
radio.1/wlan.1/add-wlan/wep-key-index: 1
radio.1/wlan.1/add-wlan/wlan-capability: 17
radio.1/wlan.1/add-wlan/wlan-id: 1
@ -267,7 +267,7 @@ radio.1/wlan.13/add-wlan/scan-defer-time: 100
radio.1/wlan.13/add-wlan/session-timout: 1800
radio.1/wlan.13/add-wlan/ssid: SuperSSID
radio.1/wlan.13/add-wlan/wep-encryption: false
radio.1/wlan.13/add-wlan/wep-key: .x47067708e07287af779e30c94a
radio.1/wlan.13/add-wlan/wep-key: .x150728c73ce900b86693fc5e57
radio.1/wlan.13/add-wlan/wep-key-index: 1
radio.1/wlan.13/add-wlan/wlan-capability: 1
radio.1/wlan.13/add-wlan/wlan-id: 13

@ -26,7 +26,6 @@
#include "wtp_interface.h"
#include "cw/dbg.h"
#include "cfg.h"
int update =1;
@ -98,7 +97,7 @@ int run(struct cw_Conn * conn)
while (!cw_timer_timeout(timer) && conn->capwap_state == CAPWAP_STATE_RUN) {
mavl_del_all(conn->remote_cfg);
cw_cfg_clear(conn->remote_cfg);
rc = cw_read_messages(conn);
if (rc < 0 && errno == EAGAIN) {
continue;

Loading…
Cancel
Save