diff --git a/libcw.project b/libcw.project
index e0411581..c14e2613 100644
--- a/libcw.project
+++ b/libcw.project
@@ -41,7 +41,6 @@
-
@@ -77,7 +76,6 @@
-
@@ -309,18 +307,24 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -343,9 +347,9 @@
-
+
-
+
diff --git a/src/ac/ac_main.c b/src/ac/ac_main.c
index c7d1ed1f..521a93e6 100644
--- a/src/ac/ac_main.c
+++ b/src/ac/ac_main.c
@@ -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;
diff --git a/src/ac/conf.c b/src/ac/conf.c
index ef393c74..99e1a318 100644
--- a/src/ac/conf.c
+++ b/src/ac/conf.c
@@ -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);
diff --git a/src/ac/wtpman.c b/src/ac/wtpman.c
index 371942db..6d9e5d73 100644
--- a/src/ac/wtpman.c
+++ b/src/ac/wtpman.c
@@ -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) {
diff --git a/src/cw/bstrv_create_from_str.c b/src/cw/bstrv_create_from_str.c
index d841c567..b8efa112 100644
--- a/src/cw/bstrv_create_from_str.c
+++ b/src/cw/bstrv_create_from_str.c
@@ -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;
+*/
}
diff --git a/src/cw/capwap.h b/src/cw/capwap.h
index 08fb1b47..bc88765d 100644
--- a/src/cw/capwap.h
+++ b/src/cw/capwap.h
@@ -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,
diff --git a/src/cw/conn.h b/src/cw/conn.h
index 9c803c1e..ca4b2bf1 100644
--- a/src/cw/conn.h
+++ b/src/cw/conn.h
@@ -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);
diff --git a/src/cw/conn_process_packet.c b/src/cw/conn_process_packet.c
index 1dc7c7f0..e68aaf1a 100644
--- a/src/cw/conn_process_packet.c
+++ b/src/cw/conn_process_packet.c
@@ -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);
@@ -506,6 +506,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);
{
@@ -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);
diff --git a/src/cw/conn_send_msg.c b/src/cw/conn_send_msg.c
new file mode 100644
index 00000000..412727af
--- /dev/null
+++ b/src/cw/conn_send_msg.c
@@ -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);
+}
+
diff --git a/src/cw/cw.h b/src/cw/cw.h
index 5def2b8d..f5b055f4 100644
--- a/src/cw/cw.h
+++ b/src/cw/cw.h
@@ -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);
diff --git a/src/cw/cw_check_missing_mand.c b/src/cw/cw_check_missing_mand.c
index 846357fa..ed5e4fc0 100644
--- a/src/cw/cw_check_missing_mand.c
+++ b/src/cw/cw_check_missing_mand.c
@@ -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
}
+
diff --git a/src/cw/cw_in_check_cfg_update_req.c b/src/cw/cw_in_check_cfg_update_req.c
index a06c6cc9..55471aed 100644
--- a/src/cw/cw_in_check_cfg_update_req.c
+++ b/src/cw/cw_in_check_cfg_update_req.c
@@ -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);
diff --git a/src/cw/cw_in_check_cipwap_join_req.c b/src/cw/cw_in_check_cipwap_join_req.c
index d2b6aec5..857aee5c 100644
--- a/src/cw/cw_in_check_cipwap_join_req.c
+++ b/src/cw/cw_in_check_cipwap_join_req.c
@@ -9,6 +9,7 @@
#include "vendors.h"
+/*
void cw_get_wtp_name(struct conn *conn,struct sockaddr *addr)
{
@@ -30,7 +31,7 @@ int cw_detect_capwap(struct conn *conn)
mbag_item_t * item = mbag_get(is,CW_ITEM_WTP_SOFTWARE_VERSION);
if (item) {
bstrv_t s = item->u2.data;
- uint32_t v = bstrv_get_vendor_id(s);
+ uint32_t v = bstrv_get_vendor_id(s);
switch(v) {
case CW_VENDOR_ID_CISCO:
@@ -62,3 +63,5 @@ int cw_in_check_cipwap_join_req(struct conn *conn, struct cw_action_in *a, uint8
return rc;
}
+*/
+
diff --git a/src/cw/cw_in_check_disc_req.c b/src/cw/cw_in_check_disc_req.c
index 4bc66e38..6d25f376 100644
--- a/src/cw/cw_in_check_disc_req.c
+++ b/src/cw/cw_in_check_disc_req.c
@@ -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;
}
diff --git a/src/cw/cw_in_check_generic_req.c b/src/cw/cw_in_check_generic_req.c
index 7eed56e8..7b107c2f 100644
--- a/src/cw/cw_in_check_generic_req.c
+++ b/src/cw/cw_in_check_generic_req.c
@@ -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;
}
diff --git a/src/cw/cw_in_check_generic_resp.c b/src/cw/cw_in_check_generic_resp.c
index 1f98beb1..c495e318 100644
--- a/src/cw/cw_in_check_generic_resp.c
+++ b/src/cw/cw_in_check_generic_resp.c
@@ -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;
}
diff --git a/src/cw/cw_in_check_img_data_req_ac.c b/src/cw/cw_in_check_img_data_req_ac.c
index 05b19e4f..9cf4c955 100644
--- a/src/cw/cw_in_check_img_data_req_ac.c
+++ b/src/cw/cw_in_check_img_data_req_ac.c
@@ -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;
-
+*/
}
diff --git a/src/cw/cw_in_check_img_data_req_wtp.c b/src/cw/cw_in_check_img_data_req_wtp.c
index 22d4117a..fe717985 100644
--- a/src/cw/cw_in_check_img_data_req_wtp.c
+++ b/src/cw/cw_in_check_img_data_req_wtp.c
@@ -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;
-
+*/
}
diff --git a/src/cw/cw_in_check_img_data_resp.c b/src/cw/cw_in_check_img_data_resp.c
index 23ca4c58..4af2c5eb 100644
--- a/src/cw/cw_in_check_img_data_resp.c
+++ b/src/cw/cw_in_check_img_data_resp.c
@@ -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;
}
diff --git a/src/cw/cw_in_check_join_req.c b/src/cw/cw_in_check_join_req.c
index 3d22a083..d54269c1 100644
--- a/src/cw/cw_in_check_join_req.c
+++ b/src/cw/cw_in_check_join_req.c
@@ -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;
}
diff --git a/src/cw/cw_in_check_join_request.c b/src/cw/cw_in_check_join_request.c
deleted file mode 100644
index b28b04f6..00000000
--- a/src/cw/cw_in_check_join_request.c
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/src/cw/cw_in_check_join_resp.c b/src/cw/cw_in_check_join_resp.c
index f06c5e52..e39804e7 100644
--- a/src/cw/cw_in_check_join_resp.c
+++ b/src/cw/cw_in_check_join_resp.c
@@ -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;
}
diff --git a/src/cw/cw_in_generic.c b/src/cw/cw_in_generic.c
index 05592db7..d23e64e2 100644
--- a/src/cw/cw_in_generic.c
+++ b/src/cw/cw_in_generic.c
@@ -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);
/*
diff --git a/src/cw/cw_inline.c b/src/cw/cw_inline.c
index 33e4d5fa..7c58d87d 100644
--- a/src/cw/cw_inline.c
+++ b/src/cw/cw_inline.c
@@ -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) {
diff --git a/src/cw/cw_kvt_add.c b/src/cw/cw_ktv_add.c
similarity index 88%
rename from src/cw/cw_kvt_add.c
rename to src/cw/cw_ktv_add.c
index 0bcc826d..f4ec3a8f 100644
--- a/src/cw/cw_kvt_add.c
+++ b/src/cw/cw_ktv_add.c
@@ -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,
diff --git a/src/cw/cw_ktv_mavlcmp.c b/src/cw/cw_ktv_mavlcmp.c
new file mode 100644
index 00000000..0f663e34
--- /dev/null
+++ b/src/cw/cw_ktv_mavlcmp.c
@@ -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);
+}
diff --git a/src/cw/cw_ktv_mavlcmp_type_by_name.c b/src/cw/cw_ktv_mavlcmp_type_by_name.c
new file mode 100644
index 00000000..eb0e24e1
--- /dev/null
+++ b/src/cw/cw_ktv_mavlcmp_type_by_name.c
@@ -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);
+}
diff --git a/src/cw/cw_kvt_mavldel.c b/src/cw/cw_ktv_mavldel.c
similarity index 54%
rename from src/cw/cw_kvt_mavldel.c
rename to src/cw/cw_ktv_mavldel.c
index 409ead6a..627111df 100644
--- a/src/cw/cw_kvt_mavldel.c
+++ b/src/cw/cw_ktv_mavldel.c
@@ -2,11 +2,11 @@
#include
-#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);
diff --git a/src/cw/cw_ktv_read_file.c b/src/cw/cw_ktv_read_file.c
new file mode 100644
index 00000000..c387c3dd
--- /dev/null
+++ b/src/cw/cw_ktv_read_file.c
@@ -0,0 +1,8 @@
+
+#include "ktv.h"
+
+cw_kvt_read_file(mavl_t ktv, mavl_t types)
+{
+
+
+}
\ No newline at end of file
diff --git a/src/cw/cw_ktv_readline.c b/src/cw/cw_ktv_readline.c
new file mode 100644
index 00000000..19fb90d3
--- /dev/null
+++ b/src/cw/cw_ktv_readline.c
@@ -0,0 +1,229 @@
+#include
+
+#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 && nerror,"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 && n0){
+ 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;
+}
diff --git a/src/cw/cw_kvt_mavlcmp.c b/src/cw/cw_kvt_mavlcmp.c
deleted file mode 100644
index 84b89629..00000000
--- a/src/cw/cw_kvt_mavlcmp.c
+++ /dev/null
@@ -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);
-}
diff --git a/src/cw/cw_out_wtp_descriptor.c b/src/cw/cw_out_wtp_descriptor.c
index 117653ae..5d52b242 100644
--- a/src/cw/cw_out_wtp_descriptor.c
+++ b/src/cw/cw_out_wtp_descriptor.c
@@ -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);
}
diff --git a/src/cw/cw_process_element.c b/src/cw/cw_process_element.c
index 8e0a669d..6a33f769 100644
--- a/src/cw/cw_process_element.c
+++ b/src/cw/cw_process_element.c
@@ -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",
diff --git a/src/cw/cw_read_descriptor_subelems.c b/src/cw/cw_read_descriptor_subelems.c
index 749db387..1ba57418 100644
--- a/src/cw/cw_read_descriptor_subelems.c
+++ b/src/cw/cw_read_descriptor_subelems.c
@@ -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);
diff --git a/src/cw/cw_read_wtp_descriptor.c b/src/cw/cw_read_wtp_descriptor.c
index 8bf1bd54..4bc3a990 100644
--- a/src/cw/cw_read_wtp_descriptor.c
+++ b/src/cw/cw_read_wtp_descriptor.c
@@ -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[] = {
diff --git a/src/cw/cw_read_wtp_descriptor_7.c b/src/cw/cw_read_wtp_descriptor_7.c
index b6385ef2..f3eebaf8 100644
--- a/src/cw/cw_read_wtp_descriptor_7.c
+++ b/src/cw/cw_read_wtp_descriptor_7.c
@@ -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));
diff --git a/src/cw/cw_read_wtp_descriptor_versions.c b/src/cw/cw_read_wtp_descriptor_versions.c
index b27a4273..6d61e2c0 100644
--- a/src/cw/cw_read_wtp_descriptor_versions.c
+++ b/src/cw/cw_read_wtp_descriptor_versions.c
@@ -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;
}
diff --git a/src/cw/cw_type_bstr16.c b/src/cw/cw_type_bstr16.c
index dee17d46..6a39b5d0 100644
--- a/src/cw/cw_type_bstr16.c
+++ b/src/cw/cw_type_bstr16.c
@@ -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;
}
diff --git a/src/cw/cw_type_byte.c b/src/cw/cw_type_byte.c
index ec99c6b3..7b77b6b3 100644
--- a/src/cw/cw_type_byte.c
+++ b/src/cw/cw_type_byte.c
@@ -19,26 +19,26 @@
#include
#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;
diff --git a/src/cw/cw_type_dword.c b/src/cw/cw_type_dword.c
index 66fa08e5..c168cd73 100644
--- a/src/cw/cw_type_dword.c
+++ b/src/cw/cw_type_dword.c
@@ -19,26 +19,26 @@
#include
#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;
diff --git a/src/cw/cw_type_word.c b/src/cw/cw_type_word.c
index 0779ed4f..4d079e0b 100644
--- a/src/cw/cw_type_word.c
+++ b/src/cw/cw_type_word.c
@@ -18,28 +18,28 @@
#include
-#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;
diff --git a/src/cw/dbg.c b/src/cw/dbg.c
index cfaa485d..087614eb 100644
--- a/src/cw/dbg.c
+++ b/src/cw/dbg.c
@@ -36,7 +36,7 @@
#include "capwap_cisco.h"
#include "lwapp_cisco.h"
#include "cw.h"
-#include "msget.h"
+#include "msgset.h"
diff --git a/src/cw/kvt.h b/src/cw/ktv.h
similarity index 58%
rename from src/cw/kvt.h
rename to src/cw/ktv.h
index f5fb7fc5..ce188877 100644
--- a/src/cw/kvt.h
+++ b/src/cw/ktv.h
@@ -2,20 +2,23 @@
#define __KVT_H
#include
+#include
#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 */
diff --git a/src/cw/mavl.h b/src/cw/mavl.h
index ff6b7553..1a15fe85 100644
--- a/src/cw/mavl.h
+++ b/src/cw/mavl.h
@@ -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)))
diff --git a/src/cw/mavl_add_ptr.c b/src/cw/mavl_add_ptr.c
index 5008686f..00bba563 100644
--- a/src/cw/mavl_add_ptr.c
+++ b/src/cw/mavl_add_ptr.c
@@ -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)
diff --git a/src/cw/mlist.h b/src/cw/mlist.h
index 54a7ba9b..ba2d3264 100644
--- a/src/cw/mlist.h
+++ b/src/cw/mlist.h
@@ -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
/**
* @}
@@ -75,6 +78,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);
+
+
/**
* @}
diff --git a/src/cw/mlist_append_ptr.c b/src/cw/mlist_append_ptr.c
new file mode 100644
index 00000000..d96c6b6e
--- /dev/null
+++ b/src/cw/mlist_append_ptr.c
@@ -0,0 +1,6 @@
+#include "mlist.h"
+
+mlistelem_t * mlist_append_ptr (mlist_t list, void * ptr)
+{
+ return mlist_append (list, &ptr);
+}
diff --git a/src/cw/mlist_destroy.c b/src/cw/mlist_destroy.c
new file mode 100644
index 00000000..a7ca1eb5
--- /dev/null
+++ b/src/cw/mlist_destroy.c
@@ -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);
+}
diff --git a/src/cw/mod.c b/src/cw/mod.c
index d6b09e77..46c4970e 100644
--- a/src/cw/mod.c
+++ b/src/cw/mod.c
@@ -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;
diff --git a/src/cw/mod.h b/src/cw/mod.h
index dee4f2bb..356d5f38 100644
--- a/src/cw/mod.h
+++ b/src/cw/mod.h
@@ -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"
diff --git a/src/cw/msgset.c b/src/cw/msgset.c
index 01887ecc..99b0653c 100644
--- a/src/cw/msgset.c
+++ b/src/cw/msgset.c
@@ -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)
{
@@ -129,6 +130,12 @@ struct cw_MsgSet *cw_msgset_create()
cw_msgset_destroy(set);
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++) {
@@ -164,6 +172,14 @@ static int update_msgdata(struct cw_MsgSet *set, struct cw_MsgData *msgdata,
elemdef->proto, elemdef->vendor, elemdef->id);
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;
@@ -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 */
@@ -235,6 +273,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;
}
diff --git a/src/cw/msget.h b/src/cw/msgset.h
similarity index 95%
rename from src/cw/msget.h
rename to src/cw/msgset.h
index 1266f15b..f60304ed 100644
--- a/src/cw/msget.h
+++ b/src/cw/msgset.h
@@ -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 */
};
diff --git a/src/cw/send.c b/src/cw/send.c
index 5e0fa6da..721fbd99 100644
--- a/src/cw/send.c
+++ b/src/cw/send.c
@@ -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;
diff --git a/src/mod/capwap/capwap_actions_ac.c b/src/mod/capwap/capwap_actions_ac.c
index d146f291..b731bf32 100644
--- a/src/mod/capwap/capwap_actions_ac.c
+++ b/src/mod/capwap/capwap_actions_ac.c
@@ -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"
diff --git a/src/mod/capwap/capwap_in_mtu_discovery_padding.c b/src/mod/capwap/capwap_in_mtu_discovery_padding.c
index 11e3cfb7..741cdf94 100644
--- a/src/mod/capwap/capwap_in_mtu_discovery_padding.c
+++ b/src/mod/capwap/capwap_in_mtu_discovery_padding.c
@@ -17,7 +17,7 @@
*/
#include "cw/capwap.h"
-#include "cw/msget.h"
+#include "cw/msgset.h"
#include "cw/dbg.h"
diff --git a/src/mod/capwap/capwap_in_vendor_specific_payload.c b/src/mod/capwap/capwap_in_vendor_specific_payload.c
index 26c5e548..7c2046f3 100644
--- a/src/mod/capwap/capwap_in_vendor_specific_payload.c
+++ b/src/mod/capwap/capwap_in_vendor_specific_payload.c
@@ -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;
diff --git a/src/mod/capwap/capwap_in_wtp_board_data.c b/src/mod/capwap/capwap_in_wtp_board_data.c
index 6a9e9d67..bf9c12fc 100644
--- a/src/mod/capwap/capwap_in_wtp_board_data.c
+++ b/src/mod/capwap/capwap_in_wtp_board_data.c
@@ -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;
diff --git a/src/mod/capwap/capwap_out_ac_descriptor.c b/src/mod/capwap/capwap_out_ac_descriptor.c
index 440ec121..4f9b37d8 100644
--- a/src/mod/capwap/capwap_out_ac_descriptor.c
+++ b/src/mod/capwap/capwap_out_ac_descriptor.c
@@ -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);
diff --git a/src/mod/capwap/capwap_out_wtp_descriptor.c b/src/mod/capwap/capwap_out_wtp_descriptor.c
index 5bd06a1f..c9a06db1 100644
--- a/src/mod/capwap/capwap_out_wtp_descriptor.c
+++ b/src/mod/capwap/capwap_out_wtp_descriptor.c
@@ -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);
}
diff --git a/src/mod/capwap/mod_capwap.h b/src/mod/capwap/mod_capwap.h
index 8cd32528..0d739993 100644
--- a/src/mod/capwap/mod_capwap.h
+++ b/src/mod/capwap/mod_capwap.h
@@ -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"
diff --git a/src/mod/capwap/mod_capwap_ac.c b/src/mod/capwap/mod_capwap_ac.c
index e82f3524..dae21368 100644
--- a/src/mod/capwap/mod_capwap_ac.c
+++ b/src/mod/capwap/mod_capwap_ac.c
@@ -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;
}
diff --git a/src/mod/capwap80211/mod_capwap80211_ac.c b/src/mod/capwap80211/mod_capwap80211_ac.c
index 10e5cf64..dd7323d7 100644
--- a/src/mod/capwap80211/mod_capwap80211_ac.c
+++ b/src/mod/capwap80211/mod_capwap80211_ac.c
@@ -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);
diff --git a/src/mod/capwap80211/mod_capwap80211_wtp.c b/src/mod/capwap80211/mod_capwap80211_wtp.c
index 9dd9cdc3..d058380b 100644
--- a/src/mod/capwap80211/mod_capwap80211_wtp.c
+++ b/src/mod/capwap80211/mod_capwap80211_wtp.c
@@ -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);
}
diff --git a/src/mod/cisco/Makefile b/src/mod/cisco/Makefile
index e1947683..d2158b0b 100644
--- a/src/mod/cisco/Makefile
+++ b/src/mod/cisco/Makefile
@@ -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
diff --git a/src/mod/cisco/cisco_actions_ac.c b/src/mod/cisco/cisco_actions_ac.c
index 378f35d5..58c745ef 100644
--- a/src/mod/cisco/cisco_actions_ac.c
+++ b/src/mod/cisco/cisco_actions_ac.c
@@ -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}
};
diff --git a/src/mod/cisco/cisco_out_ac_descriptor.c b/src/mod/cisco/cisco_out_ac_descriptor.c
index 0c9a5113..37f76692 100644
--- a/src/mod/cisco/cisco_out_ac_descriptor.c
+++ b/src/mod/cisco/cisco_out_ac_descriptor.c
@@ -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;
diff --git a/src/mod/cisco/cisco_out_wtp_descriptor.c b/src/mod/cisco/cisco_out_wtp_descriptor.c
index d85f5707..1635227a 100644
--- a/src/mod/cisco/cisco_out_wtp_descriptor.c
+++ b/src/mod/cisco/cisco_out_wtp_descriptor.c
@@ -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);
diff --git a/src/mod/cisco/mod_cisco_ac.c b/src/mod/cisco/mod_cisco_ac.c
index 1e1061a9..d74fd5c3 100644
--- a/src/mod/cisco/mod_cisco_ac.c
+++ b/src/mod/cisco/mod_cisco_ac.c
@@ -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;
diff --git a/src/mod/cisco/mod_cisco_wtp.c b/src/mod/cisco/mod_cisco_wtp.c
index d66b687c..6d017078 100644
--- a/src/mod/cisco/mod_cisco_wtp.c
+++ b/src/mod/cisco/mod_cisco_wtp.c
@@ -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;
diff --git a/src/mod/fortinet/mod_fortinet_ac.c b/src/mod/fortinet/mod_fortinet_ac.c
index a1eda779..ee0fe47d 100644
--- a/src/mod/fortinet/mod_fortinet_ac.c
+++ b/src/mod/fortinet/mod_fortinet_ac.c
@@ -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;
diff --git a/src/mod/fortinet/mod_fortinet_wtp.c b/src/mod/fortinet/mod_fortinet_wtp.c
index 5ae3c011..bd57c0a7 100644
--- a/src/mod/fortinet/mod_fortinet_wtp.c
+++ b/src/mod/fortinet/mod_fortinet_wtp.c
@@ -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;
diff --git a/src/wtp/Makefile b/src/wtp/Makefile
index dc1ed00c..4f13fddc 100644
--- a/src/wtp/Makefile
+++ b/src/wtp/Makefile
@@ -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:
+ $(RM) $(OBJDIR)/*
+ $(RM) $(EXENAME)
-clean:
-# $(MAKE) -C ../src clean
- rm -f *.o
- rm -f *.d
+deps:
+ echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > .depend
+ makedepend $(SRC) -f.depend -p$(OBJDIR)/
--include $(OBJS:%.o=%.d)
+
+-include .depend
diff --git a/src/wtp/wtp_main.c b/src/wtp/wtp_main.c
index 86fbca35..b8b3a42e 100644
--- a/src/wtp/wtp_main.c
+++ b/src/wtp/wtp_main.c
@@ -1,233 +1,110 @@
#include
-#include
-#include
-
-#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
+#include
+#include
+\
+#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
-
-
-
-void update_reboot_stats(struct conn * conn, int cause)
+static int parse_args (int argc, char *argv[], struct bootcfg * bootcfg)
{
-
-
- mbag_t rs = mbag_get_mbag(conn->config,CW_ITEM_WTP_REBOOT_STATISTICS,NULL);
-
- switch (cause){
- case CW_REBOOT_TYPE_NOT_SUPPORTED:
- break;
- case CW_REBOOT_TYPE_AC_INITIATED:
- mbag_inc_word(rs,CW_ITEM_REBOOT_AC_INITIATED_COUNT,1);
- break;
- case CW_REBOOT_TYPE_OTHER_FAILURE:
- mbag_inc_word(rs,CW_ITEM_REBOOT_OTHER_FAILURE_COUNT,1);
- 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);
- }
-
-
- }
+ int c;
+ opterr = 1;
-
-
-
- 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();
-
+ bootcfg->modname = "cisco";
+ bootcfg->cfgfilename = "config.ktv";
+
+ while ( (c = getopt (argc, argv, "p:d:vc:m:h")) != -1) {
+
+ switch (c) {
+ case 'v':
+ printf("WFAT version 0.0.1\n");
+ exit(EXIT_SUCCESS);
+ break;
+ 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 '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;
+ }
+ }
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);
}
diff --git a/wtp.project b/wtp.project
index d4ff59f8..f35c1a13 100644
--- a/wtp.project
+++ b/wtp.project
@@ -32,6 +32,8 @@
+
+
@@ -48,9 +50,9 @@
-
+
-
+
@@ -119,6 +121,4 @@
-
-