More work on typeless
This commit is contained in:
parent
add6ffa314
commit
370942ef7e
@ -19,6 +19,7 @@ enum {
|
||||
AC_PROTO_UNKNOWN
|
||||
};
|
||||
|
||||
void start_shell();
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -175,19 +175,27 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
int rc = 0;
|
||||
struct bootcfg bootcfg;
|
||||
FILE * file;
|
||||
mavl_t types_tree;
|
||||
const cw_Type_t **ti;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
cw_Cfg_t * tcfg = cw_cfg_create();
|
||||
cw_cfg_set(tcfg,"tube.0","hallo");
|
||||
cw_cfg_set(tcfg,"tube.1","welt");
|
||||
cw_cfg_set(tcfg,"tube.2","der guten laune");
|
||||
cw_cfg_dump(tcfg);
|
||||
|
||||
printf("Next Index: %d\n",cw_cfg_get_next_index(tcfg,"kinder"));
|
||||
|
||||
|
||||
exit(0);
|
||||
*/
|
||||
|
||||
|
||||
/* parse arguments */
|
||||
parse_args (argc, argv, &bootcfg);
|
||||
|
||||
|
||||
cw_statemachine_run(NULL);
|
||||
exit(0);
|
||||
|
||||
|
||||
global_cfg=cw_cfg_create();
|
||||
if (!global_cfg){
|
||||
@ -250,12 +258,6 @@ void process_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, in
|
||||
void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len);
|
||||
|
||||
|
||||
static void pcb(char *dst, struct mavlnode *node)
|
||||
{
|
||||
struct cw_Cfg_entry *e = mavlnode_dataptr(node);
|
||||
sprintf(dst, "%s", e->key);
|
||||
}
|
||||
|
||||
|
||||
int ac_run(cw_Cfg_t * cfg)
|
||||
{
|
||||
@ -441,7 +443,7 @@ void process_cw_data_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
|
||||
dataman_list_unlock();
|
||||
|
||||
dataman_add_packet (dm, buffer, len);
|
||||
//dataman_add_packet (dm, buffer, len);
|
||||
|
||||
return;
|
||||
|
||||
@ -505,7 +507,7 @@ void process_cw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
wtpman_start (wtpman, preamble & 0xf);
|
||||
}
|
||||
|
||||
printf("Got Packet with len: %d\n",len);
|
||||
//printf("Got Packet with len: %d\n",len);
|
||||
|
||||
wtpman_addpacket (wtpman, buffer, len);
|
||||
wtplist_unlock();
|
||||
|
@ -37,3 +37,20 @@ actube/mod.0: cisco
|
||||
actube/mod.1: capwap
|
||||
actube/mod.2: capwap80211
|
||||
|
||||
|
||||
ac-descriptor/dtls-policy: 1
|
||||
ac-descriptor/hardware/vendor: 4232704
|
||||
ac-descriptor/hardware/version: .x01000001
|
||||
ac-descriptor/max-wtps : 200
|
||||
ac-descriptor/active-wtps: 2
|
||||
ac-descriptor/r-mac-field: 1
|
||||
ac-descriptor/reserved1 : 0
|
||||
ac-descriptor/security : 2
|
||||
ac-descriptor/software/vendor : 0
|
||||
ac-descriptor/software/version: v0.0.1
|
||||
ac-descriptor/station-limit: 1000
|
||||
ac-descriptor/stations: 0
|
||||
|
||||
|
||||
capwap-control-ip-address/address.0: 192.168.0.14
|
||||
|
||||
|
@ -45,34 +45,6 @@
|
||||
|
||||
#include "actube.h"
|
||||
|
||||
static void reset_echointerval_timer(struct wtpman *wtpman)
|
||||
{
|
||||
/* char sock_buf[SOCK_ADDR_BUFSIZE];*/
|
||||
/* uint16_t ct = mbag_get_word(wtpman->conn->local, CW_ITEM_CAPWAP_TIMERS,
|
||||
CW_MAX_DISCOVERY_INTERVAL << 8 |
|
||||
CAPWAP_ECHO_INTERVAL);
|
||||
*/
|
||||
/* start echinterval timer and put 2 seconds for "safety" on it */
|
||||
|
||||
/*
|
||||
// wtpman->echointerval_timer = cw_timer_start(2+ (ct & 0xff));
|
||||
// db_ping_wtp(sock_addr2str_p(&wtpman->conn->addr,sock_buf), conf_acname);
|
||||
// cw_dbg(DBG_X, "Starting capwap timer: %d", wtpman->echointerval_timer);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
static int msg_start_handler(struct cw_Conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len, struct sockaddr *from)
|
||||
{
|
||||
struct wtpman *wtpman = conn->data;
|
||||
reset_echointerval_timer(wtpman);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
static void wtpman_remove(struct wtpman *wtpman)
|
||||
{
|
||||
@ -86,9 +58,6 @@ static void wtpman_remove(struct wtpman *wtpman)
|
||||
|
||||
static void wtpman_run_discovery(void *arg)
|
||||
{
|
||||
cw_dbg(DBG_STATE,"Run discovery");
|
||||
exit(0);
|
||||
|
||||
|
||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
||||
|
||||
@ -100,6 +69,7 @@ static void wtpman_run_discovery(void *arg)
|
||||
&& wtpman->conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
|
||||
int rc;
|
||||
rc = cw_read_messages(wtpman->conn);
|
||||
|
||||
if (cw_result_is_ok(rc)) {
|
||||
wtpman->conn->capwap_state = CAPWAP_STATE_JOIN;
|
||||
|
||||
@ -141,7 +111,7 @@ static int wtpman_dtls_setup(void *arg)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
static int wtpman_join(void *arg)
|
||||
{
|
||||
int rc;
|
||||
@ -192,6 +162,9 @@ static int wtpman_join(void *arg)
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
static void wtpman_image_data(struct wtpman *wtpman)
|
||||
{
|
||||
@ -312,7 +285,7 @@ int cw_run_state_machine(struct cw_Conn *conn, time_t * timer)
|
||||
|
||||
if (result->timer_key) {
|
||||
timerval =
|
||||
cw_ktv_get_word(conn->local_cfg, result->timer_key,
|
||||
cw_cfg_get_word(conn->local_cfg, result->timer_key,
|
||||
result->timer_default);
|
||||
*timer = cw_timer_start(timerval);
|
||||
cw_dbg(DBG_STATE, "Starting timer: [%s] - %d seconds.",
|
||||
@ -338,7 +311,7 @@ static void *wtpman_main(void *arg)
|
||||
wtpman->conn->seqnum = 0;
|
||||
conn = wtpman->conn;
|
||||
|
||||
wtpman->conn->remote_cfg = cw_ktv_create();
|
||||
wtpman->conn->remote_cfg = cw_cfg_create();
|
||||
|
||||
|
||||
if (!wtpman->dtlsmode) {
|
||||
@ -647,6 +620,41 @@ void wtpman_destroy(struct wtpman *wtpman)
|
||||
free(wtpman);
|
||||
}
|
||||
|
||||
static void discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
{
|
||||
struct wtpman * wtpman = (struct wtpman *)params->conn->data;
|
||||
cw_dbg(DBG_X,"Discovery->Callback");
|
||||
wtpman->pdiscovery(params,elems_ptr,elems_len);
|
||||
}
|
||||
|
||||
static void join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
{
|
||||
struct wtpman * wtpman = (struct wtpman *)params->conn->data;
|
||||
cw_dbg(DBG_X,"JOIN->Callback");
|
||||
wtpman->pjoin(params,elems_ptr,elems_len);
|
||||
}
|
||||
|
||||
static void update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
{
|
||||
struct wtpman * wtpman = (struct wtpman *)params->conn->data;
|
||||
cw_dbg(DBG_X,"UPDATE->Callback");
|
||||
if ( wtpman->pupdate )
|
||||
wtpman->pupdate(params,elems_ptr,elems_len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static setup_complete(struct cw_Conn *conn)
|
||||
{
|
||||
struct wtpman * wtpman = (struct wtpman *)conn->data;
|
||||
wtpman->pdiscovery = cw_msgset_set_postprocess(conn->msgset,CAPWAP_MSG_DISCOVERY_REQUEST,discovery_cb);
|
||||
wtpman->pjoin = cw_msgset_set_postprocess(conn->msgset,CAPWAP_MSG_JOIN_REQUEST,join_cb);
|
||||
wtpman->pupdate = cw_msgset_set_postprocess(conn->msgset,CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,update_cb);
|
||||
cw_dbg(DBG_X,"SETUP COMPLETE");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
@ -662,8 +670,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
if (!wtpman)
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
if (socklist[socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
|
||||
|
||||
int port = sock_getport(&socklist[socklistindex].addr);
|
||||
@ -699,9 +705,11 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
wtpman_destroy(wtpman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
wtpman->conn->global_cfg = global_cfg;
|
||||
wtpman->conn->local_cfg = cw_cfg_create();
|
||||
|
||||
wtpman->conn->role = CW_ROLE_AC;
|
||||
wtpman->conn->data=wtpman;
|
||||
|
||||
wtpman->conn->data_sock = socklist[socklistindex].data_sockfd;
|
||||
sock_copyaddr(&wtpman->conn->data_addr,
|
||||
@ -712,6 +720,8 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
|
||||
wtpman->conn->strict_capwap = conf_strict_capwap;
|
||||
wtpman->conn->strict_hdr = conf_strict_headers;
|
||||
|
||||
wtpman->conn->setup_complete = setup_complete;
|
||||
/*
|
||||
// wtpman->conn->radios = mbag_i_create();
|
||||
// wtpman->conn->radios_upd = mbag_i_create();
|
||||
@ -722,9 +732,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
*/
|
||||
|
||||
|
||||
wtpman->conn->local_cfg = cw_ktv_create();
|
||||
wtpman->conn->global_cfg = global_cfg;
|
||||
wtpman->conn->local_cfg = global_cfg;
|
||||
|
||||
/* when created caused by a packet in DTLS mode, we try
|
||||
* to find out the modules to load, for detected connection
|
||||
@ -742,15 +749,22 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
cw_mod_get_msg_set(wtpman->conn, cmod, bmod);
|
||||
wtpman->conn->detected = 1;
|
||||
cmod->setup_cfg(wtpman->conn);
|
||||
if (wtpman->conn->setup_complete)
|
||||
wtpman->conn->setup_complete(wtpman->conn);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
|
||||
|
||||
return wtpman;
|
||||
}
|
||||
|
||||
|
||||
void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
||||
{
|
||||
cw_dbg(DBG_X,"ADD PACKET DETECTED %d",wtpman->conn->detected);
|
||||
conn_q_add_packet(wtpman->conn, packet, len);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "cw/fragman.h"
|
||||
#include "cw/timer.h"
|
||||
#include "cw/cfg.h"
|
||||
#include "cw/capwap.h"
|
||||
|
||||
#define WTPMAN_QSIZE 1024
|
||||
|
||||
@ -38,6 +39,12 @@ struct wtpman {
|
||||
*/
|
||||
|
||||
|
||||
cw_MsgCallbackFun pdiscovery;
|
||||
cw_MsgCallbackFun pjoin;
|
||||
cw_MsgCallbackFun pupdate;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -140,7 +140,7 @@ static inline int bstr16_ncpy(uint8_t *dst,uint8_t*src,uint16_t len)
|
||||
|
||||
|
||||
bstr16_t bstr16_create(const uint8_t *data, uint16_t len);
|
||||
uint8_t * bstr16_create_from_str(const char *s);
|
||||
bstr16_t bstr16_create_from_str(const char *s);
|
||||
extern uint8_t * bstr16_create_from_cfgstr(const char * s);
|
||||
|
||||
#define bstr16_replace bstr_replace
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "format.h"
|
||||
|
||||
|
||||
uint8_t * bstr16_create_from_str(const char *s)
|
||||
bstr16_t bstr16_create_from_str(const char *s)
|
||||
{
|
||||
uint8_t * mem;
|
||||
int msize;
|
||||
|
@ -1,18 +0,0 @@
|
||||
#include "bstr.h"
|
||||
|
||||
/*
|
||||
uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len)
|
||||
{
|
||||
uint8_t * str = malloc(bstrv_size(len));
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
bstrv_set_vendor_id(str,vendor_id);
|
||||
bstrv_set_len(str,len);
|
||||
memcpy(bstrv_data(str),data,len);
|
||||
*(bstrv_data(str)+bstrv_len(str))=0;
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
*/
|
107
src/cw/cfg.c
107
src/cw/cfg.c
@ -3,10 +3,13 @@
|
||||
|
||||
#include <mavl.h>
|
||||
|
||||
#include "cw.h"
|
||||
#include "cfg.h"
|
||||
#include "val.h"
|
||||
#include "cfg.h"
|
||||
|
||||
|
||||
#include "dbg.h"
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
|
||||
static const char *nextc(const char *s)
|
||||
{
|
||||
@ -119,6 +122,30 @@ const char *cw_cfg_get(cw_Cfg_t * cfg, const char *key, const char *def)
|
||||
return r->val;
|
||||
}
|
||||
|
||||
const char *cw_cfg_get2(cw_Cfg_t *cfg1, cw_Cfg_t *cfg2, const char *key, const char *def)
|
||||
{
|
||||
return cw_cfg_get(cfg1, key, cw_cfg_get(cfg2,key,def));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
s = cw_cfg_get(cfg,key,def);
|
||||
if(s==NULL)
|
||||
return NULL;
|
||||
|
||||
return bstr16_create_from_str(s);
|
||||
}
|
||||
|
||||
int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str)
|
||||
{
|
||||
CW_TYPE_BSTR16->read(cfg,key,bstr16_data(str),bstr16_len(str),NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void cw_cfg_dump(cw_Cfg_t * cfg)
|
||||
@ -492,27 +519,95 @@ int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, const char *def)
|
||||
}
|
||||
|
||||
|
||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, const char * def)
|
||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def)
|
||||
{
|
||||
struct cw_Val v;
|
||||
const char *s = cw_cfg_get(cfg,key,def);
|
||||
memset(&v,0,sizeof(struct cw_Val));
|
||||
const char *s = cw_cfg_get(cfg,key,NULL);
|
||||
if (s==NULL)
|
||||
return def;
|
||||
CW_TYPE_BYTE->from_str(&v,s);
|
||||
return v.val.word;
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
|
||||
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key, uint16_t def)
|
||||
{
|
||||
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_WORD->from_str(&v,s);
|
||||
return v.val.word;
|
||||
}
|
||||
|
||||
/*
|
||||
int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
|
||||
{
|
||||
const char *s;
|
||||
s=cw_cfg_get(cfg,key,def);
|
||||
if (s==NULL)
|
||||
return 0;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void cw_cfg_set_int(cw_Cfg_t * cfg, const char * key, int val)
|
||||
{
|
||||
char a[128];
|
||||
sprintf(a,"%d",val);
|
||||
cw_cfg_set(cfg,key,a);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key)
|
||||
{
|
||||
char ikey[CW_CFG_MAX_KEY_LEN];
|
||||
struct cw_Cfg_entry search, * result;
|
||||
char *d;
|
||||
|
||||
sprintf(ikey,"%s.%d",key,65536);
|
||||
|
||||
search.key=ikey;
|
||||
/*//result = ktvn(ktv,&search);*/
|
||||
|
||||
result = mavl_get_last(cfg,&search);
|
||||
if (result == NULL){
|
||||
return 0;
|
||||
}
|
||||
|
||||
d = strchr(result->key,'.');
|
||||
if (d==NULL){
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (strncmp(result->key,ikey,d-result->key)!=0)
|
||||
return 0;
|
||||
|
||||
return atoi(d+1)+1;
|
||||
}
|
||||
|
||||
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *type, const void * valguard, const uint8_t * data, int len)
|
||||
{
|
||||
cw_Val_t mdata, *mresult;
|
||||
char str[2048];
|
||||
memset(&mdata,0,sizeof(cw_Val_t));
|
||||
mdata.type=type;
|
||||
mdata.valguard=valguard;
|
||||
cw_dbg(DBG_X,"SETVAL FOR TYPE: %s",type->name);
|
||||
mresult = type->get(&mdata,data,len);
|
||||
if (!mresult){
|
||||
cw_log(LOG_ERR, "Can't create cfg element for key %s of type %s: %s",
|
||||
key,type->name, strerror(errno));
|
||||
free(mdata.key);
|
||||
return 0;
|
||||
}
|
||||
type->to_str(&mdata,str,2048);
|
||||
cw_cfg_set(cfg,key,str);
|
||||
|
||||
if (type->del)
|
||||
type->del(&mdata);
|
||||
return 1;
|
||||
}
|
||||
|
18
src/cw/cfg.h
18
src/cw/cfg.h
@ -2,6 +2,8 @@
|
||||
#define _CFG_H
|
||||
|
||||
#include <mavl.h>
|
||||
#include "val.h"
|
||||
#include "bstr.h"
|
||||
|
||||
#define CW_CFG_MAX_KEY_LEN 1024
|
||||
|
||||
@ -30,9 +32,21 @@ 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);
|
||||
|
||||
int cw_cfg_get_bool(cw_Cfg_t * cfg, const char * key, const char *def);
|
||||
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * 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);
|
||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, const char * def);
|
||||
uint8_t cw_cfg_get_byte(cw_Cfg_t * cfg, char *key, uint8_t def);
|
||||
bstr16_t cw_cfg_get_bstr16(cw_Cfg_t * cfg, const char * key, const char *def);
|
||||
int cw_cfg_set_bstr16(cw_Cfg_t * cfg, const char * key, bstr16_t str);
|
||||
int cw_cfg_get_next_index(cw_Cfg_t * cfg, const char *key);
|
||||
|
||||
|
||||
int cw_cfg_set_val(cw_Cfg_t * cfg, const char *key, const struct cw_Type *t, const void * valguard, const uint8_t * data, int len);
|
||||
|
||||
#define cw_cfg_get_word2(cfg1,cfg2,key,def) \
|
||||
cw_cfg_get_word(cfg1,key,cw_cfg_get_word(cfg2,key,def))
|
||||
|
||||
#define cw_dget(fun,cfg1,cfg2,key,def)\
|
||||
fun(cfg1,key,fun(cfg2,key,def))
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -54,7 +54,7 @@ int cw_assemble_message(struct cw_Conn *conn, uint8_t * rawout)
|
||||
struct mlistelem * elem;
|
||||
int len,l;
|
||||
|
||||
cw_dbg(DBG_INFO, "Number of elements in ktv: %d",conn->local_cfg->count);
|
||||
//cw_dbg(DBG_INFO, "Number of elements in ktv: %d",conn->local_cfg->count);
|
||||
/* cw_dbg_ktv_dump(conn->local_cfg,DBG_CFG_DMP,"Local CFG","LOCAL:","End Local CFG");*/
|
||||
|
||||
/* rawout is already initialized, so we can get
|
||||
@ -86,14 +86,13 @@ int cw_assemble_message(struct cw_Conn *conn, uint8_t * rawout)
|
||||
|
||||
data = mlistelem_dataptr(elem);
|
||||
handler = cw_msgset_get_elemhandler(conn->msgset,data->proto,data->vendor,data->id);
|
||||
printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);
|
||||
// cw_dbg(DBG_X,"Elem: %d %d %d %s\n", 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;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_X,"Hello!");
|
||||
|
||||
if (handler->put == NULL){
|
||||
if (data->mand){
|
||||
@ -104,11 +103,10 @@ cw_dbg(DBG_X,"Hello!");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* params.conn=conn;*/
|
||||
params.local_cfg=conn->local_cfg;
|
||||
params.remote_cfg=conn->remote_cfg;
|
||||
params.conn=conn;
|
||||
params.cfg=conn->remote_cfg;
|
||||
params.default_cfg=conn->default_cfg;
|
||||
params.global_cfg=conn->global_cfg;
|
||||
|
||||
params.msgset=conn->msgset;
|
||||
|
||||
|
||||
@ -123,11 +121,9 @@ cw_dbg(DBG_X,"Hello!");
|
||||
cisco/ap-led-flash-config/flash-enable
|
||||
}*/
|
||||
|
||||
cw_dbg(DBG_X,"Calling Handler put for %s",handler->name);
|
||||
|
||||
l = handler->put(handler,¶ms,dst+len);
|
||||
|
||||
cw_dbg(DBG_X,"L = %d",l);
|
||||
|
||||
/* if(l>0)
|
||||
cw_dbg_elem(DBG_ELEM_OUT,conn,type,handler,dst+len,l);
|
||||
@ -156,11 +152,12 @@ cw_dbg(DBG_X,"L = %d",l);
|
||||
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);
|
||||
mavl_t * cfg = cw_ktv_create();
|
||||
mavl_t * cfg = cw_cfg_create();
|
||||
|
||||
struct cw_ElemHandlerParams params;
|
||||
|
||||
params.remote_cfg=cfg;
|
||||
params.cfg=cfg;
|
||||
params.default_cfg=NULL;
|
||||
params.msgset=conn->msgset;
|
||||
params.msgdata=msg;
|
||||
|
||||
|
@ -235,6 +235,8 @@ struct cw_Conn {
|
||||
|
||||
|
||||
int detected;
|
||||
void (*setup_complete)(struct cw_Conn *conn);
|
||||
|
||||
// void * mods;
|
||||
|
||||
|
||||
|
@ -274,7 +274,7 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
||||
}
|
||||
|
||||
|
||||
/* Detect the connecting AC type */
|
||||
/* Detect the connecting WTP type */
|
||||
if (!conn->detected) {
|
||||
|
||||
struct cw_MsgSet *set =
|
||||
@ -289,6 +289,10 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
||||
conn->cmod->setup_cfg(conn);
|
||||
conn->msgset = set;
|
||||
conn->detected = 1;
|
||||
|
||||
if (conn->setup_complete)
|
||||
conn->setup_complete(conn);
|
||||
|
||||
}
|
||||
|
||||
/** debug the received message */
|
||||
@ -365,16 +369,6 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
||||
|
||||
elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||
|
||||
params.local_cfg = conn->local_cfg;
|
||||
params.remote_cfg = conn->remote_cfg;
|
||||
params.default_cfg = conn->default_cfg;
|
||||
params.global_cfg = conn->global_cfg;
|
||||
params.msgset = conn->msgset;
|
||||
|
||||
params.from = from;
|
||||
params.msgdata = message;
|
||||
params.mand_found = mand_found;
|
||||
|
||||
|
||||
|
||||
mand_found = mavl_create_conststr();
|
||||
@ -386,8 +380,14 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
||||
cw_dbg(DBG_MSG_PARSING, "*** Parsing message of type %d - (%s) ***",
|
||||
message->type, message->name);
|
||||
|
||||
params.cfg = cw_cfg_create(); //conn->remote_cfg;
|
||||
params.default_cfg = NULL;
|
||||
params.from = from;
|
||||
params.msgdata = message;
|
||||
params.mand_found = mand_found;
|
||||
params.msgset=conn->msgset;
|
||||
params.conn = conn;
|
||||
|
||||
params.cfg = cw_cfg_create();
|
||||
cw_decode_elements(¶ms,elems_ptr, elems_len);
|
||||
|
||||
/* all message elements are processed, do now after processing
|
||||
@ -407,7 +407,8 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
||||
|
||||
|
||||
if (message->postprocess) {
|
||||
message->postprocess(conn);
|
||||
// message->postprocess(conn);
|
||||
message->postprocess(¶ms,elems_ptr, elems_len);
|
||||
}
|
||||
|
||||
|
||||
@ -660,7 +661,6 @@ int cw_read_messages(struct cw_Conn *conn)
|
||||
{
|
||||
uint8_t buf[2024];
|
||||
int len = 2024;
|
||||
cw_dbg(DBG_X,"Conn cw_read_messages from dsco request");
|
||||
|
||||
int n = conn->read(conn, buf, len);
|
||||
if (n < 0)
|
||||
|
@ -527,7 +527,7 @@ int cw_put_elem_radio_administrative_state(uint8_t * dst, int rid, int state);
|
||||
int cw_put_local_ip_address(uint8_t *dst, int id, int ipv_id, int ipv6_id,
|
||||
uint8_t *src, int len);
|
||||
|
||||
int cw_detect_nat(struct cw_Conn *conn);
|
||||
int cw_detect_nat(struct cw_ElemHandlerParams *conn);
|
||||
|
||||
uint8_t *cw_init_data_keep_alive_msg(uint8_t * buffer,uint8_t *rmac);
|
||||
|
||||
|
@ -10,15 +10,13 @@
|
||||
* @retval 1 NAT detected
|
||||
* @retval 0 no NAT was detected
|
||||
*/
|
||||
int cw_detect_nat(struct cw_Conn *conn)
|
||||
int cw_detect_nat(struct cw_ElemHandlerParams *params)
|
||||
{
|
||||
cw_Val_t * result;
|
||||
|
||||
const char * remote_str;
|
||||
char local_str[128];
|
||||
char remote_str[128];
|
||||
|
||||
result = cw_ktv_get(conn->remote_cfg,"capwap-local-ip-address",CW_TYPE_IPADDRESS);
|
||||
if (result == NULL){
|
||||
remote_str = cw_cfg_get(params->cfg,"capwap-local-ip-address",NULL);
|
||||
if (remote_str == NULL){
|
||||
cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
|
||||
return 0;
|
||||
}
|
||||
@ -26,8 +24,7 @@ int cw_detect_nat(struct cw_Conn *conn)
|
||||
/* convert remote connected and sent ip addresse to
|
||||
* strings */
|
||||
|
||||
sock_addrtostr((struct sockaddr*)&conn->addr,local_str,128,0);
|
||||
result->type->to_str(result,remote_str,128);
|
||||
sock_addrtostr((struct sockaddr*)&(params->conn->addr),local_str,128,0);
|
||||
|
||||
|
||||
/* if connected and sent address is the same, there is
|
||||
@ -37,3 +34,4 @@ int cw_detect_nat(struct cw_Conn *conn)
|
||||
/* otherwise ther must be something between AC and WTP */
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -3,48 +3,35 @@
|
||||
#include "msgset.h"
|
||||
#include "val.h"
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||
uint8_t * elem_data, int elem_len)
|
||||
{
|
||||
cw_Val_t * result;
|
||||
cw_Val_t val;
|
||||
cw_Type_t * type;
|
||||
int n;
|
||||
char strval[2048];
|
||||
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
|
||||
|
||||
type = (cw_Type_t*)handler->type;
|
||||
char mkey[CW_KTV_MAX_KEY_LEN];
|
||||
const char *key;
|
||||
|
||||
|
||||
|
||||
if (!type){
|
||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
|
||||
type->read(params->local_cfg, handler->key,elem_data,elem_len,handler->param);
|
||||
|
||||
|
||||
// exit(0);
|
||||
|
||||
/* if (!result){
|
||||
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s",
|
||||
handler->key,type->name, strerror(errno));
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
if (handler->mkkey != NULL){
|
||||
handler->mkkey(handler->key,elem_data,elem_len, mkey);
|
||||
key = mkey;
|
||||
}
|
||||
else{
|
||||
key = handler->key;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// n = type->to_str(&val,strval,2048);
|
||||
|
||||
// printf("SETTING: %s: %s (%d)\n",handler->key,strval,n);
|
||||
|
||||
|
||||
// result = cw_ktv_add(params->remote_cfg, handler->key,
|
||||
// handler->type,NULL, elem_data,elem_len);
|
||||
// params->elem=result;
|
||||
/* cw_dbg(DBG_X, "READ: %s / %s",type->name,key);*/
|
||||
type->read(params->cfg, key,elem_data,elem_len,handler->param);
|
||||
return CAPWAP_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
|
||||
#include "cw.h"
|
||||
#include "cfg.h"
|
||||
|
||||
|
||||
|
||||
static const cw_ValEnum_t * get_enum(const cw_ValEnum_t * e, int val){
|
||||
@ -21,7 +23,7 @@ int cw_in_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHa
|
||||
const cw_ValEnum_t * e;
|
||||
const cw_ValIndexed_t * ie;
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
struct cw_ElemHandler thandler;
|
||||
|
||||
ie = handler->type;
|
||||
@ -46,8 +48,11 @@ int cw_in_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHa
|
||||
}
|
||||
|
||||
memset(&thandler,0,sizeof(thandler));
|
||||
thandler.type=e->type;
|
||||
|
||||
thandler.key=key;
|
||||
|
||||
thandler.type=e->type;
|
||||
thandler.param=e->param;
|
||||
return e->fun_in(&thandler,params,elem_data+f,elem_len-l);
|
||||
|
||||
}
|
||||
|
@ -3,13 +3,17 @@
|
||||
#include "msgset.h"
|
||||
#include "val.h"
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||
uint8_t * elem_data, int elem_len)
|
||||
{
|
||||
cw_dbg(DBG_X,"STRUCT KEY: %s",handler->key);
|
||||
stop();
|
||||
const char * key;
|
||||
char tmpkey[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
|
||||
if (handler->mkkey != NULL){
|
||||
handler->mkkey(key,elem_data,elem_len, tmpkey);
|
||||
key = tmpkey;
|
||||
@ -29,7 +33,7 @@ printf("CW_IN_GENERIC STRUCT: %s\n",key);
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
|
||||
cw_ktv_read_struct(params->remote_cfg,handler->type,key,elem_data,elem_len);
|
||||
cw_ktv_read_struct(params->cfg,handler->type,key,elem_data,elem_len);
|
||||
|
||||
return CAPWAP_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "cw.h"
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_in_generic_with_index(struct cw_ElemHandler *eh,
|
||||
struct cw_ElemHandlerParams *params,
|
||||
@ -7,8 +8,11 @@ int cw_in_generic_with_index(struct cw_ElemHandler *eh,
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int idx;
|
||||
|
||||
cw_dbg(DBG_X,"Fix cw_in_generic_with_index");
|
||||
stop();
|
||||
idx = cw_get_byte(data);
|
||||
sprintf(key,"%s.%d",eh->key,idx);
|
||||
cw_ktv_add(params->remote_cfg,key,eh->type,NULL,data+1,len-1);
|
||||
// cw_cfg_add(params->cfg,key,eh->type,NULL,data+1,len-1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
#include "cw.h"
|
||||
#include "log.h"
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_in_idx_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||
uint8_t * elem_data, int elem_len)
|
||||
{
|
||||
stop();
|
||||
/*
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
cw_Val_t * result;
|
||||
int idx;
|
||||
@ -16,10 +19,10 @@ int cw_in_idx_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerPara
|
||||
idx=cw_get_byte(elem_data);
|
||||
sprintf(key,handler->key,idx);
|
||||
|
||||
result = cw_ktv_add(params->remote_cfg, key,
|
||||
result = cw_ktv_add(params->cfg, key,
|
||||
handler->type, NULL, elem_data+1,elem_len-1);
|
||||
|
||||
// params->elem=result;
|
||||
|
||||
*/
|
||||
return CAPWAP_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "val.h"
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||
uint8_t * elem_data, int elem_len)
|
||||
@ -11,6 +13,10 @@ int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHand
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int idx;
|
||||
|
||||
|
||||
cw_dbg(DBG_X,"Fix cw_in_idx_generic_struct");
|
||||
exit(1);
|
||||
|
||||
if (!handler->type){
|
||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
@ -19,7 +25,7 @@ int cw_in_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHand
|
||||
idx = cw_get_byte(elem_data);
|
||||
sprintf(key, handler->key, idx);
|
||||
|
||||
cw_ktv_read_struct(params->remote_cfg,handler->type,key,elem_data+1,elem_len-1);
|
||||
cw_ktv_read_struct(params->cfg,handler->type,key,elem_data+1,elem_len-1);
|
||||
|
||||
return CAPWAP_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -5,9 +5,14 @@
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_in_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||
uint8_t * elem_data, int elem_len)
|
||||
{
|
||||
|
||||
stop();
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int radio;
|
||||
|
||||
@ -19,7 +24,7 @@ int cw_in_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHa
|
||||
radio = cw_get_byte(elem_data);
|
||||
sprintf(key,"radio.%d/%s",radio,handler->key);
|
||||
|
||||
cw_ktv_read_struct(params->remote_cfg,handler->type,key,elem_data+1,elem_len-1);
|
||||
cw_ktv_read_struct(params->cfg,handler->type,key,elem_data+1,elem_len-1);
|
||||
|
||||
/*params->elem=result;*/
|
||||
|
||||
|
@ -10,7 +10,6 @@ cw_Val_t * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *ty
|
||||
{
|
||||
cw_Val_t mdata, *mresult;
|
||||
int exists;
|
||||
|
||||
mdata.key=cw_strdup(key);
|
||||
mdata.valguard=valguard;
|
||||
|
||||
|
@ -12,19 +12,18 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
|
||||
, uint8_t * dst)
|
||||
{
|
||||
|
||||
struct cw_Val * elem;
|
||||
int start, len, l;
|
||||
|
||||
/* Get the element */
|
||||
/* search.key=(char*)handler->key;
|
||||
elem = mavl_get(params->conn->local_cfg, &search);
|
||||
*/
|
||||
elem = cw_ktv_get(params->local_cfg,handler->key,NULL);
|
||||
// cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
// cw_cfg_dump(params->cfg);
|
||||
// cw_dbg(DBG_X,"Generic out!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDDUMP");
|
||||
|
||||
/* if (elem == NULL && params->conn->default_cfg !=NULL)
|
||||
elem = mavl_get(params->conn->default_cfg, &search);
|
||||
*/
|
||||
if (elem == NULL) {
|
||||
start = params->msgset->header_len(handler);
|
||||
len = ((const cw_Type_t*)(handler->type))->
|
||||
write(params->cfg,handler->key,dst+start,handler->param);
|
||||
|
||||
|
||||
if (len == -1) {
|
||||
const char *vendor="";
|
||||
if ( handler->vendor ) {
|
||||
vendor=cw_strvendor(handler->vendor);
|
||||
@ -46,32 +45,8 @@ int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Size for msg elem header depends on
|
||||
vendor specific payload */
|
||||
/* start = handler->vendor ? 10 : 4; */
|
||||
start = params->msgset->header_len(handler);
|
||||
|
||||
if (cw_ktv_cast(elem,handler->type)==NULL){
|
||||
cw_log(LOG_ERR,"Can't put element '%s'- can't cast from %s to %s for key: %s", handler->name,
|
||||
elem->type->name, ((const cw_Type_t*)handler->type)->name, handler->key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
len = ((const cw_Type_t*)(handler->type))->put(elem,dst+start);
|
||||
|
||||
/* ((const cw_Type_t*)(handler->type))->to_str(elem,detail,120);
|
||||
sprintf(params->debug_details, " Value = %s", detail);
|
||||
params->elem = elem;*/
|
||||
|
||||
/* if (handler->vendor)
|
||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
||||
|
||||
l = len + cw_put_elem_hdr(dst, handler->id, len); */
|
||||
l = params->msgset->write_header(handler,dst,len);
|
||||
|
||||
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,handler,dst,l);
|
||||
/* cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);*/
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,14 @@
|
||||
#include "cw.h"
|
||||
#include"dbg.h"
|
||||
|
||||
|
||||
int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
{
|
||||
cw_dbg(DBG_X,"Fix: cw_out_generic_indexed_enum");
|
||||
exit(1);
|
||||
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int i;
|
||||
cw_Val_t * result;
|
||||
@ -24,7 +30,7 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
|
||||
|
||||
//printf("Her is the Key: %s - %s\n",key, );
|
||||
|
||||
result = cw_ktv_base_exists(params->local_cfg,key);
|
||||
result = cw_ktv_base_exists(params->cfg,key);
|
||||
if (result==NULL)
|
||||
continue;
|
||||
start = params->msgset->header_len(handler);
|
||||
@ -35,7 +41,7 @@ int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemH
|
||||
if (e[i].fun_out==NULL)
|
||||
len += result->type->put(result,ob+start+len);
|
||||
else
|
||||
len += cw_ktv_write_struct(params->local_cfg,
|
||||
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);
|
||||
|
@ -4,9 +4,15 @@
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
{
|
||||
stop();
|
||||
|
||||
|
||||
int start;
|
||||
int len;
|
||||
cw_Val_t search, *result;
|
||||
@ -17,7 +23,7 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
|
||||
}
|
||||
|
||||
search.key = (char*)handler->key;
|
||||
result = mavl_get_first(params->local_cfg,&search);
|
||||
result = mavl_get_first(params->cfg,&search);
|
||||
if (result == NULL ){
|
||||
if (params->elemdata->mand)
|
||||
cw_log(LOG_ERR,"Can't put mandatory message element %s, no data available",handler->name);
|
||||
@ -32,7 +38,7 @@ int cw_out_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandler
|
||||
|
||||
start = params->msgset->header_len(handler);
|
||||
|
||||
len = cw_ktv_write_struct(params->local_cfg,
|
||||
len = cw_ktv_write_struct(params->cfg,
|
||||
params->default_cfg,
|
||||
handler->type,handler->key,dst+start);
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
|
||||
#include "cw.h"
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_out_generic_with_index(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
|
||||
{
|
||||
stop();
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int idx;
|
||||
cw_Val_t * result, search;
|
||||
@ -18,7 +20,7 @@ int cw_out_generic_with_index(struct cw_ElemHandler * eh,
|
||||
do {
|
||||
sprintf(key,"%s.%d",eh->key,idx);
|
||||
search.key=key;
|
||||
result = mavl_get_first(params->local_cfg,&search);
|
||||
result = mavl_get_first(params->cfg,&search);
|
||||
if (result==NULL)
|
||||
break;
|
||||
if (strncmp(result->key,key,strlen(key))!=0)
|
||||
|
@ -5,6 +5,9 @@
|
||||
int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
{
|
||||
|
||||
stop();
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
struct cw_Val * elem, search;
|
||||
int i;
|
||||
@ -24,7 +27,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
|
||||
sprintf(key,handler->key,i);
|
||||
search.key=key;
|
||||
/*elem = mavl_get(params->conn->local_cfg, &search);*/
|
||||
elem = mavl_get_first(params->local_cfg,&search);
|
||||
elem = mavl_get_first(params->cfg,&search);
|
||||
if(elem != NULL){
|
||||
printf("Elem key: %s\n",elem->key);
|
||||
}
|
||||
@ -41,7 +44,7 @@ int cw_out_idx_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHan
|
||||
start = mdst + params->msgset->header_len(handler);
|
||||
|
||||
len += cw_put_byte(start+len,idx);
|
||||
len += cw_ktv_write_struct(params->local_cfg,NULL, handler->type,key,start+len);
|
||||
len += cw_ktv_write_struct(params->cfg,NULL, handler->type,key,start+len);
|
||||
|
||||
mdst += params->msgset->write_header(handler,mdst,len);
|
||||
|
||||
|
@ -7,6 +7,8 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n);
|
||||
int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
{
|
||||
stop();
|
||||
|
||||
int len,i,l;
|
||||
int radios;
|
||||
len =0;
|
||||
@ -20,7 +22,7 @@ int cw_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
|
||||
idx++;
|
||||
}
|
||||
*/
|
||||
radios = cw_ktv_get_byte(params->local_cfg,"wtp-descriptor/max-radios",0);
|
||||
radios = cw_ktv_get_byte(params->cfg,"wtp-descriptor/max-radios",0);
|
||||
|
||||
for(i=0;i<radios;i++){
|
||||
l = cw_write_radio_element(handler,params,i,dst+len);
|
||||
|
@ -7,6 +7,8 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n);
|
||||
int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
{
|
||||
stop();
|
||||
|
||||
int i,l, offset;
|
||||
|
||||
uint8_t * cdst;
|
||||
@ -21,12 +23,12 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
|
||||
char basekey[CW_KTV_MAX_KEY_LEN];
|
||||
cw_Val_t * result;
|
||||
|
||||
i = cw_ktv_idx_get_next(params->local_cfg,"radio",i+1);
|
||||
i = cw_ktv_idx_get_next(params->cfg,"radio",i+1);
|
||||
if (i==-1)
|
||||
break;
|
||||
sprintf(basekey,"radio.%d/%s",i,handler->key);
|
||||
|
||||
result = cw_ktv_base_exists(params->local_cfg,basekey);
|
||||
result = cw_ktv_base_exists(params->cfg,basekey);
|
||||
if (result == NULL){
|
||||
continue;
|
||||
}
|
||||
@ -34,7 +36,7 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
|
||||
|
||||
l=0;
|
||||
l+=cw_put_byte(cdst+offset+l,i);
|
||||
l+= cw_ktv_write_struct(params->local_cfg,NULL, handler->type,basekey,cdst+offset+l);
|
||||
l+= cw_ktv_write_struct(params->cfg,NULL, handler->type,basekey,cdst+offset+l);
|
||||
|
||||
|
||||
cdst+=params->msgset->write_header(handler,cdst,l);
|
||||
@ -59,7 +61,7 @@ printf("Next: %s\n", next);
|
||||
if (sl==NULL){
|
||||
cw_Val_t * result;
|
||||
sprintf(key,"%s/%s",current,next);
|
||||
result = cw_ktv_base_exists(params->local_cfg,key);
|
||||
result = cw_ktv_base_exists(params->cfg,key);
|
||||
if (result != NULL){
|
||||
int offset;
|
||||
int i,l;
|
||||
@ -68,7 +70,7 @@ printf("Next: %s\n", next);
|
||||
for (i=0;i<stack[0];i++){
|
||||
printf("I=%i\n",stack[i+1]);
|
||||
}
|
||||
l= cw_ktv_write_struct(params->local_cfg,params->default_cfg,
|
||||
l= cw_ktv_write_struct(params->cfg,params->default_cfg,
|
||||
handler->type,key,dst+offset);
|
||||
|
||||
printf("Write struct len %i\n",l);
|
||||
@ -96,19 +98,19 @@ printf("current is %s\n", current);
|
||||
|
||||
|
||||
printf("Here we are %s\n",key);
|
||||
cw_dbg_ktv_dump(params->local_cfg,DBG_INFO,"start"," ", "end" );
|
||||
cw_dbg_ktv_dump(params->cfg,DBG_INFO,"start"," ", "end" );
|
||||
i=-1;
|
||||
while(1){
|
||||
char basekey[CW_KTV_MAX_KEY_LEN];
|
||||
cw_Val_t * result;
|
||||
|
||||
i = cw_ktv_idx_get_next(params->local_cfg,key,i+1);
|
||||
i = cw_ktv_idx_get_next(params->cfg,key,i+1);
|
||||
|
||||
if (i==-1)
|
||||
break;
|
||||
sprintf(basekey,"%s.%d",key,i);
|
||||
printf("Our basekey is %s\n",basekey);
|
||||
result = cw_ktv_base_exists(params->local_cfg,basekey);
|
||||
result = cw_ktv_base_exists(params->cfg,basekey);
|
||||
if (result == NULL){
|
||||
continue;
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ int cw_read_ac_descriptor(mavl_t store,
|
||||
struct cw_DescriptorSubelemDef *allowed)
|
||||
{
|
||||
|
||||
cw_ktv_read_struct(params->remote_cfg,acstatus,eh->key,data,len);
|
||||
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)
|
||||
allowed=allowed_default;
|
||||
|
@ -5,26 +5,29 @@
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_in_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
|
||||
uint8_t * elem_data, int elem_len)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
cw_Val_t * result;
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
int radio;
|
||||
struct cw_Type *type;
|
||||
type = (struct cw_Type*)handler->type;
|
||||
|
||||
if (!handler->type){
|
||||
if (!type){
|
||||
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
radio=cw_get_byte(elem_data);
|
||||
sprintf(key,"radio.%d/%s",radio,handler->key);
|
||||
|
||||
result = cw_ktv_add(params->remote_cfg, key,
|
||||
handler->type, NULL, elem_data+1,elem_len-1);
|
||||
|
||||
// params->elem=result;
|
||||
/*cw_cfg_set_val(params->cfg, key,
|
||||
handler->type, handler->param, elem_data+1,elem_len-1);*/
|
||||
|
||||
type->read(params->cfg, key,elem_data+1,elem_len-1,handler->param);
|
||||
return CAPWAP_RESULT_SUCCESS;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "cw.h"
|
||||
#include "cfg.h"
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
|
||||
@ -47,7 +48,6 @@ int cw_setup_dtls(struct cw_Conn *conn, mavl_t cfg, const char *prefix,
|
||||
sprintf(key, "%s/%s", prefix, "ssl-cipher");
|
||||
conn->dtls_cipher = cw_cfg_get(cfg, key, default_cipher);
|
||||
|
||||
|
||||
sprintf(key, "%s/%s", prefix, "ssl-psk");
|
||||
conn->dtls_psk = cw_cfg_get(cfg, key, NULL);
|
||||
|
||||
@ -61,9 +61,9 @@ int cw_setup_dtls(struct cw_Conn *conn, mavl_t cfg, const char *prefix,
|
||||
|
||||
|
||||
sprintf(key, "%s/%s", prefix, "ssl-certfile");
|
||||
ssl_cert = cw_cfg_get(conn->local_cfg, key, NULL);
|
||||
ssl_cert = cw_cfg_get(cfg, key, NULL);
|
||||
sprintf(key, "%s/%s", prefix, "ssl-keyfile");
|
||||
ssl_key = cw_cfg_get(conn->local_cfg, key, NULL);
|
||||
ssl_key = cw_cfg_get(cfg, key, NULL);
|
||||
|
||||
if (ssl_cert != NULL && ssl_key != NULL) {
|
||||
conn->dtls_cert_file = ssl_cert;
|
||||
@ -74,9 +74,8 @@ int cw_setup_dtls(struct cw_Conn *conn, mavl_t cfg, const char *prefix,
|
||||
}
|
||||
|
||||
sprintf(key, "%s/%s", prefix, "ssl-dhbits");
|
||||
conn->dtls_dhbits = cw_cfg_get_word(cfg, key, "1024");
|
||||
conn->dtls_dhbits = cw_cfg_get_word(cfg, key, 1024);
|
||||
|
||||
conn->dtls_get_psk = get_psk;
|
||||
|
||||
return security;
|
||||
}
|
||||
|
@ -84,6 +84,25 @@ static const char * get_type_name(cw_Val_t *data)
|
||||
return CW_TYPE_BOOL->name;
|
||||
}
|
||||
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
cw_Val_t val;
|
||||
int l;
|
||||
char str[2048];
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
val.valguard = param;
|
||||
get(&val,src,len);
|
||||
to_str(&val,str,2048);
|
||||
cw_cfg_set(cfg,key,str);
|
||||
l = val.type->len(&val);
|
||||
if (val.type->del)
|
||||
val.type->del(&val);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct cw_Type cw_type_bool = {
|
||||
"Bool", /* name */
|
||||
NULL, /* del */
|
||||
@ -93,5 +112,7 @@ const struct cw_Type cw_type_bool = {
|
||||
from_str, /* from_str */
|
||||
len, /* len */
|
||||
data, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
get_type_name, /* get_type_name */
|
||||
NULL,
|
||||
bread
|
||||
};
|
||||
|
@ -104,7 +104,7 @@ static int cast(cw_Val_t * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, void *param)
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
char *d, *dst;
|
||||
dst = malloc(len*2+3);
|
||||
@ -125,9 +125,52 @@ static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, v
|
||||
return d - dst;
|
||||
}
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, const uint8_t *dst, void * param)
|
||||
|
||||
|
||||
static int xput(uint8_t * dst,const char *s)
|
||||
{
|
||||
return 0;
|
||||
int msize;
|
||||
int l;
|
||||
l = strlen(s);
|
||||
if (s[0]!='.'){
|
||||
memcpy(dst,(uint8_t*)s,l);
|
||||
return l;
|
||||
}
|
||||
|
||||
if (l<=2){
|
||||
memcpy(dst,(uint8_t*)s,l);
|
||||
return l;
|
||||
}
|
||||
|
||||
if (s[1]=='.'){
|
||||
memcpy(dst,(uint8_t*)s+1,l-1);
|
||||
return l-1;
|
||||
}
|
||||
|
||||
if (s[1]!='x'){
|
||||
memcpy(dst,(uint8_t*)s,l);
|
||||
return l;
|
||||
}
|
||||
|
||||
/* the string starts with ".x" - read hexbytes */
|
||||
l-=2;
|
||||
msize=l/2;
|
||||
if(l&1)
|
||||
msize++;
|
||||
cw_format_scan_hex_bytes(dst,s+2,l);
|
||||
return msize;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, uint8_t *dst, const void * param)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
s = cw_cfg_get(cfg,key,NULL);
|
||||
if (s==NULL)
|
||||
return -1;
|
||||
return xput(dst,s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +124,7 @@ static int cast(cw_Val_t * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, void *param)
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
uint8_t val;
|
||||
cw_ValValRange_t * valrange = (cw_ValValRange_t *) param;
|
||||
@ -140,9 +140,22 @@ static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, v
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, const uint8_t *dst, void * param)
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, uint8_t *dst, const void * param)
|
||||
{
|
||||
return 0;
|
||||
|
||||
cw_Val_t val;
|
||||
int l;
|
||||
const char *s;
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
val.valguard=param;
|
||||
s = cw_cfg_get(cfg,key,NULL);
|
||||
if (s==NULL)
|
||||
return -1;
|
||||
from_str(&val,s);
|
||||
l = put(&val,dst);
|
||||
if(val.type->del)
|
||||
val.type->del(&val);
|
||||
return l;
|
||||
}
|
||||
|
||||
const struct cw_Type cw_type_byte = {
|
||||
|
@ -66,6 +66,42 @@ static int cast(cw_Val_t * data)
|
||||
}
|
||||
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
uint32_t val;
|
||||
//cw_ValValRange_t * valrange = (cw_ValValRange_t *) param;
|
||||
//const char *str;
|
||||
|
||||
val = cw_get_dword(src);
|
||||
/* str = get_guardstr(val, valrange);
|
||||
if (str != NULL)
|
||||
cw_cfg_set(cfg,key,str);
|
||||
else*/
|
||||
cw_cfg_set_int(cfg,key,val);
|
||||
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, uint8_t *dst, const void * param)
|
||||
{
|
||||
|
||||
cw_Val_t val;
|
||||
int l;
|
||||
const char *s;
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
val.valguard=param;
|
||||
s = cw_cfg_get(cfg,key,NULL);
|
||||
if (s==NULL)
|
||||
return -1;
|
||||
from_str(&val,s);
|
||||
l = put(&val,dst);
|
||||
if(val.type->del)
|
||||
val.type->del(&val);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
const struct cw_Type cw_type_dword = {
|
||||
"Dword", /* name */
|
||||
NULL, /* del */
|
||||
@ -76,6 +112,8 @@ const struct cw_Type cw_type_dword = {
|
||||
NULL, /* len */
|
||||
NULL, /* data */
|
||||
get_type_name, /* get_type_name */
|
||||
cast
|
||||
cast,
|
||||
bread,
|
||||
bwrite
|
||||
};
|
||||
|
||||
|
@ -111,6 +111,24 @@ static const char * get_type_name(cw_Val_t *data)
|
||||
return CW_TYPE_IPADDRESS->name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
char str[128];
|
||||
int rc;
|
||||
cw_Val_t val;
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
get(&val,src,len);
|
||||
to_str(&val,str,128);
|
||||
cw_cfg_set(cfg,key,str);
|
||||
rc = val.type->len(&val);
|
||||
del(&val);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct cw_Type cw_type_ipaddress = {
|
||||
"IPAddress", /* name */
|
||||
del, /* del */
|
||||
@ -120,7 +138,10 @@ const struct cw_Type cw_type_ipaddress = {
|
||||
from_str, /* from_str */
|
||||
len, /* len */
|
||||
data, /* data */
|
||||
get_type_name
|
||||
get_type_name,
|
||||
NULL,
|
||||
bread,
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -90,6 +90,21 @@ static const char * get_type_name(cw_Val_t *data)
|
||||
return CW_TYPE_STR->name;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
cw_Val_t val;
|
||||
int l;
|
||||
char str[2048];
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
val.valguard = param;
|
||||
get(&val,src,len);
|
||||
to_str(&val,str,2048);
|
||||
cw_cfg_set(cfg,key,str);
|
||||
l = val.type->len(&val);
|
||||
del(&val);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const struct cw_Type cw_type_str = {
|
||||
@ -101,5 +116,9 @@ const struct cw_Type cw_type_str = {
|
||||
from_str, /* from_str */
|
||||
len, /* len */
|
||||
NULL, /* data */
|
||||
get_type_name /* get_type_name */
|
||||
get_type_name, /* get_type_name */
|
||||
NULL,
|
||||
bread,
|
||||
|
||||
|
||||
};
|
||||
|
@ -79,7 +79,7 @@ static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, c
|
||||
|
||||
|
||||
const struct cw_Type cw_type_struct = {
|
||||
"Byte", /* name */
|
||||
"Struct", /* name */
|
||||
NULL, /* del */
|
||||
NULL, /* put */
|
||||
NULL, /* get */
|
||||
|
@ -63,6 +63,40 @@ static int cast(cw_Val_t * data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bread(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void *param)
|
||||
{
|
||||
uint16_t val;
|
||||
//cw_ValValRange_t * valrange = (cw_ValValRange_t *) param;
|
||||
//const char *str;
|
||||
|
||||
val = cw_get_word(src);
|
||||
/* str = get_guardstr(val, valrange);
|
||||
if (str != NULL)
|
||||
cw_cfg_set(cfg,key,str);
|
||||
else*/
|
||||
cw_cfg_set_int(cfg,key,val);
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int bwrite(cw_Cfg_t *cfg, const char *key, uint8_t *dst, const void * param)
|
||||
{
|
||||
|
||||
cw_Val_t val;
|
||||
int l;
|
||||
const char *s;
|
||||
memset(&val,0,sizeof(cw_Val_t));
|
||||
val.valguard=param;
|
||||
s = cw_cfg_get(cfg,key,NULL);
|
||||
if (s==NULL)
|
||||
return -1;
|
||||
from_str(&val,s);
|
||||
l = put(&val,dst);
|
||||
if(val.type->del)
|
||||
val.type->del(&val);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
const struct cw_Type cw_type_word = {
|
||||
"Word", /* name */
|
||||
@ -74,7 +108,9 @@ const struct cw_Type cw_type_word = {
|
||||
NULL,
|
||||
NULL,
|
||||
get_type_name,
|
||||
cast
|
||||
cast,
|
||||
bread,
|
||||
bwrite,
|
||||
|
||||
};
|
||||
|
||||
|
@ -3,30 +3,34 @@
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
#include "dbg.h"
|
||||
#include "cfg.h"
|
||||
|
||||
int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore,
|
||||
int cw_write_descriptor_subelem (uint8_t *dst, cw_Cfg_t * cfg,
|
||||
int subelem_id, const char * parent_key )
|
||||
{
|
||||
char key[256];
|
||||
cw_Val_t * vendor, *version ;
|
||||
uint8_t *d;
|
||||
uint32_t vendor;
|
||||
bstr16_t version;
|
||||
const char *vendor_s;
|
||||
|
||||
uint8_t *d;
|
||||
|
||||
/* d += cw_put_dword(d, bstrv_get_vendor_id(v));
|
||||
d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
|
||||
d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
|
||||
*/
|
||||
sprintf (key, "%s/%s", parent_key, CW_SKEY_VENDOR);
|
||||
vendor = cw_ktv_get (ktvstore, key, CW_TYPE_DWORD);
|
||||
vendor_s = cw_cfg_get (cfg, key, NULL);
|
||||
|
||||
if (vendor == NULL) {
|
||||
if (vendor_s == NULL) {
|
||||
cw_log (LOG_ERR, "Can't put subelem %s, no value of type Dword found.", key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
vendor = atoi(vendor_s);
|
||||
|
||||
sprintf (key, "%s/%s", parent_key, CW_SKEY_VERSION);
|
||||
version = cw_ktv_get (ktvstore, key, CW_TYPE_BSTR16);
|
||||
version = cw_cfg_get_bstr16 (cfg, key, NULL);
|
||||
|
||||
if (version == NULL) {
|
||||
cw_log (LOG_ERR, "Can't put subelem %s, no value of type Bstr16 found.", key);
|
||||
@ -36,12 +40,14 @@ int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore,
|
||||
d = dst;
|
||||
|
||||
/* put vendor */
|
||||
d += vendor->type->put (vendor, d);
|
||||
d += cw_put_dword(d, vendor); //->type->put (vendor, d);
|
||||
|
||||
/* put version */
|
||||
|
||||
d += cw_put_dword (d, (subelem_id << 16) | version->type->len(version));
|
||||
d += version->type->put(version,d);
|
||||
d += cw_put_dword (d, (subelem_id << 16) | bstr16_len(version));
|
||||
d += cw_put_bstr16(d, version);
|
||||
|
||||
free(version);
|
||||
|
||||
return d-dst;
|
||||
}
|
||||
|
@ -4,6 +4,9 @@
|
||||
int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params, int idx
|
||||
, uint8_t * dst)
|
||||
{
|
||||
return 0;
|
||||
stop();
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
cw_Val_t *elem, search;
|
||||
int len;
|
||||
@ -15,7 +18,7 @@ int cw_write_radio_element(struct cw_ElemHandler * handler, struct cw_ElemHandle
|
||||
printf("Looking for readio key: %s\n",key);
|
||||
|
||||
search.key=key;
|
||||
elem = mavl_get(params->local_cfg, &search);
|
||||
elem = mavl_get(params->cfg, &search);
|
||||
|
||||
if (elem==NULL){
|
||||
printf("Nothing found\n");
|
||||
|
@ -234,6 +234,9 @@ void cw_dbg_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
||||
*/
|
||||
int cw_dbg_is_level(int level);
|
||||
|
||||
|
||||
#define stop() printf("STOP IN %s:%d - %s\n", __FILE__, __LINE__, __FUNCTION__); exit(1)
|
||||
|
||||
/**
|
||||
*@} LOGDBG
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ struct dtls_ssl_cert
|
||||
uint8_t * data;
|
||||
};
|
||||
|
||||
extern int dtls_bio_read(struct conn *conn, char *out, int maxlen);
|
||||
extern int dtls_bio_write(struct conn * conn, const char *data, int len);
|
||||
extern int dtls_bio_read(struct cw_Conn *conn, char *out, int maxlen);
|
||||
extern int dtls_bio_write(struct cw_Conn * conn, const char *data, int len);
|
||||
|
||||
|
||||
|
@ -392,7 +392,6 @@ struct dtls_openssl_data * dtls_openssl_data_create(struct cw_Conn * conn, const
|
||||
SSL_CTX_set_timeout(d->ctx,30);
|
||||
|
||||
rc =SSL_CTX_set_max_proto_version (d->ctx,DTLS1_VERSION);
|
||||
printf("MAXMAMX = %d\n",rc);
|
||||
|
||||
|
||||
/*
|
||||
|
10
src/cw/mod.h
10
src/cw/mod.h
@ -52,7 +52,7 @@ struct cw_Mod {
|
||||
* @param conn current connection
|
||||
* @return 0 if notdetected
|
||||
**/
|
||||
int (*detect) (struct conn * conn, const uint8_t * rawmsg, int rawlen,
|
||||
int (*detect) (struct cw_Conn * conn, const uint8_t * rawmsg, int rawlen,
|
||||
int elems_len, struct sockaddr * from, int mode);
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ struct cw_Mod {
|
||||
/** used for private data */
|
||||
void *data;
|
||||
|
||||
int (*setup_cfg)(struct conn *conn);
|
||||
int (*setup_cfg)(struct cw_Conn *conn);
|
||||
|
||||
};
|
||||
|
||||
@ -79,7 +79,7 @@ extern struct cw_Mod mod_null;
|
||||
#define MOD_NULL (&mod_null)
|
||||
|
||||
/*
|
||||
struct cw_actiondef * mod_cache_add(struct conn *conn,struct cw_Mod *c, struct cw_Mod *b);
|
||||
struct cw_actiondef * mod_cache_add(struct cw_Conn *conn,struct cw_Mod *c, struct cw_Mod *b);
|
||||
*/
|
||||
|
||||
#define mod_init_config(mod,cfg) (mod->init_config ? mod->init_config(cfg):1)
|
||||
@ -95,11 +95,11 @@ extern int mod_caching;
|
||||
|
||||
struct cw_Mod * cw_mod_load(const char * mod_name, mavl_t global_cfg, int role);
|
||||
struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod );
|
||||
struct cw_Mod * cw_mod_detect(struct conn *conn,
|
||||
struct cw_Mod * cw_mod_detect(struct cw_Conn *conn,
|
||||
uint8_t * rawmsg, int len,
|
||||
int elems_len, struct sockaddr *from,
|
||||
int mode);
|
||||
struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn,
|
||||
struct cw_MsgSet *cw_mod_get_msg_set(struct cw_Conn *conn,
|
||||
struct cw_Mod * capwap_mod, struct cw_Mod *bindings_mod);
|
||||
|
||||
void cw_mod_set_path(const char * path);
|
||||
|
@ -387,3 +387,21 @@ struct cw_MsgData *cw_msgset_get_msgdata(struct cw_MsgSet *set, int type)
|
||||
search.type = type;
|
||||
return mavl_get(set->msgdata, &search);
|
||||
}
|
||||
|
||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
||||
cw_MsgCallbackFun fun)
|
||||
|
||||
{
|
||||
struct cw_MsgData * md;
|
||||
cw_MsgCallbackFun old_callback;
|
||||
md = cw_msgset_get_msgdata(set,msg_id);
|
||||
if (md != NULL){
|
||||
old_callback = md->postprocess;
|
||||
md->postprocess=fun;
|
||||
}
|
||||
return old_callback;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -24,7 +24,8 @@ struct cw_ElemData{
|
||||
};
|
||||
|
||||
struct cw_ElemHandlerParams {
|
||||
/* struct conn * conn;*/
|
||||
struct cw_Conn * conn; /**< a connection the message belongs to*/
|
||||
struct cw_MsgSet * msgset;
|
||||
struct cw_MsgData * msgdata;
|
||||
struct cw_ElemData * elemdata;
|
||||
struct sockaddr *from;
|
||||
@ -32,11 +33,7 @@ struct cw_ElemHandlerParams {
|
||||
// cw_Val_t * elem;
|
||||
char * debug_details;
|
||||
cw_Cfg_t * cfg;
|
||||
mavl_t remote_cfg;
|
||||
mavl_t local_cfg;
|
||||
mavl_t default_cfg;
|
||||
mavl_t global_cfg;
|
||||
struct cw_MsgSet * msgset;
|
||||
cw_Cfg_t * default_cfg;
|
||||
};
|
||||
|
||||
|
||||
@ -90,7 +87,9 @@ struct cw_MsgDef{
|
||||
|
||||
struct cw_ElemDef * elements;
|
||||
int (*preprocess)(struct conn * conn);
|
||||
int (*postprocess)(struct conn * conn);
|
||||
// int (*postprocess)(struct conn * conn);
|
||||
int (*postprocess)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||
|
||||
/* uint8_t next_state;*/
|
||||
};
|
||||
|
||||
@ -107,7 +106,8 @@ struct cw_MsgData{
|
||||
mlist_t mand_keys; /**< Keys of mandatory elements */
|
||||
|
||||
int (*preprocess)(struct conn * conn);
|
||||
int (*postprocess)(struct conn * conn);
|
||||
//int (*postprocess)(struct conn * conn);
|
||||
int (*postprocess)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||
/* uint8_t next_state;*/
|
||||
};
|
||||
|
||||
@ -141,4 +141,12 @@ struct cw_ElemHandler * cw_msgset_get_elemhandler(struct cw_MsgSet * set,
|
||||
int proto, int vendor, int id);
|
||||
|
||||
|
||||
#define CW_MSGSET_POSTPROCESS 1
|
||||
#define CW_MSGSET_PREPROCESS 2
|
||||
|
||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
||||
cw_MsgCallbackFun fun);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "mavltypes.h"
|
||||
|
||||
#include "bstr.h"
|
||||
#include "cfg.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -24,6 +23,8 @@
|
||||
|
||||
#define CW_KTV_MAX_KEY_LEN 1024
|
||||
|
||||
typedef struct mavl cw_Cfg_t;
|
||||
|
||||
/**
|
||||
* @struct cw_Val
|
||||
* @file ktv.h
|
||||
@ -93,7 +94,7 @@ struct cw_Type {
|
||||
int (*cast)(cw_Val_t *);
|
||||
|
||||
int (*read)(cw_Cfg_t *cfg, const char * key, const uint8_t *src, int len, const void * param);
|
||||
int (*write)(cw_Cfg_t *cfg, const char *key, const uint8_t *dst, const void * param);
|
||||
int (*write)(cw_Cfg_t *cfg, const char *key, uint8_t *dst, const void * param);
|
||||
|
||||
};
|
||||
typedef struct cw_Type cw_Type_t;
|
||||
@ -134,6 +135,7 @@ struct cw_ValEnum{
|
||||
const void * type;
|
||||
int (*fun_in)();
|
||||
int (*fun_out)();
|
||||
void *param;
|
||||
};
|
||||
typedef struct cw_ValEnum cw_ValEnum_t;
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#include "cw/mavltypes.h"
|
||||
|
||||
static int postprocess_join_request(struct cw_Conn *conn);
|
||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||
|
||||
|
||||
static cw_ValStruct_t wtp_reboot_statistics[] = {
|
||||
@ -335,10 +335,14 @@ static struct cw_ElemHandler handlers[] = {
|
||||
CAPWAP_ELEM_WTP_REBOOT_STATISTICS, /* Element ID */
|
||||
0,0, /* Vendor / Proto */
|
||||
15,15, /* min/max length */
|
||||
wtp_reboot_statistics, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"wtp-reboot-statistics", /* Key */
|
||||
cw_in_generic_struct, /* handler */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* handler */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
wtp_reboot_statistics
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -347,10 +351,14 @@ static struct cw_ElemHandler handlers[] = {
|
||||
CAPWAP_ELEM_RADIO_ADMINISTRATIVE_STATE, /* Element ID */
|
||||
0, 0, /* Vendor / Proto */
|
||||
2, 2, /* min/max length */
|
||||
radio_admin_state, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"admin-state", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
cw_out_radio_generic_struct /* put */
|
||||
cw_in_radio_generic, /* get */
|
||||
cw_out_radio_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
radio_admin_state, /* type */
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -772,14 +780,13 @@ static struct cw_MsgDef messages[] = {
|
||||
};
|
||||
|
||||
|
||||
static int postprocess_join_request(struct cw_Conn *conn)
|
||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
{
|
||||
cw_Val_t * result;
|
||||
|
||||
result = cw_ktv_get(conn->remote_cfg,"session-id",CW_TYPE_BSTR16);
|
||||
bstr16_t result;
|
||||
result = cw_cfg_get_bstr16(params->cfg,"session-id",NULL);
|
||||
if (result != NULL){
|
||||
conn->session_id = result->val.ptr;
|
||||
connlist_add_by_session_id(conn->connlist,conn);
|
||||
params->conn->session_id = result;
|
||||
connlist_add_by_session_id(params->conn->connlist,params->conn);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -9,6 +9,8 @@ int capwap_in_ac_descriptor(struct cw_ElemHandler *eh,
|
||||
struct cw_ElemHandlerParams *params,
|
||||
uint8_t * data, int len)
|
||||
{
|
||||
stop();
|
||||
|
||||
static struct cw_DescriptorSubelemDef allowed[] = {
|
||||
{0,CAPWAP_SUBELEM_AC_HARDWARE_VERSION, "hardware", 1024,1},
|
||||
{0,CAPWAP_SUBELEM_AC_SOFTWARE_VERSION, "software", 1024,1},
|
||||
@ -16,6 +18,6 @@ int capwap_in_ac_descriptor(struct cw_ElemHandler *eh,
|
||||
};
|
||||
|
||||
|
||||
return cw_read_ac_descriptor(params->remote_cfg,eh,params,data,len,allowed);
|
||||
return cw_read_ac_descriptor(params->cfg,eh,params,data,len,allowed);
|
||||
|
||||
}
|
||||
|
@ -23,24 +23,28 @@
|
||||
#include "cw/conn.h"
|
||||
#include "mod_capwap.h"
|
||||
|
||||
#include "cw/dbg.h"
|
||||
|
||||
int capwap_in_capwap_control_ip_address(struct cw_ElemHandler *eh,
|
||||
struct cw_ElemHandlerParams *params,
|
||||
uint8_t * data, int len)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
return 0;
|
||||
stop();
|
||||
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
int idx;
|
||||
|
||||
sprintf(key,"%s/address",eh->key);
|
||||
idx = cw_ktv_idx_get(params->remote_cfg,key);
|
||||
idx = cw_cfg_get_next_index(params->cfg,key);
|
||||
|
||||
/* printf("SKEY is %s , idx: %d\n",key,idx);*/
|
||||
|
||||
sprintf(key,"%s/address.%d",eh->key,idx+1);
|
||||
cw_ktv_add(params->remote_cfg,key,CW_TYPE_IPADDRESS,NULL,data,len-2);
|
||||
sprintf(key,"%s/address.%d",eh->key,idx);
|
||||
cw_ktv_add(params->cfg,key,CW_TYPE_IPADDRESS,NULL,data,len-2);
|
||||
|
||||
sprintf(key,"%s/wtps.%d",eh->key,idx+1);
|
||||
cw_ktv_add(params->remote_cfg,key,CW_TYPE_WORD,NULL,data+len-2,2);
|
||||
sprintf(key,"%s/wtps.%d",eh->key,idx);
|
||||
cw_ktv_add(params->cfg,key,CW_TYPE_WORD,NULL,data+len-2,2);
|
||||
|
||||
/* if (handler-id == CW_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS) {
|
||||
struct sockaddr_in addr;
|
||||
|
@ -56,45 +56,25 @@ static void readsubelems_wtp_board_data(mavl_t cfg, uint8_t * msgelem,
|
||||
return;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_SUBELEM, "WTP board data sub-element, type=%d, len=%d",
|
||||
subtype, sublen);
|
||||
/* cw_dbg(DBG_SUBELEM, "WTP board data sub-element, type=%d, len=%d",
|
||||
subtype, sublen);*/
|
||||
|
||||
switch (subtype) {
|
||||
|
||||
|
||||
case CW_BOARDDATA_MODELNO:
|
||||
/* mbag_set_bstrn(itemstore,
|
||||
CW_ITEM_WTP_BOARD_MODELNO,
|
||||
msgelem + i, sublen);
|
||||
*/
|
||||
key = "model-no";
|
||||
break;
|
||||
case CW_BOARDDATA_SERIALNO:
|
||||
/* mbag_set_bstrn(itemstore,
|
||||
CW_ITEM_WTP_BOARD_SERIALNO,
|
||||
msgelem + i, sublen);
|
||||
|
||||
*/
|
||||
key = "serial-no";
|
||||
break;
|
||||
case CW_BOARDDATA_MACADDRESS:
|
||||
/* mbag_set_bstrn(itemstore,
|
||||
CW_ITEM_WTP_BOARD_MACADDRESS,
|
||||
msgelem + i, sublen);
|
||||
*/
|
||||
key = "mac-address";
|
||||
break;
|
||||
case CW_BOARDDATA_BOARDID:
|
||||
/* mbag_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_ID,
|
||||
msgelem + i, sublen);
|
||||
*/
|
||||
key = "board-id";
|
||||
break;
|
||||
case CW_BOARDDATA_REVISION:
|
||||
/* mbag_set_bstrn(itemstore,
|
||||
CW_ITEM_WTP_BOARD_REVISION,
|
||||
msgelem + i, sublen);
|
||||
*/
|
||||
key = "revision";
|
||||
break;
|
||||
default:
|
||||
@ -102,9 +82,9 @@ static void readsubelems_wtp_board_data(mavl_t cfg, uint8_t * msgelem,
|
||||
break;
|
||||
}
|
||||
if (key != NULL){
|
||||
char add_key[256];
|
||||
char add_key[CW_CFG_MAX_KEY_LEN];
|
||||
sprintf(add_key,"wtp-board-data/%s",key);
|
||||
cw_ktv_add(cfg,add_key,CW_TYPE_BSTR16,NULL,msgelem+i,sublen);
|
||||
cw_cfg_set_val(cfg,add_key,CW_TYPE_BSTR16,NULL,msgelem+i,sublen);
|
||||
|
||||
}
|
||||
|
||||
@ -122,32 +102,12 @@ static void readsubelems_wtp_board_data(mavl_t cfg, uint8_t * msgelem,
|
||||
int capwap_in_wtp_board_data(struct cw_ElemHandler *eh, struct cw_ElemHandlerParams *params,
|
||||
uint8_t * data, int len)
|
||||
{
|
||||
char vendor_key[CW_CFG_MAX_KEY_LEN];
|
||||
|
||||
/*
|
||||
if (len < 4) {
|
||||
cw_dbg(DBG_ELEM_ERR,
|
||||
"Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d",
|
||||
a->elem_id, len);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
char vendor_key[128];
|
||||
mavl_t cfg = params->remote_cfg;
|
||||
|
||||
|
||||
sprintf(vendor_key,"%s/%s",eh->key,CW_SKEY_VENDOR);
|
||||
|
||||
cw_ktv_add(cfg,vendor_key,CW_TYPE_DWORD,NULL,data,len);
|
||||
|
||||
/*
|
||||
mbag_t itemstore = conn->incomming;
|
||||
mbag_set_dword(itemstore, CW_ITEM_WTP_BOARD_VENDOR, cw_get_dword(data));
|
||||
*/
|
||||
|
||||
readsubelems_wtp_board_data(cfg, data + 4, len - 4);
|
||||
sprintf(vendor_key,"%s/%s",eh->key,"vendor");
|
||||
cw_cfg_set_val(params->cfg,vendor_key,CW_TYPE_DWORD,NULL,data,len);
|
||||
|
||||
readsubelems_wtp_board_data(params->cfg, data + 4, len - 4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -19,15 +19,18 @@
|
||||
|
||||
#include "cw/sock.h"
|
||||
#include "cw/cw.h"
|
||||
#include "cw/dbg.h"
|
||||
|
||||
#include "mod_capwap.h"
|
||||
|
||||
int capwap_in_wtp_descriptor(struct cw_ElemHandler *eh, struct cw_ElemHandlerParams *params, uint8_t * data,
|
||||
int len)
|
||||
{
|
||||
stop();
|
||||
|
||||
int rc;
|
||||
/*rc =cw_read_wtp_descriptor(params->remote_cfg, params->conn, eh, data, len, NULL);*/
|
||||
rc =cw_read_wtp_descriptor(params->remote_cfg, NULL, eh, data, len, NULL);
|
||||
rc =cw_read_wtp_descriptor(params->cfg, NULL, eh, data, len, NULL);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
|
||||
static int put_ac_status(mavl_t global, mavl_t local, uint8_t *dst, const char * parent_key){
|
||||
|
||||
stop();
|
||||
|
||||
uint8_t *d = dst;
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
@ -58,16 +60,16 @@ int capwap_out_ac_descriptor(struct cw_ElemHandler * eh,
|
||||
uint8_t *d = dst+4;
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
d+=put_ac_status(params->local_cfg,
|
||||
params->global_cfg,
|
||||
d+=put_ac_status(params->cfg,
|
||||
params->default_cfg,
|
||||
d, eh->key);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CAPWAP_SUBELEM_AC_HARDWARE_VERSION, key);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CAPWAP_SUBELEM_AC_SOFTWARE_VERSION, key);
|
||||
|
||||
len = d-dst-4;
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
#include "cw/cw.h"
|
||||
#include "cw/dbg.h"
|
||||
#include "cw/cfg.h"
|
||||
|
||||
#include "mod_capwap.h"
|
||||
|
||||
/*
|
||||
@ -50,10 +52,12 @@ static int put_ip(uint8_t *dst void *priv, cw_acip_t * acip void *data)
|
||||
int capwap_out_capwap_control_ip_address(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
int i;
|
||||
int wtps;
|
||||
cw_Val_t * address;
|
||||
cw_Val_t address;
|
||||
const char *as;
|
||||
uint8_t *d;
|
||||
|
||||
d = dst;
|
||||
@ -63,17 +67,22 @@ int capwap_out_capwap_control_ip_address(struct cw_ElemHandler * eh,
|
||||
int l;
|
||||
|
||||
sprintf(key,"%s/address.%d",eh->key,i);
|
||||
address = cw_ktv_get(params->local_cfg,key,CW_TYPE_IPADDRESS);
|
||||
as = cw_cfg_get(params->conn->global_cfg,key,NULL);
|
||||
|
||||
|
||||
sprintf(key,"%s/wtps.%d",eh->key,i);
|
||||
wtps = cw_ktv_get_word(params->local_cfg,key,0);
|
||||
wtps = cw_cfg_get_word(params->conn->global_cfg,key,0);
|
||||
i++;
|
||||
if (address==NULL){
|
||||
if (as==NULL){
|
||||
break;
|
||||
}
|
||||
|
||||
/* msg = d;*/
|
||||
address.type=CW_TYPE_IPADDRESS;
|
||||
address.type->from_str(&address,as);
|
||||
|
||||
l = address->type->len(address);
|
||||
|
||||
l = address.type->len(&address);
|
||||
|
||||
switch(eh->id){
|
||||
case CAPWAP_ELEM_CAPWAP_CONTROL_IPV4_ADDRESS:
|
||||
@ -90,13 +99,15 @@ int capwap_out_capwap_control_ip_address(struct cw_ElemHandler * eh,
|
||||
continue;
|
||||
}
|
||||
|
||||
l = address->type->put(address,d+4);
|
||||
l = address.type->put(&address,d+4);
|
||||
l+=cw_put_word(dst+4+l,wtps);
|
||||
l+=cw_put_elem_hdr(d,eh->id,l);
|
||||
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,eh,d+4,l-4);
|
||||
// cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,eh,d+4,l-4);
|
||||
|
||||
d+=l;
|
||||
}while(address != NULL);
|
||||
|
||||
address.type->del(&address);
|
||||
}while(as != NULL);
|
||||
|
||||
|
||||
return d-dst;
|
||||
|
@ -1,17 +1,28 @@
|
||||
#include "cw/conn.h"
|
||||
#include "mod_capwap.h"
|
||||
#include "cw/cw.h"
|
||||
#include "cw/dbg.h"
|
||||
|
||||
int capwap_out_capwap_local_ip_address(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
cw_Val_t * ip;
|
||||
ip = cw_ktv_get(params->local_cfg,eh->key,CW_TYPE_IPADDRESS);
|
||||
if (ip==NULL){
|
||||
const char * ipstr;
|
||||
cw_Val_t ip;
|
||||
memset(&ip,0,sizeof(cw_Val_t));
|
||||
ip.type=CW_TYPE_IPADDRESS;
|
||||
|
||||
ipstr = cw_cfg_get(params->cfg,eh->key,NULL);
|
||||
if (ipstr==NULL){
|
||||
return 0;
|
||||
}
|
||||
return cw_put_local_ip_address(dst,eh->id,
|
||||
|
||||
ip.type->from_str(&ip,ipstr);
|
||||
|
||||
int rc = cw_put_local_ip_address(dst,eh->id,
|
||||
CAPWAP_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS,
|
||||
CAPWAP_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS,
|
||||
ip->type->data(ip),ip->type->len(ip));
|
||||
ip.type->data(&ip),ip.type->len(&ip));
|
||||
|
||||
ip.type->del(&ip);
|
||||
return rc;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "cw/msgset.h"
|
||||
#include "cw/keys.h"
|
||||
#include "cw/cw.h"
|
||||
|
||||
#include "cw/dbg.h"
|
||||
|
||||
static int write_boarddata_subelem(uint8_t * dst, mavl_t ktv, const char * parent_key,
|
||||
const char *skey, int type){
|
||||
@ -40,6 +40,8 @@ static int write_boarddata_subelem(uint8_t * dst, mavl_t ktv, const char * paren
|
||||
int capwap_out_wtp_board_data(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
stop();
|
||||
|
||||
cw_Val_t * val;
|
||||
mavl_t cfg;
|
||||
uint8_t * d;
|
||||
@ -48,7 +50,7 @@ int capwap_out_wtp_board_data(struct cw_ElemHandler * eh,
|
||||
|
||||
d=dst+4;
|
||||
|
||||
cfg = params->local_cfg;
|
||||
cfg = params->cfg;
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_VENDOR);
|
||||
val = cw_ktv_get(cfg,key,CW_TYPE_DWORD);
|
||||
|
@ -8,6 +8,8 @@
|
||||
|
||||
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
||||
{
|
||||
stop();
|
||||
|
||||
int n=2;
|
||||
int i;
|
||||
|
||||
@ -36,7 +38,7 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
d = dst+4;
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_MAX_RADIOS);
|
||||
val = cw_ktv_get(params->local_cfg,key, CW_TYPE_BYTE);
|
||||
val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
|
||||
if (val != NULL)
|
||||
d+=val->type->put(val,d);
|
||||
else{
|
||||
@ -45,7 +47,7 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
}
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
|
||||
val = cw_ktv_get(params->local_cfg,key, CW_TYPE_BYTE);
|
||||
val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
|
||||
if (val != NULL){
|
||||
d+=val->type->put(val,d);
|
||||
}
|
||||
@ -62,17 +64,17 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
|
||||
/* hardware version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CW_SUBELEM_WTP_HARDWARE_VERSION, key);
|
||||
|
||||
/* software version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CW_SUBELEM_WTP_SOFTWARE_VERSION, key);
|
||||
|
||||
/* bootloader version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CW_SUBELEM_WTP_BOOTLOADER_VERSION, key);
|
||||
|
||||
len = d-dst-4;
|
||||
|
@ -77,9 +77,9 @@ static cw_ValStruct_t cisco_8021xlogin[] = {
|
||||
|
||||
|
||||
static cw_ValEnum_t cisco_ap_username_and_password_enum[] ={
|
||||
{2, "802.1x-credentials", cisco_8021xlogin, cw_in_generic_struct, cw_ktv_write_struct },
|
||||
{2, "802.1x-credentials", CW_TYPE_STRUCT, cw_in_generic, cw_out_generic, cisco_8021xlogin },
|
||||
|
||||
{1, "login-credentials", cisco_login, cw_in_generic_struct, cw_ktv_write_struct },
|
||||
{1, "login-credentials", CW_TYPE_STRUCT, cw_in_generic, cw_out_generic, cisco_login },
|
||||
|
||||
{0,0,0,0}
|
||||
};
|
||||
@ -120,6 +120,7 @@ static cw_ValIndexed_t cisco_ap_telnet_ssh = {
|
||||
};
|
||||
|
||||
static cw_ValStruct_t cisco_multi_domain_cabability[]={
|
||||
{CW_TYPE_BYTE, "radio-id", 1, -1},
|
||||
{CW_TYPE_BYTE, "reserved", 1, -1},
|
||||
{CW_TYPE_WORD, "first-channel", 2, -1},
|
||||
{CW_TYPE_WORD, "number-of-channels", 2, -1},
|
||||
@ -190,7 +191,8 @@ static cw_ValStruct_t cisco_ap_regulatory_domain5[]={
|
||||
};
|
||||
|
||||
|
||||
static cw_ValStruct_t cisco_mac_operation73[]={
|
||||
static cw_ValStruct_t cisco_mac_operation70[]={
|
||||
{CW_TYPE_BYTE,"radio-id",1,-1},
|
||||
{CW_TYPE_BYTE,"reserved",1,-1},
|
||||
{CW_TYPE_WORD,"rts-threshold",2,-1},
|
||||
{CW_TYPE_BYTE,"short-retry",1,-1},
|
||||
@ -225,19 +227,20 @@ 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];
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
int idx;
|
||||
void * type;
|
||||
|
||||
idx = cw_ktv_idx_get(params->remote_cfg,eh->key);
|
||||
idx = cw_cfg_get_next_index(params->cfg,eh->key);
|
||||
|
||||
sprintf(key,"%s.%d",eh->key,idx+1);
|
||||
sprintf(key,"%s.%d",eh->key,idx);
|
||||
|
||||
if(len==4)
|
||||
type = cisco_ap_regulatory_domain4;
|
||||
if(len==5)
|
||||
type = cisco_ap_regulatory_domain5;
|
||||
cw_ktv_read_struct(params->remote_cfg,type,key,data,len);
|
||||
// cw_ktv_read_struct(params->cfg,type,key,data,len);
|
||||
CW_TYPE_STRUCT->read(params->cfg,key,data,len,type);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -256,12 +259,15 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
|
||||
uint8_t * ob;
|
||||
|
||||
|
||||
stop();
|
||||
|
||||
idx = 0;
|
||||
ob = dst;
|
||||
|
||||
stop();
|
||||
|
||||
type = NULL;
|
||||
result = cw_ktv_get(params->local_cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16);
|
||||
result = cw_ktv_get(params->cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16);
|
||||
if (result!=NULL){
|
||||
if(result->type->len(result)==4){
|
||||
uint32_t rv;
|
||||
@ -280,7 +286,7 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
|
||||
do {
|
||||
sprintf(key,"%s.%d",eh->key,idx);
|
||||
search.key=key;
|
||||
result = mavl_get_first(params->local_cfg,&search);
|
||||
result = mavl_get_first(params->cfg,&search);
|
||||
if (result==NULL)
|
||||
break;
|
||||
if (strncmp(result->key,key,strlen(key))!=0)
|
||||
@ -288,7 +294,8 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
|
||||
|
||||
if(type == NULL){
|
||||
sprintf(testkey,"%s/%s",key,"band-id");
|
||||
result = cw_ktv_get(params->local_cfg,key,CW_TYPE_BYTE);
|
||||
stop();
|
||||
result = cw_ktv_get(params->cfg,key,CW_TYPE_BYTE);
|
||||
if (result==NULL){
|
||||
type = cisco_ap_regulatory_domain4;
|
||||
}
|
||||
@ -298,7 +305,8 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
|
||||
}
|
||||
|
||||
start = params->msgset->header_len(eh);
|
||||
len = cw_ktv_write_struct(params->local_cfg,NULL,type,key,ob+start);
|
||||
stop();
|
||||
len = cw_ktv_write_struct(params->cfg,NULL,type,key,ob+start);
|
||||
ob += params->msgset->write_header(eh,ob,len);
|
||||
|
||||
idx++;
|
||||
@ -328,6 +336,7 @@ static cw_ValStruct_t cisco_direct_sequence_control70[]={
|
||||
};
|
||||
|
||||
static cw_ValStruct_t cisco_antenna_payload70[]={
|
||||
{CW_TYPE_BYTE,"radio-id",1,-1},
|
||||
{CW_TYPE_BYTE,"diversity-selection",1,-1},
|
||||
{CW_TYPE_BYTE,"antenna-mode",1,-1},
|
||||
{CW_TYPE_BYTE,"number-of-antennas",1,-1},
|
||||
@ -341,6 +350,7 @@ static cw_ValStruct_t cisco_antenna_payload70[]={
|
||||
|
||||
|
||||
static cw_ValStruct_t cisco_wtp_radio_config70[]={
|
||||
{CW_TYPE_BYTE,"radio-id",1,-1},
|
||||
{CW_TYPE_BYTE,"cfg-type",1,-1},
|
||||
{CW_TYPE_WORD,"occupancy-limit",2,-1},
|
||||
{CW_TYPE_BYTE,"cfg-period",1,-1},
|
||||
@ -461,6 +471,15 @@ static cw_ValStruct_t cisco_rouge_and_mss[]={
|
||||
{NULL,NULL,0,0}
|
||||
};
|
||||
|
||||
|
||||
static cw_ValStruct_t cisco_rouge_detection70[]={
|
||||
{CW_TYPE_BOOL,"rouge-detection",1,-1},
|
||||
{CW_TYPE_BSTR16,"rest",4,-1},
|
||||
{NULL,NULL,0,0}
|
||||
};
|
||||
|
||||
|
||||
|
||||
static cw_ValStruct_t cisco_rouge_detections[]={
|
||||
{CW_TYPE_BOOL,"rouge-detection",1,-1},
|
||||
{CW_TYPE_BSTR16,"rest",6,-1},
|
||||
@ -536,23 +555,33 @@ static int cisco_in_lw_del_wlan(struct cw_ElemHandler *eh,
|
||||
struct cw_ElemHandlerParams *params,
|
||||
uint8_t * data, int len)
|
||||
{
|
||||
stop();
|
||||
|
||||
int wlan_id, radio_id;
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
radio_id=cw_get_byte(data);
|
||||
wlan_id=cw_get_word(data+1);
|
||||
sprintf(key,"radio.%d/wlan.%d",radio_id,wlan_id);
|
||||
cw_ktv_del_sub(params->local_cfg,key);
|
||||
cw_ktv_del_sub(params->cfg,key);
|
||||
cw_dbg(DBG_INFO,"Del WLAN rid=%d, id=%d",wlan_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int cw_mkradiokey(const char *pkey, uint8_t*data, int len, char *dst)
|
||||
{
|
||||
int radio_id;
|
||||
radio_id = cw_get_byte(data);
|
||||
sprintf(dst,"radio.%d/%s",radio_id,pkey);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *dst)
|
||||
{
|
||||
int wlan_id,radio_id;
|
||||
|
||||
stop();
|
||||
radio_id = cw_get_byte(data);
|
||||
wlan_id = cw_get_byte(data+3);
|
||||
sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id);
|
||||
@ -563,7 +592,7 @@ static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *d
|
||||
static int cisoc_add_wlan_mkkey70(const char *pkey, uint8_t*data, int len, char *dst)
|
||||
{
|
||||
int wlan_id,radio_id;
|
||||
|
||||
stop();
|
||||
radio_id = cw_get_byte(data);
|
||||
wlan_id = cw_get_byte(data+4);
|
||||
sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id);
|
||||
@ -572,6 +601,7 @@ static int cisoc_add_wlan_mkkey70(const char *pkey, uint8_t*data, int len, char
|
||||
|
||||
static int cisco_patch_add_wlan70(uint8_t * data, void * st)
|
||||
{
|
||||
stop();
|
||||
int * stack = st;
|
||||
cw_set_byte(data,stack[1]);
|
||||
cw_set_byte(data+3, stack[2]);
|
||||
@ -619,7 +649,7 @@ static cw_ValStruct_t cisco_capwap_timers[] = {
|
||||
static int cisoc_add_lwwlan_mkkey(const char *pkey, uint8_t*data, int len, char *dst)
|
||||
{
|
||||
int wlan_id,radio_id;
|
||||
|
||||
stop();
|
||||
radio_id = cw_get_byte(data);
|
||||
wlan_id = cw_get_byte(data+1);
|
||||
sprintf(dst,"radio.%d/wlan.%d/add-lw-wlan",radio_id,wlan_id);
|
||||
@ -628,6 +658,7 @@ static int cisoc_add_lwwlan_mkkey(const char *pkey, uint8_t*data, int len, char
|
||||
|
||||
static int cisco_patch_add_lwwlan(uint8_t * data, void * st)
|
||||
{
|
||||
stop();
|
||||
int * stack = st;
|
||||
cw_set_byte(data,stack[1]);
|
||||
cw_set_byte(data+1, stack[2]);
|
||||
@ -710,7 +741,7 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
0,0, /* Vendor / Proto */
|
||||
0,CAPWAP_MAX_AC_NAME_LEN, /* min/max length */
|
||||
CW_TYPE_BSTR16, /* type */
|
||||
"ac-name", /* Key */
|
||||
"capwap/ac-name", /* Key */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic /* put */
|
||||
}
|
||||
@ -770,10 +801,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_TIMESYNC, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
5,5, /* min/max length */
|
||||
ap_time_sync, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-timesync", /* Key */
|
||||
cw_in_generic_struct, /* handler */
|
||||
cisco_out_ap_timesync /* put */
|
||||
cw_in_generic, /* handler */
|
||||
cisco_out_ap_timesync, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
ap_time_sync
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -828,10 +863,13 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_MWAR_ADDR, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
7,7, /* min/max length */
|
||||
mwar_addr, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/mwar-addr", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
mwar_addr
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -873,10 +911,13 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_LWELEM_PATH_MTU, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
|
||||
0,0, /* min/max length */
|
||||
cisco_lw_path_mtu, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/lw-path-mtu", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cisco_out_lw_path_mtu /* put */
|
||||
cw_in_generic, /* get */
|
||||
cisco_out_lw_path_mtu, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_lw_path_mtu,
|
||||
}
|
||||
,
|
||||
|
||||
@ -885,10 +926,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_UPTIME, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
8,8, /* min/max length */
|
||||
cisco_ap_uptime, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-uptime", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_uptime,
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -900,7 +945,9 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
&cisco_ap_username_and_password, /* type */
|
||||
"cisco/ap-username-and-password", /* Key */
|
||||
cw_in_generic_indexed_enum, /* get */
|
||||
cw_out_generic_indexed_enum /* put */
|
||||
cw_out_generic_indexed_enum, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -908,10 +955,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_LWELEM_AP_LOGHOST_CONFIG, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
|
||||
36,36, /* min/max length */
|
||||
cisco_loghost_config, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/loghost-config", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_loghost_config, /* type */
|
||||
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -919,10 +970,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_LED_STATE_CONFIG, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
1,1, /* min/max length */
|
||||
cisco_ap_led_state_config70, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-led-state-config", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_led_state_config70
|
||||
|
||||
}
|
||||
,
|
||||
{
|
||||
@ -952,10 +1007,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_MULTI_DOMAIN_CAPABILITY, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
8,8, /* min/max length */
|
||||
cisco_multi_domain_cabability, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/multi-domain-capability", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
NULL /* put */
|
||||
cw_in_generic, /* get */
|
||||
NULL, /* put */
|
||||
cw_mkradiokey,
|
||||
NULL,
|
||||
cisco_multi_domain_cabability,
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -964,20 +1023,27 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_WTP_BOARD_DATA, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
8,48, /* min/max length */
|
||||
cisco_wtp_board_data, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/wtp-board-data", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_wtp_board_data,
|
||||
},
|
||||
{
|
||||
"AP LED Flash Config", /* name */
|
||||
CISCO_ELEM_AP_LED_FLASH_CONFIG, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
0,48, /* min/max length */
|
||||
cisco_ap_led_flash_config, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-led-flash-config", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_led_flash_config
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -996,10 +1062,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_POWER_INJECTOR_CONFIG, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
8,8, /* min/max length */
|
||||
cisco_ap_power_injector_config, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-power-injector-config", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_power_injector_config
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1007,10 +1077,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_MODE_AND_TYPE, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
2,2, /* min/max length */
|
||||
cisco_ap_mode_and_type, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-mode-and-type", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_mode_and_type,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1028,10 +1102,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_STATIC_IP_ADDR, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
17,17, /* min/max length */
|
||||
cisco_ap_static_ip_addr, /* type */
|
||||
"cisco/ap-satic-ip-addr", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-static-ip-addr", /* Key */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_static_ip_addr,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1085,10 +1163,13 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_AP_MODEL, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
60,60, /* min/max length */
|
||||
cisco_ap_model, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/ap-model", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_ap_model,
|
||||
},
|
||||
|
||||
{
|
||||
@ -1104,14 +1185,18 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
|
||||
{ /* WTP Radio Configuration for AC/WPT with version 7.0 */
|
||||
|
||||
"WTP Radio Configuration (v7.3)", /* name */
|
||||
"WTP Radio Configuration (v7.0)", /* name */
|
||||
CISCO_ELEM_WTP_RADIO_CONFIGURATION, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
25,25, /* min/max length */
|
||||
cisco_wtp_radio_config70, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/wtp-radio-config", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
cw_out_radio_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic, /* put */
|
||||
cw_mkradiokey,
|
||||
NULL,
|
||||
cisco_wtp_radio_config70,
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -1134,10 +1219,15 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CW_CISCO_ANTENNA_PAYLOAD, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
9,9, /* min/max length */
|
||||
cisco_antenna_payload70, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/antenna-payload", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
cw_out_radio_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_radio_generic_struct, /* put */
|
||||
cw_mkradiokey,
|
||||
NULL,
|
||||
cisco_antenna_payload70,
|
||||
|
||||
|
||||
}
|
||||
,
|
||||
|
||||
@ -1153,14 +1243,19 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
},
|
||||
|
||||
{
|
||||
"Mac Operation", /* name */
|
||||
"Mac Operation (7.0)", /* name */
|
||||
CISCO_ELEM_MAC_OPERATION, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
16,16, /* min/max length */
|
||||
cisco_mac_operation73, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/mac-operation", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
cw_out_radio_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_radio_generic_struct, /* put */
|
||||
cw_mkradiokey,
|
||||
NULL,
|
||||
cisco_mac_operation70,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1168,10 +1263,14 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_TX_POWER, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
4,4, /* min/max length */
|
||||
cisco_tx_power, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/tx-power", /* Key */
|
||||
cw_in_radio_generic_struct, /* get */
|
||||
cw_out_radio_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_radio_generic_struct, /* put */
|
||||
cw_mkradiokey,
|
||||
NULL,
|
||||
cisco_tx_power,
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1181,8 +1280,12 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
5,150, /* min/max length */
|
||||
CW_TYPE_BSTR16, /* type */
|
||||
"cisco/tx-power-levels", /* Key */
|
||||
cw_in_radio_generic, /* get */
|
||||
cw_out_radio_generic /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_radio_generic, /* put */
|
||||
cw_mkradiokey,
|
||||
NULL,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1422,23 +1525,29 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_LWELEM_TCP_ADJUST_MSS, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
|
||||
3,3, /* min/max length */
|
||||
cisco_rouge_and_mss, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/rouge-and-mss", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_rouge_and_mss,
|
||||
}
|
||||
,
|
||||
|
||||
|
||||
{
|
||||
"Rouge Detection", /* name */
|
||||
"Rouge Detection 7.0", /* name */
|
||||
CISCO_LWELEM_ROUGE_DETECTION, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
|
||||
7,7, /* min/max length */
|
||||
cisco_rouge_detections, /* type */
|
||||
5,5, /* min/max length */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/rouge-detection", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_rouge_detection70,
|
||||
}
|
||||
,
|
||||
|
||||
@ -1537,10 +1646,15 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_LWELEM_DISCOVERY_PROTOCOL, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
|
||||
3,3, /* min/max length */
|
||||
cisco_discovery_protocol, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"cisco/cisco-discovery-protocol", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic_struct, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_discovery_protocol,
|
||||
|
||||
|
||||
},
|
||||
|
||||
{
|
||||
@ -1559,10 +1673,13 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CISCO_ELEM_CAPWAP_TIMERS, /* Element ID */
|
||||
0, 0, /* Vendor / Proto */
|
||||
2, 2, /* min/max length */
|
||||
cisco_capwap_timers, /* type */
|
||||
CW_TYPE_STRUCT, /* type */
|
||||
"capwap-timers", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic, /* put */
|
||||
NULL,
|
||||
NULL,
|
||||
cisco_capwap_timers, /* param */
|
||||
}
|
||||
,
|
||||
|
||||
@ -2048,6 +2165,19 @@ static struct cw_MsgDef messages70[] = {
|
||||
};
|
||||
|
||||
static struct cw_ElemHandler handlers73[] = {
|
||||
{
|
||||
"Rouge Detection (>=7.3)", /* name */
|
||||
CISCO_LWELEM_ROUGE_DETECTION, /* Element ID */
|
||||
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
|
||||
7,7, /* min/max length */
|
||||
cisco_rouge_detections, /* type */
|
||||
"cisco/rouge-detection", /* Key */
|
||||
cw_in_generic_struct, /* get */
|
||||
cw_out_generic_struct /* put */
|
||||
}
|
||||
|
||||
,
|
||||
|
||||
{
|
||||
"AP LED State Config (>= v7.3)", /* name */
|
||||
CISCO_ELEM_AP_LED_STATE_CONFIG, /* Element ID */
|
||||
@ -2142,7 +2272,9 @@ static cw_StateMachineState_t statemachine_states[]={
|
||||
};
|
||||
|
||||
|
||||
static int (*postprocess_join_request_parent)(struct cw_Conn * conn);
|
||||
//static int (*postprocess_join_request_parent)(struct cw_Conn * conn);
|
||||
static int (*postprocess_join_request_parent)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||
|
||||
struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode){
|
||||
|
||||
struct cw_MsgData * md;
|
||||
@ -2162,48 +2294,52 @@ struct cw_MsgSet * cisco_register_msg_set(struct cw_MsgSet * set, int mode){
|
||||
|
||||
|
||||
|
||||
static void set_ac_version(struct cw_Conn * conn)
|
||||
static void set_ac_version(struct cw_ElemHandlerParams * params)
|
||||
{
|
||||
cw_Val_t * wtpver;
|
||||
bstr16_t wtpver;
|
||||
char verstr[512];
|
||||
wtpver = cw_ktv_get(conn->remote_cfg,"wtp-descriptor/software/version", CW_TYPE_BSTR16);
|
||||
if (wtpver){
|
||||
wtpver = cw_cfg_get_bstr16(params->cfg,"wtp-descriptor/software/version",NULL);
|
||||
if (wtpver==NULL)
|
||||
return;
|
||||
|
||||
cw_format_version(verstr,wtpver->type->data(wtpver),wtpver->type->len(wtpver));
|
||||
cw_format_version(verstr,bstr16_data(wtpver),bstr16_len(wtpver));
|
||||
cw_dbg(DBG_INFO, "Cisco - Setting AC software version to: %s", verstr);
|
||||
|
||||
mavl_del(conn->local_cfg,&wtpver);
|
||||
cw_ktv_add(conn->local_cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16, NULL,
|
||||
wtpver->type->data(wtpver),wtpver->type->len(wtpver));
|
||||
cw_cfg_set_bstr16(params->conn->local_cfg,"ac-descriptor/software/version",wtpver);
|
||||
cw_cfg_set_int(params->conn->local_cfg,"ac-descriptor/software/vendor",CW_VENDOR_ID_CISCO);
|
||||
|
||||
if(wtpver->type->len(wtpver)==4){
|
||||
if(bstr16_len(wtpver)==4){
|
||||
uint32_t rv;
|
||||
rv = cw_get_dword(wtpver->type->data(wtpver));
|
||||
rv = cw_get_dword(bstr16_data(wtpver));
|
||||
|
||||
if (rv >= 0x07030000){
|
||||
cw_msgset_add(conn->msgset,messages73, handlers73);
|
||||
cw_msgset_add(params->msgset,messages73, handlers73);
|
||||
}
|
||||
if (rv >= 0x07056600){
|
||||
cw_msgset_add(conn->msgset,messages75, handlers75);
|
||||
}
|
||||
}
|
||||
cw_msgset_add(params->msgset,messages75, handlers75);
|
||||
}
|
||||
}
|
||||
|
||||
static int postprocess_discovery(struct cw_Conn *conn)
|
||||
free(wtpver);
|
||||
}
|
||||
|
||||
static int postprocess_discovery(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
//static int postprocess_discovery(struct cw_Conn *conn)
|
||||
{
|
||||
if (conn->role == CW_ROLE_AC ){
|
||||
set_ac_version(conn);
|
||||
cw_detect_nat(conn);
|
||||
if (params->conn->role == CW_ROLE_AC ){
|
||||
set_ac_version(params);
|
||||
cw_detect_nat(params);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int postprocess_join_request(struct cw_Conn *conn)
|
||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
//static int postprocess_join_request(struct cw_Conn *conn)
|
||||
{
|
||||
if (postprocess_join_request_parent!=NULL){
|
||||
postprocess_join_request_parent(conn);
|
||||
postprocess_join_request_parent(params,elems_ptr,elems_len);
|
||||
}
|
||||
postprocess_discovery(conn);
|
||||
postprocess_discovery(params,elems_ptr,elems_len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -2216,6 +2352,8 @@ static int preprocess_join_request(struct cw_Conn *conn)
|
||||
if (conn->role != CW_ROLE_WTP)
|
||||
return 0;
|
||||
|
||||
stop();
|
||||
|
||||
use_ac_version = cw_ktv_get_bool(conn->local_cfg,"cisco/wtp-use-ac-version",0);
|
||||
|
||||
if (use_ac_version){
|
||||
|
@ -15,7 +15,7 @@ int cisco_in_ac_descriptor(struct cw_ElemHandler *eh,
|
||||
{0,0, NULL,0, 0}
|
||||
};
|
||||
|
||||
return cw_read_ac_descriptor(params->remote_cfg,eh,params,data,len,allowed);
|
||||
return cw_read_ac_descriptor(params->cfg,eh,params,data,len,allowed);
|
||||
|
||||
|
||||
/*return cw_read_ac_descriptor(conn->config,data,len,allowed);*/
|
||||
|
@ -8,6 +8,7 @@
|
||||
int cisco_in_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from)
|
||||
{
|
||||
stop();
|
||||
|
||||
cw_dbg(DBG_X,"This is radio admin statie in for Cisco");
|
||||
|
||||
|
@ -12,20 +12,19 @@
|
||||
#include "cw/cfg.h"
|
||||
|
||||
|
||||
static int put_ac_status(cw_Cfg_t * cfg, cw_Cfg_t * default_cfg, uint8_t *dst, const char * parent_key){
|
||||
static int put_ac_status(cw_Cfg_t * cfg1, cw_Cfg_t * cfg2, uint8_t *dst, const char * parent_key){
|
||||
|
||||
uint8_t *d = dst;
|
||||
uint8_t security;
|
||||
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
|
||||
d += cw_put_word(d,cw_dget(cw_cfg_get_word,cfg1,cfg2,"ac-descriptor/stations",0));
|
||||
d += cw_put_word(d,cw_dget(cw_cfg_get_word,cfg1,cfg2,"ac-descriptor/station-limit",0));
|
||||
d += cw_put_word(d,cw_dget(cw_cfg_get_word,cfg1,cfg2,"ac-descriptor/active-wtps",0));
|
||||
d += cw_put_word(d,cw_dget(cw_cfg_get_word,cfg1,cfg2,"ac-descriptor/max-wtps",0));
|
||||
|
||||
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/stations","0"));
|
||||
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/station-limit","0"));
|
||||
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/active-wtps","0"));
|
||||
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/max-wtps","0"));
|
||||
|
||||
d += cw_put_byte(d,cw_cfg_get_byte(cfg,"ac-descriptor/security",0));
|
||||
d += cw_put_byte(d,cw_dget(cw_cfg_get_byte,cfg1,cfg2,"ac-descriptor/security",0));
|
||||
/*
|
||||
security = 0;
|
||||
if (cw_ktv_get(local,"dtls-cert-file",CW_TYPE_BSTR16))
|
||||
@ -40,14 +39,14 @@ static int put_ac_status(cw_Cfg_t * cfg, cw_Cfg_t * default_cfg, uint8_t *dst, c
|
||||
d += cw_put_byte(dst,security);
|
||||
*/
|
||||
sprintf(key,"%s/%s",parent_key,"ac-descriptor/r-mac-field");
|
||||
d += cw_put_byte(d,cw_cfg_get_byte(cfg,"ac-descriptor/r-mac-field",0));
|
||||
d += cw_put_byte(d,cw_dget(cw_cfg_get_byte,cfg1,cfg2,"ac-descriptor/r-mac-field",0));
|
||||
/*d += cw_put_byte(d,3);*/
|
||||
|
||||
d += cw_put_byte(d,0);
|
||||
|
||||
|
||||
sprintf(key,"%s/%s",parent_key,CW_SKEY_DTLS_POLICY);
|
||||
d += cw_put_byte(d,cw_cfg_get_byte(cfg,"ac-descriptor/dtls-policy",0));
|
||||
d += cw_put_byte(d,cw_dget(cw_cfg_get_byte,cfg1,cfg2,"ac-descriptor/dtls-policy",0));
|
||||
|
||||
return d - dst;
|
||||
}
|
||||
@ -60,20 +59,18 @@ int cisco_out_ac_descriptor(struct cw_ElemHandler * eh,
|
||||
uint8_t *d = dst+4;
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
|
||||
cw_dbg(DBG_X,"Putting AC TATUS WIITH KEY: %s",eh->key);
|
||||
|
||||
d+=put_ac_status(params->cfg,
|
||||
params->default_cfg,
|
||||
d+=put_ac_status(params->conn->local_cfg,
|
||||
params->conn->global_cfg,
|
||||
d, eh->key);
|
||||
|
||||
/* it is important to send software version first,
|
||||
* because APs don't check the type */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg,
|
||||
1, key);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg,
|
||||
0, key);
|
||||
|
||||
|
||||
|
@ -2,12 +2,16 @@
|
||||
|
||||
#include "mod_cisco.h"
|
||||
#include "cw/cw.h"
|
||||
#include "cw/dbg.h"
|
||||
|
||||
|
||||
int cisco_out_capwap_local_ip_address(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
stop();
|
||||
|
||||
cw_Val_t * ip;
|
||||
ip = cw_ktv_get(params->local_cfg,eh->key,CW_TYPE_IPADDRESS);
|
||||
ip = cw_ktv_get(params->cfg,eh->key,CW_TYPE_IPADDRESS);
|
||||
if (ip==NULL){
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "cw/lw.h"
|
||||
#include "cw/cw.h"
|
||||
#include "cw/dbg.h"
|
||||
#include "cw/cfg.h"
|
||||
|
||||
#include "capwap_cisco.h"
|
||||
#include "mod_cisco.h"
|
||||
@ -9,15 +11,16 @@
|
||||
int cisco_out_lw_path_mtu(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
char key[CW_CFG_MAX_KEY_LEN];
|
||||
int len,max;
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,"len");
|
||||
len = cw_ktv_get_word(params->local_cfg,key,0);
|
||||
len = cw_cfg_get_word(params->cfg,key,0);
|
||||
if (len == 0)
|
||||
return 0;
|
||||
sprintf(key,"%s/%s",eh->key,"max");
|
||||
max = cw_ktv_get_word(params->local_cfg,key,0);
|
||||
max = cw_cfg_get_word(params->cfg,key,0);
|
||||
|
||||
lw_set_word(dst+16,max);
|
||||
lw_set_word(dst+16+2,len);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "cw/cw.h"
|
||||
#include "cw/dbg.h"
|
||||
#include "cw/cfg.h"
|
||||
|
||||
#include "mod_cisco.h"
|
||||
|
||||
@ -9,15 +10,16 @@
|
||||
int cisco_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||
, uint8_t * dst)
|
||||
{
|
||||
|
||||
int len,i,l;
|
||||
int radios;
|
||||
len =0;
|
||||
|
||||
radios = cw_ktv_get_byte(params->local_cfg,"wtp-descriptor/max-radios",0);
|
||||
radios = cw_cfg_get_byte(params->cfg,"wtp-descriptor/max-radios","0");
|
||||
|
||||
for(i=0;i<radios+0;i++){
|
||||
l = cw_write_radio_element(handler,params,i,dst+len);
|
||||
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,handler,dst+len,l);
|
||||
// cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,handler,dst+len,l);
|
||||
len+=l;
|
||||
}
|
||||
return len;
|
||||
|
@ -7,6 +7,9 @@
|
||||
int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
|
||||
stop();
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
int len;
|
||||
/* // XXX Dummy WTP Descriptor Header */
|
||||
@ -16,7 +19,7 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
d = dst+4;
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_MAX_RADIOS);
|
||||
val = cw_ktv_get(params->local_cfg,key, CW_TYPE_BYTE);
|
||||
val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
|
||||
if (val != NULL)
|
||||
d+=val->type->put(val,d);
|
||||
else{
|
||||
@ -25,7 +28,7 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
}
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
|
||||
val = cw_ktv_get(params->local_cfg,key, CW_TYPE_BYTE);
|
||||
val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
|
||||
if (val != NULL){
|
||||
d+=val->type->put(val,d);
|
||||
}
|
||||
@ -38,17 +41,17 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
|
||||
|
||||
/* hardware version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CW_SUBELEM_WTP_HARDWARE_VERSION, key);
|
||||
|
||||
/* software version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CW_SUBELEM_WTP_SOFTWARE_VERSION, key);
|
||||
|
||||
/* bootloader version sub element */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER);
|
||||
d+=cw_write_descriptor_subelem (d, params->local_cfg,
|
||||
d+=cw_write_descriptor_subelem (d, params->cfg,
|
||||
CW_SUBELEM_WTP_BOOTLOADER_VERSION, key);
|
||||
|
||||
len = d-dst-4;
|
||||
|
@ -60,10 +60,10 @@ static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
|
||||
capwap_mod->register_messages(set, CW_MOD_MODE_CAPWAP);
|
||||
capwap80211_mod->register_messages(set, CW_MOD_MODE_BINDINGS);
|
||||
cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
|
||||
|
||||
set->write_header = write_header;
|
||||
set->header_len = header_len;
|
||||
|
||||
|
||||
/* cw_dbg(DBG_MOD,"Cisco: loading cisco message set");*/
|
||||
|
||||
/* cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);*/
|
||||
@ -228,11 +228,11 @@ int static setup_cfg(struct cw_Conn * conn)
|
||||
conn->write_header=write_header;
|
||||
conn->header_len=header_len;
|
||||
|
||||
security = cw_setup_dtls(conn,conn->local_cfg,"cisco",CAPWAP_CIPHER);
|
||||
security = cw_setup_dtls(conn,conn->global_cfg,"cisco",CAPWAP_CIPHER);
|
||||
cw_cfg_set_int(conn->local_cfg,"ac-descriptor/security",security);
|
||||
|
||||
if (conn->default_cfg==NULL){
|
||||
conn->default_cfg=cw_ktv_create();
|
||||
conn->default_cfg=cw_cfg_create();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user