Compare commits

...

5 Commits

Author SHA1 Message Date
b54f4fb9fa updatedd libmavl to 1.2.0 2022-08-18 08:45:10 +02:00
7420a5d2fc WTP can join and goes into REG status on WLC 2022-08-18 08:17:31 +02:00
c2cb96e5dc WTP can join and send cfg request 2022-08-17 18:41:17 +02:00
9307b05b46 Deleted 2022-08-15 22:08:48 +02:00
be210692c6 Moved message encoding/decoding to message.c 2022-08-15 21:14:01 +02:00
50 changed files with 490 additions and 1315 deletions

View File

@ -4,6 +4,7 @@
#include "cw/mlist.h" #include "cw/mlist.h"
#include "mavl.h" #include "mavl.h"
#include "cw/mod.h" #include "cw/mod.h"
#include "cw/dbg.h"
#include "discovery_cache.h" #include "discovery_cache.h"
struct cw_DiscoveryCacheElem{ struct cw_DiscoveryCacheElem{
@ -108,15 +109,25 @@ errX:
void discovery_cache_add(struct cw_DiscoveryCache *cache, void discovery_cache_add(struct cw_DiscoveryCache *cache,
struct sockaddr * addr, struct cw_Mod * mod_capwap, struct cw_Mod * mod_bindings) struct sockaddr * addr, struct cw_Mod * mod_capwap, struct cw_Mod * mod_bindings)
{ {
{
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; struct cw_DiscoveryCacheElem * cur = cache->queue+cache->qpos;
if (cur->cmod!=NULL){ if (cur->cmod!=NULL){
/* delete here */ /* delete here */
cw_dbg(DBG_X,"DOIN MAVL DEL ----- ///////////");
void * ptr = &cur; void * ptr = &cur;
mavl_del(cache->byaddr,ptr); mavl_del(cache->byaddr,ptr);
mavl_del(cache->byaddr,ptr); mavl_del(cache->byaddrp,ptr);
} }
cur->cmod=mod_capwap; cur->cmod=mod_capwap;
cur->bmod=mod_bindings; cur->bmod=mod_bindings;
sock_copyaddr(&cur->addr,addr); sock_copyaddr(&cur->addr,addr);
@ -144,9 +155,24 @@ int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
sock_copyaddr(&search.addr,addr); sock_copyaddr(&search.addr,addr);
search.ctrhi=search.ctrlo=0; search.ctrhi=search.ctrlo=0;
{
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; search_ptr = &search;
result = mavl_get(cache->byaddrp ,&search_ptr); result = mavl_get(cache->byaddrp ,&search_ptr);
if (result != NULL){ if (result != NULL){
{
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);
}
elem = *result; elem = *result;
if (elem != NULL){ if (elem != NULL){
mavl_del(cache->byaddr,result); mavl_del(cache->byaddr,result);
@ -166,14 +192,37 @@ int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
result = mavl_get_first(cache->byaddr, &search_ptr); result = mavl_get_first(cache->byaddr, &search_ptr);
if (result == NULL) if (result == NULL)
return 0; return 0;
{
cw_dbg(DBG_X,"DISCOVERY CACHE ---------------------------- DOUND BY ADDR");
char str[128];
sock_addrtostr(addr,str,128,1);
printf("Add addr: %s\n",str);
}
elem = *result; elem = *result;
if (elem != NULL){ if (elem != NULL){
cw_dbg(DBG_X,"elem != NULL");
{
cw_dbg(DBG_X,"DISCOVERY CACHE ---------------------------- DOUND BY ADDR");
char str[128];
sock_addrtostr(&elem->addr,str,128,1);
printf("ELEM addr: %s\n",str);
}
if (sock_cmpaddr((struct sockaddr*)&elem->addr,addr,0)!=0) if (sock_cmpaddr((struct sockaddr*)&elem->addr,addr,0)!=0)
return 0; return 0;
mavl_del(cache->byaddr,result); cw_dbg(DBG_X,"DOIN MAVL DEL HERO ----- ///////////");
mavl_del(cache->byaddrp,result); mavl_del(cache->byaddr,&elem);
cw_dbg(DBG_X,"DOIN MAVL DEL HERXXXXXXO ----- ///////////");
mavl_del(cache->byaddrp,&elem);
cw_dbg(DBG_X,"DOIN MAVL DEL HERO 0000 ----- ///////////");
*modcapwap=elem->cmod; *modcapwap=elem->cmod;
*modbindings=elem->bmod; *modbindings=elem->bmod;

View File

@ -310,7 +310,7 @@ static void *wtpman_main(void *arg)
wtpman->conn->seqnum = 0; wtpman->conn->seqnum = 0;
conn = wtpman->conn; conn = wtpman->conn;
wtpman->conn->remote_cfg = cw_cfg_create(); // wtpman->conn->remote_cfg = cw_cfg_create();
if (!wtpman->dtlsmode) { if (!wtpman->dtlsmode) {
@ -358,32 +358,6 @@ static void *wtpman_main(void *arg)
while (!cw_timer_timeout(timer)) { while (!cw_timer_timeout(timer)) {
if (conn->update_cfg != NULL) {
mavl_t tmp;
tmp = conn->local_cfg;
/* mavl_merge(conn->default_cfg, conn->local_cfg);*/
/* mavl_merge(conn->default_cfg, conn->remote_cfg);*/
conn->local_cfg = conn->update_cfg;
cw_dbg(DBG_INFO, "Updating WTP %s",
sock_addr2str(&conn->addr, sock_buf));
rc = cw_send_request(conn,
CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST);
mavl_merge(conn->remote_cfg, conn->update_cfg);
conn->update_cfg = NULL;
conn->local_cfg = tmp;
}
rc = cw_read_messages(wtpman->conn); rc = cw_read_messages(wtpman->conn);
if (rc < 0) { if (rc < 0) {
@ -627,13 +601,16 @@ void wtpman_destroy(struct wtpman *wtpman)
static void copy(struct cw_ElemHandlerParams * params) static void copy(struct cw_ElemHandlerParams * params)
{ {
struct wtpman * wtpman; struct wtpman * wtpman;
struct cw_Conn * conn;
wtpman = (struct wtpman*)params->conn->data; wtpman = (struct wtpman*)params->conn->data;
conn = (struct cw_Conn*)params->conn;
cw_dbg(DBG_X,"------------- Here is the config we ve got from WTP ---------------- "); cw_dbg(DBG_X,"------------- Here is the config we ve got from WTP ---------------- ");
cw_cfg_dump(params->cfg); cw_cfg_dump(params->cfg);
cw_dbg(DBG_X,"------------- This was the config we ve got from WTP ---------------- "); cw_dbg(DBG_X,"------------- This was the config we ve got from WTP ---------------- ");
cw_dbg(DBG_X,"Now copying:"); cw_dbg(DBG_X,"Now copying:");
cw_cfg_copy(params->cfg,wtpman->wtp_cfg); cw_cfg_copy(params->cfg,conn->local_cfg);
cw_dbg(DBG_X,"Copying done."); cw_dbg(DBG_X,"Copying done.");
} }
@ -647,17 +624,32 @@ static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_pt
static int join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len) static int join_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,"JOIN Callback"); cw_dbg(DBG_X,"JOIN Callback");
copy(params); copy(params);
const char * wtpname = cw_cfg_get(conn->local_cfg,"wtp-name","default");
sprintf(filename,"wtp-join-%s.ckv",wtpname);
cw_cfg_save(filename,params->cfg);
cw_cfg_clear(params->cfg); cw_cfg_clear(params->cfg);
return 0; return 0;
} }
static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len) static int update_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,"UPDATE Callback"); cw_dbg(DBG_X,"UPDATE Callback");
copy(params); copy(params);
cw_cfg_clear(params->cfg);
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);
return 0; return 0;
} }

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
VERSION="1.1.0a" VERSION="1.2.0"
wget -O libmavl-${VERSION}.tgz ftp://ftp.planix.org/pub/planix/libmavl-${VERSION}.tgz wget -O libmavl-${VERSION}.tgz ftp://ftp.planix.org/pub/planix/libmavl-${VERSION}.tgz
tar xzvf libmavl-${VERSION}.tgz tar xzvf libmavl-${VERSION}.tgz

View File

@ -34,7 +34,6 @@ CWSRC=\
cw_load_file.c\ cw_load_file.c\
cw_out_generic_with_index.c\ cw_out_generic_with_index.c\
cw_out_radio_administrative_states.c\ cw_out_radio_administrative_states.c\
cw_process_element.c\
cw_put_elem_radio_administrative_state.c\ cw_put_elem_radio_administrative_state.c\
cw_put_elem_radio_operational_state.c\ cw_put_elem_radio_operational_state.c\
cw_put_image_data.c\ cw_put_image_data.c\
@ -77,6 +76,7 @@ CWSRC=\
# cw_in_generic.c\ # cw_in_generic.c\
# cw_out_generic.c\ # cw_out_generic.c\
# #
# cw_process_element.c\
KTVSRC=\ KTVSRC=\
cw_ktv_add.c\ cw_ktv_add.c\
@ -181,7 +181,6 @@ MISCSRC=\
conn_create_noq.c\ conn_create_noq.c\
connlist.c\ connlist.c\
conn_prepare_image_data_request.c\ conn_prepare_image_data_request.c\
cw_decode_msg.c \
conn_q_add_packet.c\ conn_q_add_packet.c\
conn_q_get_packet.c\ conn_q_get_packet.c\
conn_q_recv_packet.c\ conn_q_recv_packet.c\
@ -194,7 +193,6 @@ MISCSRC=\
format.c\ format.c\
format_is_utf8.c\ format_is_utf8.c\
fragman.c\ fragman.c\
intavltree.c\
md5sum.c\ md5sum.c\
mod.c\ mod.c\
msgset.c\ msgset.c\
@ -204,8 +202,11 @@ MISCSRC=\
conn.c \ conn.c \
val.c \ val.c \
discovery.c\ discovery.c\
message.c\
# intavltree.c\
# conn_q_wait_packet.c\ # conn_q_wait_packet.c\
# conn_init.c\ # conn_init.c\
# conn_create.c\ # conn_create.c\

View File

@ -127,6 +127,7 @@ const char *cw_cfg_get_l(cw_Cfg_t ** cfg, const char * key, const char *def)
int i; int i;
struct cw_Cfg_entry e, *r; struct cw_Cfg_entry e, *r;
for(i=0; cfg[i]!=NULL; i++){ for(i=0; cfg[i]!=NULL; i++){
// cw_dbg(DBG_X,"GET_L IN: %p",cfg[i]);
e.key = key; e.key = key;
r = mavl_get(cfg[i], &e); r = mavl_get(cfg[i], &e);
if (r!=NULL) if (r!=NULL)
@ -456,7 +457,6 @@ int cw_cfg_read_from_file(FILE * f, cw_Cfg_t * cfg)
return errs; return errs;
} }
int cw_cfg_load(const char *filename, cw_Cfg_t * cfg) int cw_cfg_load(const char *filename, cw_Cfg_t * cfg)
{ {
int errs; int errs;
@ -471,6 +471,42 @@ int cw_cfg_load(const char *filename, cw_Cfg_t * cfg)
return errno; return errno;
} }
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_foreach(&it) {
int n;
e = mavliter_get(&it);
n=strlen(e->val);
if (n>0)
n-=1;
//printf("Write %s: \"%s\" - %d %d (%02x)\n",e->key,e->val,n,isspace(e->val[n]),e->val[n]);
if(isspace(e->val[0]) || isspace(e->val[n]))
fprintf(f,"%s: \"%s\"\n", e->key, e->val);
else
fprintf(f,"%s: %s\n", e->key, e->val);
//cw_dbg(dbglevel,"%s%s :%s: %s",prefix,data->key,type->get_type_name(data), value);
}
return 0;
}
int cw_cfg_save(const char *filename, cw_Cfg_t *cfg)
{
int rc;
FILE *f = fopen(filename, "wb");
if (!f)
return errno;
rc = cw_cfg_write_to_file(f, cfg);
fclose(f);
return rc;
}
void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base) void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base)
{ {
@ -524,10 +560,12 @@ const char *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *key)
} }
int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, const char *def) int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, int def)
{ {
struct cw_Val v; struct cw_Val v;
const char *s = cw_cfg_get(cfg,key,def); const char *s = cw_cfg_get(cfg,key,NULL);
if (s==NULL)
return def;
CW_TYPE_BOOL->from_str(&v,s); CW_TYPE_BOOL->from_str(&v,s);
return v.val.boolean; return v.val.boolean;
} }
@ -688,19 +726,48 @@ void cw_cfg_clear(cw_Cfg_t *cfg)
int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key) int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key)
{ {
struct cw_Cfg_entry e, *result; struct cw_Cfg_entry e, *result;
//cw_dbg(DBG_X,"LOOX FOR: %s",key);
e.key=key; e.key=key;
result = mavl_get_first(cfg,&e); result = mavl_get_first(cfg,&e);
if (result == NULL) if (result == NULL)
return 0; return 0;
//cw_dbg(DBG_X,"BASEXXX: %s",result->key);
if (strlen(result->key)<strlen(key)) if (strlen(result->key)<strlen(key))
return 0; return 0;
//cw_dbg(DBG_X,"BASEXXX1: %d",strlen(key));
if (result->key[strlen(key)]!='/' && result->key[strlen(key)]!='.') if (result->key[strlen(key)]!='/' && result->key[strlen(key)]!='.')
return 0; return 0;
//cw_dbg(DBG_X,"BASEXXX2: ");
if (strncmp(result->key,key,strlen(key))==0) if (strncmp(result->key,key,strlen(key))==0)
return 1; return 1;
cw_dbg(DBG_X,"BASEXXX3: ");
return 0; return 0;
}
int cw_cfg_base_exists_l(cw_Cfg_t ** cfgs, const char *key)
{
int i;
for(i=0; cfgs[i]; i++){
if (cw_cfg_base_exists(cfgs[i],key))
return 1;
}
cw_dbg(DBG_X,"NOX EXISIS: %s in %d",key,i);
return 0;
}
cw_Val_t * cw_cfg_get_val_l(cw_Cfg_t ** cfgs, const char *key, const struct cw_Type *type)
{
const char *s;
cw_Val_t * val;
s = cw_cfg_get_l(cfgs,key,NULL);
val = malloc(sizeof(cw_Val_t));
if (val==NULL)
return NULL;
val->type=type;
val->type->from_str(val,s);
return val;
} }

View File

@ -31,7 +31,7 @@ const char * cw_cfg_get(cw_Cfg_t * cfg, const char *key, const char *def);
const char *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *key); const char *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *key);
void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base); void cw_cfg_iter_init(cw_Cfg_t * cfg, struct cw_Cfg_iter *cfi, const char *base);
int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, const char *def); int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, int def);
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key, uint16_t def); uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key, uint16_t def);
void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val); void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val);
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def); uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def);
@ -44,6 +44,10 @@ void cw_cfg_destroy(cw_Cfg_t *cfg);
void cw_cfg_clear(cw_Cfg_t *cfg); void cw_cfg_clear(cw_Cfg_t *cfg);
int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key); int cw_cfg_base_exists(cw_Cfg_t * cfg, const char *key);
uint8_t cw_cfg_get_byte_l(cw_Cfg_t ** cfgs, char *key, uint8_t def); uint8_t cw_cfg_get_byte_l(cw_Cfg_t ** cfgs, char *key, uint8_t def);
cw_Val_t * cw_cfg_get_val_l(cw_Cfg_t ** cfgs, const char *key, const struct cw_Type *type);
int cw_cfg_base_exists_l(cw_Cfg_t ** cfgs, const char *key);
int cw_cfg_save(const char *filename, cw_Cfg_t *cfg);

View File

@ -25,148 +25,6 @@
#include "dtls.h" #include "dtls.h"
/**
* Put a message to a buffer
* This functions assumes, that a message header is
* alread initilaized in buffer
* Message alements are taken fom actiondef in #conn->action
*/
int cw_assemble_message(struct cw_Conn *conn, uint8_t * rawout)
{
char details[1024];
uint8_t *msgptr,*dst;
int type;
struct cw_MsgData * msg;
struct mlistelem * elem;
int len,l;
/* rawout is already initialized, so we can get
* msg type from buffer */
msgptr = rawout + cw_get_hdr_msg_offset(rawout);
type = cw_get_msg_type(msgptr);
/* look for message data */
msg = cw_msgset_get_msgdata(conn->msgset,type);
if (msg == NULL){
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
type, cw_strmsg(type));
return CAPWAP_RESULT_MSG_UNRECOGNIZED;
}
if (msg->preprocess){
msg->preprocess(conn);
}
cw_dbg(DBG_MSG_ASSEMBLY,"*** Assembling message of type %d (%s) ***",
msg->type, msg->name);
dst = msgptr+8;
len =0;
mlist_foreach(elem,msg->elements_list){
struct cw_ElemData * data;
struct cw_ElemHandler * handler;
struct cw_ElemHandlerParams params;
data = mlistelem_dataptr(elem);
handler = cw_msgset_get_elemhandler(conn->msgset,data->proto,data->vendor,data->id);
cw_dbg(DBG_MSG_ASSEMBLY," Add Elem: %d %d %d %s", data->proto, data->vendor, data->id, handler->name);
if (handler==NULL){
cw_log(LOG_ERR,"Can't put message element %d %d %d, no handler defined.",
data->proto,data->vendor,data->id);
continue;
}
if (handler->put == NULL){
if (data->mand){
cw_log(LOG_ERR,"Error: Can't add mandatory message element %d - %s, no put method defined",
handler->id, handler->name);
}
continue;
}
params.conn=conn;
params.cfg=conn->remote_cfg;
params.cfg_list[0]=params.cfg;
params.cfg_list[1]=conn->local_cfg;
params.cfg_list[2]=conn->global_cfg;
params.cfg_list[3]=NULL;
params.msgset=conn->msgset;
params.elemdata = data;
params.msgdata=msg;
params.debug_details=details;
*details=0;
/* if (strcmp(handler->key,"cisco/ap-led-flash-config")==0){
printf("flash config\n");
cisco/ap-led-flash-config/flash-enable
}*/
if (!data->mand){
if (!cw_cfg_base_exists(params.cfg,handler->key)){
cw_dbg(DBG_X,"nothing todo");
continue;
}
}
l = handler->put(handler,&params,dst+len);
/* if(l>0)
cw_dbg_elem(DBG_ELEM_OUT,conn,type,handler,dst+len,l);
* if (strlen(details)){
cw_dbg(DBG_ELEM_DETAIL," %s",params.debug_details);
}
*/ len += l;
}
cw_set_msg_elems_len(msgptr, len);
cw_dbg(DBG_MSG_ASSEMBLY,"*** Done assenmbling message of type %d (%s) ***",
msg->type, msg->name);
if (type & 1) {
/* It's a request, so we have to set seqnum */
int s = conn_get_next_seqnum(conn);
cw_set_msg_seqnum(msgptr,s);
}
{
printf ("----------------------------------- redecode -----------------------------\n");
uint8_t *elems_ptr;
int offset = cw_get_hdr_msg_offset(rawout);
uint8_t *msg_ptr = rawout + offset;
int elems_len = cw_get_msg_elems_len(msg_ptr);
elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
cw_Cfg_t * cfg = cw_cfg_create();
struct cw_ElemHandlerParams params;
params.cfg=cfg;
params.msgset=conn->msgset;
params.msgdata=msg;
cw_decode_elements( &params, elems_ptr,elems_len);
cw_cfg_destroy(cfg);
printf ("----------------------------------- end redecode -----------------------------\n");
}
return CAPWAP_RESULT_SUCCESS;
}
struct msg_callback{ struct msg_callback{
int type; /**< message type */ int type; /**< message type */
@ -199,6 +57,11 @@ void cw_conn_init(struct cw_Conn * conn)
conn->process_message=process_message; conn->process_message=process_message;
conn->msg_callbacks = mavl_create(msg_callback_cmp,NULL,sizeof(struct msg_callback)); conn->msg_callbacks = mavl_create(msg_callback_cmp,NULL,sizeof(struct msg_callback));
conn->update_cfg = cw_cfg_create();
cw_dbg(DBG_X,"Update CFG ist %p",conn->update_cfg);
conn->remote_cfg = cw_cfg_create();
conn->local_cfg = cw_cfg_create();
} }
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun) int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
@ -378,7 +241,7 @@ int cw_send_response(struct cw_Conn *conn, uint8_t * rawmsg, int len)
{ {
int rc; int rc;
cw_init_response(conn, rawmsg); cw_init_response(conn, rawmsg);
rc = cw_assemble_message(conn, conn->resp_buffer); rc = cw_compose_message(conn, conn->resp_buffer);
if (!cw_result_is_ok(rc)) if (!cw_result_is_ok(rc))
return 0; return 0;
conn_send_msg(conn, conn->resp_buffer); conn_send_msg(conn, conn->resp_buffer);
@ -464,8 +327,6 @@ int cw_in_check_generic(struct cw_Conn *conn, struct cw_action_in *a, uint8_t *
static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len, static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
struct sockaddr *from) struct sockaddr *from)
{ {
mavl_t mand_found;
mlist_t unrecognized;
struct cw_MsgData search; struct cw_MsgData search;
struct cw_MsgData *message; struct cw_MsgData *message;
int result_code; int result_code;
@ -615,16 +476,14 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
elems_ptr = cw_get_msg_elems_ptr(msg_ptr); elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
mand_found = mavl_create_conststr();
unrecognized = mlist_create(NULL, NULL, sizeof(uint8_t *));
cw_dbg(DBG_MSG_PARSING, "*** Parsing message of type %d - (%s) ***", cw_dbg(DBG_MSG_PARSING, "*** Parsing message of type %d - (%s) ***",
message->type, message->name); message->type, message->name);
memset(&params,0,sizeof(struct cw_ElemHandlerParams));
params.mand_found = mavl_create_conststr();
params.unrecognized = mlist_create(NULL, NULL, sizeof(uint8_t *));
params.cfg = cw_cfg_create(); params.cfg = cw_cfg_create();
params.cfg_list[0]=params.cfg; params.cfg_list[0]=params.cfg;
params.cfg_list[1]=conn->local_cfg; params.cfg_list[1]=conn->local_cfg;
@ -633,7 +492,6 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
params.from = from; params.from = from;
params.msgdata = message; params.msgdata = message;
params.mand_found = mand_found;
params.msgset=conn->msgset; params.msgset=conn->msgset;
params.conn = conn; params.conn = conn;
@ -642,13 +500,14 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
/* all message elements are processed, do now after processing /* all message elements are processed, do now after processing
by calling the "end" function for the message */ by calling the "end" function for the message */
cw_check_missing_mand(message, mand_found); if (params.mand_found)
cw_check_missing_mand(message, params.mand_found,conn->msgset->handlers_by_key);
cw_dbg(DBG_MSG_PARSING, "*** End parsing message of type %d (%s) ***", cw_dbg(DBG_MSG_PARSING, "*** End parsing message of type %d (%s) ***",
message->type, message->name); message->type, message->name);
if (params.mand_found)
mavl_destroy(mand_found); mavl_destroy(params.mand_found);
if (message->postprocess) { if (message->postprocess) {
message->postprocess(&params,elems_ptr, elems_len); message->postprocess(&params,elems_ptr, elems_len);
@ -659,10 +518,10 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
result_code = cb_fun(&params,elems_ptr, elems_len); result_code = cb_fun(&params,elems_ptr, elems_len);
} }
else{ else{
cw_cfg_clear(params.cfg); cw_cfg_clear(conn->update_cfg);
} }
conn->remote_cfg=params.cfg; // conn->remote_cfg=params.cfg;
/* if we've got a request message, we always have to send a response message */ /* if we've got a request message, we always have to send a response message */
if (message->type & 1) { if (message->type & 1) {
@ -672,7 +531,7 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
cw_send_error_response(conn, rawmsg, result_code); cw_send_error_response(conn, rawmsg, result_code);
} else if (result_code == 0) { } else if (result_code == 0) {
cw_cfg_set_int(params.cfg, "result-code", cw_cfg_set_int(conn->update_cfg, "result-code",
result_code); result_code);
if (ui->next) { if (ui->next) {
conn->capwap_prevstate = conn->capwap_state; conn->capwap_prevstate = conn->capwap_state;
@ -693,9 +552,10 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
*/ */
} }
mlist_destroy(unrecognized); if (params.unrecognized)
mlist_destroy(params.unrecognized);
cw_cfg_destroy(params.cfg); cw_cfg_destroy(params.cfg);
conn->remote_cfg=NULL; // conn->remote_cfg=NULL;
return result_code; return result_code;
@ -955,8 +815,8 @@ void conn_destroy(struct cw_Conn * conn)
if (conn->local_cfg) if (conn->local_cfg)
cw_cfg_destroy(conn->local_cfg); cw_cfg_destroy(conn->local_cfg);
if (conn->update_cfg)
cw_cfg_destroy(conn->update_cfg);
free(conn); free(conn);
} }

View File

@ -38,7 +38,6 @@
/*#include "mbag.h"*/ /*#include "mbag.h"*/
#include "intavltree.h"
#include "bstr.h" #include "bstr.h"
#include "msgset.h" #include "msgset.h"
@ -70,13 +69,23 @@ struct cw_Conn {
int recv_timeout; int recv_timeout;
cw_Cfg_t * global_cfg; /**< This should set the global cfg of the program
which is using this conn object.
Teh global_cfg has to be treated read-only. */
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
mavl_t remote_cfg; device this conn object ist connected to.
// mavl_t default_cfg; 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; mavl_t update_cfg;
mavl_t local_cfg;
mavl_t global_cfg;
bstr16_t session_id; bstr16_t session_id;
@ -90,9 +99,6 @@ struct cw_Conn {
uint8_t wbid; uint8_t wbid;
/** Counter for mandatory message elements */
/* struct avltree *mand;*/
/** Actionsdefs - this defines the possible actions for /** Actionsdefs - this defines the possible actions for
this conn object, so in the end this is the specification this conn object, so in the end this is the specification
@ -119,10 +125,6 @@ struct cw_Conn {
int last_seqnum_received; int last_seqnum_received;
int last_message_id_received; int last_message_id_received;
// struct cwmsg req_msg;
// struct cwmsg resp_msg;
/** Buffer for outgoing request messages */ /** Buffer for outgoing request messages */
uint8_t req_buffer[CONN_MAX_MSG_LENGTH]; uint8_t req_buffer[CONN_MAX_MSG_LENGTH];
@ -141,17 +143,10 @@ struct cw_Conn {
int (*recv_packet) (struct cw_Conn*, uint8_t *, int); int (*recv_packet) (struct cw_Conn*, uint8_t *, int);
int (*recv_packet_peek) (struct cw_Conn*, uint8_t *, int); int (*recv_packet_peek) (struct cw_Conn*, uint8_t *, int);
int (*send_packet) (struct cw_Conn*, const uint8_t *, int); int (*send_packet) (struct cw_Conn*, const uint8_t *, int);
/*
// int (*recv_data_packet) (struct cw_Conn*, uint8_t *,int);
// int (*send_data_packet) (struct cw_Conn*, const uint8_t *, int);
*/
int (*readfrom) (struct cw_Conn*, uint8_t *, int, struct sockaddr_storage *); int (*readfrom) (struct cw_Conn*, uint8_t *, int, struct sockaddr_storage *);
int (*read) (struct cw_Conn*, uint8_t *, int); int (*read) (struct cw_Conn*, uint8_t *, int);
int (*write) (struct cw_Conn*, const uint8_t *, int); int (*write) (struct cw_Conn*, const uint8_t *, int);
/*
// int (*write_data) (struct cw_Conn*, const uint8_t *, int);
*/
/* optional packet queue */ /* optional packet queue */
uint8_t **q; uint8_t **q;
int qsize; int qsize;

View File

@ -1,74 +0,0 @@
/*
This file is part of libcapwap.
libcapwap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
* @brief conn_init
*/
#include <string.h>
#include "conn.h"
#include "capwap.h"
#include "cw.h"
/*
static int write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
{
if (handler->vendor)
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
return len + cw_put_elem_hdr(dst, handler->id, len);
}
static int header_len(struct cw_ElemHandler * handler)
{
return handler->vendor ? 10 : 4;
}
*/
/**
* Basic initialization of a conn object
* @param conn conn object to initialize
*/
void conn_init(struct cw_Conn * conn)
{
memset(conn,0,sizeof(struct cw_Conn ));
conn->retransmit_interval=CAPWAP_RETRANSMIT_INTERVAL;
conn->max_retransmit=CAPWAP_MAX_RETRANSMIT;
conn->wait_dtls=CAPWAP_WAIT_DTLS;
conn->wait_join=CAPWAP_WAIT_JOIN;
conn->mtu_discovery=1;
// conn->capwap_mode = 0;
conn->strict_capwap=1;
conn->process_packet=conn_process_packet;
conn->process_message=process_message;
/*
conn->write_header = write_header;
conn->header_len = header_len;
*/
}

View File

@ -1,40 +0,0 @@
/*
This file is part of libcapwap.
libcapwap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "cw.h"
#include "dbg.h"
#include "log.h"
#include "cw_util.h"
#include "conn.h"
#include "sock.h"
/*#include "stravltree.h"*/
#include "mod.h"
#include "msgset.h"
#include "val.h"

View File

@ -40,6 +40,8 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
{ {
int start, len, l; int start, len, l;
// cw_dbg(DBG_X,"cw_out_generic (%s)%s",((struct cw_Type*)handler->type)->name,handler->key);
// cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); // cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
// cw_cfg_dump(params->cfg); // cw_cfg_dump(params->cfg);
@ -48,7 +50,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
start = params->msgset->header_len(handler); start = params->msgset->header_len(handler);
len = ((const cw_Type_t*)(handler->type))-> len = ((const cw_Type_t*)(handler->type))->
write(params->cfg_list,handler->key,dst+start,handler->param); write(params->cfg_list,handler->key,dst+start,handler->param);
// cw_dbg(DBG_X, "Type result is %d",len);
if (len == -1) { if (len == -1) {
const char *vendor=""; const char *vendor="";
@ -69,6 +71,7 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
, cw_strmsg(a->msg_id),a->item_id); , cw_strmsg(a->msg_id),a->item_id);
*/ */
} }
return 0; return 0;
} }
@ -114,19 +117,21 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
int radios; int radios;
len =0; len =0;
radios = cw_cfg_get_byte(params->cfg,"wtp-descriptor/max-radios",0); radios = cw_cfg_get_byte_l(params->cfg_list,"wtp-descriptor/max-radios",0);
for(i=0;i<radios;i++){ for(i=0;i<radios;i++){
l=0;
type = (struct cw_Type*)handler->type; type = (struct cw_Type*)handler->type;
start = params->msgset->header_len(handler)+len; start = params->msgset->header_len(handler)+len;
sprintf(key,"radio.%d/%s",i,handler->key); sprintf(key,"radio.%d/%s",i,handler->key);
cw_dbg(DBG_X,"KEY: %s",key); // cw_dbg(DBG_X,"KEY: %s",key);
l = type->write(params->cfg_list, key,dst+start+1,handler->param);
if (l==-1)
continue;
l += cw_put_byte(dst+start,i);
l += cw_put_byte(dst+start+l,i);
l += type->write(params->cfg_list, key,dst+start+l,handler->param);
l = params->msgset->write_header(handler,dst+len,l); l = params->msgset->write_header(handler,dst+len,l);
len+=l; len+=l;
@ -134,3 +139,20 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
return len; return len;
} }
int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
{
if (handler->vendor)
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
return len + cw_put_elem_hdr(dst, handler->id, len);
}
int cw_header_len(struct cw_ElemHandler * handler)
{
return handler->vendor ? 10 : 4;
}

View File

@ -348,7 +348,8 @@ struct cw_DescriptorSubelemDef {
int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys ); //int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys );
int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys, mavl_t handlers_by_key );
@ -365,7 +366,7 @@ int cw_read_wtp_descriptor(mavl_t mbag, struct cw_Conn *conn,
struct cw_ElemHandler *eh, uint8_t * data, int len, struct cw_ElemHandler *eh, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *allowed); struct cw_DescriptorSubelemDef *allowed);
int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore, int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
int subelem_id, const char * parent_key); int subelem_id, const char * parent_key);
int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params, int idx, int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params, int idx,
@ -550,6 +551,9 @@ int cw_stricmp(char const *a, char const *b);
int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len); int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len);
int cw_header_len(struct cw_ElemHandler * handler); int cw_header_len(struct cw_ElemHandler * handler);
int cw_compose_message(struct cw_Conn *conn, uint8_t * rawout);
/** /**
*@} *@}
*/ */

View File

@ -3,7 +3,7 @@
#include "dbg.h" #include "dbg.h"
#include "log.h" #include "log.h"
int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys ) int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys, mavl_t handlers_by_key )
{ {
mlistelem_t * elem; mlistelem_t * elem;
char *mandkey, *result; char *mandkey, *result;
@ -26,7 +26,22 @@ int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys )
} }
mlist_foreach(elem,missing){ mlist_foreach(elem,missing){
cw_dbg(DBG_RFC," Missing mandatory message element: %s", mlistelem_get_str(elem)); const char * str;
struct cw_ElemHandler search, *result;
str = mlistelem_get_str(elem);
search.key = str;
result = mavl_get(handlers_by_key,&search);
if (result == NULL){
cw_log(LOG_ERR,"Can't find handler for for key %s",str);
}
else {
cw_dbg(DBG_RFC,"Missing mandatory message element: %s: %d - %s",
str,result->id, result->name);
}
} }
count = missing->count; count = missing->count;

View File

@ -1,127 +0,0 @@
#include "cw.h"
#include "dbg.h"
#include "log.h"
#include "msgset.h"
int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
int vendor, int elem_id, uint8_t * data, int len)
{
struct cw_ElemHandler *handler;
struct cw_ElemData *elem_data, elem_data_search;
int rc;
//params->elem = NULL;
/* try to retrieve a handler for this message element */
handler =
cw_msgset_get_elemhandler(params->msgset, proto, vendor,
elem_id);
if (!handler) {
cw_dbg(DBG_ELEM_ERR,
"Unrecognized message element: %d, ignoring", elem_id);
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
}
/* check if this message element in the current message allowed */
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 (!elem_data) {
cw_dbg(DBG_ELEM_ERR, "Element %d - %s, not allowed here",
elem_id, handler->name);
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
}
/* check the length of the message */
if (len < handler->min_len) {
cw_dbg(DBG_ELEM_ERR,
"%d (%s) message element too short, len=%d, min len=%d",
handler->id, handler->name, len, handler->min_len);
return -1;
}
if (elem_data->mand) {
mavl_add_str(params->mand_found, handler->key);
}
if (len > handler->max_len && handler->max_len) {
cw_dbg(DBG_ELEM_ERR,
"%d (%s) message element too big, len=%d, max len=%d",
handler->id, handler->name, len, handler->max_len);
/* TODO XXX truncate the element instead of return */
return -1;
}
cw_dbg_elem(DBG_ELEM_IN, NULL, params->msgdata->type, handler,
data, len);
if (handler->get == NULL) {
cw_log(LOG_ERR, "No get method defined for %d %s", handler->id,
handler->name);
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
}
rc = handler->get(handler, params, data, len);
return rc;
}
int cw_decode_elements(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
{
uint8_t *elem;
mavl_t mand_found;
mlist_t unrecognized;
mand_found = mavl_create_conststr();
unrecognized = mlist_create(NULL,NULL,sizeof(uint8_t*));
cw_foreach_elem(elem, elems_ptr, elems_len) {
int rc;
int elem_len, elem_id, max_len;
uint8_t * elem_data;
elem_len = cw_get_elem_len(elem);
elem_data=cw_get_elem_data(elem);
elem_id = cw_get_elem_id(elem);
max_len=elems_len-(elem_data-elems_ptr);
if (elem_len > max_len){
cw_dbg(DBG_RFC,
"Messag element claims size of %d bytes, but only %d bytes are left in the payload, truncating.",
elem_len,max_len-4);
}
params->from=NULL; /*from;*/
params->mand_found=mand_found;
rc = cw_decode_element(params,0,0,elem_id,elem_data,elem_len);
if (cw_result_is_ok(rc))
continue;
if (rc == CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT){
mlist_append(unrecognized,&elem);
continue;
}
if (rc < 0 ){
continue;
}
}
mavl_destroy(mand_found);
mlist_destroy(unrecognized);
return 0;
}

View File

@ -1,43 +0,0 @@
#include "capwap.h"
#include "intavltree.h"
#include "log.h"
#include "dbg.h"
#include "sock.h"
int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
/*
char sock_buf[SOCK_ADDR_BUFSIZE];
cw_action_in_t *mlist[120];
int n = cw_check_missing_mand(mlist, conn, a);
conn->capwap_state = CW_STATE_NONE;
if (n && conn->strict_capwap) {
cw_dbg_missing_mand(DBG_MSG_ERR, conn, mlist, n, a);
// if mandatory elements are missing, in strict
// mode send no discovery response
cw_dbg(DBG_MSG_ERR,
"Ignoring Discovery Request from %s - missing mandatory elements.",
sock_addr2str(from,sock_buf));
return -1;
}
if ( n ) {
// put a warning here
cw_dbg_missing_mand(DBG_RFC, conn, mlist, n, a);
}
// ok, send response
conn->capwap_state = CAPWAP_STATE_JOIN;
*/
return 0;
}

View File

@ -1,44 +0,0 @@
#include "capwap.h"
#include "intavltree.h"
#include "dbg.h"
#include "log.h"
#include "format.h"
#include "connlist.h"
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
/*
cw_action_in_t * mlist[60];
//Check for mandatory elements
int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
if ( conn->strict_capwap ){
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
conn->capwap_state=CAPWAP_STATE_JOIN;
return CW_RESULT_MISSING_MAND_ELEM;
}
cw_dbg_missing_mand(DBG_RFC,conn,mlist,n,a);
}
connlist_lock(conn->connlist);
struct conn *cc = connlist_get_by_session_id(conn->connlist,conn);
if (!cc){
connlist_add_by_session_id(conn->connlist,conn);
}
connlist_unlock(conn->connlist);
if (cc){
cw_dbg(DBG_ELEM_ERR,"Session already in use %s",format_bin2hex(conn->session_id,16));
conn->capwap_state=CAPWAP_STATE_JOIN;
return CW_RESULT_JOIN_FAILURE_SESSION_ALREADY_IN_USE;
}
// set result code to ok and change to configure state
mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);
conn->capwap_state = CW_STATE_CONFIGURE;
*/
return 0;
}

View File

@ -1,47 +0,0 @@
#include <errno.h>
#include "capwap.h"
#include "intavltree.h"
#include "dbg.h"
#include "log.h"
int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
/*
cw_action_in_t * mlist[60];
mbag_item_t * jresult = mbag_get(conn->incomming,CW_ITEM_RESULT_CODE);
if (jresult ) {
if (!cw_result_is_ok(jresult->u2.dword)){
return jresult->u2.dword;
}
}
// Check for mandatory elements
int n = cw_check_missing_mand(mlist,conn,a);
if (n && conn->strict_capwap) {
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
conn->capwap_state=CAPWAP_STATE_JOIN;
errno=EAGAIN;
return -1; //CW_RESULT_MISSING_MAND_ELEM;
}
if (n){
cw_dbg_missing_mand(DBG_RFC,conn,mlist,n,a);
}
if ( jresult ) {
return jresult->u2.dword;
}
// set result code to ok and change to configure state
// mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);
*/
return 0;
}

View File

@ -1,17 +1,18 @@
#include "cw.h" #include "cw.h"
#include"dbg.h" #include"dbg.h"
#include "cfg.h"
int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst) , uint8_t * dst)
{ {
cw_dbg(DBG_X,"Fix: cw_out_generic_indexed_enum"); // cw_dbg(DBG_X,"Fix: cw_out_generic_indexed_enum %s",handler->key);
stop(); // stop();
/*
char key[CW_CFG_MAX_KEY_LEN]; char key[CW_CFG_MAX_KEY_LEN];
int i; int i;
cw_Val_t * result; // cw_Val_t * result;
int len,start; int len,start;
uint8_t * ob; uint8_t * ob;
const cw_ValIndexed_t *ie; const cw_ValIndexed_t *ie;
@ -26,34 +27,42 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
e = ie->type; e = ie->type;
for(i=0; e[i].name!=NULL; i++) { for(i=0; e[i].name!=NULL; i++) {
int b;
sprintf(key,"%s/%s",handler->key,e[i].name); sprintf(key,"%s/%s",handler->key,e[i].name);
//printf("Her is the Key: %s - %s\n",key, ); cw_dbg(DBG_X,"Her is the Key: %s %s\n",key,e[i].name);
result = cw_ktv_base_exists(params->cfg,key); b = cw_cfg_base_exists_l(params->cfg_list,handler->key);
if (result==NULL) if (!b){
stop();
continue; continue;
}
start = params->msgset->header_len(handler); start = params->msgset->header_len(handler);
len = 0; len = 0;
if (ie->idxpos==0) if (ie->idxpos==0)
len = 1; len = 1;
if (e[i].fun_out==NULL) if (e[i].fun_out==NULL){
len += result->type->put(result,ob+start+len); stop();
else // result =
len += cw_ktv_write_struct(params->cfg, // len += result->type->put(result,ob+start+len);
NULL,e[i].type,key,ob+start+len); }
else{
len += ((cw_Type_t*)e[i].type)->write(params->cfg_list,key,ob+start+len,e[i].param);
// len += cw_ktv_write_struct(params->cfg,
// NULL,e[i].type,key,ob+start+len);
}
cw_set_byte(ob+start+ie->idxpos,e[i].value); cw_set_byte(ob+start+ie->idxpos,e[i].value);
if (ie->idxpos==len) if (ie->idxpos==len)
len++; len++;
ob += params->msgset->write_header(handler,ob,len); ob += params->msgset->write_header(handler,ob,len);
// cw_val_destroy(result);
} }
return ob-dst; return ob-dst;
*/
return 0; return 0;
} }

View File

@ -33,7 +33,6 @@ int cw_read_ac_descriptor(mavl_t store,
{ {
CW_TYPE_STRUCT->read(params->cfg,eh->key,data,len,acstatus); CW_TYPE_STRUCT->read(params->cfg,eh->key,data,len,acstatus);
// cw_ktv_read_struct(params->remote_cfg,acstatus,eh->key,data,len);
if (!allowed) if (!allowed)
allowed=allowed_default; allowed=allowed_default;

View File

@ -39,10 +39,12 @@ int cw_read_wtp_descriptor(mavl_t cfg, struct cw_Conn *conn,
} }
sprintf(key,"%s/%s",eh->key, "max-radios"); sprintf(key,"%s/%s",eh->key, "max-radios");
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data,1); // cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data,1);
CW_TYPE_BYTE->read(cfg,key,data,1,eh->param);
sprintf(key,"%s/%s",eh->key, CW_SKEY_RADIOS_IN_USE); sprintf(key,"%s/%s",eh->key, CW_SKEY_RADIOS_IN_USE);
cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data+1,1); // cw_ktv_add(cfg,key,CW_TYPE_BYTE,NULL,data+1,1);
CW_TYPE_BYTE->read(cfg,key,data,1,eh->param);

View File

@ -21,6 +21,7 @@
#include "format.h" #include "format.h"
#include "cw.h" #include "cw.h"
#include "val.h" #include "val.h"
#include "dbg.h"
static void del ( struct cw_Val * data ) static void del ( struct cw_Val * data )

View File

@ -105,6 +105,10 @@ static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, c
return l; return l;
} }
static int bwrite(cw_Cfg_t ** cfgs, const char *key, uint8_t *dst, const void * param)
{
return cw_generic_write_l(cfgs,CW_TYPE_STR,key,dst,param);
}
const struct cw_Type cw_type_str = { const struct cw_Type cw_type_str = {
@ -119,6 +123,8 @@ const struct cw_Type cw_type_str = {
get_type_name, /* get_type_name */ get_type_name, /* get_type_name */
NULL, NULL,
bread, bread,
bwrite,
}; };

View File

@ -115,7 +115,7 @@ static int write_struct(cw_Cfg_t ** cfgs, const cw_ValStruct_t * stru, const ch
else{ else{
struct cw_Type * type; struct cw_Type * type;
type = (struct cw_Type *)stru[i].type; type = (struct cw_Type *)stru[i].type;
wrlen = type->write(cfgs,stru[i].key,dst+pos,stru[i].valguard); wrlen = type->write(cfgs,key,dst+pos,stru[i].valguard);
/* result->valguard=stru[i].valguard; /* result->valguard=stru[i].valguard;
@ -142,7 +142,6 @@ static int bwrite(cw_Cfg_t **cfgs, const char *key, uint8_t *dst, const void *
{ {
return write_struct(cfgs,param,key,dst); return write_struct(cfgs,param,key,dst);
cw_dbg(DBG_X,"Key: %s",key);
stop(); stop();
/* /*

View File

@ -5,22 +5,23 @@
#include "dbg.h" #include "dbg.h"
#include "cfg.h" #include "cfg.h"
int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t * cfg, int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t ** cfg_list,
int subelem_id, const char * parent_key ) int subelem_id, const char * parent_key )
{ {
char key[256]; char key[256];
uint32_t vendor; uint32_t vendor;
bstr16_t version; //bstr16_t version;
const char *vendor_s; const char *vendor_s;
uint8_t *d; uint8_t *d;
/* d += cw_put_dword(d, bstrv_get_vendor_id(v)); /* d += cw_put_dword(d, bstrv_get_vendor_id(v));
d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v)); d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
d += cw_put_data(d, bstrv_data(v), bstrv_len(v)); d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
*/ */
sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR); sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR);
vendor_s = cw_cfg_get (cfg, key, NULL); vendor_s = cw_cfg_get_l (cfg_list, key, NULL);
if (vendor_s == NULL) { if (vendor_s == NULL) {
cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key); cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key);
@ -28,11 +29,16 @@ int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t * cfg,
} }
vendor = atoi(vendor_s); vendor = atoi(vendor_s);
sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION); sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION);
version = cw_cfg_get_bstr16 (cfg, key, NULL); cw_Val_t * val = cw_cfg_get_val_l(cfg_list, key, CW_TYPE_BSTR16);
if (version == NULL) { //version = cw_cfg_get_bstr16 (cfg, key, NULL);
if (val == NULL) {
cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key); cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key);
return 0; return 0;
} }
@ -44,10 +50,13 @@ int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t * cfg,
/* put version */ /* put version */
d += cw_put_dword (d, (subelem_id << 16) | bstr16_len(version)); d += cw_put_dword (d, (subelem_id << 16) | val->type->len(val));
d += cw_put_bstr16(d, version); // d += cw_put_bstr16(d, version);
d += val->type->put(val,d);
free(version); cw_val_destroy(val);
// free(version);
return d-dst; return d-dst;
} }

View File

@ -1,20 +0,0 @@
#include "conn.h"
#include "msgset.h"
#include "cw.h"
int cw_write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
{
if (handler->vendor)
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
return len + cw_put_elem_hdr(dst, handler->id, len);
}
int cw_header_len(struct cw_ElemHandler * handler)
{
return handler->vendor ? 10 : 4;
}

View File

@ -1,12 +1,12 @@
#include "cw.h" #include "cw.h"
#include "dbg.h" #include "dbg.h"
#include "log.h"
int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params, int idx int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params, int idx
, uint8_t * dst) , uint8_t * dst)
{ {
stop();
return 0;
char key[CW_CFG_MAX_KEY_LEN]; char key[CW_CFG_MAX_KEY_LEN];
cw_Val_t *elem, search; cw_Val_t *elem, search;
@ -16,32 +16,58 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
len =0; len =0;
sprintf(key,"radio.%d/%s",idx,handler->key); sprintf(key,"radio.%d/%s",idx,handler->key);
printf("Looking for readio key: %s\n",key); // printf("Looking for readio key: %s\n",key);
search.key=key; // search.key=key;
elem = mavl_get(params->cfg, &search); // elem = mavl_get(params->cfg, &search);
// elem = cw_cfg_get_val_l(params->cfg_list, key, handler->type);
if (elem==NULL){
printf("Nothing found\n"); // if (elem==NULL){
return 0; // printf("Nothing found\n");
} // return 0;
// }
/* Size for msg elem header depends on /* Size for msg elem header depends on
vendor specific payload */ vendor specific payload */
d = handler->vendor ? dst+10 : dst+4; // d = handler->vendor ? dst+10 : dst+4;
d = dst + params->msgset->header_len(handler);
/* put radio id */ /* put radio id */
len = cw_generic_write_l(params->cfg_list,((const cw_Type_t*)(handler->type)),
key, d, handler->param);
if (len==-1){
const char *vendor="";
if ( handler->vendor ) {
vendor=cw_strvendor(handler->vendor);
}
if ( params->elemdata->mand) {
cw_log(LOG_ERR,
"Can't put mandatory element %s %d-(%s) into %s. No value for '%s' found.",
vendor, handler->id, handler->name, params->msgdata->name
, handler->key
);
}
return 0;
}
printf("Putting put byte index: %d\n",idx); printf("Putting put byte index: %d\n",idx);
len += cw_put_byte(d+len,idx); len += cw_put_byte(d+len,idx);
len += ((const cw_Type_t*)(handler->type))->put(elem,d+len); // len += ((const cw_Type_t*)(handler->type))->put(elem,d+len);
/* l = len + cw_put_elem_hdr(dst, handler->id, len);*/ /* l = len + cw_put_elem_hdr(dst, handler->id, len);*/
return params->msgset->write_header(handler,dst,len);
/*
if (handler->vendor) if (handler->vendor)
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len); return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
return len + cw_put_elem_hdr(dst, handler->id, len); return len + cw_put_elem_hdr(dst, handler->id, len);*/
} }

View File

@ -104,12 +104,6 @@ void cw_discovery_results_add(struct cw_DiscoveryResults *dis,
mavl_insert(dis->list,&e,NULL); mavl_insert(dis->list,&e,NULL);
/* cw_ktv_add(dis->prio_ip, key, CW_TYPE_SYSPTR, NULL, (uint8_t *) (&ipval),
sizeof(ipval));
cw_ktv_add(dis->prio_ac, key, CW_TYPE_SYSPTR, NULL, (uint8_t *)(&remote_cfg),
sizeof(remote_cfg)); */
// cw_dbg(DBG_X, "KEY: %s: %s", key, ipval);
} while (i < 255); } while (i < 255);
dis->nr++; dis->nr++;

View File

@ -1,35 +0,0 @@
#include <stdlib.h>
#include "intavltree.h"
static int cmp(const void *v1,const void*v2)
{
return *((int*)v1) - *((int*)v2);
}
static void del(void* d)
{
free (d);
return;
}
struct mavl * intavltree_create()
{
return mavl_create(cmp,del,100);
}
int * intavltree_add(struct mavl * t, int val)
{
int *v = mavl_get(t,&val);
if (v)
return v;
v = malloc(sizeof(int));
if (!v)
return NULL;
*v=val;
return mavl_insert(t,v,NULL);
}

View File

@ -1,15 +0,0 @@
#ifndef __INTAVLTREE_H
#define __INTAVLTREE_H
#include <mavl.h>
extern struct mavl * intavltree_create();
typedef struct mavl * intavltree_t;
int * intavltree_add(struct mavl * t, int val);
#define intavltree_destroy(t) mavl_destroy(t)
#define intavltree_foreach_asc(t,f,p) mavl_foreach_asc(t,f,p)
#define intavltree_foreach_desc(t,f,p) mavl_foreach_desc(t,f,p)
#endif

View File

@ -30,6 +30,7 @@ struct cw_ElemHandlerParams {
struct cw_ElemData * elemdata; struct cw_ElemData * elemdata;
struct sockaddr *from; struct sockaddr *from;
mavl_t mand_found; mavl_t mand_found;
mlist_t unrecognized;
// cw_Val_t * elem; // cw_Val_t * elem;
char * debug_details; char * debug_details;
cw_Cfg_t * cfg; cw_Cfg_t * cfg;

View File

@ -173,7 +173,7 @@ int cw_send_request(struct cw_Conn *conn,int msg_id)
int rc; int rc;
char sock_buf[SOCK_ADDR_BUFSIZE]; char sock_buf[SOCK_ADDR_BUFSIZE];
cw_init_request(conn, msg_id); cw_init_request(conn, msg_id);
if ( cw_assemble_message(conn, conn->req_buffer) == -1 ){ if ( cw_compose_message(conn, conn->req_buffer) == -1 ){
errno=ENOMSG; errno=ENOMSG;
return -1; return -1;
} }

View File

@ -249,6 +249,7 @@ struct cw_Val_Reader {
void cw_ktv_init_str_reader(struct cw_Val_Reader *r, const char * str, int len); void cw_ktv_init_str_reader(struct cw_Val_Reader *r, const char * str, int len);
int cw_ktv_parse_string(struct cw_Val_Reader *r, char *key, char *type, char *val); int cw_ktv_parse_string(struct cw_Val_Reader *r, char *key, char *type, char *val);
int cw_generic_write_l(cw_Cfg_t **cfg, const struct cw_Type*type, const char *key, uint8_t *dst, const void * param); int cw_generic_write_l(cw_Cfg_t **cfg, const struct cw_Type*type, const char *key, uint8_t *dst, const void * param);
void cw_val_destroy(cw_Val_t *val);
/** /**
* @} KTV * @} KTV

View File

@ -338,7 +338,7 @@ static struct cw_ElemHandler handlers[] = {
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"wtp-reboot-statistics", /* Key */ "wtp-reboot-statistics", /* Key */
cw_in_generic, /* handler */ cw_in_generic, /* handler */
cw_out_generic_struct, /* put */ cw_out_generic, /* put */
NULL, NULL,
NULL, NULL,
wtp_reboot_statistics wtp_reboot_statistics

View File

@ -37,7 +37,7 @@ int capwap_in_vendor_specific_payload(struct cw_ElemHandler *handler,
// cw_dbg_elem(DBG_ELEM_IN,params->conn,0,vhandler, data+6,len-6); // cw_dbg_elem(DBG_ELEM_IN,params->conn,0,vhandler, data+6,len-6);
//vhandler->get(vhandler, params, data+6, len-6); //vhandler->get(vhandler, params, data+6, len-6);
*/ */
cw_process_element(params,0,vendor_id,elem_id,data+6,len-6); cw_decode_element(params,0,vendor_id,elem_id,data+6,len-6);
return 1; return 1;

View File

@ -26,8 +26,6 @@
int capwap_in_wtp_descriptor(struct cw_ElemHandler *eh, struct cw_ElemHandlerParams *params, uint8_t * data, int capwap_in_wtp_descriptor(struct cw_ElemHandler *eh, struct cw_ElemHandlerParams *params, uint8_t * data,
int len) int len)
{ {
stop();
int rc; int rc;
/*rc =cw_read_wtp_descriptor(params->remote_cfg, params->conn, eh, data, len, NULL);*/ /*rc =cw_read_wtp_descriptor(params->remote_cfg, params->conn, eh, data, len, NULL);*/
rc =cw_read_wtp_descriptor(params->cfg, NULL, eh, data, len, NULL); rc =cw_read_wtp_descriptor(params->cfg, NULL, eh, data, len, NULL);

View File

@ -11,7 +11,7 @@ int capwap_out_capwap_local_ip_address(struct cw_ElemHandler * eh,
memset(&ip,0,sizeof(cw_Val_t)); memset(&ip,0,sizeof(cw_Val_t));
ip.type=CW_TYPE_IPADDRESS; ip.type=CW_TYPE_IPADDRESS;
ipstr = cw_cfg_get(params->cfg,eh->key,NULL); ipstr = cw_cfg_get_l(params->cfg_list,eh->key,NULL);
if (ipstr==NULL){ if (ipstr==NULL){
return 0; return 0;
} }

View File

@ -45,7 +45,8 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE); sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
val = cw_cfg_get_byte_l(params->cfg_list,key, 0); val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
d+=cw_put_byte(d,val); /*radios in use*/ cw_dbg("WTP-DESCRIPTOR: radios in use: %d",val);
d+=cw_put_byte(d,val); /*radios in use*/
/* d+=cw_put_encryption_capabilities_7(d,1); */ /* d+=cw_put_encryption_capabilities_7(d,1); */
/* d+=cw_put_encryption_subelems(d,params->conn->capwap_mode);*/ /* d+=cw_put_encryption_subelems(d,params->conn->capwap_mode);*/
@ -56,17 +57,17 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
/* hardware version sub element */ /* hardware version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE); sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_HARDWARE_VERSION, key); CW_SUBELEM_WTP_HARDWARE_VERSION, key);
/* software version sub element */ /* software version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE); sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
d+=cw_write_descriptor_subelem (d, params->cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_SOFTWARE_VERSION, key); CW_SUBELEM_WTP_SOFTWARE_VERSION, key);
/* bootloader version sub element */ /* bootloader version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER); sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER);
d+=cw_write_descriptor_subelem (d, params->cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_BOOTLOADER_VERSION, key); CW_SUBELEM_WTP_BOOTLOADER_VERSION, key);
len = d-dst-4; len = d-dst-4;

View File

@ -110,8 +110,8 @@ static cw_ValStruct_t cisco_ap_led_state_config73[] = {
}; };
static cw_ValEnum_t cisco_ap_telnet_ssh_enum[] ={ static cw_ValEnum_t cisco_ap_telnet_ssh_enum[] ={
{0, "telnet", CW_TYPE_BOOL, cw_in_generic, NULL }, {0, "telnet", CW_TYPE_BOOL, cw_in_generic, cw_out_generic },
{1, "ssh", CW_TYPE_BOOL, cw_in_generic, NULL }, {1, "ssh", CW_TYPE_BOOL, cw_in_generic, cw_out_generic },
{0,0,0,0} {0,0,0,0}
}; };
@ -119,8 +119,7 @@ static cw_ValIndexed_t cisco_ap_telnet_ssh = {
1,cisco_ap_telnet_ssh_enum 1,cisco_ap_telnet_ssh_enum
}; };
static cw_ValStruct_t cisco_multi_domain_cabability[]={ static cw_ValStruct_t cisco_multi_domain_capability[]={
{CW_TYPE_BYTE, "radio-id", 1, -1},
{CW_TYPE_BYTE, "reserved", 1, -1}, {CW_TYPE_BYTE, "reserved", 1, -1},
{CW_TYPE_WORD, "first-channel", 2, -1}, {CW_TYPE_WORD, "first-channel", 2, -1},
{CW_TYPE_WORD, "number-of-channels", 2, -1}, {CW_TYPE_WORD, "number-of-channels", 2, -1},
@ -192,7 +191,6 @@ static cw_ValStruct_t cisco_ap_regulatory_domain5[]={
static cw_ValStruct_t cisco_mac_operation70[]={ static cw_ValStruct_t cisco_mac_operation70[]={
{CW_TYPE_BYTE,"radio-id",1,-1},
{CW_TYPE_BYTE,"reserved",1,-1}, {CW_TYPE_BYTE,"reserved",1,-1},
{CW_TYPE_WORD,"rts-threshold",2,-1}, {CW_TYPE_WORD,"rts-threshold",2,-1},
{CW_TYPE_BYTE,"short-retry",1,-1}, {CW_TYPE_BYTE,"short-retry",1,-1},
@ -254,24 +252,23 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
char testkey[CW_CFG_MAX_KEY_LEN]; char testkey[CW_CFG_MAX_KEY_LEN];
int idx; int idx;
void * type; void * type;
cw_Val_t * result, search; cw_Val_t * result;
int len,start; int len,start;
uint8_t * ob; uint8_t * ob;
stop();
idx = 0; idx = 0;
ob = dst; ob = dst;
stop();
type = NULL; type = NULL;
result = cw_ktv_get(params->cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16); result = cw_cfg_get_val_l(params->cfg_list,"wtp-descriptor/software/version",CW_TYPE_BSTR16);
if (result!=NULL){ if (result!=NULL){
if(result->type->len(result)==4){ if(result->type->len(result)==4){
uint32_t rv; uint32_t rv;
rv = cw_get_dword(result->type->data(result)); rv = cw_get_dword(result->type->data(result));
cw_dbg(DBG_X,"Version is %08X",rv);
if (rv >= 0x07056600){ if (rv >= 0x07056600){
type = cisco_ap_regulatory_domain5; type = cisco_ap_regulatory_domain5;
} }
@ -281,32 +278,33 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
} }
} }
else {
stop();
}
cw_val_destroy(result);
do { do {
sprintf(key,"%s.%d",eh->key,idx); sprintf(key,"%s.%d",eh->key,idx);
search.key=key; if (!cw_cfg_base_exists_l(params->cfg_list,key))
result = mavl_get_first(params->cfg,&search);
if (result==NULL)
break; break;
if (strncmp(result->key,key,strlen(key))!=0)
break;
if(type == NULL){ if(type == NULL){
sprintf(testkey,"%s/%s",key,"band-id"); sprintf(testkey,"%s/%s",key,"band-id");
stop(); stop();
result = cw_ktv_get(params->cfg,key,CW_TYPE_BYTE); result = cw_ktv_get_val_l(params->cfg_list,key,CW_TYPE_BYTE);
if (result==NULL){ if (result==NULL){
type = cisco_ap_regulatory_domain4; type = cisco_ap_regulatory_domain4;
} }
else{ else{
type = cisco_ap_regulatory_domain5; type = cisco_ap_regulatory_domain5;
cw_val_destroy(result);
} }
} }
start = params->msgset->header_len(eh); start = params->msgset->header_len(eh);
stop(); len = CW_TYPE_STRUCT->write(params->cfg_list,key,ob+start,type);
len = cw_ktv_write_struct(params->cfg,NULL,type,key,ob+start); // len = cw_ktv_write_struct(params->cfg,NULL,type,key,ob+start);
ob += params->msgset->write_header(eh,ob,len); ob += params->msgset->write_header(eh,ob,len);
idx++; idx++;
@ -349,7 +347,6 @@ static cw_ValStruct_t cisco_antenna_payload70[]={
static cw_ValStruct_t cisco_wtp_radio_config70[]={ static cw_ValStruct_t cisco_wtp_radio_config70[]={
{CW_TYPE_BYTE,"radio-id",1,-1},
{CW_TYPE_BYTE,"cfg-type",1,-1}, {CW_TYPE_BYTE,"cfg-type",1,-1},
{CW_TYPE_WORD,"occupancy-limit",2,-1}, {CW_TYPE_WORD,"occupancy-limit",2,-1},
{CW_TYPE_BYTE,"cfg-period",1,-1}, {CW_TYPE_BYTE,"cfg-period",1,-1},
@ -401,7 +398,6 @@ static cw_ValStruct_t cisco_wtp_radio_config75[]={
static cw_ValStruct_t cisco_tx_power[]={ static cw_ValStruct_t cisco_tx_power[]={
{CW_TYPE_BYTE,"radio-id",1,-1},
{CW_TYPE_BYTE,"reserved",1,-1}, {CW_TYPE_BYTE,"reserved",1,-1},
{CW_TYPE_WORD,"current-tx-power",2,-1}, {CW_TYPE_WORD,"current-tx-power",2,-1},
{NULL,NULL,0,0} {NULL,NULL,0,0}
@ -578,6 +574,7 @@ static int cw_mkradiokey(const char *pkey, uint8_t*data, int len, char *dst)
return 1; return 1;
} }
/*
static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *dst) static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *dst)
{ {
int wlan_id,radio_id; int wlan_id,radio_id;
@ -587,7 +584,7 @@ static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *d
sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id); sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id);
return 1; return 1;
} }
*/
static int cisoc_add_wlan_mkkey70(const char *pkey, uint8_t*data, int len, char *dst) static int cisoc_add_wlan_mkkey70(const char *pkey, uint8_t*data, int len, char *dst)
{ {
@ -831,7 +828,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_DWORD, /* type */ CW_TYPE_DWORD, /* type */
"wtp-radio-information", /* Key */ "wtp-radio-information", /* Key */
cw_in_radio_generic, /* get */ cw_in_radio_generic, /* get */
cisco_out_radio_generic /* put */ cw_out_radio_generic /* put */
} }
, ,
{ {
@ -958,7 +955,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/loghost-config", /* Key */ "cisco/loghost-config", /* Key */
cw_in_generic, /* get */ cw_in_generic, /* get */
cw_out_generic_struct, /* put */ cw_out_generic, /* put */
NULL, NULL,
NULL, NULL,
cisco_loghost_config, /* type */ cisco_loghost_config, /* type */
@ -1009,11 +1006,11 @@ static struct cw_ElemHandler handlers70[] = {
8,8, /* min/max length */ 8,8, /* min/max length */
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/multi-domain-capability", /* Key */ "cisco/multi-domain-capability", /* Key */
cw_in_generic, /* get */ cw_in_radio_generic, /* get */
NULL, /* put */ cw_out_radio_generic, /* put */
cw_mkradiokey,
NULL, NULL,
cisco_multi_domain_cabability, NULL,
cisco_multi_domain_capability,
} }
, ,
@ -1080,7 +1077,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/ap-mode-and-type", /* Key */ "cisco/ap-mode-and-type", /* Key */
cw_in_generic, /* get */ cw_in_generic, /* get */
cw_out_generic_struct, /* put */ cw_out_generic, /* put */
NULL, NULL,
NULL, NULL,
cisco_ap_mode_and_type, cisco_ap_mode_and_type,
@ -1166,7 +1163,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/ap-model", /* Key */ "cisco/ap-model", /* Key */
cw_in_generic, /* get */ cw_in_generic, /* get */
cw_out_generic_struct, /* put */ cw_out_generic, /* put */
NULL, NULL,
NULL, NULL,
cisco_ap_model, cisco_ap_model,
@ -1191,9 +1188,9 @@ static struct cw_ElemHandler handlers70[] = {
25,25, /* min/max length */ 25,25, /* min/max length */
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/wtp-radio-config", /* Key */ "cisco/wtp-radio-config", /* Key */
cw_in_generic, /* get */ cw_in_radio_generic, /* get */
cw_out_generic, /* put */ cw_out_radio_generic, /* put */
cw_mkradiokey, NULL,
NULL, NULL,
cisco_wtp_radio_config70, cisco_wtp_radio_config70,
@ -1253,9 +1250,9 @@ static struct cw_ElemHandler handlers70[] = {
16,16, /* min/max length */ 16,16, /* min/max length */
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/mac-operation", /* Key */ "cisco/mac-operation", /* Key */
cw_in_generic, /* get */ cw_in_radio_generic, /* get */
cw_out_radio_generic_struct, /* put */ cw_out_radio_generic, /* put */
cw_mkradiokey, NULL,
NULL, NULL,
cisco_mac_operation70, cisco_mac_operation70,
@ -1269,9 +1266,9 @@ static struct cw_ElemHandler handlers70[] = {
4,4, /* min/max length */ 4,4, /* min/max length */
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/tx-power", /* Key */ "cisco/tx-power", /* Key */
cw_in_generic, /* get */ cw_in_radio_generic, /* get */
cw_out_radio_generic_struct, /* put */ cw_out_radio_generic, /* put */
cw_mkradiokey, NULL,
NULL, NULL,
cisco_tx_power, cisco_tx_power,
@ -1284,9 +1281,9 @@ static struct cw_ElemHandler handlers70[] = {
5,150, /* min/max length */ 5,150, /* min/max length */
CW_TYPE_BSTR16, /* type */ CW_TYPE_BSTR16, /* type */
"cisco/tx-power-levels", /* Key */ "cisco/tx-power-levels", /* Key */
cw_in_generic, /* get */ cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */ cw_out_radio_generic, /* put */
cw_mkradiokey, NULL,
NULL, NULL,
@ -1555,19 +1552,19 @@ static struct cw_ElemHandler handlers70[] = {
} }
, ,
{ // {
"Add Cisco WLAN", /* name */ // "Add Cisco WLAN", /* name */
CISCO_ELEM_ADD_WLAN, /* Element ID */ /// CISCO_ELEM_ADD_WLAN, /* Element ID */
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */ /// CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
7,1117, /* min/max length */ /// 7,1117, /* min/max length */
cisco_add_wlan70, /* type */ // cisco_add_wlan70, /* type */
"radio/wlan/add-wlan", /* Key */ // "radio/wlan/add-wlan", /* Key */
cw_in_generic_struct, /* get */ /// cw_in_generic_struct, /* get */
cw_out_traverse, /* put */ // cw_out_traverse, /* put */
cisoc_add_wlan_mkkey70, // cisoc_add_wlan_mkkey70,
cisco_patch_add_wlan70 // cisco_patch_add_wlan70
} // }
, // ,
{ {
"Add Cisco WLAN (LWAPP)", /* name */ "Add Cisco WLAN (LWAPP)", /* name */
@ -1642,10 +1639,14 @@ static struct cw_ElemHandler handlers70[] = {
CISCO_LWELEM_HARDWARE_INFO, /* Element ID */ CISCO_LWELEM_HARDWARE_INFO, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */ CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
17,417, /* min/max length */ 17,417, /* min/max length */
cisco_hardware_info, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/hardware-info", /* Key */ "cisco/hardware-info", /* Key */
cw_in_generic_struct, /* get */ cw_in_generic, /* get */
cw_out_generic_struct /* put */ cw_out_generic, /* put */
NULL,
NULL,
cisco_hardware_info,
}, },
{ {
@ -1656,7 +1657,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */ CW_TYPE_STRUCT, /* type */
"cisco/cisco-discovery-protocol", /* Key */ "cisco/cisco-discovery-protocol", /* Key */
cw_in_generic, /* get */ cw_in_generic, /* get */
cw_out_generic_struct, /* put */ cw_out_generic, /* put */
NULL, NULL,
NULL, NULL,
cisco_discovery_protocol, cisco_discovery_protocol,
@ -1695,10 +1696,13 @@ static struct cw_ElemHandler handlers70[] = {
CISCO_ELEM_80211_ASSOC_LIMIT, /* Element ID */ CISCO_ELEM_80211_ASSOC_LIMIT, /* Element ID */
CW_VENDOR_ID_CISCO, 0, /* Vendor / Proto */ CW_VENDOR_ID_CISCO, 0, /* Vendor / Proto */
4, 4, /* min/max length */ 4, 4, /* min/max length */
cisco_80211_assoc_limit, /* type */ CW_TYPE_STRUCT, /* type */
"cisco-8011-assoc-limit", /* Key */ "cisco-8011-assoc-limit", /* Key */
cw_in_generic_struct, /* get */ cw_in_generic, /* get */
cw_out_generic_struct /* put */ cw_out_generic, /* put */
NULL,
NULL,
cisco_80211_assoc_limit
} }
, ,
@ -2362,11 +2366,15 @@ static int preprocess_join_request(struct cw_Conn *conn)
use_ac_version = cw_cfg_get_bool(conn->global_cfg,"cisco/wtp-use-ac-version",0); use_ac_version = cw_cfg_get_bool(conn->global_cfg,"cisco/wtp-use-ac-version",0);
if (use_ac_version){ if (use_ac_version){
ver = cw_cfg_get_bstr16(conn->remote_cfg,"ac-descriptor/software/version",NULL ); ver = cw_cfg_get_bstr16(conn->remote_cfg,"ac-descriptor/software/version",NULL );
cw_cfg_set_bstr16(conn->local_cfg,"wtp-descriptor/software/version",ver); if (ver != NULL){
cw_cfg_set_bstr16(conn->local_cfg,"wtp-descriptor/software/version",ver);
cw_format_version(verstr,bstr16_data(ver),bstr16_len(ver)); cw_format_version(verstr,bstr16_data(ver),bstr16_len(ver));
cw_dbg(DBG_INFO, "Cisco WTP - Using AC's software version: %s", verstr); cw_dbg(DBG_INFO, "Cisco WTP - Using AC's software version: %s", verstr);
free(ver); free(ver);
}
else{
cw_dbg(DBG_X,"No version defined");
}
} }

View File

@ -1,47 +0,0 @@
/*
This file is part of actube.
actube is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file
* @brief Implements cw_in_capwap_control_ip_address
*/
#include "mod_capwap.h"
int cisco_in_ap_regulatory_domain(struct cw_ElemHandler *eh,
struct cw_ElemHandlerParams *params,
uint8_t * data, int len)
{
char key[CW_KTV_MAX_KEY_LEN];
int idx;
sprintf(key,"%s/address",eh->key);
idx = cw_ktv_idx_get(params->conn->remote_cfg,key);
/* printf("SKEY is %s , idx: %d\n",key,idx);*/
sprintf(key,"%s/address.%d",eh->key,idx+1);
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_IPADDRESS,data,len-2);
sprintf(key,"%s/wtps.%d",eh->key,idx+1);
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_WORD,data+len-2,2);
return 1;
}

View File

@ -25,5 +25,5 @@ int cisco_in_spam_vendor_specific(struct cw_ElemHandler *eh,
} }
return cw_process_element(params,CW_PROTO_LWAPP,vendor_id,elem_id,data+6,len-6); return cw_decode_element(params,CW_PROTO_LWAPP,vendor_id,elem_id,data+6,len-6);
} }

View File

@ -66,11 +66,11 @@ int cisco_out_ac_descriptor(struct cw_ElemHandler * eh,
/* it is important to send software version first, /* it is important to send software version first,
* because APs don't check the type */ * because APs don't check the type */
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE); sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
1, key); 1, key);
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE); sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
0, key); 0, key);

View File

@ -15,7 +15,7 @@ int cisco_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandl
int radios; int radios;
len =0; len =0;
radios = cw_cfg_get_byte(params->cfg,"wtp-descriptor/max-radios",0); radios = cw_cfg_get_byte_l(params->cfg_list,"wtp-descriptor/max-radios",0);
cw_dbg(DBG_X,"NUM RADIOS: %d",radios); cw_dbg(DBG_X,"NUM RADIOS: %d",radios);
for(i=0;i<radios+0;i++){ for(i=0;i<radios+0;i++){
l = cw_write_radio_element(handler,params,i,dst+len); l = cw_write_radio_element(handler,params,i,dst+len);

View File

@ -20,23 +20,33 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
rc = cw_generic_write_l(params->cfg_list, CW_TYPE_BYTE,key, rc = cw_generic_write_l(params->cfg_list, CW_TYPE_BYTE,key,
d, eh->param); d, eh->param);
const char *
xxx = cw_cfg_get_l(params->cfg_list, key, NULL);
cw_dbg(DBG_X,"What??? %s: %s",key,xxx);
// val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE); // val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
if (rc==-1){ if (rc==-1){
cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", key); cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", key);
d+=cw_put_byte(d,0); d+=cw_put_byte(d,0);
} }
else { else {
int yyy = cw_get_byte(d);
cw_dbg(DBG_X,"Verify: %d",yyy);
d+=rc; d+=rc;
} }
sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE); sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
xxx = cw_cfg_get_l(params->cfg_list, key, NULL);
cw_dbg(DBG_X,"What??? %s: %s",key,xxx);
rc = cw_generic_write_l(params->cfg_list, CW_TYPE_BYTE,key, rc = cw_generic_write_l(params->cfg_list, CW_TYPE_BYTE,key,
d, eh->param); d, eh->param);
// val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE); // val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
if (rc != -1){ if (rc == -1){
cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", key); cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", key);
d+=cw_put_byte(d,0); d+=cw_put_byte(d,0);
} }
@ -46,20 +56,20 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
d+=cw_put_encryption_capabilities_7(d,1); d+=cw_put_encryption_capabilities_7(d,1);
cw_dbg(DBG_X,"befor subelem ^p",params->cfg_list);
/* hardware version sub element */ /* hardware version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE); sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_HARDWARE_VERSION, key); CW_SUBELEM_WTP_HARDWARE_VERSION, key);
/* software version sub element */ /* software version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE); sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
d+=cw_write_descriptor_subelem (d, params->cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_SOFTWARE_VERSION, key); CW_SUBELEM_WTP_SOFTWARE_VERSION, key);
/* bootloader version sub element */ /* bootloader version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER); sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER);
d+=cw_write_descriptor_subelem (d, params->cfg, d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_BOOTLOADER_VERSION, key); CW_SUBELEM_WTP_BOOTLOADER_VERSION, key);
len = d-dst-4; len = d-dst-4;

View File

@ -1,6 +1,7 @@
#include "cw/capwap.h" #include "cw/capwap.h"
#include "cw/conn.h" #include "cw/conn.h"
#include "cw/dbg.h"
#include "wtp_interface.h" #include "wtp_interface.h"
@ -16,6 +17,7 @@ int changestate(struct conn * conn)
/*// mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);*/ /*// mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);*/
cw_dbg(DBG_X,"CHANGE STATE");
/* Change State ... */ /* Change State ... */
int rc = cw_send_request(conn,CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST); int rc = cw_send_request(conn,CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST);

View File

@ -1,377 +0,0 @@
ac-descriptor/active-wtps :Word: 2
ac-descriptor/dtls-policy :Byte: 0
ac-descriptor/hardware/vendor :Dword: 4232704
ac-descriptor/hardware/version :Bstr16: .x01000001
ac-descriptor/max-wtps :Word: 12
ac-descriptor/r-mac-field :Byte: 1
ac-descriptor/reserved1 :Byte: 0
ac-descriptor/security :Byte: 2
ac-descriptor/software/vendor :Dword: 4232704
ac-descriptor/software/version :Bstr16: .x07007400
ac-descriptor/station-limit :Word: 1000
ac-descriptor/stations :Word: 0
ac-name :Bstr16: Cisco_e2:60:a0
ac-name-with-index.0 :Bstr16: tabbe88
ac-name-with-index.1 :Bstr16: nudelnudel
ac-name-with-index.2 :Bstr16: nadelnalde
ac-name-with-priority/X1 :Byte: 3
ac-name-with-priority/ac2 :Byte: 5
capwap-control-ip-address/address.0 :IPAddress: 192.168.0.162
capwap-control-ip-address/address.1 :IPAddress: d96c:4c0a:da6c:4c0a:db6c:4c0a:dc6c:4c0a
capwap-control-ip-address/address.2 :IPAddress: 192.168.0.162
capwap-control-ip-address/wtps.0 :Word: 0
capwap-control-ip-address/wtps.1 :Word: 10
capwap-control-ip-address/wtps.2 :Word: 0
capwap-local-ip-address :IPAddress: 192.168.0.14
capwap-timers/echo-interval :Byte: 30
capwap-timers/max-discovery-interval :Byte: 10
capwap-timers/min-discovery-interval :Byte: 0
cisco-8011-assoc-limit/enable :Bool: false
cisco-8011-assoc-limit/interval :Word: 500
cisco-8011-assoc-limit/limit :Byte: 25
cisco/ac-ip-addr-with-index.0 :IPAddress: 1.1.1.1
cisco/ac-ip-addr-with-index.1 :IPAddress: 9.9.9.9
cisco/ac-ip-addr-with-index.2 :IPAddress: 3.3.3.3
cisco/ap-core-dump/compression :Bool: false
cisco/ap-core-dump/enable :Bool: false
cisco/ap-core-dump/filename :Str:
cisco/ap-core-dump/tftp-server :IPAddress: 0.0.0.0
cisco/ap-failover-priority :Byte: 1
cisco/ap-group-name :Bstr16: default-group
cisco/ap-led-state-config/led-state :Byte: 1
cisco/ap-led-state-config/save-flag :Byte: 1
cisco/ap-log-facility :Byte: 0
cisco/ap-mode-and-type/mode :Byte: 0
cisco/ap-mode-and-type/type :Byte: 0
cisco/ap-model/model :Str: AIR-LAP1131AG-E-K9
cisco/ap-power-injector-config/selection :Byte: 0
cisco/ap-power-injector-config/sitch-mac-address :Bstr16: .x000000000000
cisco/ap-power-injector-config/state :Byte: 17
cisco/ap-pre-std-switch-config :Byte: 0
cisco/ap-regulatory-domain.0/band-id :Byte: 0
cisco/ap-regulatory-domain.0/code0 :Byte: 0
cisco/ap-regulatory-domain.0/code1 :Byte: 1
cisco/ap-regulatory-domain.0/set :Bool: true
cisco/ap-regulatory-domain.0/slot :Byte: 0
cisco/ap-regulatory-domain.1/band-id :Byte: 0
cisco/ap-regulatory-domain.1/code0 :Byte: 0
cisco/ap-regulatory-domain.1/code1 :Byte: 1
cisco/ap-regulatory-domain.1/set :Bool: true
cisco/ap-regulatory-domain.1/slot :Byte: 0
cisco/ap-sub-mode :Byte: 0
cisco/ap-telnet-ssh/ssh :Bool: false
cisco/ap-telnet-ssh/telnet :Bool: false
cisco/ap-timesync/timestamp :Dword: 1469886778
cisco/ap-timesync/type :Byte: 0
cisco/ap-username-and-password/802.1x-credentials/option :Word: 2
cisco/ap-username-and-password/802.1x-credentials/password :Str:
cisco/ap-username-and-password/802.1x-credentials/username :Str:
cisco/ap-username-and-password/login-credentials/enable-password :Str: $1$nPEe$k81RL0xZkiYryiUh.yM2J1
cisco/ap-username-and-password/login-credentials/option :Word: 1025
cisco/ap-username-and-password/login-credentials/password :Str: $1$R1hh$.3Jgrg.1DHuxmiQVDNqxB.
cisco/ap-username-and-password/login-credentials/username :Str: admin
cisco/ap-venue-settings/group :Word: 2
cisco/ap-venue-settings/language :Str: en
cisco/ap-venue-settings/name :Str:
cisco/ap-venue-settings/type :Byte: 1
cisco/board-data-options :Dword: 16777217
cisco/cisco-discovery-protocol/data :Word: 0
cisco/cisco-discovery-protocol/enabled :Bool: false
cisco/elem132 :Bstr16: .x0100000000
cisco/hash/hash :Bstr16: c4084177cd95ddbba1237bfcb3de6780fdf48214
cisco/hash/validate :Bool: true
cisco/loghost-config/last-joined-ap :Str:
cisco/loghost-config/loghost.0 :IPAddress: 7.7.1.3
cisco/loghost-config/loghost.1 :IPAddress: 0.0.0.0
cisco/loghost-config/loghost.2 :IPAddress: 0.0.0.0
cisco/loghost-config/loghost.3 :IPAddress: 0.0.0.0
cisco/mcast-mgid-info :Bstr16: .x0000000d0000000000000000000000000000000101000000
cisco/mwar-addr/address :IPAddress: 192.168.0.162
cisco/mwar-addr/mwar-type :Byte: 0
cisco/mwar-addr/unknown :Word: 0
cisco/mwar-hash-value :Bstr16: c4084177cd95ddbba1237bfcb3de6780fdf48214
cisco/mwar-type :Byte: 1
cisco/rouge-and-mss/enable :Bool: false
cisco/rouge-and-mss/mss :Word: 666
cisco/rouge-and-mss/roge-detection :Bool: true
cisco/rouge-and-mss/tcp-adjust-mss :Word: 0
cisco/rouge-detection/rest :Bstr16: .x000aff800000
cisco/rouge-detection/rouge-detection :Bool: false
cisco/sig-toogle :Bool: true
cisco/spam-domain-secret :Bstr16: .xe1ffd18a8f15b3b59c0a47a7f17a96e7cb36174f00
cisco/ssl-certfile :Str: ../../ssl/certs/wtpc.crt
cisco/ssl-cipher :Str: RSA:AES-128-CBC:SHA1
cisco/ssl-keyfile :Str: ../../ssl/certs/wtpc.key
cisco/vlan/id :Word: 0
cisco/vlan/tagging :Bool: false
cisco/wtp-board-data/card-id :Word: 0
cisco/wtp-board-data/card-revision :Word: 0
cisco/wtp-board-data/ethernet-mac-address :Bstr16: .x0800276edf58
cisco/wtp-board-data/failover-priority :Bstr16: .x01010003
cisco/wtp-board-data/options/ant-type :Byte: 1
cisco/wtp-board-data/options/ap-type :Byte: 0
cisco/wtp-board-data/options/failover-priority :Byte: 1
cisco/wtp-board-data/options/flex-connect :Byte: 1
cisco/wtp-board-data/wtp-model-hi :Dword: 0
cisco/wtp-board-data/wtp-model-lo :Dword: 0
cisco/wtp-board-data/wtp-serial-number :Str: FCZ1406W232
cisco/wtp-use-ac-version :Bool: true
discovery-type :Byte: 0
idle-timeout :Dword: 300
location-data :Bstr16: Berlin
lwapp20 :Bstr16: .x000001
maximum-message-length :Word: 4096
radio.0/admin-state :Byte: reserved
radio.0/cisco-multi-domain-capability/first-channel :Word: 1
radio.0/cisco-multi-domain-capability/max-tx-power-level :Word: 65535
radio.0/cisco-multi-domain-capability/number-of-channels :Word: 13
radio.0/cisco-multi-domain-capability/reserved :Byte: 1
radio.0/cisco/air-space-capability :Byte: 0
radio.0/cisco/antenna-payload/802-11n-rx-antennas :Byte: 7
radio.0/cisco/antenna-payload/802-11n-tx-antennas :Byte: 0
radio.0/cisco/antenna-payload/antenna-1 :Byte: 1
radio.0/cisco/antenna-payload/antenna-2 :Byte: 1
radio.0/cisco/antenna-payload/antenna-mode :Byte: 3
radio.0/cisco/antenna-payload/diversity-selection :Byte: 255
radio.0/cisco/antenna-payload/number-of-antennas :Byte: 2
radio.0/cisco/antenna-payload/unknown :Byte: 3
radio.0/cisco/channel-power :Bstr16: .x08080d0108221c16100a04fefe0208221c16100a04fefe0308221c16100a04fefe0408221c16100a04fefe0508221c16100a04fefe0608221c16100a04fefe0708221c16100a04fefe0808221c16100a04fefe0908221c16100a04fefe0a08221c16100a04fefe0b08221c16100a04fefe0c08221c16100a04fefe0d08221c16100a04fefe
radio.0/cisco/direct-sequence-control/cfg-type :Byte: 1
radio.0/cisco/direct-sequence-control/current-cca-mode :Byte: 0
radio.0/cisco/direct-sequence-control/current-channel :Byte: 1
radio.0/cisco/direct-sequence-control/energy-detect-threshold :Dword: -50
radio.0/cisco/direct-sequence-control/unknown :Byte: 1
radio.0/cisco/elem19 :Bstr16: .xc0a800a10001000bc0a800a103000101001ecd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000001060b010101
radio.0/cisco/elem22 :Bstr16: .x0d00b400320102030405060708090a0b0c0d
radio.0/cisco/elem24 :Bstr16: .x003c000c
radio.0/cisco/elem81 :Bstr16: .x00000000010101010a001e0a02051cbfffbfff0a00
radio.0/cisco/lwelem9 :Bstr16: .x0100000000000000000000000000000000
radio.0/cisco/mac-operation/byte75 :Byte: 0
radio.0/cisco/mac-operation/fragmentation-threshold :Word: 2346
radio.0/cisco/mac-operation/long-retry :Byte: 4
radio.0/cisco/mac-operation/reserved :Byte: 0
radio.0/cisco/mac-operation/rts-threshold :Word: 2347
radio.0/cisco/mac-operation/rx-msdu-lifetime :Dword: 512
radio.0/cisco/mac-operation/short-retry :Byte: 7
radio.0/cisco/mac-operation/tx-msdu-lifetime :Dword: 512
radio.0/cisco/multi-domain-capability/first-channel :Word: 1
radio.0/cisco/multi-domain-capability/max-tx-power-level :Word: 20
radio.0/cisco/multi-domain-capability/number-of-channels :Word: 13
radio.0/cisco/multi-domain-capability/reserved :Byte: 1
radio.0/cisco/rad-extended-config/beacon-interval :Word: 25600
radio.0/cisco/rad-extended-config/beacon-range :Word: 0
radio.0/cisco/rad-extended-config/c-ccat :Word: 0
radio.0/cisco/rad-extended-config/multicast-buffer :Word: 0
radio.0/cisco/rad-extended-config/multicast-data-range :Word: 0
radio.0/cisco/rad-extended-config/rx-sensop-threshold :Word: 0
radio.0/cisco/tx-power-levels :Bstr16: .x070011000e000b000800050002ffff0000
radio.0/cisco/tx-power/current-tx-power :Word: 1
radio.0/cisco/tx-power/reserved :Byte: 1
radio.0/cisco/wtp-radio-config/beacon-period :Word: 100
radio.0/cisco/wtp-radio-config/bss-id :Bstr16: .x0800276edf58
radio.0/cisco/wtp-radio-config/cfg-period :Byte: 4
radio.0/cisco/wtp-radio-config/cfg-type :Byte: 1
radio.0/cisco/wtp-radio-config/cfp-maximum-duration :Word: 60
radio.0/cisco/wtp-radio-config/country-str1 :Str: DE
radio.0/cisco/wtp-radio-config/country-str2 :Str: DE
radio.0/cisco/wtp-radio-config/gpr-period :Byte: 10
radio.0/cisco/wtp-radio-config/max-stations :Byte: 200
radio.0/cisco/wtp-radio-config/occupancy-limit :Word: 100
radio.0/cisco/wtp-radio-config/reg :Dword: 167772416
radio.0/cisco/wtp-radio-config/unknown75 :Byte: 0
radio.0/decryption-error-report-period :Word: 120
radio.0/operational-state/cause :Byte: Normal
radio.0/operational-state/state :Byte: enabled
radio.0/rate_set :Bstr16: .x82848b960c1218243048606c
radio.0/wlan.0/add-lw-wlan/misc :Bstr16: .x3e9904fac0000100
radio.0/wlan.0/add-lw-wlan/misc2 :Word: 4
radio.0/wlan.0/add-lw-wlan/ssid :Str: TubeSSID
radio.0/wlan.0/add-wlan/broadcast-ssid :Bool: true
radio.0/wlan.0/add-wlan/dtim-period :Byte: 1
radio.0/wlan.0/add-wlan/encryption-policy :Dword: 4
radio.0/wlan.0/add-wlan/profile-name :Str: tubeC
radio.0/wlan.0/add-wlan/qos :Byte: 0
radio.0/wlan.0/add-wlan/radio-id :Byte: 0
radio.0/wlan.0/add-wlan/scan-defer-time :Word: 100
radio.0/wlan.0/add-wlan/session-timout :Word: 1800
radio.0/wlan.0/add-wlan/ssid :Str:
radio.0/wlan.0/add-wlan/wep-encryption :Bool: false
radio.0/wlan.0/add-wlan/wep-key :Bstr16: .x25c544f95684f1f8687a411ca5
radio.0/wlan.0/add-wlan/wep-key-index :Byte: 1
radio.0/wlan.0/add-wlan/wlan-capability :Word: 1073
radio.0/wlan.0/add-wlan/wlan-id :Byte: 1
radio.0/wlan.0/allow-aaa-override :Byte: 0
radio.0/wlan.0/broadcast-ssid :Bool: true
radio.0/wlan.0/dtim-period :Byte: 1
radio.0/wlan.0/encryption :Byte: 0
radio.0/wlan.0/encryption-policy :Dword: 16777216
radio.0/wlan.0/max-stations :Byte: 200
radio.0/wlan.0/radio-id :Byte: 0
radio.0/wlan.0/session-timout :Word: 1800
radio.0/wlan.0/ssid-a :Str: Schlosspark
radio.0/wlan.0/wep-key :Bstr16: .xaa0c0a02000000000000000000
radio.0/wlan.0/wlan-capability :Word: 1057
radio.0/wlan.0/wlan-id :Byte: 0
radio.0/wlan.1/add-wlan/aironet-ie :Bool: true
radio.0/wlan.1/add-wlan/broadcast-ssid :Bool: true
radio.0/wlan.1/add-wlan/dtim-period :Byte: 1
radio.0/wlan.1/add-wlan/encryption-policy :Dword: 4
radio.0/wlan.1/add-wlan/hreap-local-switch :Byte: 0
radio.0/wlan.1/add-wlan/profile-name :Str: tubeC
radio.0/wlan.1/add-wlan/qos :Byte: 0
radio.0/wlan.1/add-wlan/radio-id :Byte: 0
radio.0/wlan.1/add-wlan/scan-defer-period :Word: 28784
radio.0/wlan.1/add-wlan/scan-defer-time :Word: 100
radio.0/wlan.1/add-wlan/session-timout :Word: 1800
radio.0/wlan.1/add-wlan/ssid :Str: tubeC
radio.0/wlan.1/add-wlan/wep-encryption :Bool: false
radio.0/wlan.1/add-wlan/wep-key :Bstr16: .xc3616fee42fcf74fa02bff3d87
radio.0/wlan.1/add-wlan/wep-key-index :Byte: 1
radio.0/wlan.1/add-wlan/wlan-capability :Word: 1073
radio.0/wlan.1/add-wlan/wlan-id :Byte: 1
radio.0/wlan.13/add-wlan/aironet-ie :Bool: true
radio.0/wlan.13/add-wlan/broadcast-ssid :Bool: true
radio.0/wlan.13/add-wlan/dtim-period :Byte: 19
radio.0/wlan.13/add-wlan/encryption-policy :Dword: 1
radio.0/wlan.13/add-wlan/hreap-local-switch :Byte: 16
radio.0/wlan.13/add-wlan/profile-name :Str: SuerWLAN
radio.0/wlan.13/add-wlan/qos :Byte: 0
radio.0/wlan.13/add-wlan/radio-id :Byte: 0
radio.0/wlan.13/add-wlan/scan-defer-period :Word: 15420
radio.0/wlan.13/add-wlan/scan-defer-time :Word: 100
radio.0/wlan.13/add-wlan/session-timout :Word: 1800
radio.0/wlan.13/add-wlan/ssid :Str: SuperSSID
radio.0/wlan.13/add-wlan/wep-encryption :Bool: false
radio.0/wlan.13/add-wlan/wep-key :Bstr16: .x00000000000000000000000000
radio.0/wlan.13/add-wlan/wep-key-index :Byte: 1
radio.0/wlan.13/add-wlan/wlan-capability :Word: 1057
radio.0/wlan.13/add-wlan/wlan-id :Byte: 13
radio.0/wtp-radio-information :Dword: 1
radio.1/admin-state :Byte: reserved
radio.1/cisco-multi-domain-capability/first-channel :Word: 36
radio.1/cisco-multi-domain-capability/max-tx-power-level :Word: 65535
radio.1/cisco-multi-domain-capability/number-of-channels :Word: 16
radio.1/cisco-multi-domain-capability/reserved :Byte: 1
radio.1/cisco/air-space-capability :Byte: 0
radio.1/cisco/antenna-payload/802-11n-rx-antennas :Byte: 7
radio.1/cisco/antenna-payload/802-11n-tx-antennas :Byte: 0
radio.1/cisco/antenna-payload/antenna-1 :Byte: 1
radio.1/cisco/antenna-payload/antenna-2 :Byte: 1
radio.1/cisco/antenna-payload/antenna-mode :Byte: 3
radio.1/cisco/antenna-payload/diversity-selection :Byte: 255
radio.1/cisco/antenna-payload/number-of-antennas :Byte: 2
radio.1/cisco/antenna-payload/unknown :Byte: 3
radio.1/cisco/channel-power :Bstr16: .x0808102408221c16100a04fefe2808221c16100a04fefe2c08221c16100a04fefe3008221c16100a04fefe3408221c16100a04fefe3808221c16100a04fefe3c08221c16100a04fefe4008221c16100a04fefe6408221c16100a04fefe6808221c16100a04fefe6c08221c16100a04fefe7008221c16100a04fefe7408221c16100a04fefe8408221c16100a04fefe8808221c16100a04fefe8c08221c16100a04fefe
radio.1/cisco/elem15 :Bstr16: .x027007ffffffce010001
radio.1/cisco/elem19 :Bstr16: .xc0a800a10001000ac0a800a110000101001ecd774fc43bd27db633509934957d3acb000000000000000052464d000000000000000000000000000000000000000000000000000000000024282c3034383c4064686c707484888c01010101010101010101010101010101
radio.1/cisco/elem22 :Bstr16: .x1000b4003224282c3034383c4064686c707484888c
radio.1/cisco/elem24 :Bstr16: .x003c000c
radio.1/cisco/elem47 :Bstr16: .x01ccb0000c000f42401999ba1040000003
radio.1/cisco/elem81 :Bstr16: .x00000000010101010a001e0a02050fbfffbfff0a00
radio.1/cisco/lwelem9 :Bstr16: .x0100000000000000000000000000000000
radio.1/cisco/mac-operation/byte75 :Byte: 0
radio.1/cisco/mac-operation/fragmentation-threshold :Word: 2346
radio.1/cisco/mac-operation/long-retry :Byte: 4
radio.1/cisco/mac-operation/reserved :Byte: 1
radio.1/cisco/mac-operation/rts-threshold :Word: 2347
radio.1/cisco/mac-operation/rx-msdu-lifetime :Dword: 512
radio.1/cisco/mac-operation/short-retry :Byte: 7
radio.1/cisco/mac-operation/tx-msdu-lifetime :Dword: 512
radio.1/cisco/multi-domain-capability/first-channel :Word: 36
radio.1/cisco/multi-domain-capability/max-tx-power-level :Word: 20
radio.1/cisco/multi-domain-capability/number-of-channels :Word: 4
radio.1/cisco/multi-domain-capability/reserved :Byte: 1
radio.1/cisco/tx-power-levels :Bstr16: .x070011000e000b000800050002ffff0000
radio.1/cisco/tx-power/current-tx-power :Word: 1
radio.1/cisco/tx-power/reserved :Byte: 1
radio.1/cisco/wtp-radio-config/beacon-period :Word: 100
radio.1/cisco/wtp-radio-config/bss-id :Bstr16: .x04fe7f499b90
radio.1/cisco/wtp-radio-config/cfg-period :Byte: 4
radio.1/cisco/wtp-radio-config/cfg-type :Byte: 1
radio.1/cisco/wtp-radio-config/cfp-maximum-duration :Word: 60
radio.1/cisco/wtp-radio-config/country-str1 :Str: DE
radio.1/cisco/wtp-radio-config/country-str2 :Str: DE
radio.1/cisco/wtp-radio-config/gpr-period :Byte: 10
radio.1/cisco/wtp-radio-config/max-stations :Byte: 200
radio.1/cisco/wtp-radio-config/occupancy-limit :Word: 100
radio.1/cisco/wtp-radio-config/reg :Dword: 167772416
radio.1/cisco/wtp-radio-config/unknown75 :Byte: 1
radio.1/decryption-error-report-period :Word: 120
radio.1/operational-state/cause :Byte: Normal
radio.1/operational-state/state :Byte: enabled
radio.1/rate_set :Bstr16: .x8c129824b048606c
radio.1/wlan.1/add-wlan/aironet-ie :Bool: true
radio.1/wlan.1/add-wlan/broadcast-ssid :Bool: true
radio.1/wlan.1/add-wlan/dtim-period :Byte: 1
radio.1/wlan.1/add-wlan/encryption-policy :Dword: 4
radio.1/wlan.1/add-wlan/hreap-local-switch :Byte: 0
radio.1/wlan.1/add-wlan/profile-name :Str: tubeC
radio.1/wlan.1/add-wlan/qos :Byte: 0
radio.1/wlan.1/add-wlan/radio-id :Byte: 1
radio.1/wlan.1/add-wlan/scan-defer-period :Word: 28784
radio.1/wlan.1/add-wlan/scan-defer-time :Word: 100
radio.1/wlan.1/add-wlan/session-timout :Word: 1800
radio.1/wlan.1/add-wlan/ssid :Str: tubeC
radio.1/wlan.1/add-wlan/wep-encryption :Bool: false
radio.1/wlan.1/add-wlan/wep-key :Bstr16: .xcac80297ec10e7a8da2c9b1f03
radio.1/wlan.1/add-wlan/wep-key-index :Byte: 1
radio.1/wlan.1/add-wlan/wlan-capability :Word: 17
radio.1/wlan.1/add-wlan/wlan-id :Byte: 1
radio.1/wlan.13/add-wlan/aironet-ie :Bool: true
radio.1/wlan.13/add-wlan/broadcast-ssid :Bool: true
radio.1/wlan.13/add-wlan/dtim-period :Byte: 19
radio.1/wlan.13/add-wlan/encryption-policy :Dword: 1
radio.1/wlan.13/add-wlan/hreap-local-switch :Byte: 16
radio.1/wlan.13/add-wlan/profile-name :Str: SuerWLAN
radio.1/wlan.13/add-wlan/qos :Byte: 0
radio.1/wlan.13/add-wlan/radio-id :Byte: 1
radio.1/wlan.13/add-wlan/scan-defer-period :Word: 15420
radio.1/wlan.13/add-wlan/scan-defer-time :Word: 100
radio.1/wlan.13/add-wlan/session-timout :Word: 1800
radio.1/wlan.13/add-wlan/ssid :Str: SuperSSID
radio.1/wlan.13/add-wlan/wep-encryption :Bool: false
radio.1/wlan.13/add-wlan/wep-key :Bstr16: .x00000000000000000000000000
radio.1/wlan.13/add-wlan/wep-key-index :Byte: 1
radio.1/wlan.13/add-wlan/wlan-capability :Word: 1
radio.1/wlan.13/add-wlan/wlan-id :Byte: 13
radio.1/wtp-radio-information :Dword: 2
radio.255/admin-state :Byte: reserved
radio.255/operational-state/cause :Byte: Normal
radio.255/operational-state/state :Byte: enabled
radio/wlan/encryption-policy :Dword: 16777216
radio/wlan/radio-od :Byte: 1
radio/wlan/wlan-capability :Word: 17
radio/wlan/wlan-id :Byte: 0
result-code :Dword: 0
session-id :Bstr16: .x00006215
statistics-timer :Word: 60
tube.0/main :Byte: 12
tube.0/zumsel :Byte: 12
tube.1/main :Byte: 12
tube.1/zumsel :Byte: 12
wtp-board-data/board-id :Bstr16: .x0000
wtp-board-data/mac-address :Bstr16: .x0800276edf58
wtp-board-data/model-no :Bstr16: AIR-LAP1131AG-E-K9
wtp-board-data/revision :Bstr16: B0
wtp-board-data/serial-no :Bstr16: FCZ1441Q0XZ
wtp-board-data/vendor :Dword: 4232704
wtp-descriptor/bootloader/vendor :Dword: 4232704
wtp-descriptor/bootloader/version :Bstr16: .x0c030800
wtp-descriptor/hardware/vendor :Dword: 4232704
wtp-descriptor/hardware/version :Bstr16: .x01000000
wtp-descriptor/max-radios :Byte: 2
wtp-descriptor/radios-in-use :Byte: 2
wtp-descriptor/software/vendor :Dword: 4232704
wtp-descriptor/software/version :Bstr16: .x07007400
wtp-fallback :Byte: 1
wtp-frame-tunnel-mode :Byte: 4
wtp-mac-type :Byte: 1
wtp-name :Bstr16: Supertube
wtp-reboot-statistics/ac-initiated-count :Word: 2
wtp-reboot-statistics/hw-failure-count :Word: 0
wtp-reboot-statistics/last-failure-type :Byte: 0
wtp-reboot-statistics/link-failure-count :Word: 522
wtp-reboot-statistics/other-failure-count :Word: 13
wtp-reboot-statistics/reboot-count :Word: 0
wtp-reboot-statistics/sw-failure-count :Word: 0
wtp-reboot-statistics/unknown-failure-count :Word: 0

View File

@ -10,11 +10,23 @@
#include "cfg.h" #include "cfg.h"
static int config_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
{
struct cw_DiscoveryResults *results = (struct cw_DiscoveryResults *)params->conn->data;
cw_dbg(DBG_X,"Configurations status response received");
cw_cfg_dump(params->cfg);
return 0;
}
int configure(struct cw_Conn * conn) int configure(struct cw_Conn * conn)
{ {
char sockbuff[SOCK_ADDR_BUFSIZE]; char sockbuff[SOCK_ADDR_BUFSIZE];
cw_dbg_ktv_dump(conn->local_cfg,DBG_INFO,"KTV DUMP ----------------","LOCAL:", "DUMP done -------"); // cw_dbg_ktv_dump(conn->local_cfg,DBG_INFO,"KTV DUMP ----------------","LOCAL:", "DUMP done -------");
cw_conn_set_msg_cb(conn,CAPWAP_MSG_CONFIGURATION_STATUS_RESPONSE,config_cb);
int rc; int rc;
rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST); rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST);
@ -35,7 +47,7 @@ int configure(struct cw_Conn * conn)
return 0; return 0;
} }
cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"Config ***","CFG: ", "End config ***"); // cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"Config ***","CFG: ", "End config ***");
// cw_ktv_set_byte(conn->remote_cfg," // cw_ktv_set_byte(conn->remote_cfg,"
/*exit(0);*/ /*exit(0);*/

View File

@ -29,7 +29,6 @@ static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_pt
// cw_cfg_copy(params->cfg,cfg); // cw_cfg_copy(params->cfg,cfg);
cw_discovery_results_add(results,params->cfg,params->conn->global_cfg); cw_discovery_results_add(results,params->cfg,params->conn->global_cfg);
printf("Have Discovery %d\n",results->nr);
// cw_cfg_dump(params->cfg); // cw_cfg_dump(params->cfg);
// mlist_append_ptr(dis->results, cfg); // mlist_append_ptr(dis->results, cfg);
@ -46,9 +45,9 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
results = cw_discovery_results_create(); results = cw_discovery_results_create();
min = cw_cfg_get_byte(conn->local_cfg,"capwap-timers/min-discovery-interval", min = cw_cfg_get_byte(conn->global_cfg,"capwap-timers/min-discovery-interval",
CAPWAP_MIN_DISCOVERY_INTERVAL); CAPWAP_MIN_DISCOVERY_INTERVAL);
max = cw_cfg_get_byte(conn->local_cfg,"capwap-timers/max-discovery-interval", max = cw_cfg_get_byte(conn->global_cfg,"capwap-timers/max-discovery-interval",
CAPWAP_MAX_DISCOVERY_INTERVAL); CAPWAP_MAX_DISCOVERY_INTERVAL);
delay = cw_randint(min,max); delay = cw_randint(min,max);
@ -60,15 +59,12 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
conn->capwap_state = CAPWAP_STATE_DISCOVERY; conn->capwap_state = CAPWAP_STATE_DISCOVERY;
conn->remote_cfg=cw_cfg_create();
/* create and send a discovery request message */ /* create and send a discovery request message */
cw_init_request(conn, CAPWAP_MSG_DISCOVERY_REQUEST); cw_init_request(conn, CAPWAP_MSG_DISCOVERY_REQUEST);
cw_assemble_message(conn, conn->req_buffer); cw_compose_message(conn, conn->req_buffer);
conn_send_msg(conn, conn->req_buffer); conn_send_msg(conn, conn->req_buffer);
cw_cfg_destroy(conn->remote_cfg);
conn->remote_cfg=NULL;
@ -85,7 +81,6 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
while (!cw_timer_timeout(timer) while (!cw_timer_timeout(timer)
&& conn->capwap_state == CAPWAP_STATE_DISCOVERY) { && conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
int rc; int rc;
cw_dbg(DBG_X,"READ NOW");
// conn->remote_cfg = cw_ktv_create(); // conn->remote_cfg = cw_ktv_create();
// if (conn->remote_cfg == NULL) { // if (conn->remote_cfg == NULL) {
// cw_log_errno("Can't allocate memory for remote_cfg"); // cw_log_errno("Can't allocate memory for remote_cfg");

View File

@ -154,10 +154,10 @@ static int run_join_d(struct cw_Conn * conn, struct sockaddr *sa,cw_Cfg_t * cfg)
cw_dbg(DBG_DTLS, "DTLS Connection successful established with %s", cw_dbg(DBG_DTLS, "DTLS Connection successful established with %s",
sock_addr2str(sa,addrstr)); sock_addr2str(sa,addrstr));
conn->remote_cfg=cfg; // conn->remote_cfg=cfg;
run_join(conn); rc = run_join(conn);
conn->remote_cfg=NULL; // conn->remote_cfg=NULL;
return 1; return rc;
} }
@ -214,53 +214,16 @@ int join(struct cw_Conn * conn, struct cw_DiscoveryResults * results)
sock_strtoaddr(e->ip,(struct sockaddr*)(&sockaddr)); sock_strtoaddr(e->ip,(struct sockaddr*)(&sockaddr));
sock_setport((struct sockaddr*)&sockaddr,5246); sock_setport((struct sockaddr*)&sockaddr,5246);
cw_cfg_clear(conn->remote_cfg);
cw_cfg_copy(e->cfg,conn->remote_cfg);
rc = run_join_d(conn,(struct sockaddr*)(&sockaddr),e->cfg); rc = run_join_d(conn,(struct sockaddr*)(&sockaddr),e->cfg);
if (rc) if (rc)
return 1; return 1;
} }
stop();
/*
mavliter_t ii;
mavliter_init(&ii,dis->prio_ip);
mavliter_foreach(&ii){
int rc;
cw_Val_t * val,*ac;
mavl_t rcfg;
char * rk;
char ipstr[100];
char ac_name[CAPWAP_MAX_AC_NAME_LEN];
struct sockaddr_storage sockaddr;
val = mavliter_get(&ii);
rk = val->key;
val = val->val.ptr;
val->type->to_str(val, ipstr, 100);
rcfg = cw_ktv_get_sysptr(dis->prio_ac,rk,NULL);
ac=cw_ktv_get(rcfg,"ac-name",CW_TYPE_BSTR16);
if (ac != NULL){
ac->type->to_str(ac,ac_name,sizeof(ac_name));
}
else{
strcpy(ac_name,"");
}
cw_dbg(DBG_INFO, "Going to join CAPWAP controller '%s' at %s.",ac_name,ipstr);
conn->remote_cfg=rcfg;
sock_strtoaddr(ipstr,(struct sockaddr*)(&sockaddr));
sock_setport((struct sockaddr*)&sockaddr,5246);
rc = run_join_d(conn,(struct sockaddr*)(&sockaddr));
if (rc)
return 1;
}*/
return 0; return 0;
} }

View File

@ -3,6 +3,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include "cw/cw.h"
#include "cw/capwap.h" #include "cw/capwap.h"
#include "cw/conn.h" #include "cw/conn.h"
#include "cw/radioinfo.h" #include "cw/radioinfo.h"
@ -149,7 +150,7 @@ int run(struct cw_Conn * conn)
do { do {
int echo_interval = cw_ktv_get_byte(conn->local_cfg,"capwap-timers/echo-interval",CAPWAP_ECHO_INTERVAL); int echo_interval = cw_cfg_get_byte(conn->global_cfg,"capwap-timers/echo-interval",CAPWAP_ECHO_INTERVAL);
/*mbag_get_word(conn->config,CW_ITEM_CAPWAP_TIMERS,CW_TIMERS)&0xff;*/ /*mbag_get_word(conn->config,CW_ITEM_CAPWAP_TIMERS,CW_TIMERS)&0xff;*/
@ -173,12 +174,12 @@ printf("---------------------- cwrsult is not ok\n");
} }
printf("lalalala\n"); printf("lalalala\n");
cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"KTV DUMP ----------------","Remote:", "DUMP done -------"); //cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"KTV DUMP ----------------","Remote:", "DUMP done -------");
printf("Saving Config\n"); // printf("Saving Config\n");
mavl_merge(conn->local_cfg,conn->remote_cfg); // mavl_merge(conn->local_cfg,conn->remote_cfg);
cw_ktv_save(conn->local_cfg,"cisco.ktv"); // cw_ktv_save(conn->local_cfg,"cisco.ktv");
clean_cfg(conn->remote_cfg); // clean_cfg(conn->remote_cfg);
cw_dbg(DBG_X,"We hav a message processed"); cw_dbg(DBG_X,"We hav a message processed");
update=1; update=1;

View File

@ -145,7 +145,6 @@ int main (int argc, char **argv)
conn->dtls_mtu = 1200; conn->dtls_mtu = 1200;
conn->msgset=msgset; conn->msgset=msgset;
conn->global_cfg = global_cfg; conn->global_cfg = global_cfg;
conn->local_cfg = cw_cfg_create();
//conn->remote_cfg = cw_cfg_create(); //conn->remote_cfg = cw_cfg_create();
conn->role = CW_ROLE_WTP; conn->role = CW_ROLE_WTP;
@ -183,28 +182,27 @@ int main (int argc, char **argv)
results = cw_run_discovery(conn, "255.255.255.255","192.168.0.14"); results = cw_run_discovery(conn, "255.255.255.255","192.168.0.14");
// mavl_del_all(conn->remote_cfg); // mavl_del_all(conn->remote_cfg);
join(conn,results); if (!join(conn,results)){
cw_discovery_results_destroy(results);
cw_discovery_results_destroy(results); goto errX;
rc = 0; }
printf("Goto errx 0");
goto errX;
configure(conn);
cw_discovery_results_destroy(results);
// clean_cfg(conn->remote_cfg); // clean_cfg(conn->remote_cfg);
// mavl_merge(conn->local_cfg,conn->remote_cfg); // mavl_merge(conn->local_cfg,conn->remote_cfg);
mavl_del_all(conn->remote_cfg);
printf("JOIN CONF\n");
configure(conn);
clean_cfg(conn->remote_cfg);
mavl_merge(conn->local_cfg,conn->remote_cfg);
changestate(conn); changestate(conn);
run(conn); run(conn);
rc = 0;
printf("Goto errx 0\n");
goto errX;
// cw_discovery_free_results(&dis); // cw_discovery_free_results(&dis);