A lot of bug fixes and improvments

This commit is contained in:
7u83 2022-08-22 01:59:23 +02:00
parent 226c4b832a
commit 65153617b7
37 changed files with 229 additions and 177 deletions

View File

@ -33,7 +33,6 @@
#include "socklist.h"
#include "db.h"
#include "cw/capwap_crypto.h"
@ -78,12 +77,18 @@ static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
exit(EXIT_SUCCESS);
break;
case 'd':{
int b = cw_strlist_get_id(cw_dbg_strings, optarg);
if (!cw_dbg_set_level_from_str(optarg)){
fprintf(stderr,"Invalid debug option: %s\n",optarg);
exit(EXIT_FAILURE);
}
/* int b = cw_strlist_get_id(cw_dbg_strings, optarg);
if (b==-1){
fprintf(stderr,"Invalid debug option: %s\n",optarg);
exit(EXIT_FAILURE);
}
cw_dbg_set_level(b, 1);
cw_dbg_set_level(b, 1);*/
break;
}
@ -259,7 +264,7 @@ int main (int argc, char *argv[])
errX:
if (global_cfg)
mavl_destroy(global_cfg);
cw_cfg_destroy(global_cfg);
if (discovery_cache)
discovery_cache_destroy(discovery_cache);
@ -302,8 +307,8 @@ int ac_run(cw_Cfg_t * cfg)
conf_parse_listen_addr (s, addr, port, &proto);
socklist_add_unicast (addr, port, proto,
cw_cfg_get_bool(cfg,"actube/ipv4","true"),
cw_cfg_get_bool(cfg,"actube/ipv6","true")
cw_cfg_get_bool(cfg,"actube/ipv4",1),
cw_cfg_get_bool(cfg,"actube/ipv6",1)
);
}
if (!i) {

View File

@ -114,7 +114,6 @@ void discovery_cache_add(struct cw_DiscoveryCache *cache,
cw_dbg(DBG_X,"////////////////////////// ADDD CAHCE ///////////////////////");
char str[128];
sock_addrtostr(addr,str,128,1);
printf("Add addr: %s\n",str);
}
struct cw_DiscoveryCacheElem * cur = cache->queue+cache->qpos;
@ -159,7 +158,6 @@ int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
cw_dbg(DBG_X,"DISCOVERY CACHE ---------------------------- GET ENTER");
char str[128];
sock_addrtostr(addr,str,128,1);
printf("Add addr: %s\n",str);
}
search_ptr = &search;
@ -169,7 +167,6 @@ int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
cw_dbg(DBG_X,"DISCOVERY CACHE ---------------------------- FOUND 1 with Port");
char str[128];
sock_addrtostr(addr,str,128,1);
printf("Add addr: %s\n",str);
}
@ -196,7 +193,6 @@ int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
cw_dbg(DBG_X,"DISCOVERY CACHE ---------------------------- DOUND BY ADDR");
char str[128];
sock_addrtostr(addr,str,128,1);
printf("Add addr: %s\n",str);
}

View File

@ -64,11 +64,13 @@ static void wtpman_run_discovery(void *arg)
wtpman->conn->capwap_state = CAPWAP_STATE_DISCOVERY;
while (!cw_timer_timeout(timer)
&& wtpman->conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
int rc;
rc = cw_read_messages(wtpman->conn);
if (cw_result_is_ok(rc)) {
wtpman->conn->capwap_state = CAPWAP_STATE_JOIN;
@ -85,7 +87,6 @@ static void wtpman_run_discovery(void *arg)
}
}
return;
}
@ -606,12 +607,14 @@ static void copy(struct cw_ElemHandlerParams * params)
conn = (struct cw_Conn*)params->conn;
cw_dbg(DBG_X,"------------- Here is the config we ve got from WTP ---------------- ");
cw_cfg_dump(params->cfg);
cw_dbg(DBG_X,"------------- This was the config we ve got from WTP ---------------- ");
cw_dbg(DBG_X,"Now copying:");
cw_cfg_copy(params->cfg,conn->local_cfg,0,"");
cw_dbg(DBG_X,"Copying done.");
// cw_dbg(DBG_X,"------------- Here is the config we ve got from WTP ---------------- ");
// cw_cfg_dump(params->cfg);
// cw_dbg(DBG_X,"------------- This was the config we ve got from WTP ---------------- ");
// cw_dbg(DBG_X,"Now copying:");
// cw_cfg_copy(params->cfg,conn->local_cfg,0,"");
cw_cfg_copy(params->cfg, params->conn->local_cfg,DBG_CFG_UPDATES,"GlobalCfg");
// cw_dbg(DBG_X,"Copying done.");
}
static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
@ -649,7 +652,24 @@ static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr,
const char * wtpname = cw_cfg_get(conn->local_cfg,"wtp-name","default");
sprintf(filename,"wtp-status-%s.ckv",wtpname);
cw_cfg_save(filename,params->cfg,NULL);
stop();
//stop();
return 0;
}
static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
{
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
char filename[200];
cw_dbg(DBG_X,"WTP EVENT Callback");
copy(params);
const char * wtpname = cw_cfg_get(conn->local_cfg,"wtp-name","default");
sprintf(filename,"wtp-status-%s.ckv",wtpname);
cw_cfg_save(filename,params->cfg,NULL);
//stop();
return 0;
}
@ -739,6 +759,10 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
update_cb);
cw_conn_set_msg_cb(wtpman->conn,
CAPWAP_MSG_WTP_EVENT_REQUEST,
event_cb);

View File

@ -18,7 +18,6 @@ CWSRC=\
cw_in_capwap_local_ipv4_address.c\
cw_in_capwap_local_ipv6_address.c\
cw_in_generic_with_index.c\
cw_in_generic_struct.c\
cw_in_radio_generic_struct.c\
cw_in_idx_generic.c\
cw_in_idx_generic_struct.c\
@ -67,6 +66,7 @@ CWSRC=\
cw_write_radio_element.c\
cw_detect_nat.c\
cw_read_from.c \
cw_in_generic_struct.c\
# cw_in_check_disc_req.c\
# cw_in_check_img_data_req_ac.c\
@ -210,6 +210,7 @@ MISCSRC=\
val.c \
discovery.c\
message.c\
cw_out_radio_generic_struct.c\
# intavltree.c\
@ -228,7 +229,6 @@ DTLSSRC+=\
RADIOSRC=\
cw_out_radio_generic_struct.c\
# cw_in_radio_generic.c\
# cw_out_radio_generic.c\

View File

@ -621,6 +621,19 @@ uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key, uint16_t def)
return v.val.word;
}
uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, char *key, uint16_t def)
{
struct cw_Val v;
const char *s = cw_cfg_get_l(cfg,key,NULL);
if (s==NULL)
return def;
CW_TYPE_WORD->from_str(&v,s);
return v.val.word;
}
/*
int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
{

View File

@ -55,6 +55,7 @@ cw_Val_t * cw_cfg_get_val_l(cw_Cfg_t ** cfgs, const char *key, const struct cw_T
int cw_cfg_base_exists_l(cw_Cfg_t ** cfgs, const char *key);
int cw_cfg_save(const char *filename, cw_Cfg_t *cfg, const char *format, ...);
uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, char *key, uint16_t def);

View File

@ -139,7 +139,7 @@ struct cw_Conn * cw_conn_create(int sock, struct sockaddr * addr, int qsize)
/* conn->send_data_packet = conn_send_data_packet;*/
conn->last_seqnum_received=-1;
conn->mtu=600;
conn->mtu=1480;
conn->cur_packet=0;
@ -149,7 +149,7 @@ struct cw_Conn * cw_conn_create(int sock, struct sockaddr * addr, int qsize)
conn->write = conn->send_packet;
conn->read = conn->recv_packet;
conn->dtls_mtu = 600;
conn->dtls_mtu = 1480;
@ -349,7 +349,8 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
/* pre-check message */
if (payloadlen - 8 != elems_len) {
//printf ("The elems_len is %d\n",elems_len);
//printf ("The len = %d\n",len);
if (conn->strict_hdr) {
cw_dbg(DBG_MSG_ERR,
"Discarding message from %s, msgelems len=%d, payload len=%d, (Strict CAPWAP) ",
@ -365,7 +366,7 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
"Packet from from %s has %d bytes of extra data, ignoring.",
sock_addr2str(&conn->addr, sock_buf),
payloadlen - 8 - elems_len);
elems_len = len - 8;
//elems_len = len - 8;
}
if (elems_len > payloadlen - 8) {

View File

@ -42,7 +42,6 @@ void conn_q_add_packet(struct cw_Conn * conn,uint8_t *packet,int len)
conn->q[qwpos]=malloc(len+4);
if (conn->q[qwpos]==NULL)
return;
*((uint32_t*)(conn->q[qwpos]))=len;
memcpy(conn->q[qwpos]+4,packet,len);
conn->qwpos=qwpos+1;

View File

@ -29,6 +29,7 @@
int conn_recv_packet_(struct cw_Conn *conn, uint8_t * buf, int len, int flags)
{
printf("conn_recv\n");
int n;
while ((n = recv(conn->sock, (char *) buf, len, flags)) < 0) {
if (errno != EINTR) {

View File

@ -353,7 +353,7 @@ int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys, mavl_t handle
extern int cw_read_descriptor_subelems(mavl_t store, const char * key, uint8_t * data, int len,
extern int cw_read_descriptor_subelems(cw_Cfg_t * store, const char * key, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *elems);
/*
@ -362,7 +362,7 @@ int cw_read_wtp_descriptor(mavl_t mbag, struct cw_Conn *conn,
struct cw_DescriptorSubelemDef *allowed);
*/
int cw_read_wtp_descriptor(mavl_t mbag, struct cw_Conn *conn,
int cw_read_wtp_descriptor(cw_Cfg_t * mbag, struct cw_Conn *conn,
struct cw_ElemHandler *eh, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *allowed);
@ -373,12 +373,12 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
uint8_t * dst);
extern int cw_read_wtp_descriptor_7(mavl_t mbag, struct cw_Conn *conn,
extern int cw_read_wtp_descriptor_7(cw_Cfg_t * cfg, struct cw_Conn *conn,
struct cw_ElemHandler *eh, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *allowed);
int cw_read_ac_descriptor(mavl_t store,
int cw_read_ac_descriptor(cw_Cfg_t * store,
struct cw_ElemHandler *eh,
struct cw_ElemHandlerParams * params,
uint8_t *data, int len,

View File

@ -9,6 +9,9 @@ int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys, mavl_t handle
char *mandkey, *result;
mlist_t missing;
int count;
if (msgdata==NULL)
return 0;
missing = mlist_create_conststr();
if (missing==NULL){

View File

@ -10,7 +10,7 @@ int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
{
cw_dbg(DBG_X,"STRUCT KEY: %s",handler->key);
stop();
const char * key;
/* const char * key;
char tmpkey[CW_CFG_MAX_KEY_LEN];
@ -22,11 +22,8 @@ int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
key = handler->key;
}
printf("CW_IN_GENERIC STRUCT: %s\n",key);
//printf("CW_IN_GENERIC STRUCT: %s\n",key);
/* int (*mkkey)(struct cw_ElemHandler * handler, char *dst, struct cw_ElemHandlerParams * params,
uint8_t*data, int len);
*/
if (!handler->type){
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
@ -34,6 +31,6 @@ printf("CW_IN_GENERIC STRUCT: %s\n",key);
}
cw_ktv_read_struct(params->cfg,handler->type,key,elem_data,elem_len);
*/
return CAPWAP_RESULT_SUCCESS;
}

View File

@ -7,9 +7,6 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
struct cw_ElemHandlerParams * params, uint8_t * dst)
{
char key[CW_CFG_MAX_KEY_LEN];
int idx;
cw_Val_t * result, search;
int len,start;
uint8_t * ob;
struct cw_Cfg_entry *e;
@ -18,7 +15,6 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
int i,l;
idx = 0;
ob = dst;
cw_cfg_iter_init(params->cfg_list[0], &cfi, eh->key);
@ -42,31 +38,5 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
return ob-dst;
stop();
return 0;
do {
sprintf(key,"%s.%d",eh->key,idx);
search.key=key;
result = mavl_get_first(params->cfg,&search);
if (result==NULL)
break;
if (strncmp(result->key,key,strlen(key))!=0)
break;
start = params->msgset->header_len(eh);
len = cw_put_byte(ob+start,idx);
len += result->type->put(result,ob+start+len);
ob += params->msgset->write_header(eh,ob,len);
idx++;
}while(1);
return ob-dst;
}

View File

@ -133,11 +133,11 @@ int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
{
char current[CW_CFG_MAX_KEY_LEN];
int stack[10];
stack[0]=0;
//char current[CW_CFG_MAX_KEY_LEN];
//int stack[10];
//stack[0]=0;
current[0]=0;
//current[0]=0;
stop();
return 0;

View File

@ -25,7 +25,7 @@ cw_ValStruct_t acstatus [] = {
int cw_read_ac_descriptor(mavl_t store,
int cw_read_ac_descriptor(cw_Cfg_t * store,
struct cw_ElemHandler *eh,
struct cw_ElemHandlerParams * params,
uint8_t *data, int len,

View File

@ -22,7 +22,7 @@
#include "keys.h"
int cw_read_descriptor_subelems(mavl_t cfg, const char *parent_key,
int cw_read_descriptor_subelems(cw_Cfg_t *cfg, const char *parent_key,
uint8_t * data, int len,
struct cw_DescriptorSubelemDef *elems)
{

View File

@ -16,7 +16,7 @@ static struct cw_DescriptorSubelemDef allowed_default[] = {
};
int cw_read_wtp_descriptor(mavl_t cfg, struct cw_Conn *conn,
int cw_read_wtp_descriptor(cw_Cfg_t * cfg, struct cw_Conn *conn,
struct cw_ElemHandler *eh, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *allowed)
{

View File

@ -20,7 +20,7 @@ static struct cw_DescriptorSubelemDef allowed_default[] = {
/**
* Read WTP Descriptor in Cisco-Style (Draft 7)
*/
int cw_read_wtp_descriptor_7(mavl_t cfg, struct cw_Conn *conn,
int cw_read_wtp_descriptor_7(cw_Cfg_t * cfg, struct cw_Conn *conn,
struct cw_ElemHandler *eh, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *allowed)
{

View File

@ -50,10 +50,10 @@ int cw_setup_dtls(struct cw_Conn *conn, cw_Cfg_t * cfg, const char *prefix,
conn->dtls_cipher = cw_cfg_get(cfg, key, default_cipher);
sprintf(key, "%s/%s", prefix, "ssl-psk");
conn->dtls_psk = cw_cfg_get(cfg, key, NULL);
conn->dtls_psk = (bstr16_t)cw_cfg_get(cfg, key, NULL);
sprintf(key, "%s/%s", prefix, "ssl-psk-enable");
conn->dtls_psk_enable = cw_cfg_get_bool(cfg, key, "flase");
conn->dtls_psk_enable = cw_cfg_get_bool(cfg, key, 0);
if (conn->dtls_psk_enable) {
security |= CAPWAP_FLAG_AC_SECURITY_S;

View File

@ -92,7 +92,7 @@ static struct cw_StrListElem theme0[] = {
{DBG_WARN, ANSI_CYAN},
{DBG_MOD, ANSI_WHITE},
// {DBG_CFG_DMP, ANSI_BCYAN },
{DBG_CFG_UPDATES,ANSI_BRED},
{DBG_CFG_UPDATES,ANSI_GREEN},
{CW_STR_STOP, ""}
};

View File

@ -120,10 +120,12 @@ enum cw_dbg_levels{
DBG_MSG_COMPOSE = (1<<26),
DBG_CFG_UPDATES = (1<<27),
DBG_ELEM_VNDR = (1<<28),
DBG_X = (1<<30),
DBG_ALL = (0xffffffff),
DBG_ALL = (0x7fffffff),
DBG_ELEM_DMP_IN = 7,

View File

@ -47,42 +47,49 @@ struct cw_StrListElem cw_dbg_strings[] = {
{ DBG_MSG_DMP_IN, "msg_dmp_in" },
{ DBG_MSG_DMP_OUT, "msg_dmp_out" },
{ DBG_MSG_ERR, "msg_err"},
{ DBG_MSG_ERR, "msg_err"},
{ DBG_RFC, "rfc", },
{ DBG_RFC, "rfc", },
{ DBG_ELEM_IN, "elem_in"},
{ DBG_ELEM_OUT, "elem_out"},
{ DBG_ELEM_DMP, "elem_dmp"},
{ DBG_ELEM_ERR, "elem_err" },
{ DBG_ELEM_DETAIL_IN, "elem_detail_in" },
{ DBG_ELEM_DETAIL_OUT, "elem_detail_out" },
{ DBG_ELEM_IN, "elem_in"},
{ DBG_ELEM_OUT, "elem_out"},
{ DBG_ELEM_DMP, "elem_dmp"},
{ DBG_ELEM_ERR, "elem_err" },
{ DBG_ELEM_DETAIL_IN, "elem_detail_in" },
{ DBG_ELEM_DETAIL_OUT, "elem_detail_out" },
{ DBG_ELEM_VNDR, "elem_vndr"},
{ DBG_DTLS, "dtls" },
{ DBG_DTLS_BIO, "dtls_bio" },
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
{ DBG_DTLS_DETAIL, "dtls_detail"},
{ DBG_DTLS, "dtls" },
{ DBG_DTLS_BIO, "dtls_bio" },
{ DBG_DTLS_BIO_DMP, "dtls_bio_dmp"},
{ DBG_DTLS_DETAIL, "dtls_detail"},
{ DBG_CFG_UPDATES, "cfg_updates" },
{ DBG_CFG_UPDATES, "cfg_updates" },
// {DBG_CFG_DMP, "cfg_dmp" },
{ DBG_WARN, "warn" },
{ DBG_WARN, "warn" },
{ DBG_MOD,"mod"},
{ DBG_STATE, "state" },
{ DBG_MSG_COMPOSE, "msg_compose" },
{ DBG_MOD, "mod"},
{ DBG_STATE, "state" },
{ DBG_MSG_COMPOSE, "msg_compose" },
{ (DBG_MSG_IN | DBG_MSG_OUT), "msg" },
{ (DBG_PKT_IN | DBG_PKT_OUT), "pkt" },
{ (DBG_ELEM_IN | DBG_ELEM_OUT), "elem" },
{ (DBG_ELEM_DETAIL_IN | DBG_ELEM_DETAIL_OUT), "elem_detail" },
{ (DBG_ELEM_IN | DBG_ELEM_OUT | DBG_ELEM_DMP | DBG_ELEM_DETAIL_IN | DBG_ELEM_DETAIL_OUT), "elem_all" },
{ (DBG_MSG_IN | DBG_MSG_OUT | DBG_ELEM_IN | DBG_ELEM_OUT | DBG_STATE), "std" },
{ DBG_ALL, "all"},
{ ( DBG_MSG_IN | DBG_MSG_OUT |
DBG_ELEM_IN | DBG_ELEM_OUT |
DBG_MSG_ERR | DBG_ELEM_ERR |
DBG_PKT_ERR | DBG_RFC | DBG_WARN
| DBG_STATE), "std" },
{ DBG_ALL, "all"},
{ CW_STR_STOP, NULL }

View File

@ -224,7 +224,7 @@ int dtls_openssl_set_certs(struct cw_Conn * conn, struct dtls_openssl_data *d)
{
int rc;
if (conn->dtls_key_file && conn->dtls_cert_file){
SSL_CTX_set_default_passwd_cb_userdata(d->ctx, conn->dtls_key_pass);
SSL_CTX_set_default_passwd_cb_userdata(d->ctx, (char*)conn->dtls_key_pass);
SSL_CTX_set_default_passwd_cb(d->ctx, pem_passwd_cb);
@ -291,18 +291,18 @@ return 1;
/*
static unsigned int psk_server_cb(SSL *ssl,const char *identity, unsigned char * psk, unsigned int max_psk_len)
{
BIO * b = SSL_get_rbio(ssl);
struct cw_Conn * conn = BIO_get_data(b); /*->ptr;*/
struct cw_Conn * conn = BIO_get_data(b); //->ptr;
int l = bstr16_len(conn->dtls_psk) < max_psk_len ? bstr16_len(conn->dtls_psk) : max_psk_len;
memcpy(psk,conn->dtls_psk,l);
return l;
}
*/
@ -323,10 +323,8 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
}
rc = SSL_CTX_get_security_level(d->ctx);
printf("Security Level is %d\n");
SSL_CTX_set_security_level(d->ctx,0);
printf("Security Level is %d\n");

View File

@ -32,7 +32,7 @@ int dtls_openssl_accept(struct cw_Conn *conn)
if (!conn->dtls_data)
conn->dtls_data =
dtls_openssl_data_create(conn, DTLSv1_server_method(),
dtls_openssl_data_create(conn, DTLS_server_method(),
dtls_openssl_bio_method());
d = (struct dtls_openssl_data *) conn->dtls_data;

View File

@ -11,6 +11,8 @@ int cw_encode_elements(struct cw_ElemHandlerParams *params, mlist_t elements_lis
struct mlistelem * elem;
len =0;
params->len=len;
mlist_foreach(elem,elements_list){
int l;
struct cw_ElemData * data;
@ -52,6 +54,7 @@ int cw_encode_elements(struct cw_ElemHandlerParams *params, mlist_t elements_lis
data->proto, data->vendor, data->id, handler->name,l);
len += l;
params->len=len;
}
return len;
@ -96,6 +99,7 @@ int cw_compose_message(struct cw_Conn *conn, uint8_t * rawout)
len =0;
//cw_dbg(DBG_X,"setting with update CFG");
params.conn=conn;
params.rawmsg = rawout;
params.cfg_list[0]=conn->update_cfg;
params.cfg_list[1]=conn->local_cfg;
params.cfg_list[2]=conn->global_cfg;
@ -220,7 +224,10 @@ int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
elem_data_search.id = elem_id;
elem_data_search.proto = proto;
elem_data_search.vendor = vendor;
elem_data = mavl_get(params->msgdata->elements_tree, &elem_data_search);
if (params->msgdata)
elem_data = mavl_get(params->msgdata->elements_tree, &elem_data_search);
else
elem_data = NULL;
if (!elem_data) {
cw_dbg(DBG_ELEM_ERR, "Element %d - %s, not allowed here",
elem_id, handler->name);
@ -249,7 +256,7 @@ int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
return -1;
}
if (!handler->flags)
if (!handler->flags || cw_dbg_is_level(DBG_ELEM_VNDR))
cw_dbg_elem(params->dbg_level, NULL, params->msgdata->type, handler,
data, len);
@ -273,7 +280,6 @@ int cw_decode_elements(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr
//mand_found = mavl_create_conststr();
//unrecognized = mlist_create(NULL,NULL,sizeof(uint8_t*));
cw_foreach_elem(elem, elems_ptr, elems_len) {
int rc;

View File

@ -119,7 +119,7 @@ void cw_mod_set_path(const char *path)
* @param mod_name Name of the module
* @return a pointer to the module interface
*/
struct cw_Mod *cw_mod_load(const char *mod_name, mavl_t global_cfg, int role)
struct cw_Mod *cw_mod_load(const char *mod_name, cw_Cfg_t * global_cfg, int role)
{
struct cw_Mod search;
struct cw_Mod *mod;

View File

@ -29,7 +29,7 @@
#include "sock.h"
#include "conn.h"
#include "cfg.h"
enum {
CW_MOD_MODE_CAPWAP,
@ -44,7 +44,7 @@ struct cw_Mod {
const char *name;
/** Initializion method */
int (*init) (struct cw_Mod *mod, mavl_t global_cfg, int role);
int (*init) (struct cw_Mod *mod, cw_Cfg_t * global_cfg, int role);
/** Detect capwap
* This function is called after receiving and disassembling a complete
@ -93,7 +93,7 @@ extern int mod_caching;
#define mod_set_caching(var) (mod_caching=var)
#define mod_get_caching() (mod_caching)
struct cw_Mod * cw_mod_load(const char * mod_name, mavl_t global_cfg, int role);
struct cw_Mod * cw_mod_load(const char * mod_name, cw_Cfg_t * global_cfg, int role);
struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod );
struct cw_Mod * cw_mod_detect(struct cw_Conn *conn,
uint8_t * rawmsg, int len,

View File

@ -384,6 +384,9 @@ int cw_msgset_add_states(struct cw_MsgSet * set, cw_StateMachineState_t * states
return 1;
}
/**
* @brief Find message data to a specific message
* @param set message set
@ -392,9 +395,14 @@ int cw_msgset_add_states(struct cw_MsgSet * set, cw_StateMachineState_t * states
*/
struct cw_MsgData *cw_msgset_get_msgdata(struct cw_MsgSet *set, int type)
{
struct cw_MsgData search;
struct cw_MsgData search, *result;
search.type = type;
return mavl_get(set->msgdata, &search);
result = mavl_get(set->msgdata, &search);
if (result != NULL)
return result;
return NULL;
}
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);

View File

@ -24,18 +24,20 @@ struct cw_ElemData{
};
struct cw_ElemHandlerParams {
struct cw_Conn * conn; /**< a connection the message belongs to*/
struct cw_MsgSet * msgset;
struct cw_Conn * conn; /**< a connection the message belongs to*/
uint8_t * rawmsg;
struct cw_MsgSet * msgset; /**< msgset to use */
struct cw_MsgData * msgdata;
struct cw_ElemData * elemdata;
struct sockaddr *from;
mavl_t mand_found;
mlist_t unrecognized;
// cw_Val_t * elem;
mavl_t mand_found; /**< used to ad the keys of mand. msg elements
found while parsing */
mlist_t unrecognized; /**< to catch ids of unreconized mss elements */
char * debug_details;
uint32_t dbg_level;
cw_Cfg_t * cfg;
cw_Cfg_t * cfg_list[10];
int len;
};

View File

@ -146,12 +146,6 @@ struct cw_ValIndexed{
};
typedef struct cw_ValIndexed cw_ValIndexed_t;
int cw_ktv_read_struct(mavl_t ktv,const cw_ValStruct_t * stru, const char *pkey,
uint8_t * data, int len);
int cw_ktv_write_struct(mavl_t ktv, mavl_t def, const cw_ValStruct_t * stru, const char *pkey,
uint8_t * dst);
extern const struct cw_Type cw_type_byte;
extern const struct cw_Type cw_type_word;
@ -178,24 +172,7 @@ extern const struct cw_Type cw_type_struct;
/*
void cw_kvstore_mavl_delete(const void *data);
*/
cw_Val_t *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
const void * valguard,
const uint8_t * data, int len);
void cw_ktv_del_sub(mavl_t ktvstore, const char *basekey);
cw_Val_t * cw_ktv_replace(mavl_t kvtstore, const char *key, const struct cw_Type *type,
const void * valguard,
const uint8_t * data, int len);
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key, const struct cw_Type *type,
const void * valguard,
const char * str);
int cw_ktv_mavlcmp(const void *v1, const void *v2);
int cw_ktv_mavlcmp_type_by_name(const void *v1,const void *v2);
void cw_ktv_mavldel(void *data);
/**
* Create a KTV store

View File

@ -26,6 +26,9 @@ int capwap_in_vendor_specific_payload(struct cw_ElemHandler *handler,
if (!vhandler) {
cw_dbg_elem(params->dbg_level, NULL, params->msgdata->type, handler,
data, len);
cw_dbg(DBG_WARN,
"Can't handle Vendor Specific Payload %s/%d, in msg %d (%s) in %s state.",
cw_strvendor(vendor_id), elem_id, params->msgdata->type,

View File

@ -30,7 +30,7 @@
#include "cw/keys.h"
static void readsubelems_wtp_board_data(mavl_t cfg, uint8_t * msgelem,
static void readsubelems_wtp_board_data(cw_Cfg_t * cfg, uint8_t * msgelem,
int len)
{
int i = 0;

View File

@ -437,6 +437,17 @@ static cw_ValStruct_t cisco_tx_power[]={
{NULL,NULL,0,0}
};
static cw_ValStruct_t cisco_lw_radio_module_info_stru[]={
{CW_TYPE_STR,"name",21,-1},
{CW_TYPE_STR,"serial",11,-1},
{CW_TYPE_STR,"type",25,-1},
{CW_TYPE_STR,"descr",126,-1},
{NULL,NULL,0,0}
};
static cw_ValStruct_t cisco_ap_qos[]={
{CW_TYPE_BYTE,"tag-packets",1,-1},
{CW_TYPE_BYTE,"uranium-queue-depth",1,-1},
@ -597,7 +608,7 @@ static int cisco_in_lw_del_wlan(struct cw_ElemHandler *eh,
uint8_t * data, int len)
{
stop();
/*
int wlan_id, radio_id;
char key[CW_CFG_MAX_KEY_LEN];
@ -606,7 +617,7 @@ static int cisco_in_lw_del_wlan(struct cw_ElemHandler *eh,
sprintf(key,"radio.%d/wlan.%d",radio_id,wlan_id);
cw_ktv_del_sub(params->cfg,key);
cw_dbg(DBG_INFO,"Del WLAN rid=%d, id=%d",wlan_id);
return 0;
return 0;*/
}
@ -955,7 +966,7 @@ static struct cw_ElemHandler handlers70[] = {
}
,
{
"Path MTU", /* name */
"Cisco LWAPP Path MTU", /* name */
CISCO_LWELEM_PATH_MTU, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
0,0, /* min/max length */
@ -1518,7 +1529,7 @@ static struct cw_ElemHandler handlers70[] = {
{
"Cisco LWAP Elem 9", /* name */
"Cisco LWAPP Elem 9", /* name */
CISCO_LWELEM_9, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
@ -1531,7 +1542,7 @@ static struct cw_ElemHandler handlers70[] = {
},
{
"Cisco LWAP Elem 11", /* name */
"Cisco LWAPP Elem 11", /* name */
CISCO_LWELEM_11, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
@ -1585,7 +1596,7 @@ static struct cw_ElemHandler handlers70[] = {
},
{
"Cisco LWAP Elem 29", /* name */
"Cisco LWAPP Elem 29", /* name */
CISCO_LWELEM_29, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
@ -1638,6 +1649,21 @@ static struct cw_ElemHandler handlers70[] = {
cw_out_radio_generic /* put */
},
{
"Cisco LWAPP Radio Module Info", /* name */
CISCO_LWELEM_RADIO_MODULE_INFO, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
183,183, /* min/max length */
CW_TYPE_STRUCT, /* type */
"cisco/radio-module-info", /* Key */
cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */
NULL,
NULL,
cisco_lw_radio_module_info_stru /* param */
},
{
@ -2033,7 +2059,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_VENDOR_ID_CISCO, 0, /* Vendor / Proto */
1, 1, /* min/max length */
CW_TYPE_BOOL, /* type */
"cisco/sig-toogle", /* Key */
"cisco/sig-toggle", /* Key */
cw_in_generic, /* get */
cw_out_generic /* put */
}
@ -2140,10 +2166,9 @@ static struct cw_ElemDef join_request_elements[] ={
static struct cw_ElemDef join_response_elements[] ={
{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},
{0,0, CAPWAP_ELEM_ECN_SUPPORT, 0, CW_DELETE},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_PATH_MTU, 1, 0},
{0,0,0,00}
};
@ -2229,10 +2254,11 @@ static struct cw_ElemDef configuration_status_request_elements[] ={
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_ETHERNET_PORT_SUBTYPE, 1, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AC_IP_ADDR_WITH_INDEX, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_VLAN, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_TCP_ADJUST_MSS, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_HARDWARE_INFO, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_ROUGE_DETECTION, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_DTLS_DATA_CFG, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_TCP_ADJUST_MSS, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_HARDWARE_INFO, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_ROUGE_DETECTION, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_DTLS_DATA_CFG, 0, 0},
// {CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_PATH_MTU, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_DISCOVERY_PROTOCOL, 1, 0},
{0,0,0,00}
@ -2410,6 +2436,8 @@ static struct cw_ElemDef wtp_event_request_elements[] ={
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_ADD_WLAN, 0, CW_IGNORE},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_ADD_WLAN, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_HARDWARE_INFO, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_RADIO_MODULE_INFO, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_29, 0, 0},
{0,0,0,0,0}
};
@ -2428,10 +2456,12 @@ static struct cw_ElemDef change_state_event_request_elements[] ={
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_ADD_WLAN, 1, CW_IGNORE},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_OPER_STATE_DETAIL_CAUSE, 1, CW_IGNORE},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_105, 0, 0},
{0, 0, CAPWAP_ELEM_RADIO_ADMINISTRATIVE_STATE, 1, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_HARDWARE_INFO, 1, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_HARDWARE_INFO, 1, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_RADIO_MODULE_INFO, 1, 0},
{0,0,0,0,0}

View File

@ -17,6 +17,9 @@ int cisco_in_spam_vendor_specific(struct cw_ElemHandler *eh,
if (!vhandler) {
cw_dbg_elem(params->dbg_level, NULL, params->msgdata->type, eh,
data, len);
cw_dbg(DBG_WARN,
"Can't handle Vendor Specific LWAPP Payload %s/%d, in msg %d (%s) in %s state.",
cw_strvendor(vendor_id), elem_id, params->msgdata->type,

View File

@ -14,21 +14,26 @@ int cisco_out_lw_path_mtu(struct cw_ElemHandler * eh,
char key[CW_CFG_MAX_KEY_LEN];
int len,max;
int hl = params->msgset->header_len(eh);
int cl = dst-params->rawmsg;
int wl = 1400-cl-hl;
printf("HL:%d CL:%d WL: %d\n",hl,cl,wl);
sprintf(key,"%s/%s",eh->key,"len");
len = cw_cfg_get_word(params->cfg,key,0);
len = cw_cfg_get_word_l(params->cfg_list,key,0);
if (len == 0)
return 0;
sprintf(key,"%s/%s",eh->key,"max");
max = cw_cfg_get_word(params->cfg,key,0);
max = cw_cfg_get_word_l(params->cfg_list,key,0);
lw_set_word(dst+16,max);
lw_set_word(dst+16+2,len);
memset(dst+16+4,0,len-4);
/* put the lwap elem header */
lw_set_dword(dst + 10, eh->vendor);
lw_set_word(dst + 14, eh->id);
lw_set_word(dst+hl,max);
lw_set_word(dst+hl+2,wl);
memset(dst+hl+4,0,wl-4);
return len + 6 + cw_put_elem_vendor_hdr(dst, eh->vendor, CISCO_ELEM_SPAM_VENDOR_SPECIFIC, len+6);
len = wl;
return params->msgset->write_header(eh,dst,len);
}

View File

@ -97,7 +97,7 @@ static void errfunc(cfg_t *cfg, const char *fmt, va_list ap){
}
*/
static int init(struct cw_Mod *mod, mavl_t global_cfg, int role)
static int init(struct cw_Mod *mod, cw_Cfg_t * global_cfg, int role)
{
/* uint8_t * str;*/
static char * hardware_version; /*strdup(".x01000001");*/

View File

@ -76,6 +76,7 @@ cisco/rouge-and-mss/enable: false
cisco/rouge-and-mss/tcp-adjust-mss: 0
cisco/rouge-detection/rest: .x0000000a
cisco/rouge-detection/rouge-detection: true
cisco/sig-toggle: true
cisco/sig-toogle: true
cisco/spam-domain-secret: .xe1ffd18a8f15b3b59c0a47a7f17a96e7cb36174f00
cisco/ssl-certfile: ../../ssl/certs/wtpc.crt
@ -116,7 +117,7 @@ radio.0/cisco/elem146: .x690f
radio.0/cisco/elem153: .x00
radio.0/cisco/elem156: .x020100
radio.0/cisco/elem16: .x02040b0c
radio.0/cisco/elem19: .xc0a800a10001000cc0a800a103000101003ccd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000001060b010101
radio.0/cisco/elem19: .xc0a800a10001000cc0a800a103000101001ecd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000001060b010101
radio.0/cisco/elem22: .x0d00b400320102030405060708090a0b0c0d
radio.0/cisco/elem24: .x003c000c
radio.0/cisco/elem47: .x0100000000000000000000000000000000
@ -169,7 +170,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: .xc214aef5bd4c4e1ff2574303a4
radio.0/wlan.1/add-wlan/wep-key: .xe90245968787036bf1e1756fc8
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
@ -186,7 +187,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: .xc214aef5bd4c4e1ff2574303a4
radio.0/wlan.13/add-wlan/wep-key: .xe90245968787036bf1e1756fc8
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
@ -204,12 +205,12 @@ 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: 124
radio.1/cisco/elem15/rest: .x07ffffffce010001
radio.1/cisco/elem15/channel: 48
radio.1/cisco/elem15/rest: .x07ffffffce000000
radio.1/cisco/elem153: .x00
radio.1/cisco/elem156: .x020100
radio.1/cisco/elem16: .x0c121824
radio.1/cisco/elem19: .xc0a800a10001000bc0a800a110000101003ccd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000024282c3034383c4064686c707484888c01010101010101010101010101010101
radio.1/cisco/elem19: .xc0a800a10001000bc0a800a110000101001ecd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000024282c3034383c4064686c707484888c01010101010101010101010101010101
radio.1/cisco/elem22: .x1000b4003224282c3034383c4064686c707484888c
radio.1/cisco/elem24: .x003c000c
radio.1/cisco/elem47: .x0100000000000000000000000000000000
@ -262,7 +263,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: .xc97bf74c5a6b5d327384ac9065
radio.1/wlan.1/add-wlan/wep-key: .x495089a65b115670f2f2bd7c99
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
@ -279,7 +280,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: .xc97bf74c5a6b5d327384ac9065
radio.1/wlan.13/add-wlan/wep-key: .x495089a65b115670f2f2bd7c99
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