diff --git a/actube.workspace b/actube.workspace index b21adfd1..c63c2d68 100644 --- a/actube.workspace +++ b/actube.workspace @@ -1,10 +1,10 @@ - + - + diff --git a/src/cw/conn_process_packet.c b/src/cw/conn_process_packet.c index 79fe6711..af81c6d4 100644 --- a/src/cw/conn_process_packet.c +++ b/src/cw/conn_process_packet.c @@ -32,7 +32,7 @@ #include "stravltree.h" #include "mod.h" - +#include "message_set.h" int conn_send_msg(struct conn *conn, uint8_t * rawmsg); @@ -189,6 +189,7 @@ static struct cw_MsgSet *load_msg_set(struct conn *conn, uint8_t * rawmsg, int l // struct cw_actiondef *ad = mod_cache_add(conn,cmod, bmod); + struct cw_MsgSet * set = cw_mod_get_msg_set(conn,cmod,bmod); return set; @@ -253,6 +254,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, if (!conn->detected) { //struct mod_ac *mod; struct cw_MsgSet *set = load_msg_set(conn, rawmsg, len, elems_len, from); + + if (!set) { //cw_log(LOG_ERR, "Error"); errno = EAGAIN; @@ -264,13 +267,25 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, conn->detected = 1; } +printf("We have loaded the message set\n"); + + cw_dbg_msg(DBG_MSG_IN, conn, rawmsg, len, from); + /* prepare struct for search operation */ + struct cw_MsgData search; + search.type = cw_get_msg_id(msg_ptr); + struct cw_MsgData * message; + message = mavl_get(conn->msgset->messages,&search); + +printf("Got Message %d (%s)\n", message->type, message->name); +exit(0); +/* as.capwap_state = conn->capwap_state; as.msg_id = cw_get_msg_id(msg_ptr); as.vendor_id = 0; as.elem_id = 0; as.proto = 0; - +*/ /* Search for state/message combination */ // afm = cw_actionlist_in_get(conn->actions->in, &as); @@ -346,7 +361,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, "Element %d (%s) not allowed in msg of type %d (%s), ignoring.", as.elem_id, cw_strelemp(conn->actions, as.elem_id), as.msg_id, cw_strmsg(as.msg_id)); -/* * +*/ continue; } @@ -454,7 +469,6 @@ int process_message(struct conn *conn, uint8_t * rawmsg, int rawlen, { - uint8_t *msgptr = rawmsg + cw_get_hdr_msg_offset(rawmsg); @@ -596,7 +610,7 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len, cw_dbg_pkt(DBG_PKT_IN, conn, f + 4, *(uint32_t *) f, from); - cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from); +// cw_dbg_msg(DBG_MSG_IN, conn, f + 4, *(uint32_t *) f, from); // XXX: Modify fragman to not throw away CAPWAP headers @@ -607,7 +621,7 @@ int conn_process_packet2(struct conn *conn, uint8_t * packet, int len, } /* not fragmented, we have a complete message */ - cw_dbg_msg(DBG_MSG_IN, conn, packet, len, from); +// cw_dbg_msg(DBG_MSG_IN, conn, packet, len, from); return conn->process_message(conn, packet, len, from); } diff --git a/src/cw/cw.h b/src/cw/cw.h index dfe4f521..1910f9d4 100644 --- a/src/cw/cw.h +++ b/src/cw/cw.h @@ -133,12 +133,13 @@ typedef struct{ int op; }cw_msgelemprops_t; -typedef struct { +struct cw_MsgDef{ int type; int * states; cw_msgelemprops_t * elements; const char * name; -}cw_msgdef_t; +}; +typedef struct cw_MsgDef cw_msgdef_t; /** * Get length wireless specific data diff --git a/src/cw/dbg.c b/src/cw/dbg.c index 2ac9fec8..b59aea36 100644 --- a/src/cw/dbg.c +++ b/src/cw/dbg.c @@ -36,6 +36,8 @@ #include "capwap.h" #include "capwap_cisco.h" #include "lwapp_cisco.h" +#include "cw.h" +#include "message_set.h" /** *@addtogroup DBG @@ -485,7 +487,15 @@ void cw_dbg_msg(int level, struct conn *conn, uint8_t * packet, int len, // int pplen = len - (msgptr-packet); int msg_id = cw_get_msg_id(msgptr); - s += sprintf(s, "%s Message (type=%d) ", cw_strmsg(msg_id), msg_id); + + struct cw_MsgData search; + search.type = msg_id; + struct cw_MsgData * message; + message = mavl_get(conn->msgset->messages,&search); + + + + s += sprintf(s, "%s Message (type=%d) ", message->name /*cw_strmsg(msg_id)*/, msg_id); if (level == DBG_MSG_IN) s += sprintf(s, "from %s ", sock_addr2str(from)); else diff --git a/src/cw/message_set.c b/src/cw/message_set.c index 75dc0a92..93da9ed7 100644 --- a/src/cw/message_set.c +++ b/src/cw/message_set.c @@ -5,6 +5,7 @@ #include "message_set.h" +/* typedef struct { int type; const char * name; @@ -12,6 +13,7 @@ typedef struct { mavl_t elements_tree; mlist_t elements_list; }message2_t; +*/ static inline int cmp_cw_msgelemprops(const void *elem1, const void *elem2){ cw_elem_handler_t * e1 = ((cw_msgelemprops_t*)elem1)->elem; @@ -98,13 +100,13 @@ static void update_message(message2_t * msg, cw_msgdef_t * src, cw_MsgSet_t * se void cw_msgset_add(cw_MsgSet_t * set, cw_msgdef_t messages[]){ - cw_msgdef_t * m; - for (m=messages; m->type !=0; m++){ + cw_msgdef_t * message; + for (message=messages; message->type !=0; message++){ message2_t search, *next; - search.type = m->type; + search.type = message->type; - cw_dbg(DBG_INFO,"Add message: Type:%d - %s",m->type,m->name); + cw_dbg(DBG_INFO,"Add message: Type:%d - %s",message->type,message->name); next = mavl_find(set->messages,&search); @@ -125,17 +127,17 @@ void cw_msgset_add(cw_MsgSet_t * set, free(next); return; } - next->type=m->type; + next->type=message->type; mavl_add(set->messages,next); } /* massage is alreaddy in there */ - if (m->name) - next->name=m->name; - if (m->states) - next->states=m->states; + if (message->name) + next->name=message->name; + if (message->states) + next->states=message->states; - update_message(next,m, set); + update_message(next,message, set); } } diff --git a/src/cw/message_set.h b/src/cw/message_set.h index 5e087afe..02aea9d0 100644 --- a/src/cw/message_set.h +++ b/src/cw/message_set.h @@ -8,4 +8,17 @@ extern cw_MsgSet_t * cw_message_set_create(); extern void cw_msgset_add(cw_MsgSet_t * set, cw_msgdef_t messages[]); mlist_t cw_msgset_get_msg(cw_MsgSet_t * set, int type); + + +typedef struct cw_MsgData{ + int type; + const char * name; + int * states; + mavl_t elements_tree; + mlist_t elements_list; +}; + +typedef struct cw_MsgData message2_t; + + #endif \ No newline at end of file diff --git a/src/cw/mod.h b/src/cw/mod.h index e92c0f91..fbfdc247 100644 --- a/src/cw/mod.h +++ b/src/cw/mod.h @@ -97,6 +97,8 @@ struct cw_Mod * cw_mod_detect(struct conn *conn, uint8_t * rawmsg, int len, int elems_len, struct sockaddr *from, int mode); +struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn, + struct cw_Mod * capwap_mod, struct cw_Mod *bindings_mod); #define CW_MOD_MAX_MOD_NAME_LEN 128 #define CW_MOD_INTERFACE_FUNCTION_NAME_SUFFIX "_get_interface" diff --git a/src/mod/capwap/capwap_actions_ac.c b/src/mod/capwap/capwap_actions_ac.c index 0bef9a59..50886051 100644 --- a/src/mod/capwap/capwap_actions_ac.c +++ b/src/mod/capwap/capwap_actions_ac.c @@ -133,12 +133,10 @@ static cw_msgdef_t messages[] = { struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode){ - printf("Register Message set %p\n",set); if (mode != CW_MOD_MODE_CAPWAP) return NULL; cw_msgset_add(set,messages); - printf("Done Addin gmessages"); - exit(0); + return set; } void test_sets(){ diff --git a/src/mod/cisco/mod_cisco_ac.c b/src/mod/cisco/mod_cisco_ac.c index 6c53dd5e..3adf3a96 100644 --- a/src/mod/cisco/mod_cisco_ac.c +++ b/src/mod/cisco/mod_cisco_ac.c @@ -171,7 +171,8 @@ static struct cw_Mod capwap_ac = { .name = "cisco", .init = init, .detect = detect, - .register_actions = register_actions, +// .register_actions = register_actions, + }; struct cw_Mod *mod_cisco_ac()