Some work on wtp and ktv config files

FossilOrigin-Name: 3747732055809fd587f96cff65c389a0878a09a197947c1e68a76f605bdb44a0
This commit is contained in:
7u83@mail.ru 2018-03-12 10:22:06 +00:00
parent 27869b8c11
commit d6133e0434
74 changed files with 775 additions and 565 deletions

View File

@ -41,7 +41,6 @@
<File Name="src/cw/dtls_bio.c"/>
<File Name="src/cw/rand.h"/>
<File Name="src/cw/capwap_items.h"/>
<File Name="src/cw/acinfo_print.c"/>
<File Name="src/cw/mbag_type_bstr.c"/>
<File Name="src/cw/cw_in_cisco_image_identifier.c"/>
<File Name="src/cw/radioinfo.h"/>
@ -77,7 +76,6 @@
<File Name="src/cw/mavliter_next.c"/>
<File Name="src/cw/lw_msg_id_to_str.c"/>
<File Name="src/cw/lw_put_cisco_path_mtu.c"/>
<File Name="src/cw/cw_in_check_join_request.c"/>
<File Name="src/cw/conn_get_message.c"/>
<File Name="src/cw/cw_readelem_maximum_message_length.c"/>
<File Name="src/cw/capwap_msg_new.c"/>
@ -309,18 +307,24 @@
<File Name="src/cw/cw_process_element.c"/>
<File Name="src/cw/cw_result_is_ok.c"/>
<File Name="src/cw/mavliter_get.c"/>
<File Name="src/cw/kvt.h"/>
<File Name="src/cw/cw_kvt_mavlcmp.c"/>
<File Name="src/cw/cw_kvt_mavldel.c"/>
<File Name="src/cw/mavliter_get_ptr.c"/>
<File Name="src/cw/mavl_cmpstr.c"/>
<File Name="src/cw/mavl_freeptr.c"/>
<File Name="src/cw/msgset.c"/>
<File Name="src/cw/msget.h"/>
<File Name="src/cw/mavl_replace.c"/>
<File Name="src/cw/cw_kvt_add.c"/>
<File Name="src/cw/mlist_create.c"/>
<File Name="src/cw/mlist_append.c"/>
<File Name="src/cw/conn_send_msg.c"/>
<File Name="src/cw/mlist_destroy.c"/>
<File Name="src/cw/mlist_append_ptr.c"/>
<File Name="src/cw/ktv.h"/>
<File Name="src/cw/cw_ktv_add.c"/>
<File Name="src/cw/cw_ktv_mavlcmp.c"/>
<File Name="src/cw/cw_ktv_mavldel.c"/>
<File Name="src/cw/cw_ktv_readline.c"/>
<File Name="src/cw/cw_ktv_read_file.c"/>
<File Name="src/cw/cw_ktv_mavlcmp_type_by_name.c"/>
<File Name="src/cw/msgset.h"/>
</VirtualDirectory>
</VirtualDirectory>
<Description/>
@ -343,9 +347,9 @@
</Compiler>
<Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/ac/actube" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
<![CDATA[LD_LIBRARY_PATH=../../lib]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
<DebuggerSearchPaths/>

View File

@ -97,7 +97,7 @@ extern struct cw_Mod * cw_get_mod_ac (const char *name);
extern void test_sets();
#include "cw/file.h"
#include "cw/kvt.h"
#include "cw/ktv.h"
struct mykv {
@ -153,6 +153,36 @@ int stcmp (const void * sa1, const void *sa2)
int main (int argc, char *argv[])
{
mlist_t list;
mlistelem_t * elem;
list = mlist_create_conststr();
mlist_append_ptr(list, "helo");
mlist_append_ptr(list, "tobias");
mlist_append_ptr(list, "nase");
mlist_foreach(elem,list){
// data = mlistelem_dataptr(elem);
// char * str = ((char**)data)[0];
// printf("%p %p\n",data,str);
printf("String: %s\n", mlistelem_get_str(elem));
}
mlist_destroy(list);
mlist_foreach(elem,list){
// data = mlistelem_dataptr(elem);
// char * str = ((char**)data)[0];
// printf("%p %p\n",data,str);
printf("String: %s\n", mlistelem_get_str(elem));
}
//exit(0);
/* mavl_t tree;
int i;
mavliter_t it;

View File

@ -573,7 +573,7 @@ static int conf_read_mods(cfg_t *cfg){
conf_mods = malloc(sizeof(struct cw_Mod *)*(n+1));
cw_dbg(DBG_INFO,"Mods directory: %s",conf_mods_dir);
cw_mod_set_mod_path(conf_mods_dir);
cw_mod_set_path(conf_mods_dir);
for (i=0; i < n; i++){
char *modname = cfg_getnstr(cfg, CFG_ENTRY_MODS, i);

View File

@ -41,7 +41,7 @@
#include "socklist.h"
#include "wtpman.h"
#include "wtplist.h"
#include "cw/kvt.h"
#include "cw/ktv.h"
static void reset_echointerval_timer(struct wtpman *wtpman)
{
@ -97,7 +97,7 @@ static void wtpman_run_discovery(void *arg)
/* wtpman->conn->outgoing = mbag_create();
wtpman->conn->incomming = mbag_create();
*/
wtpman->conn->remote_cfg = cw_kvt_create(); //mavl_cmp_kv,NULL,1312);
wtpman->conn->remote_cfg = cw_ktv_create(); //mavl_cmp_kv,NULL,1312);
while (!cw_timer_timeout(timer)
&& wtpman->conn->capwap_state == CAPWAP_STATE_DISCOVERY) {

View File

@ -32,7 +32,7 @@
*/
uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
{
int l = strlen(s);
/*int l = strlen(s);
if (s[0]!='.')
return bstrv_create(vendor_id,(uint8_t*)s,l);
@ -45,7 +45,7 @@ uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
if (s[1]!='x')
return bstrv_create(vendor_id,(uint8_t*)s,l);
/* the string starts with ".x" - read hexbytes */
// the string starts with ".x" - read hexbytes
l-=2;
int msize=l/2;
if(l&1)
@ -60,6 +60,7 @@ uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l);
return mem;
*/
}

View File

@ -747,7 +747,7 @@ extern int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8
int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from);
int cw_check_missing_mand(cw_action_in_t ** out, struct conn *conn, cw_action_in_t * a);
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from);
extern int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a,

View File

@ -308,6 +308,7 @@ extern int conn_recvfrom_packet(struct conn *conn, uint8_t * buf, int len,
int conn_send_msg(struct conn * conn, uint8_t *rawmsg);
int cw_read_from(struct conn * conn);
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
void conn_clear_upd(struct conn *conn, int merge);

View File

@ -30,11 +30,11 @@
#include "stravltree.h"
#include "mod.h"
#include "msget.h"
#include "msgset.h"
#include "ktv.h"
#include "kvt.h"
int conn_send_msg(struct conn *conn, uint8_t * rawmsg);
@ -193,7 +193,7 @@ static struct cw_MsgSet *load_msg_set(struct conn *conn, uint8_t * rawmsg, int l
}
bmod =
cw_mod_detect(conn, rawmsg, len, elems_len, from, MOD_MODE_BINDINGS);
cw_mod_detect(conn, rawmsg, len, elems_len, from, CW_MOD_MODE_BINDINGS);
cw_dbg(DBG_INFO, "Mods deteced: %s,%s", cmod->name, bmod->name);
@ -507,6 +507,8 @@ exit(0);
/* all message elements are processed, do now after processing
by calling the "end" function for the message */
cw_check_missing_mand(message,mand_found);
{
mavliter_t it;
@ -517,7 +519,7 @@ exit(0);
mavliter_foreach(&it){
char value[500];
struct cw_KVT * data;
struct cw_KTV * data;
data = mavliter_get(&it);
type = data->type;
type->to_str(data,value,0);

60
src/cw/conn_send_msg.c Normal file
View File

@ -0,0 +1,60 @@
#include "conn.h"
#include "cw.h"
#include "dbg.h"
int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
{
uint8_t * ptr;
int packetlen;
int fragoffset,hlen,mtu;
packetlen = cw_get_hdr_msg_total_len(rawmsg);
cw_dbg_msg(DBG_MSG_OUT, conn,rawmsg, packetlen,(struct sockaddr*)&conn->addr);
/* Zyxel doesn't count msg element length from
behind seqnum */
if (conn->capwap_mode == CW_MODE_ZYXEL){
/* // XXX val-=3; */
}
ptr = rawmsg;
fragoffset = 0;
hlen = cw_get_hdr_hlen(rawmsg)*4;
mtu = conn->mtu;
while (packetlen>mtu){
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F,1);
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,mtu,(struct sockaddr*)&conn->addr);
if (conn->write(conn,ptr,mtu)<0)
return -1;
/* // XXX Fragmentation stuff.. */
ptr +=mtu-hlen;
fragoffset+=(mtu-hlen)/8;
packetlen-=mtu-hlen;
}
if (fragoffset)
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F | CAPWAP_FLAG_HDR_L,1);
else
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F,0);
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
return conn->write(conn,ptr,packetlen-0);
}

View File

@ -10,7 +10,7 @@
#include "lw.h"
#include "capwap.h"
#include "msget.h"
#include "msgset.h"
/**
* @defgroup CW CW
@ -310,6 +310,9 @@ struct cw_DescriptorSubelemDef {
#define CW_REPLACE 4
int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys );
extern int cw_read_descriptor_subelems(mavl_t store, const char * key, uint8_t * data, int len,
struct cw_DescriptorSubelemDef *elems);

View File

@ -2,17 +2,31 @@
#include "capwap.h"
#include "dbg.h"
int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_in_t *a)
int cw_check_missing_mand(struct cw_MsgData *msgdata, mavl_t keys )
{
mlistelem_t * elem;
char *mandkey, *result;
mlist_foreach(elem, msgdata->mand_keys){
mandkey = mlistelem_get_str(elem);
result = mavl_get_str(keys,mandkey);
if (result == NULL){
printf("Missing\n");
}
else printf("Ok\n");
cw_action_in_t as;
}
/* cw_action_in_t as;
as.capwap_state = a->capwap_state;
as.msg_id = a->msg_id;
as.vendor_id = 0;
as.elem_id = 0;
as.proto=0;
*/
/// TODO XXXX
/*
DEFINE_AVLITER(it,conn->actions->in);
@ -36,3 +50,4 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i
}

View File

@ -13,7 +13,7 @@ int cw_in_check_cfg_update_req(struct conn *conn, struct cw_action_in *a, uint8_
cw_action_in_t * mlist[60];
/* Check for mandatory elements */
int n = cw_check_missing_mand(mlist,conn,a);
/* int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
if ( conn->strict_capwap ){
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
@ -22,7 +22,7 @@ int cw_in_check_cfg_update_req(struct conn *conn, struct cw_action_in *a, uint8_
}
cw_dbg_missing_mand(DBG_RFC,conn,mlist,n,a);
}
*/
/* set result code to ok and change to configure state */
mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);

View File

@ -9,6 +9,7 @@
#include "vendors.h"
/*
void cw_get_wtp_name(struct conn *conn,struct sockaddr *addr)
{
@ -62,3 +63,5 @@ int cw_in_check_cipwap_join_req(struct conn *conn, struct cw_action_in *a, uint8
return rc;
}
*/

View File

@ -10,6 +10,7 @@
int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
/*
char sock_buf[SOCK_ADDR_BUFSIZE];
cw_action_in_t *mlist[120];
@ -20,8 +21,8 @@ int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * da
if (n && conn->strict_capwap) {
cw_dbg_missing_mand(DBG_MSG_ERR, conn, mlist, n, a);
/* if mandatory elements are missing, in strict
mode send no discovery response */
// if mandatory elements are missing, in strict
// mode send no discovery response
cw_dbg(DBG_MSG_ERR,
"Ignoring Discovery Request from %s - missing mandatory elements.",
sock_addr2str(from,sock_buf));
@ -29,14 +30,14 @@ int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * da
}
if ( n ) {
/* put a warning here */
// put a warning here
cw_dbg_missing_mand(DBG_RFC, conn, mlist, n, a);
}
/* ok, send response */
// ok, send response
conn->capwap_state = CAPWAP_STATE_JOIN;
*/
return 0;
}

View File

@ -13,7 +13,7 @@ int cw_in_check_generic_req(struct conn *conn, struct cw_action_in *a, uint8_t *
cw_action_in_t * mlist[60];
/* Check for mandatory elements */
int n = cw_check_missing_mand(mlist,conn,a);
/* int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
if ( conn->strict_capwap ){
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
@ -21,7 +21,7 @@ int cw_in_check_generic_req(struct conn *conn, struct cw_action_in *a, uint8_t *
}
cw_dbg_missing_mand(DBG_RFC,conn,mlist,n,a);
}
*/
return 0;
}

View File

@ -11,9 +11,9 @@ int cw_in_check_generic_resp(struct conn *conn, struct cw_action_in *a, uint8_t
int len,struct sockaddr *from)
{
/* Check if the message contains a result code and
if it indicates an errror */
/*
//Check if the message contains a result code and
if it indicates an errror //
mbag_item_t * result = mbag_get(conn->incomming,CW_ITEM_RESULT_CODE);
if (result ) {
@ -24,21 +24,21 @@ int cw_in_check_generic_resp(struct conn *conn, struct cw_action_in *a, uint8_t
cw_action_in_t * mlist[60];
/* Check for mandatory elements */
// Check for mandatory elements
int n = cw_check_missing_mand(mlist,conn,a);
if (n && conn->strict_capwap) {
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
errno=EAGAIN;
return -1; /* CW_RESULT_MISSING_MAND_ELEM */
// return -1; /* CW_RESULT_MISSING_MAND_ELEM
}
if (n){
cw_dbg_missing_mand(DBG_RFC,conn,mlist,n,a);
}
/* if we hava a result code, return it */
// if we hava a result code, return it
if ( result ) {
return result->u2.dword;
}
*/
return 0;
}

View File

@ -12,7 +12,7 @@ int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a, uint8
int len,struct sockaddr *from)
{
/* Check for mandatory elements */
cw_action_in_t * mlist[60];
/* cw_action_in_t * mlist[60];
int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
cw_dbg_missing_mand(DBG_ELEM,conn,mlist,n,a);
@ -52,5 +52,5 @@ int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a, uint8
return CAPWAP_RESULT_IMAGE_DATA_ERROR;
*/
}

View File

@ -22,7 +22,7 @@ int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a, uint
/* Check for mandatory elements */
cw_action_in_t * mlist[60];
/* cw_action_in_t * mlist[60];
int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
cw_dbg_missing_mand(DBG_ELEM,conn,mlist,n,a);
@ -62,5 +62,5 @@ int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a, uint
return CAPWAP_RESULT_IMAGE_DATA_ERROR;
*/
}

View File

@ -14,7 +14,7 @@ int cw_in_check_img_data_resp(struct conn *conn, struct cw_action_in *a, uint8_t
cw_action_in_t * mlist[60];
/* Check for mandatory elements */
int n = cw_check_missing_mand(mlist,conn,a);
/* int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
cw_dbg_missing_mand(DBG_ELEM,conn,mlist,n,a);
conn->capwap_state=CAPWAP_STATE_JOIN;
@ -29,7 +29,7 @@ int cw_in_check_img_data_resp(struct conn *conn, struct cw_action_in *a, uint8_t
if ( iresult ) {
return iresult->u2.dword;
}
*/
return 0;
}

View File

@ -10,10 +10,10 @@
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
/*
cw_action_in_t * mlist[60];
/* Check for mandatory elements */
//Check for mandatory elements
int n = cw_check_missing_mand(mlist,conn,a);
if (n) {
if ( conn->strict_capwap ){
@ -36,9 +36,9 @@ int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * da
return CW_RESULT_JOIN_FAILURE_SESSION_ALREADY_IN_USE;
}
/* set result code to ok and change to configure state */
// set result code to ok and change to configure state
mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);
conn->capwap_state = CW_STATE_CONFIGURE;
*/
return 0;
}

View File

@ -1,3 +0,0 @@

View File

@ -10,7 +10,7 @@
int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
/*
cw_action_in_t * mlist[60];
mbag_item_t * jresult = mbag_get(conn->incomming,CW_ITEM_RESULT_CODE);
@ -21,7 +21,7 @@ int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a, uint8_t * d
}
/* Check for mandatory elements */
// Check for mandatory elements
int n = cw_check_missing_mand(mlist,conn,a);
if (n && conn->strict_capwap) {
cw_dbg_missing_mand(DBG_MSG_ERR,conn,mlist,n,a);
@ -40,8 +40,8 @@ int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a, uint8_t * d
return jresult->u2.dword;
}
/* set result code to ok and change to configure state */
// set result code to ok and change to configure state
// mbag_set_dword(conn->outgoing,CW_ITEM_RESULT_CODE,0);
*/
return 0;
}

View File

@ -1,5 +1,5 @@
#include "msget.h"
#include "kvt.h"
#include "msgset.h"
#include "ktv.h"
#include "log.h"
int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
@ -12,7 +12,7 @@ int cw_in_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams *
cw_log(LOG_ERR,"Can't handle element: %s, no type defined",handler->name);
return 0;
}
cw_kvt_add(params->conn->remote_cfg, handler->key, handler->type, elem_data,elem_len);
cw_ktv_add(params->conn->remote_cfg, handler->key, handler->type, elem_data,elem_len);
/*

View File

@ -171,7 +171,7 @@ int cw_put_elem_result_code(uint8_t * dst, uint32_t code)
/*
int cw_put_version(uint8_t * dst, uint16_t subelem_id, bstrv_t v)
{
uint8_t *d = dst;
@ -180,6 +180,7 @@ int cw_put_version(uint8_t * dst, uint16_t subelem_id, bstrv_t v)
d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
return d - dst;
}
*/
int cw_put_elem_radio_operational_state(uint8_t * dst, int rid, int state, int cause) {

View File

@ -1,13 +1,13 @@
#include "kvt.h"
#include "ktv.h"
#include "cw.h"
#include "log.h"
#include "dbg.h"
const char * cw_kvt_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
const char * cw_ktv_add(mavl_t kvtstore, const char *key, const struct cw_Type *type,
const uint8_t * data, int len)
{
cw_KVT_t mdata, *mresult;
cw_KTV_t mdata, *mresult;
int exists;
/* cw_dbg(DBG_ELEM,"KVStore (%p,%d) add elem (%s): %s", kvstore, kvstore->count,

6
src/cw/cw_ktv_mavlcmp.c Normal file
View File

@ -0,0 +1,6 @@
#include "ktv.h"
int cw_ktv_mavlcmp(const void *v1, const void *v2)
{
return strcmp(((cw_KTV_t *) v1)->key, ((cw_KTV_t *) v2)->key);
}

View File

@ -0,0 +1,8 @@
#include "ktv.h"
int cw_ktv_mavlcmp_type_by_name (const void *v1, const void *v2)
{
return strcmp ( (*((struct cw_Type**) v1))->name,
(*((struct cw_Type**) v2))->name);
}

View File

@ -2,11 +2,11 @@
#include <stdlib.h>
#include "kvt.h"
#include "ktv.h"
void cw_kvt_mavldel(void *data)
void cw_ktv_mavldel(void *data)
{
struct cw_KVT *kvt = data;
struct cw_KTV *kvt = data;
if (kvt->type->del)
kvt->type->del(data);

View File

@ -0,0 +1,8 @@
#include "ktv.h"
cw_kvt_read_file(mavl_t ktv, mavl_t types)
{
}

229
src/cw/cw_ktv_readline.c Normal file
View File

@ -0,0 +1,229 @@
#include <ctype.h>
#include "ktv.h"
struct parser {
int line;
int pos;
int prevpos;
char error[256];
};
static int get_char(FILE * f, struct parser *p)
{
int c;
c = fgetc (f);
p->pos++;
if (c=='\n'){
p->prevpos=p->pos;
p->line ++;
p->pos=0;
}
return c;
}
static void unget_char(int c, FILE *f, struct parser *p){
ungetc(c,f);
if (c=='\n'){
p->line--;
p->pos=p->prevpos;
}
else
p->pos--;
}
static int skip_chars (FILE *f, const char * chars, struct parser * p )
{
int c;
while ( (c = get_char (f, p)) != EOF) {
if (strchr (chars, c))
continue;
return c;
}
return c;
}
static int skip_to_chars (FILE *f, const char *chars, struct parser * p)
{
int c;
while ( (c = get_char (f, p)) != EOF) {
if (strchr (chars, c))
return c;
}
return c;
}
static int read_key (FILE *f, char *key, int max_len, struct parser * p)
{
int c,n;
do {
c = skip_chars (f, " \t\n\a\v", p);
if (c == '#') {
c = skip_to_chars (f, "\n\a",p);
} else {
break;
}
} while (c != EOF);
n=0;
while(c!=EOF && n<max_len){
if (!isalnum(c) && !strchr("_/-()@#|{}[]",c)/*strchr(": \t\n\a",c)*/){
unget_char(c,f,p);
break;
}
key[n]=c;
c=get_char(f,p);
n++;
}
key[n]=0;
return n;
}
static int skip_to_colon(FILE *f,struct parser * p)
{
int c;
c = skip_chars (f, " \t", p);
if (c!=':'){
if (c=='\n'){
unget_char(c,f,p);
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL, collon expected.", p->line, p->pos);
return 0;
}
sprintf(p->error,"Error at line %d, pos %d: Collon expected.", p->line, p->pos);
return 0;
}
return 1;
}
static int read_type(FILE *f, char *type, int max_len, struct parser *p)
{
int c,n;
if (!skip_to_colon(f,p))
return -1;
c = skip_chars (f, " \t", p);
if (c==':'){
unget_char(c,f,p);
sprintf(type,"");
return 0;
}
if (!isalpha(c)){
if (c=='\n'){
unget_char(c,f,p);
sprintf(p->error,"Error at line %d, pos %d: Unexpected EOL.", p->line, p->pos);
return -1;
}
sprintf(p->error,"Error at line %d, pos %d: Letter expected.", p->line, p->pos);
return -1;
}
n=0;
while(c!=EOF && n<max_len){
if (!isalnum(c) && !strchr("_/-.()@#|{}[]",c)/*strchr(": \t\n\a",c)*/){
unget_char(c,f,p);
break;
}
type[n]=c;
c=get_char(f,p);
n++;
}
type[n]=0;
return n;
}
static int read_val(FILE *f, char *val, int max_len, struct parser *p){
int c,n,quote;
if (!skip_to_colon(f,p))
return -1;
c = skip_chars (f, " \t", p);
if (c=='"'){
quote=1;
c=get_char(f,p);
}
else{
quote=0;
}
n=0;
while(c!=EOF && n<max_len){
if (quote && c=='"'){
break;
}
if (c=='\n'){
break;
}
if (quote){
if (c=='\\'){
c = get_char(f,p);
switch(c){
case 'n':
c='\n';
break;
case '\\':
break;
case '"':
break;
default:
unget_char(c,f,p);
c='\\';
}
}
}
val[n++]=c;
c=get_char(f,p);
}
if(!quote && n>0){
while(n>0){
if (isspace(val[n-1]))
n--;
else
break;
}
}
val[n]=0;
return n;
}
int cw_ktv_read_line (FILE *f, char * key, char * type, char *val)
{
int n;
struct parser p;
p.line=1;
p.pos=0;
p.prevpos=0;
n = read_key (f,key,CW_KTV_MAX_KEY_LEN,&p);
n = read_type (f,type,CW_KTV_MAX_KEY_LEN,&p);
if (n==-1){
return -1;
}
n = read_val (f,val,CW_KTV_MAX_KEY_LEN,&p);
if (n==-1){
return -1;
}
return 0;
}

View File

@ -1,6 +0,0 @@
#include "kvt.h"
int cw_kvt_mavlcmp(const void *v1, const void *v2)
{
return strcmp(((cw_KVT_t *) v1)->key, ((cw_KVT_t *) v2)->key);
}

View File

@ -47,7 +47,7 @@ int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t *
mbag_item_t * i;
i = mbag_get(mbag,CW_ITEM_WTP_HARDWARE_VERSION);
if ( i ) {
/* if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->u2.data);
}
else {
@ -77,7 +77,7 @@ int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t *
else {
cw_log(LOG_INFO, "Can't send Other Version in WTP descriptor, not set.");
}
*/
int len = d-dst-4;
return len + cw_put_elem_hdr(dst,a->elem_id,len);
}

View File

@ -19,7 +19,7 @@ int cw_process_element(struct cw_ElemHandlerParams *params, int proto, int vendo
struct cw_ElemData * elem_data, elem_data_search;
/* try to retrieve a handler for this message element */
handler = cw_msgset_get_elemhandler(params->conn->msgset,0, 0, elem_id);
handler = cw_msgset_get_elemhandler(params->conn->msgset,proto, vendor, elem_id);
if (!handler) {
cw_dbg(DBG_ELEM_ERR, "Unrecognized message element: %d, ignoring",
elem_id);
@ -28,8 +28,8 @@ int cw_process_element(struct cw_ElemHandlerParams *params, int proto, int vendo
/* check if this message element in the current message allowed */
elem_data_search.id=elem_id;
elem_data_search.proto=0;
elem_data_search.vendor=0;
elem_data_search.proto=proto;
elem_data_search.vendor=vendor;
elem_data = mavl_find(params->msgdata->elements_tree,&elem_data_search);
if (!elem_data){
cw_dbg(DBG_ELEM_ERR, "Element %d - %s, not allowed here",

View File

@ -17,7 +17,7 @@
*/
#include "cw.h"
#include "kvt.h"
#include "ktv.h"
#include "dbg.h"
#include "keys.h"
@ -69,11 +69,11 @@ int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key,
/* vendor */
sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_KEY_VENDOR);
cw_kvt_add(cfg,key,CW_TYPE_DWORD,data + sub,4);
cw_ktv_add(cfg,key,CW_TYPE_DWORD,data + sub,4);
/* version */
sprintf(key,"%s/%s/%s",parent_key,elems[i].key,CW_KEY_VERSION);
cw_kvt_add(cfg,key,CW_TYPE_BSTR16,data+sub+8,l);
cw_ktv_add(cfg,key,CW_TYPE_BSTR16,data+sub+8,l);
sprintf(dbgstr, "%s", key);
cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vendor_id, data+sub+8,l);

View File

@ -3,7 +3,7 @@
#include "capwap.h"
#include "capwap_items.h"
#include "dbg.h"
#include "kvt.h"
#include "ktv.h"
static struct cw_DescriptorSubelemDef allowed_default[] = {

View File

@ -2,7 +2,7 @@
#include "capwap.h"
#include "capwap_items.h"
#include "kvt.h"
#include "ktv.h"
#include "keys.h"
@ -32,10 +32,10 @@ int cw_read_wtp_descriptor_7(mavl_t cfg, struct conn *conn,
/* md.kv.key=strdup(key);
mavl_replace (cfg, cw_type_byte.get(&md,data,1));
*/
cw_kvt_add(cfg,key,CW_TYPE_BYTE,data,1);
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data,1);
sprintf(key,"%s/%s",eh->key, "radios_in_use");
cw_kvt_add(cfg,key,CW_TYPE_BYTE,data+1,1);
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data+1,1);
/* md.kv.key=strdup(key);
mavl_replace (cfg, cw_type_byte.get(&md,data+1,1));

View File

@ -45,7 +45,7 @@ int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len)
free(dmpmem);
switch (subtype) {
case CW_SUBELEM_WTP_HARDWARE_VERSION:
/* case CW_SUBELEM_WTP_HARDWARE_VERSION:
mbag_set_bstrv(mbag,
CW_ITEM_WTP_HARDWARE_VERSION,
vendor_id, data + i, sublen);
@ -69,7 +69,7 @@ int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len)
"Unknown WTP descriptor subelement, type = %d",
subtype);
break;
}
*/ }
i += sublen;
}

View File

@ -20,15 +20,15 @@
#include "format.h"
#include "cw.h"
#include "kvt.h"
#include "ktv.h"
static void del ( struct cw_KVT * data )
static void del ( struct cw_KTV * data )
{
free ( data->val.ptr );
}
static struct cw_KVT *get ( struct cw_KVT * data, const uint8_t * src, int len )
static struct cw_KTV *get ( struct cw_KTV * data, const uint8_t * src, int len )
{
uint8_t * s;
s = bstr16_create ( src, len );
@ -41,12 +41,12 @@ static struct cw_KVT *get ( struct cw_KVT * data, const uint8_t * src, int len )
return data;
}
static int put ( const struct cw_KVT *data, uint8_t * dst )
static int put ( const struct cw_KTV *data, uint8_t * dst )
{
return cw_put_bstr16 ( dst, data->val.ptr );
}
static int to_str ( const struct cw_KVT *data, char *dst, int max_len )
static int to_str ( const struct cw_KTV *data, char *dst, int max_len )
{
char *d;
d = dst;
@ -63,7 +63,7 @@ static int to_str ( const struct cw_KVT *data, char *dst, int max_len )
return d - dst;
}
static struct cw_KVT *from_str ( struct cw_KVT * data, const char *src )
static struct cw_KTV *from_str ( struct cw_KTV * data, const char *src )
{
return NULL;
}

View File

@ -19,26 +19,26 @@
#include <stdio.h>
#include "cw.h"
#include "kvt.h"
#include "ktv.h"
static cw_KVT_t *get(cw_KVT_t * data, const uint8_t * src, int len)
static cw_KTV_t *get(cw_KTV_t * data, const uint8_t * src, int len)
{
data->type = &cw_type_byte;
data->val.byte = cw_get_byte(src);
return data;
}
static int put(const cw_KVT_t *data, uint8_t * dst)
static int put(const cw_KTV_t *data, uint8_t * dst)
{
return cw_put_byte(dst, data->val.byte);
}
static int to_str(const cw_KVT_t *data, char *dst, int max_len)
static int to_str(const cw_KTV_t *data, char *dst, int max_len)
{
return sprintf(dst, "%d", data->val.byte);
}
static cw_KVT_t *from_str(cw_KVT_t * data, const char *src)
static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
{
data->val.byte = atoi(src);
return data;

View File

@ -19,26 +19,26 @@
#include <stdio.h>
#include "cw.h"
#include "kvt.h"
#include "ktv.h"
static struct cw_KVT *get(struct cw_KVT * data, const uint8_t * src, int len)
static struct cw_KTV *get(struct cw_KTV * data, const uint8_t * src, int len)
{
data->type = &cw_type_dword;
data->val.dword = cw_get_dword(src);
return data;
}
static int put(const struct cw_KVT *data, uint8_t * dst)
static int put(const struct cw_KTV *data, uint8_t * dst)
{
return cw_put_dword(dst, data->val.dword);
}
static int to_str(const struct cw_KVT *data, char *dst, int max_len)
static int to_str(const struct cw_KTV *data, char *dst, int max_len)
{
return sprintf(dst, "%d", data->val.dword);
}
static struct cw_KVT *from_str(struct cw_KVT * data, const char *src)
static struct cw_KTV *from_str(struct cw_KTV * data, const char *src)
{
data->val.dword = atoi(src);
return data;

View File

@ -18,28 +18,28 @@
#include <stdio.h>
#include "kvt.h"
#include "ktv.h"
#include "cw.h"
static struct cw_KVT *get(struct cw_KVT * data, const uint8_t * src, int len)
static struct cw_KTV *get(struct cw_KTV * data, const uint8_t * src, int len)
{
data->type = &cw_type_word;
data->val.word = cw_get_word(src);
return data;
}
static int put(const cw_KVT_t *data, uint8_t * dst)
static int put(const cw_KTV_t *data, uint8_t * dst)
{
return cw_put_word(dst, data->val.word);
}
static int to_str(const cw_KVT_t *data, char *dst, int max_len)
static int to_str(const cw_KTV_t *data, char *dst, int max_len)
{
return sprintf(dst, "%d", data->val.word);
}
static cw_KVT_t *from_str(cw_KVT_t * data, const char *src)
static cw_KTV_t *from_str(cw_KTV_t * data, const char *src)
{
data->val.word = atoi(src);
return data;

View File

@ -36,7 +36,7 @@
#include "capwap_cisco.h"
#include "lwapp_cisco.h"
#include "cw.h"
#include "msget.h"
#include "msgset.h"

View File

@ -2,20 +2,23 @@
#define __KVT_H
#include <stdint.h>
#include <stdio.h>
#include "mavl.h"
struct cw_KVT {
#define CW_KTV_MAX_KEY_LEN 1024
struct cw_KTV {
char *key;
const struct cw_Type *type;
union {
uint32_t dword;
uint16_t word;
uint8_t byte;
void *ptr;
} val;
const struct cw_Type *type;
};
typedef struct cw_KVT cw_KVT_t;
typedef struct cw_KTV cw_KTV_t;
struct cw_Type {
@ -23,22 +26,22 @@ struct cw_Type {
const char *name;
/** A pointer to a function to delete elements of this type */
void (*del) (struct cw_KVT * data);
void (*del) (struct cw_KTV * data);
/** A method to put this object to a buffer */
int (*put) (const struct cw_KVT * data, uint8_t * dst);
int (*put) (const struct cw_KTV * data, uint8_t * dst);
/** The get method */
struct cw_KVT *(*get) (struct cw_KVT * data, const uint8_t * src, int len);
struct cw_KTV *(*get) (struct cw_KTV * data, const uint8_t * src, int len);
/** A pointer to a function to convert elements of this type to a string.
This function is mainly used to store elements to an SQL database
or to json strings */
int (*to_str) (const struct cw_KVT * data, char *dst, int max_len);
int (*to_str) (const struct cw_KTV * data, char *dst, int max_len);
/** Cereate an item of this type from a string, which was previously
created by the #del function. */
struct cw_KVT *(*from_str) (struct cw_KVT * data, const char *src);
struct cw_KTV *(*from_str) (struct cw_KTV * data, const char *src);
/*
int (*def)(void *, void *);
@ -58,13 +61,20 @@ extern const struct cw_Type cw_type_bstr16;
/*
void cw_kvstore_mavl_delete(const void *data);
*/
const char *cw_kvt_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
const char *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
const uint8_t * data, int len);
int cw_kvt_mavlcmp(const void *v1, const void *v2);
void cw_kvt_mavldel(void *data);
int cw_ktv_mavlcmp(const void *v1, const void *v2);
int cw_ktv_mavlcmp_type_by_name(const void *v1,const void *v2);
#define cw_kvt_create()\
mavl_create(cw_kvt_mavlcmp, cw_kvt_mavldel, sizeof(cw_KVT_t))
void cw_ktv_mavldel(void *data);
#define cw_ktv_create()\
mavl_create(cw_ktv_mavlcmp, cw_ktv_mavldel, sizeof(cw_KTV_t))
#define cw_ktv_create_types_tree()\
mavl_create(cw_ktv_mavlcmp_type_by_name,NULL,sizeof(struct cw_Type *))
int cw_ktv_read_line (FILE *f, char * key, char * type, char *val);
#endif /* __KVT_H */

View File

@ -281,7 +281,7 @@ int mavl_cmpstr(const void *p1, const void *p2);
#define mavl_create_conststr() mavl_create_ptr(mavl_cmpstr,NULL)
void * mavl_get_ptr ( mavl_t tree, void * search );
void * mavl_add_ptr ( mavl_t tree, void *ptr );
void * mavl_add_ptr ( mavl_t tree, const void *ptr );
#define mavl_add_str(tree,str) mavl_add_ptr(tree,str)
#define mavl_get_str(tree,search) ((char *)(mavl_get_ptr(tree,search)))

View File

@ -1,6 +1,6 @@
#include "mavl.h"
void *mavl_add_ptr(mavl_t tree, void *ptr){
void *mavl_add_ptr(mavl_t tree, const void *ptr){
void * result;
result = mavl_add(tree,&ptr,NULL);
if (result)

View File

@ -64,10 +64,13 @@ typedef struct mlist * mlist_t;
mlist_t mlist_create(int (*cmp) (const void *v1, const void *v2), void (*del)(void *), size_t data_size);
struct mlistelem *mlist_append(mlist_t l, void *data);
void mlist_destroy(mlist_t l);
extern struct mlistelem *mlist_find(mlist_t l, struct mlistelem *start, void *data);
extern struct mlistelem *mlist_replace(mlist_t l, struct mlistelem *start, void *data);
#define mlist_add mlist_append
/**
* @}
@ -76,6 +79,14 @@ extern struct mlistelem *mlist_replace(mlist_t l, struct mlistelem *start, void
#define mlist_foreach(elem,list)\
for (elem=list->first; elem; elem=elem->next)
#define mlistelem_get_ptr(elem) (*((void**)(mlistelem_dataptr(elem))))
#define mlistelem_get_str(elem) mlistelem_get_ptr(elem)
#define mlist_create_conststr() mlist_create(NULL,NULL,sizeof(const char*))
mlistelem_t * mlist_append_ptr (mlist_t list, void * ptr);
/**
* @}
*/

View File

@ -0,0 +1,6 @@
#include "mlist.h"
mlistelem_t * mlist_append_ptr (mlist_t list, void * ptr)
{
return mlist_append (list, &ptr);
}

15
src/cw/mlist_destroy.c Normal file
View File

@ -0,0 +1,15 @@
#include "mlist.h"
void mlist_destroy(mlist_t l){
mlistelem_t * elem, * next;
elem = l->first;
while (elem){
if (l->del != NULL){
l->del(mlistelem_dataptr(elem));
}
next = elem->next;
free(elem);
elem=next;
}
free(l);
}

View File

@ -31,7 +31,7 @@
#include "log.h"
#include "file.h"
#include "cw.h"
#include "cw/msget.h"
#include "cw/msgset.h"
static void (*actions_registered_cb) (struct cw_Mod * capwap, struct cw_Mod * bindings,
struct cw_actiondef * actions) = NULL;
@ -178,9 +178,13 @@ static int mod_cmp_mlist(const void *e1, const void *e2){
static const char * mod_path="./";
static const char * mod_path="";
void cw_mod_set_mod_path(const char * path){
/**
* @brief Set module path, where to search for modules
* @param path Path to search
*/
void cw_mod_set_path(const char * path){
mod_path = path;
}
@ -209,11 +213,14 @@ struct cw_Mod * cw_mod_load(const char * mod_name){
/* Search for the module in mods_loaded, to see if it is
* already loaded or was statically linked */
cw_dbg(DBG_MOD,"MOD: Load module '%s'",mod_name);
memset(&search,0,sizeof(search));
search.name=mod_name;
mod = mavl_find_ptr(mods_loaded,&search);
if (mod){
cw_dbg(DBG_MOD,"MOD: Module already loaded '%s'",mod_name);
return mod;
}
@ -232,6 +239,8 @@ struct cw_Mod * cw_mod_load(const char * mod_name){
if (filename==NULL)
return NULL;
cw_dbg(DBG_MOD, "MOD: loading module from file: %s", filename);
/* Open the DLL */
handle = dlopen(filename,RTLD_NOW);
@ -256,7 +265,7 @@ struct cw_Mod * cw_mod_load(const char * mod_name){
cw_log(LOG_ERR,"Can' add module %s",mod_name);
goto errX;
}
cw_dbg(DBG_MOD, "MOD: %s sucessfull loaded, calling init now.",filename);
mod->init();
errX:
free(filename);
@ -277,7 +286,6 @@ struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod ){
}
elem = mlist_append(mods_list,&mod);
printf("Append mod %p\n",mod);
if (elem == NULL)
return NULL;
return mlistelem_dataptr(elem);
@ -297,11 +305,11 @@ struct cw_Mod * cw_mod_detect(struct conn *conn,
mlist_foreach(e,mods_list){
/// 1312
/* /// 1312 */
struct cw_Mod * mod = *(struct cw_Mod**)(mlistelem_dataptr(e)); /* = e->data;*/
cw_dbg(DBG_MOD,"Checking mod: %s",mod->name);
printf("Got the mod %p\n",mod);
/*printf("Got the mod %p\n",mod);*/
/* if there is no detect method, skip */
if (!mod->detect)
continue;

View File

@ -36,7 +36,7 @@ struct cw_actiondef;
enum {
CW_MOD_MODE_CAPWAP,
MOD_MODE_BINDINGS
CW_MOD_MODE_BINDINGS
};
@ -102,7 +102,7 @@ struct cw_Mod * cw_mod_detect(struct conn *conn,
struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn,
struct cw_Mod * capwap_mod, struct cw_Mod *bindings_mod);
void cw_mod_set_mod_path(const char * path);
void cw_mod_set_path(const char * path);
#define CW_MOD_MAX_MOD_NAME_LEN 128
#define CW_MOD_INTERFACE_FUNCTION_NAME_SUFFIX "_get_interface"

View File

@ -6,7 +6,8 @@
#include "dbg.h"
#include "log.h"
#include "msget.h"
#include "msgset.h"
#include "ktv.h"
static int cmp_cw_elemhandler_by_id(const void *elem1, const void *elem2)
{
@ -130,6 +131,12 @@ struct cw_MsgSet *cw_msgset_create()
return NULL;
}
set->types_tree = cw_ktv_create_types_tree();
if (set->types_tree == NULL){
cw_msgset_destroy(set);
return NULL;
}
return set;
}
@ -149,6 +156,7 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
{
struct cw_ElemDef *elemdef;
struct cw_ElemData ed, *result;
mavliter_t it;
/* iterate through all defined elements */
for (elemdef = msgdef->elements; elemdef->id; elemdef++) {
@ -165,6 +173,14 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
continue;
}
if (handler->type != NULL){
if (mavl_add_ptr( set->types_tree, handler->type ) == NULL){
cw_log(LOG_ERR, "Can't add type from handler: %s", strerror(errno));
continue;
}
}
ed.id = elemdef->id;
ed.proto = elemdef->proto;
ed.vendor = elemdef->vendor;
@ -183,6 +199,27 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
}
}
if (msgdata->mand_keys!=NULL){
mlist_destroy(msgdata->mand_keys);
}
msgdata->mand_keys = mlist_create_conststr();
mavliter_init(&it,msgdata->elements_tree);
mavliter_foreach(&it){
struct cw_ElemHandler *handler;
result = mavliter_get(&it);
handler = cw_msgset_get_elemhandler(set,
result->proto,
result->vendor, result->id);
if (result->mand){
mlist_append_ptr(msgdata->mand_keys,(void*)handler->key);
cw_dbg(DBG_MOD," Add mandatory key: %s",handler->key);
}
/*//printf("Have Result %d %d - %s\n",result->id,result->mand, handler->key);*/
}
return 0;
}
@ -220,6 +257,7 @@ int cw_msgset_add(struct cw_MsgSet *set,
if (!exists) {
msg->elements_tree = mavl_create(cmp_elemdata, NULL,
sizeof(struct cw_ElemData));
msg->mand_keys=NULL;
}
/* Overwrite the found message */
@ -236,6 +274,18 @@ int cw_msgset_add(struct cw_MsgSet *set,
update_msgdata(set, msg, msgdef);
}
{
mavliter_t it;
cw_dbg(DBG_MOD," Known types:");
mavliter_init(&it,set->types_tree);
mavliter_foreach(&it){
struct cw_Type * t = mavliter_get_ptr(&it);
cw_dbg(DBG_MOD, " Type: %s", t->name);
}
}
return 0;
}

View File

@ -10,6 +10,7 @@ struct cw_MsgSet {
mavl_t msgdata;
mavl_t handlers_by_id;
mavl_t handlers_by_key;
mavl_t types_tree;
};
@ -70,6 +71,7 @@ struct cw_MsgData{
int receiver;
mavl_t elements_tree;
mlist_t elements_list;
mlist_t mand_keys; /**< Keys of mandatory elements */
};

View File

@ -11,63 +11,6 @@
int conn_send_msg(struct conn * conn, uint8_t *rawmsg)
{
int packetlen = cw_get_hdr_msg_total_len(rawmsg);
cw_dbg(DBG_X,"Here is a conn_send_msg for anything");
cw_dbg_msg(DBG_MSG_OUT, conn,rawmsg, packetlen,(struct sockaddr*)&conn->addr);
/* Zyxel doesn't count msg element length from
behind seqnum */
if (conn->capwap_mode == CW_MODE_ZYXEL){
// XXX val-=3;
}
uint8_t * ptr = rawmsg;
int fragoffset = 0;
int hlen = cw_get_hdr_hlen(rawmsg)*4;
int mtu = conn->mtu;
while (packetlen>mtu){
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F,1);
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,mtu,(struct sockaddr*)&conn->addr);
if (conn->write(conn,ptr,mtu)<0)
return -1;
// XXX Fragmentation stuff..
ptr +=mtu-hlen;
fragoffset+=(mtu-hlen)/8;
packetlen-=mtu-hlen;
}
if (fragoffset)
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F | CAPWAP_FLAG_HDR_L,1);
else
cw_set_hdr_flags(rawmsg,CAPWAP_FLAG_HDR_F,0);
cw_put_dword(ptr+4, conn->fragid<<16 | fragoffset<<3 );
cw_dbg_pkt(DBG_PKT_OUT,conn,ptr,packetlen,(struct sockaddr*)&conn->addr);
return conn->write(conn,ptr,packetlen-0);
}
int conn_send_data_msg(struct conn * conn, uint8_t *rawmsg,int len)
{
int packetlen = len;

View File

@ -18,10 +18,10 @@
#include "cw/cw.h"
#include "cw/kvt.h"
#include "cw/ktv.h"
#include "cw/log.h"
#include "cw/msget.h"
#include "cw/msgset.h"
#include "mod_capwap.h"

View File

@ -17,7 +17,7 @@
*/
#include "cw/capwap.h"
#include "cw/msget.h"
#include "cw/msgset.h"
#include "cw/dbg.h"

View File

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

View File

@ -24,7 +24,7 @@
#include "cw/dbg.h"
#include "cw/cw.h"
#include "cw/kvt.h"
#include "cw/ktv.h"
#include "cw/keys.h"
@ -99,7 +99,7 @@ static void readsubelems_wtp_board_data(mavl_t cfg, uint8_t * msgelem,
if (key){
char add_key[256];
sprintf(add_key,"wtp_board_data/%s",key);
cw_kvt_add(cfg,add_key,CW_TYPE_BSTR16,msgelem+i,sublen);
cw_ktv_add(cfg,add_key,CW_TYPE_BSTR16,msgelem+i,sublen);
}
@ -134,7 +134,7 @@ int capwap_in_wtp_board_data(struct cw_ElemHandler *eh, struct cw_ElemHandlerPar
sprintf(vendor_key,"%s/%s",eh->key,CW_KEY_VENDOR);
cw_kvt_add(cfg,vendor_key,CW_TYPE_DWORD,data,len);
cw_ktv_add(cfg,vendor_key,CW_TYPE_DWORD,data,len);
/*
mbag_t itemstore = conn->incomming;

View File

@ -25,7 +25,7 @@ int capwap_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t
d+=cw_put_ac_status(d ,(struct cw_ac_status*)(i->u2.data),conn);
/*
i = mbag_get(conn->local,CW_ITEM_AC_HARDWARE_VERSION);
if ( i ) {
@ -44,7 +44,7 @@ int capwap_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t
else {
cw_log(LOG_ERR, "Can't send software version in AC descriptor, not set.");
}
*/
int len = d-dst-4;
return len + cw_put_elem_hdr(dst,a->elem_id,len);

View File

@ -41,7 +41,7 @@ int capwap_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_
mbag_item_t * i;
i = mbag_get(mbag,CW_ITEM_WTP_HARDWARE_VERSION);
if ( i ) {
/* if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->u2.data);
if (bstrv_get_vendor_id(i->u2.data)){
d += cw_put_dword(d, 0);
@ -55,10 +55,10 @@ int capwap_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_
cw_log(LOG_ERR, "Can't send Hardware Version in WTP Descriptor, not set.");
}
*/
i = mbag_get(mbag,CW_ITEM_WTP_SOFTWARE_VERSION);
if ( i ) {
/* if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_SOFTWARE_VERSION,i->u2.data);
}
else {
@ -73,7 +73,7 @@ int capwap_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_
cw_log(LOG_ERR, "Can't send Bootloader Version in WTP descriptor, not set.");
}
*/
int len = d-dst-4;
return len + cw_put_elem_hdr(dst,a->elem_id,len);
}

View File

@ -4,7 +4,7 @@
struct cw_Mod *mod_capwap_ac();
struct cw_Mod *mod_capwap_wtp();
#include "cw/msget.h"
#include "cw/msgset.h"
#include "cw/conn.h"

View File

@ -17,7 +17,7 @@ extern int capwap_register_actions_ac(struct cw_actiondef *def);
static int init()
{
cw_dbg(DBG_MOD, "Initialiazing mod_capwap.");
cw_dbg(DBG_MOD, "CAPWAP: Initialiazing mod_capwap.");
return 0;
}

View File

@ -27,7 +27,7 @@ static int init()
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
struct sockaddr *from, int mode)
{
if (mode != MOD_MODE_BINDINGS)
if (mode != CW_MOD_MODE_BINDINGS)
return 0;
int wbid = cw_get_hdr_wbid(rawmsg);
@ -41,7 +41,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
static int register_actions(struct cw_actiondef *actions, int mode)
{
if (mode != MOD_MODE_BINDINGS)
if (mode != CW_MOD_MODE_BINDINGS)
return 0;
return capwap80211_register_actions_ac(actions);

View File

@ -26,7 +26,7 @@ static int init()
static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
struct sockaddr *from, int mode)
{
if (mode != MOD_MODE_BINDINGS)
if (mode != CW_MOD_MODE_BINDINGS)
return 0;
cw_log(LOG_INFO, "Detecting WTP 80211");
@ -35,7 +35,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
static int register_actions(struct cw_actiondef *actions,int mode)
{
if (mode != MOD_MODE_BINDINGS)
if (mode != CW_MOD_MODE_BINDINGS)
return 0;
return capwap80211_register_actions_wtp(actions);
}

View File

@ -40,7 +40,7 @@ OBJDIR := ../../../obj/mod_cisco/$(ARCH)
SNAME := $(LIBARCHDIR)/libmod_cisco.a
DNAME := $(LIBARCHDIR)/mod_cisco.so
MODNAME := $(LIBDIR)/mod_cisco.so
SLIBS := -lcw -lmod_cipwap -lmod_capwap
SLIBS := -lcw -lmod_cipwap -lmod_capwap -lconfuse
include ../Mod.mak

View File

@ -41,8 +41,8 @@
#include "include/cipwap_items.h"
#include "cw/msget.h"
#include "cw/kvt.h"
#include "cw/msgset.h"
#include "cw/ktv.h"
static struct cw_ElemHandler handlers[] = {
@ -86,6 +86,7 @@ static int discovery_request_states[] = {CAPWAP_STATE_DISCOVERY,0};
static struct cw_ElemDef discovery_request_elements[] ={
{0,0, CAPWAP_ELEM_WTP_DESCRIPTOR, 1, 0},
{0,CW_VENDOR_ID_CISCO, CW_CISCO_RAD_NAME, 1, 0},
{0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 1, 0},
{0,0,0,00}
};

View File

@ -47,7 +47,7 @@ int cisco_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *
otherwise the AP wants us to send an image */
i = mbag_get(conn->incomming,CW_ITEM_WTP_SOFTWARE_VERSION);
}
/*
if ( i ) {
d += cw_put_version(d,1,i->u2.data);
}
@ -62,7 +62,7 @@ int cisco_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *
else {
cw_log(LOG_ERR, "Can't set Cisco Hardware Version in AC descriptor, No value defined.");
}
*/
int len = d-dst-4;

View File

@ -28,16 +28,16 @@ mbag_t mbag = NULL;
mbag_item_t * i;
i = mbag_get(mbag,CW_ITEM_WTP_HARDWARE_VERSION);
if ( i ) {
/* if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_HARDWARE_VERSION,i->u2.data);
}
else {
cw_log(LOG_ERR, "Can't send Hardware Version in WTP Descriptor, not set.");
}
*/
i = mbag_get(mbag,CW_ITEM_WTP_SOFTWARE_VERSION);
/*
if ( i ) {
d += cw_put_version(d,CW_SUBELEM_WTP_SOFTWARE_VERSION,i->u2.data);
}
@ -52,7 +52,7 @@ mbag_t mbag = NULL;
else {
cw_log(LOG_ERR, "Can't send Bootloader Version in WTP descriptor, not set.");
}
*/
int len = d-dst-4;
return len + cw_put_elem_hdr(dst,a->elem_id,len);

View File

@ -26,7 +26,7 @@ static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
switch (mode) {
case CW_MOD_MODE_CAPWAP:
{
cw_dbg(DBG_MOD,"Cisco: loading base med capwap");
cw_dbg(DBG_MOD,"Cisco: loading base mod capwap");
struct cw_Mod *cmod = cw_mod_load("capwap");
if (!cmod) {
@ -40,18 +40,19 @@ static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
cw_dbg(DBG_MOD,"Cisco: loading cisco message set");
cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messafe", 7);
cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);
return 0;
}
case MOD_MODE_BINDINGS:
case CW_MOD_MODE_BINDINGS:
{
struct cw_Mod *cmod = NULL; //modload_ac("capwap80211");
return 0;
struct cw_Mod *cmod = cw_mod_load("capwap80211"); //modload_ac("capwap80211");
if (!cmod) {
cw_log(LOG_ERR,
"Can't initialize mod_cisco, failed to load base mod mod_capwap80211");
return 1;
}
cmod->register_messages(set, MOD_MODE_BINDINGS);
cmod->register_messages(set, CW_MOD_MODE_BINDINGS);
int rc = cisco_register_actions80211_ac(set);
cw_dbg(DBG_INFO, "Initialized mod_cisco 80211 with %d actions", 12);
return 0;

View File

@ -39,7 +39,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
cw_dbg(DBG_INFO, "Initialized mod cisco with %d actions", rc);
return rc;
}
case MOD_MODE_BINDINGS:
case CW_MOD_MODE_BINDINGS:
{
struct cw_Mod *cmod = modload_wtp("capwap80211");
if (!cmod) {
@ -47,7 +47,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
"Can't initzialize mod_cisco, failed to load base mod mod_capwap80211");
return 1;
}
cmod->register_actions(actions, MOD_MODE_BINDINGS);
cmod->register_actions(actions, CW_MOD_MODE_BINDINGS);
int rc = cisco_register_actions80211_wtp(actions);
cw_dbg(DBG_INFO, "Initialized mod cisco 80211 with %d actions", rc);
return 0;

View File

@ -32,7 +32,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
cw_dbg(DBG_INFO, "Initialized mod fortinet with %d actions", rc);
return 0;
}
case MOD_MODE_BINDINGS:
case CW_MOD_MODE_BINDINGS:
{
struct cw_Mod *cmod = modload_ac("capwap80211");
if (!cmod) {
@ -40,7 +40,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
"Can't initialize mod_fortinet, failed to load base mod mod_capwap80211");
return 1;
}
cmod->register_actions(actions, MOD_MODE_BINDINGS);
cmod->register_actions(actions, CW_MOD_MODE_BINDINGS);
int rc = fortinet_register_actions80211_ac(actions);
cw_dbg(DBG_INFO, "Initialized mod_fortinet 80211 with %d actions", rc);
return 0;

View File

@ -36,7 +36,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
cw_dbg(DBG_INFO, "Initialized mod_fortinet with %d actions", rc);
return rc;
}
case MOD_MODE_BINDINGS:
case CW_MOD_MODE_BINDINGS:
{
struct cw_Mod *cmod = modload_wtp("capwap80211");
if (!cmod) {
@ -44,7 +44,7 @@ static int register_actions(struct cw_actiondef *actions, int mode)
"Can't initialize mod_fortinet, failed to load base mod mod_capwap80211");
return 1;
}
cmod->register_actions(actions, MOD_MODE_BINDINGS);
cmod->register_actions(actions, CW_MOD_MODE_BINDINGS);
int rc = cisco_register_actions80211_wtp(actions);
cw_dbg(DBG_INFO, "Initialized mod_fortinet 80211 with %d actions", rc);
return 0;

View File

@ -1,56 +1,19 @@
include ../Config.mak
include ../WtpConfig.mak
-include ../Config.local.mak
-include ../WtpConfig.local.mak
include ../Macros.mak
ifndef CC
CC=gcc
endif
V=0
CFLAGS+=-DWITH_RMAC_SUPPORT
CFLAGS+=-DWITH_IPV6
CFLAGS+=-DWITH_CW_LOG
CFLAGS+=-DWITH_CW_LOG_DEBUG
CFLAGS+=-DWITH_DTLS
ifndef ARCH
ARCH = $(shell $(CC) -dumpmachine)
endif
CFLAGS += -O0 -Wall -Wno-unused-variable -Werror -g
#CFLAGS += -Os -Wall
LDFLAGS += -L../contrib/jsmn -L../../src/lib/$(ARCH)
CONFOBJS = wtp_conf.o
LIBS+=-lcapwap
LIBS+=-lcapwap80211
LIBS+=-lcipwap
LIBS+=-lcisco
LIBS+=-lfortinet
LIBS+=-lcw
LIBS+=-lnl-3
LIBS+=-lnl-genl-3
LIBS+=-ljsmn
ifeq ($(CONF_LIBRARY),UCI)
CFLAGS+=-DWITH_UCI
LIBS+=-luci -lubox
CONFOBJS += conf_uci.o
else
LIBS+=-lconfuse
CONFOBJS += wtp_conf_confuse.o
endif
LIBDIR := ../../lib
LIBARCHDIR := $(LIBDIR)/$(ARCH)
OBJDIR := ../../obj/wtp/$(ARCH)
EXENAME := ./wtp
LIBS := -lcw
#STATICLIBS := $(LIBDIR)/$(ARCH)/libcw.a
LDFLAGS += -L$(LIBARCHDIR)
ifeq ($(SSL_LIBRARY),GNUTLS)
CFLAGS+=-DWITH_GNUTLS
@ -67,76 +30,34 @@ LIBS+=$(OPENSSL_LIBS)
endif
#SRC=$(wildcard *.c)
SRC=wtp_main.c
OBJS=$(patsubst %.c,%.o,$(SRC))
OBJS:=$(patsubst %.o,$(OBJDIR)/%.o,$(OBJS))
#HA_FILES += ../contrib/hostap/src/drivers/driver_nl80211.o
HA_INCS += -I$(INCLUDE_DIR)/libnl-tiny
HA_INCS += -I../contrib/hostap/src/utils
HA_INCS += -I../contrib/hostap/src
CFLAGS += $(HA_INCS)
#CFLAGS += -I../src
#CFLAGS += -I../src/utils
CFLAGS += -I../../src -I /usr/local/include -I ../contrib/jsmn
#CFLAGS += -I/usr/local/include
OBJS += wtp_main.o
OBJS += image_update.o
OBJS += cfg.o
#OBJS += wtp_conf.o
OBJS += discovery.o
OBJS += wtp_interface.o
OBJS += wtpdrv.o
OBJS += dot11.o
OBJS += join.o
OBJS += run.o
OBJS += sulking.o
OBJS += configure.o
OBJS += changestate.o
OBJS += setup_conf.o
OBJS += $(CONFOBJS)
OBJS += nlt_attrnames.o
OBJS += nlt_cmdnames.o
OBJS += nlt.o
#OBJS += $(HA_FILES)
ALL=wtp
ALL=$(EXENAME)
all: $(ALL)
Q=@
E=echo
ifeq ($(V), 1)
Q=
E=true
endif
%.o: %.c
@$(E) " CC " $<
$(Q)$(CC) -c -o $@ $(CFLAGS) $<
$(OBJDIR)/%.o:%.c
@mkdir -p $(OBJDIR)
@echo " $(CC) "$<
@$(CC) -c $(CFLAGS) $< -o $@
$(EXENAME): $(OBJS)
@echo " $(LD) $(EXENAME)"
@$(LD) $(LDFLAGS) -o $(EXENAME) $(OBJS) $(LIBS) $(STATICLIBS)
wtp: $(OBJS)
$(Q)$(CC) $(OBJS) ../mod/modload_wtp.o -o wtp $(LDFLAGS) $(LIBS)
@$(E) " LD " $@
clean:
# $(MAKE) -C ../src clean
rm -f *.o
rm -f *.d
$(RM) $(OBJDIR)/*
$(RM) $(EXENAME)
-include $(OBJS:%.o=%.d)
deps:
echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > .depend
makedepend $(SRC) -f.depend -p$(OBJDIR)/
-include .depend

View File

@ -1,233 +1,110 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "cw/capwap.h"
#include "cw/cipwap.h"
#include "cw/capwap_items.h"
#include "cw/conn.h"
#include "cw/log.h"
#include "cw/dtls.h"
#include "cw/acpriolist.h"
//#include "cw/capwap_80211.h"
#include "cw/radio.h"
#include "cw/capwap80211_items.h"
#include "cw/mod.h"
#include "wtp.h"
#include "wtp_conf.h"
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
\
#include "cw/ktv.h"
#include "cw/dbg.h"
#include "cw/mavl.h"
#include "cw/log.h"
#include "cw/msgset.h"
#include "jsmn.h"
struct bootcfg{
const char * modname;
const char * modpath;
const char * cfgfilename;
};
#include "cfg.h"
#include "../mod/modload.h"
/** The one and only connection object */
struct conn *the_conn;
struct cw_actiondef capwap_actions;
const char *t = CW_ITEM_WTP_NAME;
#include <signal.h>
void update_reboot_stats(struct conn * conn, int cause)
static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
{
int c;
opterr = 1;
bootcfg->modname = "cisco";
bootcfg->cfgfilename = "config.ktv";
mbag_t rs = mbag_get_mbag(conn->config,CW_ITEM_WTP_REBOOT_STATISTICS,NULL);
while ( (c = getopt (argc, argv, "p:d:vc:m:h")) != -1) {
switch (cause){
case CW_REBOOT_TYPE_NOT_SUPPORTED:
switch (c) {
case 'v':
printf("WFAT version 0.0.1\n");
exit(EXIT_SUCCESS);
break;
case CW_REBOOT_TYPE_AC_INITIATED:
mbag_inc_word(rs,CW_ITEM_REBOOT_AC_INITIATED_COUNT,1);
case 'd':{
int b = cw_strlist_get_id(cw_dbg_strings, optarg);
if (b==-1){
fprintf(stderr,"Invalid debug option: %s\n",optarg);
exit(EXIT_FAILURE);
}
cw_dbg_set_level(b, 1);
break;
case CW_REBOOT_TYPE_OTHER_FAILURE:
mbag_inc_word(rs,CW_ITEM_REBOOT_OTHER_FAILURE_COUNT,1);
}
case 'm':
bootcfg->modname = optarg;
break;
case 'p':
cw_mod_set_path(optarg);
break;
case 'c':
bootcfg->cfgfilename = optarg;
case '?':
exit(EXIT_FAILURE);
default:
case 'h':
printf("%s: -vcmh\n",argv[0]);
exit(EXIT_SUCCESS);
break;
}
mbag_inc_word(rs,CW_ITEM_REBOOT_COUNT,1);
mbag_set_byte(rs,CW_ITEM_REBOOT_LAST_FAILURE_TYPE,cause);
cfg_to_json();
}
static void sig_handler(int sig)
{
struct conn * conn = the_conn; //get_conn();
update_reboot_stats(conn, CW_REBOOT_TYPE_OTHER_FAILURE);
exit(0);
}
#include "cw/dot11.h"
#include "cw/format.h"
#include "cw/capwap80211_types.h"
int main()
{
signal (SIGINT, sig_handler);
wtpconf_preinit();
if (!read_config("./wtp_uci.conf")) {
return 1;
}
// cw_dbg_opt_level = conf_dbg_level;
if (!wtpconf_init()){
return 1;
};
cw_dbg_opt_display = DBG_DISP_ASC_DMP | DBG_DISP_COLORS;
dtls_init();
the_conn = conn_create_noq(-1, NULL);
struct conn *conn = the_conn;
conn->radios = mbag_i_create();
conn->radios_upd=mbag_i_create();
mbag_i_set_mbag(conn->radios,0,mbag_create());
mbag_i_set_mbag(conn->radios_upd,0,mbag_create());
#define CWMOD "cisco"
#define CWBIND "cisco"
//#define CWMOD "capwap"
//#define CWBIND "capwap80211"
struct cw_Mod *mod = modload_wtp(CWMOD);
if (!mod) {
printf("Can't load mod capwap\n");
exit(0);
}
mod->init();
mod->register_actions(&capwap_actions,CW_MOD_MODE_CAPWAP);
mod = modload_wtp(CWBIND);
if (!mod) {
printf("Can't load mod capwap80211\n");
exit(0);
}
int rc = mod->register_actions(&capwap_actions,MOD_MODE_BINDINGS);
conn->detected = 1;
conn->dtls_verify_peer=0;
conn->dtls_mtu = 12000;
conn->actions = &capwap_actions;
conn->outgoing = mbag_create();
conn->incomming = mbag_create();
conn->local = mbag_create();
conn->config = mbag_create();
the_conn->strict_capwap = 0;
cfg_from_json(conn);
setup_conf(conn);
mbag_t r;
// r = mbag_i_get_mbag(conn->radios,0,NULL);
r = conn->radios;
MAVLITER_DEFINE(it,r);
mavliter_foreach(&it){
struct mbag_item *i=mavliter_get(&it);
printf("RID = %d\n",i->iid);
printf("DATA: %p\n",i->data);
mbag_t radio= (mbag_t)i->data;
struct mbag_item *mri = mbag_get(radio,CW_RADIOITEM80211_WTP_RADIO_INFORMATION);
if (!mri){
printf("Setting to 8 %p %p\n",mri,r);
mbag_set_dword(radio,CW_RADIOITEM80211_WTP_RADIO_INFORMATION,1);
}
else{
printf("MRI %p\n",mri);
}
}
mod_init_config(mod,conn->config);
cfg_to_json();
mbag_t mb = mbag_get_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, NULL);
printf("mbag %p\n", mb);
cw_acpriolist_t acprios = cw_acpriolist_create();
cw_acpriolist_set(acprios, "Master AC", strlen("Master AC"), 1);
cw_acpriolist_set(acprios, "AC8new", strlen("AC8new"), 12);
mbag_set_byte(conn->local, CW_ITEM_WTP_MAC_TYPE, CAPWAP_WTP_MAC_TYPE_SPLIT);
mbag_set_byte(conn->local, CW_ITEM_WTP_FRAME_TUNNEL_MODE, CW_WTP_FRAME_TUNNEL_MODE_E);
conn->wbid=1;
// cw_set_msg_end_callback(conn->actions,CW_STATE_RUN,CW_MSG_CONFIGURATION_UPDATE_REQUEST,handle_update_req);
if (!discovery())
return -1;
if (!join())
return -1;
if (!configure())
return -1;
cw_dbg(DBG_X,"Saveing config 0");
cfg_to_json();
changestate();
run();
//image_update();
return 0;
}
struct conn *get_conn()
int main (int argc, char **argv)
{
return the_conn;
mavl_t types;
mavliter_t it;
struct bootcfg bootcfg;
struct cw_Mod * mod;
struct cw_MsgSet * msgset;
parse_args(argc,argv, &bootcfg);
msgset = cw_msgset_create();
if (msgset==NULL){
cw_log(LOG_ERR, "Error creating msgset: %s", strerror(errno));
exit(EXIT_FAILURE);
}
mod = cw_mod_load(bootcfg.modname);
if (mod == NULL){
exit (EXIT_FAILURE);
}
mod->register_messages(msgset, CW_MOD_MODE_CAPWAP);
mod->register_messages(msgset, CW_MOD_MODE_BINDINGS);
types = cw_ktv_create_types_tree();
if (types == NULL){
perror("Error creating types tree");
exit(EXIT_FAILURE);
}
mavl_add_ptr(types,CW_TYPE_BSTR16);
mavl_add_ptr(types,CW_TYPE_DWORD);
mavliter_init(&it,types);
mavliter_foreach(&it){
struct cw_Type * t = mavliter_get_ptr(&it);
printf("The Type is %s\n",t->name);
}
return (EXIT_SUCCESS);
}

View File

@ -32,6 +32,8 @@
</VirtualDirectory>
<Description/>
<Dependencies/>
<Dependencies Name="Debug"/>
<Dependencies Name="Release"/>
<Settings Type="Dynamic Library">
<GlobalSettings>
<Compiler Options="" C_Options="" Assembler="">
@ -48,9 +50,9 @@
</Compiler>
<Linker Options="" Required="yes"/>
<ResourceCompiler Options="" Required="no"/>
<General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<General OutputFile="" IntermediateDirectory="./Debug" Command="$(WorkspacePath)/src/wtp/wtp" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(WorkspacePath)/src/wtp/" PauseExecWhenProcTerminates="yes" IsGUIProgram="no" IsEnabled="yes"/>
<Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
<![CDATA[]]>
<![CDATA[LD_LIBRARY_PATH=../../lib]]>
</Environment>
<Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="" IsExtended="no">
<DebuggerSearchPaths/>
@ -119,6 +121,4 @@
</Completion>
</Configuration>
</Settings>
<Dependencies Name="Debug"/>
<Dependencies Name="Release"/>
</CodeLite_Project>