diff --git a/actube.workspace b/actube.workspace index b8870938..e0162c79 100644 --- a/actube.workspace +++ b/actube.workspace @@ -3,9 +3,9 @@ - + - + diff --git a/cw_read_wtp_descriptor.c b/cw_read_wtp_descriptor.c deleted file mode 100644 index 152c938a..00000000 --- a/cw_read_wtp_descriptor.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "cw.h" - -#include "capwap.h" -#include "capwap_items.h" -#include "dbg.h" - - -int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len,struct cw_descriptor_subelem_def *allowed) -{ - - mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); - mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, cw_get_byte(data + 1)); - - - /* Get number of encryption elements */ - int ncrypt = cw_get_byte(data + 2); - if (ncrypt == 0) { - if (conn->strict_capwap) { - cw_dbg(DBG_ELEM_ERR, - "Bad WTP Descriptor, number of encryption elements is 0."); - return 0; - } - cw_dbg(DBG_RFC, - "Non standard conform WTP Descriptor, number of encryptoin elements is 0."); - } - - int pos = 3; - int i; - for (i = 0; i < ncrypt; i++) { - // It's a dummy for now - pos += 3; - } - - static struct cw_descriptor_subelem_def allowed_default[] = { - {0,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0}, - {0,0, NULL, 0,0} - }; - - if (!allowed) { - allowed=allowed_default; - } - - return cw_read_descriptor_subelems(conn->incomming, data + pos, len - pos, allowed); -} diff --git a/libcw.project b/libcw.project index e663763d..bdcac7d3 100644 --- a/libcw.project +++ b/libcw.project @@ -328,7 +328,6 @@ - diff --git a/src/cw/capwap_items.h b/src/cw/capwap_items.h index 7633b756..87435ad2 100644 --- a/src/cw/capwap_items.h +++ b/src/cw/capwap_items.h @@ -139,8 +139,9 @@ extern const char CW_ITEM_CAPWAP_TRANSPORT_PROTOCOL[]; /* CIPWAP and Cisco */ +/* //extern const char CW_ITEM_WTP_GROUP_NAME[]; - +*/ /* Other Items */ extern const char CW_ITEM_AC_IMAGE_DIR[]; /* Path where WTP images are stored */ @@ -177,10 +178,10 @@ extern const char CW_ITEM_WTP_MAX_RADIOS[]; extern const char CW_ITEM_RADIO_INFOS[]; extern const char CW_ITEM_ECN_SUPPORT[]; - +/* //extern const char CW_ITEM_SSH_ENABLE[]; //extern const char CW_ITEM_TELNET_ENABLE[]; - +*/ diff --git a/src/cw/conn_process_packet.c b/src/cw/conn_process_packet.c index 9d4ef987..d512a624 100644 --- a/src/cw/conn_process_packet.c +++ b/src/cw/conn_process_packet.c @@ -398,11 +398,12 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, elem_len = cw_get_elem_len(elem); - - - cw_read_elem(handler, conn, cw_get_elem_data(elem), elem_len, from); - + printf ("Would start elem processing now %d - %s\n",handler->id, handler->name); + + handler->get(conn, handler, cw_get_elem_data(elem), elem_len, from); + + continue; exit(0); @@ -476,6 +477,29 @@ exit(0); /* all message elements are processed, do now after processing by calling the "end" function for the message */ + { + + mavliter_t it; + const struct cw_Type * type; + printf("********** THE REMODE CFG **************\n"); + mavliter_init(&it,conn->remote_cfg); + + + mavliter_foreach(&it){ + char value[500]; + mavldata_t * data; + data = mavliter_get(&it); + type = data->kv.priv; + type->to_str(data,value,0); + + printf("Got %s (%s): %s\n",data->kv.key,type->name, value); + } + + + + } + + //int result_code = 0; diff --git a/src/cw/cw.h b/src/cw/cw.h index 6f00448f..6c39ae21 100644 --- a/src/cw/cw.h +++ b/src/cw/cw.h @@ -10,6 +10,7 @@ #include "lw.h" #include "capwap.h" +#include "message_set.h" /** * @defgroup CW CW @@ -275,7 +276,7 @@ extern int cw_put_mbag_item(uint8_t * dst, struct mbag_item *item); /** * Put encryption capabilities as described in CAWAP - * draft 7 fpr WTP Descriptor + * draft 7 fpr WTP DescriptorSubelemDef * @param dst Destination buffer * @param cap Capability * @return number of bytes put @@ -295,10 +296,10 @@ int cw_put_version(uint8_t * dst, uint16_t subelem_id, bstrv_t v); extern int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn *conn); -struct cw_descriptor_subelem_def { +struct cw_DescriptorSubelemDef { int vendor_id; int type; - const char *item_id; + const char *key; int maxlen; int mand; }; @@ -310,19 +311,26 @@ struct cw_descriptor_subelem_def { -extern int cw_read_descriptor_subelems(mbag_t store, uint8_t * data, int len, - struct cw_descriptor_subelem_def *elems); +extern int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *elems); -extern int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len, - struct cw_descriptor_subelem_def *allowed); +/* +int cw_read_wtp_descriptor(mavl_t mbag, struct conn *conn, + struct cw_ElemHandler *eh, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *allowed); +*/ -extern int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len, - struct cw_descriptor_subelem_def *allowed); +int cw_read_wtp_descriptor(mavl_t mbag, struct conn *conn, + struct cw_ElemHandler *eh, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *allowed); + + +extern int cw_read_wtp_descriptor_7(mavl_t mbag, struct conn *conn, + struct cw_ElemHandler *eh, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *allowed); extern int cw_read_ac_descriptor(mbag_t store, uint8_t * data, int len, - struct cw_descriptor_subelem_def *allowed); + struct cw_DescriptorSubelemDef *allowed); extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len); @@ -342,11 +350,9 @@ extern int cw_in_mtu_discovery_padding(struct conn *conn, struct cw_action_in *a * @defgroup CWELEMIN Input Handlers for Message Elements * @{ */ +int cw_in_generic(struct conn * conn, struct cw_ElemHandler * handler, + uint8_t * elem_data, int elem_len, struct sockaddr * from); -extern int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, - int len,struct sockaddr *from); -extern int cw_in_generic2(struct conn *conn, struct cw_action_in *a, uint8_t * data, - int len,struct sockaddr *from); diff --git a/src/cw/cw_in_ac_descriptor.c b/src/cw/cw_in_ac_descriptor.c index 1af9c2f0..89b8dec2 100644 --- a/src/cw/cw_in_ac_descriptor.c +++ b/src/cw/cw_in_ac_descriptor.c @@ -30,7 +30,7 @@ int cw_in_ac_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * dat mbag_set_ptr(conn->incomming, CW_ITEM_AC_STATUS, status); - static struct cw_descriptor_subelem_def allowed[] = { + static struct cw_DescriptorSubelemDef allowed[] = { {0,CW_SUBELEM_AC_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1}, {0,CW_SUBELEM_AC_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, {0,0, NULL,0, 0} diff --git a/src/cw/cw_in_generic.c b/src/cw/cw_in_generic.c index eed8dac9..92bddf8f 100644 --- a/src/cw/cw_in_generic.c +++ b/src/cw/cw_in_generic.c @@ -1,125 +1,16 @@ +#include "message_set.h" +#include "cw_types.h" -#include "mbag.h" -#include "action.h" -#include "dbg.h" -#include "log.h" -#include "mbag.h" -#include "cw.h" - -/// TODO XXXX -int static check_len(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, - struct sockaddr *from) -{ - /* - if (len < a->min_len) { - cw_dbg(DBG_ELEM_ERR, - "%d (%s) message element too short, len=%d, min len=%d", - a->elem_id, cw_strelemp(conn->actions, a->elem_id), len, - a->min_len); - return 0; - } - if (len > a->max_len) { - cw_dbg(DBG_ELEM_ERR, - "%d (%s) message element too big, len=%d, max len=%d", a->elem_id, - cw_strelemp(conn->actions, a->elem_id), len, a->max_len); - return 0; - } -*/ - return 1; -} - - -int static do_save(mbag_t itemstore, struct conn *conn, struct cw_action_in *a, - uint8_t * data, int len, struct sockaddr *from) -{ - - if (a->itemtype == MBAG_BYTE) { - mbag_set_byte(itemstore, a->item_id, *data); - return 1; - } - if (a->itemtype == MBAG_WORD) { - mbag_set_word(itemstore, a->item_id, cw_get_word(data)); - return 1; - } - if (a->itemtype == MTYPE_DWORD) { - mbag_set_dword(itemstore, a->item_id, cw_get_dword(data)); - return 1; - } - if (a->itemtype == MBAG_STR) { - mbag_set_strn(itemstore, a->item_id, (char *) data, len); - return 1; - } - if (a->itemtype == MBAG_BSTR) { - mbag_set_bstrn(itemstore, a->item_id, data, len); - return 1; - } - - if (a->itemtype == MBAG_BSTR16) { - mbag_set_bstr16n(itemstore, a->item_id, data, len); - return 1; - } - -/* if (a->itemtype == MBAG_DATA) { - mbag_set_data(itemstore, a->item_id, data, len); - return 1; - } -*/ - if (a->itemtype == MBAG_VENDORSTR) { - mbag_set_bstrv(itemstore, a->item_id, - cw_get_dword(data), data + 4, len - 4); - return 1; - } - - cw_log(LOG_ERR, - "Can't handle item type %d in definition for incomming msg %d (%s) - %d, cw_in_generic.", - a->itemtype, a->msg_id, cw_strmsg(a->msg_id), a->elem_id); +int cw_in_generic(struct conn * conn, struct cw_ElemHandler * handler, + uint8_t * elem_data, int elem_len, struct sockaddr * from){ + mavldata_t data, *result; + char str[30]; + + result = handler->type->get(&data,elem_data,elem_len); + result->kv.key = strdup(handler->key); + + handler->type->to_str(result,str,30); + printf("Read %d-%s: %s %s\n", handler->id, handler->name, handler->key, str); + mavl_add(conn->remote_cfg, result); return 0; - - } - -int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, - struct sockaddr *from) -{ - - if (!check_len(conn, a, data, len, from)) - return 0; - - - mbag_t itemstore; -/// if (!a->target) - itemstore = conn->incomming; -// else -// itemstore = a->target(conn, a); - - - return do_save(itemstore, conn, a, data, len, from); - - - -} -/* -int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, - int len, struct sockaddr *from) -{ -// if (!check_len(conn, a, data, len, from)) -// return 0; - - int rid = cw_get_byte(data); - mbag_t radio = mbag_i_get_mbag(conn->radios, rid, NULL); - if (!radio) { - if (a->vendor_id != 0 - || ( (a->vendor_id == 0) && (a->msg_id != CW_MSG_DISCOVERY_REQUEST - && a->msg_id != CW_MSG_JOIN_REQUEST) )) { - cw_dbg(DBG_ELEM_ERR, "Radio not found %d", rid); - return 0; - } - mbag_i_set_mbag(conn->radios,rid,mbag_create()); - } - - - - return 1; -} - -*/ diff --git a/src/cw/cw_read_ac_descriptor.c b/src/cw/cw_read_ac_descriptor.c index f3350e5d..807e99c6 100644 --- a/src/cw/cw_read_ac_descriptor.c +++ b/src/cw/cw_read_ac_descriptor.c @@ -3,7 +3,8 @@ #include "dbg.h" #include "mbag.h" -int cw_read_ac_descriptor(mbag_t store, uint8_t *data, int len, struct cw_descriptor_subelem_def *allowed) +int cw_read_ac_descriptor(mbag_t store, uint8_t *data, int len, + struct cw_DescriptorSubelemDef *allowed) { struct cw_ac_status *status = malloc(sizeof(struct cw_ac_status)); if (!status) @@ -24,9 +25,9 @@ int cw_read_ac_descriptor(mbag_t store, uint8_t *data, int len, struct cw_descri mbag_set_ptr(store, CW_ITEM_AC_STATUS, status); - static struct cw_descriptor_subelem_def allowed_default[] = { - {0,CW_SUBELEM_AC_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_AC_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, + static struct cw_DescriptorSubelemDef allowed_default[] = { + {0,CW_SUBELEM_AC_HARDWARE_VERSION, "ac_hardware_versision", 1024,1}, + {0,CW_SUBELEM_AC_SOFTWARE_VERSION, "ac_software_version", 1024,1}, {0,0, NULL,0, 0} }; diff --git a/src/cw/cw_read_descriptor_subelems.c b/src/cw/cw_read_descriptor_subelems.c index 8fbc61b7..0adc41e8 100644 --- a/src/cw/cw_read_descriptor_subelems.c +++ b/src/cw/cw_read_descriptor_subelems.c @@ -19,9 +19,13 @@ #include "cw.h" #include "dbg.h" -int cw_read_descriptor_subelems(mbag_t store, uint8_t * data, int len, - struct cw_descriptor_subelem_def *elems) +int cw_read_descriptor_subelems(mavl_t store, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *elems) { + + printf("sub reader\n"); + + int errors = 0; int success = 0; int sub = 0; @@ -36,10 +40,14 @@ int cw_read_descriptor_subelems(mbag_t store, uint8_t * data, int len, bstrv_t vstr = NULL; int i; + + /* search sub-element */ for (i = 0; elems[i].maxlen; i++) { if (elems[i].type == subtype && elems[i].vendor_id==vendor_id) break; } + + if (!elems[i].maxlen) { vstr = bstrv_create(vendor_id, data + sub + 8, sublen); if (vstr) { @@ -58,11 +66,11 @@ int cw_read_descriptor_subelems(mbag_t store, uint8_t * data, int len, } vstr = - mbag_set_bstrv(store, elems[i].item_id, vendor_id, + mbag_set_bstrv(store, elems[i].key, vendor_id, data + sub + 8, l); char dbgstr[128]; - sprintf(dbgstr, "Storing '%s'", elems[i].item_id); + sprintf(dbgstr, "Storing '%s'", elems[i].key); cw_dbg_version_subelem(DBG_SUBELEM, dbgstr, subtype, vstr); success++; } diff --git a/src/cw/cw_read_elem.c b/src/cw/cw_read_elem.c deleted file mode 100644 index 139597f9..00000000 --- a/src/cw/cw_read_elem.c +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/cw/cw_read_wtp_descriptor.c b/src/cw/cw_read_wtp_descriptor.c index 152c938a..4eb20f07 100644 --- a/src/cw/cw_read_wtp_descriptor.c +++ b/src/cw/cw_read_wtp_descriptor.c @@ -3,18 +3,41 @@ #include "capwap.h" #include "capwap_items.h" #include "dbg.h" +#include "cw_types.h" -int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len,struct cw_descriptor_subelem_def *allowed) +static struct cw_DescriptorSubelemDef allowed_default[] = { + {0,CW_SUBELEM_WTP_HARDWARE_VERSION, "hardware_version", 1024,1}, + {0,CW_SUBELEM_WTP_SOFTWARE_VERSION, "software_version", 1024,1}, + {0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, "bootloader_version", 1024,1}, + {0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, "other_software_version", 1024,0}, + {0,0, NULL, 0,0} +}; + + +int cw_read_wtp_descriptor(mavl_t cfg, struct conn *conn, + struct cw_ElemHandler *eh, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *allowed) { + int ncrypt, pos,i; + mavldata_t md; + char key[64]; - mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); + sprintf(key,"%s/%s",eh->key, "max_radios"); + md.kv.key=strdup(key); + mavl_replace (cfg, cw_type_byte.get(&md,data,1)); + + sprintf(key,"%s/%s",eh->key, "radios_in_use"); + md.kv.key=strdup(key); + mavl_replace (cfg, cw_type_byte.get(&md,data+1,1)); + + +/* mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, cw_get_byte(data + 1)); - +*/ /* Get number of encryption elements */ - int ncrypt = cw_get_byte(data + 2); + ncrypt = cw_get_byte(data + 2); if (ncrypt == 0) { if (conn->strict_capwap) { cw_dbg(DBG_ELEM_ERR, @@ -25,24 +48,16 @@ int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, "Non standard conform WTP Descriptor, number of encryptoin elements is 0."); } - int pos = 3; - int i; + pos = 3; for (i = 0; i < ncrypt; i++) { - // It's a dummy for now +/* // It's a dummy for now */ pos += 3; } - static struct cw_descriptor_subelem_def allowed_default[] = { - {0,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,1}, - {0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0}, - {0,0, NULL, 0,0} - }; if (!allowed) { allowed=allowed_default; } - - return cw_read_descriptor_subelems(conn->incomming, data + pos, len - pos, allowed); +printf("call read subelems\n"); + return cw_read_descriptor_subelems(cfg, data + pos, len - pos, allowed); } diff --git a/src/cw/cw_read_wtp_descriptor_7.c b/src/cw/cw_read_wtp_descriptor_7.c index bf145724..ceb0cadd 100644 --- a/src/cw/cw_read_wtp_descriptor_7.c +++ b/src/cw/cw_read_wtp_descriptor_7.c @@ -2,27 +2,39 @@ #include "capwap.h" #include "capwap_items.h" +#include "cw_types.h" /** * Read WTP Descriptor in Cisco-Style (Draft 7) */ -int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len, - struct cw_descriptor_subelem_def *allowed) +int cw_read_wtp_descriptor_7(mavl_t cfg, struct conn *conn, + struct cw_ElemHandler *eh, uint8_t * data, int len, + struct cw_DescriptorSubelemDef *allowed) { + int ncrypt, pos,i; + mavldata_t md; + char key[64]; - mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); + sprintf(key,"%s/%s",eh->key, "max_radios"); + md.kv.key=strdup(key); + mavl_replace (cfg, cw_type_byte.get(&md,data,1)); + + sprintf(key,"%s/%s",eh->key, "radios_in_use"); + md.kv.key=strdup(key); + mavl_replace (cfg, cw_type_byte.get(&md,data+1,1)); + +/* mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data)); mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, cw_get_byte(data + 1)); +*/ - - int pos = 2; + pos = 2; /* Encryption element, for now dumy XXX */ //cw_get_word(data + pos + 2); pos += 2; - static struct cw_descriptor_subelem_def allowed_default[] = { + static struct cw_DescriptorSubelemDef allowed_default[] = { {-1,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,0}, {-1,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024.0}, {-1,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024,0}, @@ -33,5 +45,5 @@ int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn, if (!allowed) allowed=allowed_default; - return cw_read_descriptor_subelems(mbag, data + pos, len - pos, allowed); + return cw_read_descriptor_subelems(cfg, data + pos, len - pos, allowed); } diff --git a/src/cw/cw_type_byte.c b/src/cw/cw_type_byte.c index 7bf84700..54377064 100644 --- a/src/cw/cw_type_byte.c +++ b/src/cw/cw_type_byte.c @@ -21,24 +21,6 @@ #include "cw.h" #include "cw_types.h" -/* -static struct mdata_Elem *from_str(const char *src) -{ - struct mdata_Elem *i = mdata_elem_new(&cw_type_byte); - if (!i) - return NULL; - - i->data.byte = atoi(src); - return i; -} - - -static int to_str(const struct mdata_Elem *e, char *dst) -{ - return sprintf(dst, "%d", e->data.byte); -} -*/ - static mavldata_t *get(mavldata_t * data, const uint8_t * src, int len) { data->kv.priv = &cw_type_byte; @@ -56,12 +38,19 @@ static int to_str(const mavldata_t *data, char *dst, int max_len) return sprintf(dst, "%d", data->kv.val.byte); } +static mavldata_t *from_str(mavldata_t * data, const char *src) +{ + data->kv.val.byte = atoi(src); + return data; +} + + const struct cw_Type cw_type_byte = { - "Byte", /* name */ - NULL, /* del */ - put, /* put */ - get, /* get */ - to_str /* to_str */ + "Byte", /* name */ + NULL, /* del */ + put, /* put */ + get, /* get */ + to_str, /* to_str */ + from_str /* from_str */ }; - diff --git a/src/cw/cw_type_dword.c b/src/cw/cw_type_dword.c index ae050030..53532f66 100644 --- a/src/cw/cw_type_dword.c +++ b/src/cw/cw_type_dword.c @@ -18,45 +18,38 @@ #include -#include "cw_types.h" #include "cw.h" -/* -static struct mdata_Elem * from_str(const char *src) -{ - struct mdata_Elem * e = mdata_elem_new(&cw_type_dword); - if (!e) - return NULL; +#include "cw_types.h" - e->data.word=atoi(src); - return e; +static mavldata_t *get(mavldata_t * data, const uint8_t * src, int len) +{ + data->kv.priv = &cw_type_byte; + data->kv.val.dword = cw_get_dword(src); + return data; } - -static int to_str(const struct mdata_Elem *e, char *dst) +static int put(mavldata_t *data, uint8_t * dst) { - return sprintf(dst, "%d", e->data.word); + return cw_put_dword(dst, data->kv.val.dword); } -static struct mdata_Elem * get(const uint8_t *src,int len) +static int to_str(const mavldata_t *data, char *dst, int max_len) { - struct mdata_Elem * e = mdata_elem_new(&cw_type_dword); - if (!e) - return NULL; - e->data.word=cw_get_dword(src); - return e; + return sprintf(dst, "%d", data->kv.val.dword); } -static int put(struct mdata_Elem * e, uint8_t *dst) +static mavldata_t *from_str(mavldata_t * data, const char *src) { - return cw_put_dword(dst,e->data.word); + data->kv.val.dword = atoi(src); + return data; } -#define _I_NAME "Dword" -#define _I_PUT put -#define _I_GET get -#define _I_DEL NULL -#define _I_TO_STR to_str -#define _I_FROM_STR from_str +const struct cw_Type cw_type_dword = { + "Dword", /* name */ + NULL, /* del */ + put, /* put */ + get, /* get */ + to_str, /* to_str */ + from_str /* from_str */ +}; -const struct mdata_Type cw_type_dword = MDATA_TYPE_INIT(); -*/ diff --git a/src/cw/cw_types.h b/src/cw/cw_types.h index 279ce0ef..5cd6d6b6 100644 --- a/src/cw/cw_types.h +++ b/src/cw/cw_types.h @@ -23,7 +23,7 @@ struct cw_Type{ /** Cereate an item of this type from a string, which was previously created by the #del function. */ -/* struct mdata_Elem * (*from_str)(const char *src);*/ + mavldata_t * (*from_str)(mavldata_t * data, const char *src); /* int (*def)(void *, void *); @@ -44,4 +44,4 @@ void cw_types_mavl_delete(mavldata_t *data); #define cw_types_mavl_create()\ mavl_create(mavl_cmp_kv, cw_types_mavl_delete) -#endif +#endif /* __CW_TYPES_H */ diff --git a/src/cw/cw_types_mavl_delete.c b/src/cw/cw_types_mavl_delete.c index 04f087a1..c58e7535 100644 --- a/src/cw/cw_types_mavl_delete.c +++ b/src/cw/cw_types_mavl_delete.c @@ -4,4 +4,5 @@ void cw_types_mavl_delete(mavldata_t *data){ const struct cw_Type * type = data->kv.priv; if (type->del) type->del(data); + free(data->kv.key); } diff --git a/src/cw/mavl_replace.c b/src/cw/mavl_replace.c index d26bd51f..ac23df71 100644 --- a/src/cw/mavl_replace.c +++ b/src/cw/mavl_replace.c @@ -3,7 +3,8 @@ union mavldata *mavl_replace(struct mavl *t,union mavldata *data){ struct mavlnode * node = mavl_get_node(t,data); if (node){ - t->del(&node->data); + if (t->del) + t->del(&node->data); node->data=*data; return &node->data; } diff --git a/src/cw/message_set.h b/src/cw/message_set.h index 0f2f1fe5..7a85d273 100644 --- a/src/cw/message_set.h +++ b/src/cw/message_set.h @@ -2,6 +2,9 @@ #define __MESSAGE_SET_H #include "mlist.h" +#include "sock.h" +#include "mavl.h" +#include "conn.h" struct cw_MsgSet { mavl_t messages; @@ -34,9 +37,10 @@ struct cw_ElemHandler { int max_len; const struct cw_Type * type; const char * key; -/* - int (*start_in)(struct conn *conn,struct cw_action_in *a,uint8_t*data,int len,struct sockaddr *from); - int (*end_in)(struct conn *conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from); + int (*get)(struct conn *conn, struct cw_ElemHandler * handler, + uint8_t*data,int len,struct sockaddr *from); +/* + int (*end_in)(struct conn *conn,struct cw_action_in *a,uint8_t*elem,int len,struct sockaddr *from); */ }; diff --git a/src/cw/mod.c b/src/cw/mod.c index 36a80242..5ce2b961 100644 --- a/src/cw/mod.c +++ b/src/cw/mod.c @@ -25,8 +25,6 @@ #include #include - -//#include "action.h" #include "mbag.h" #include "mavl.h" #include "dbg.h" @@ -57,27 +55,32 @@ struct cache_item { }; static struct mavl *msgset_cache = NULL; +/* static int mod_null_register_actions(struct cw_actiondef *def, int mode) { return 0; } +*/ /** * mod_null is a dummy mod */ struct cw_Mod mod_null = { - .name = "none", - .register_actions = mod_null_register_actions, + "none", /* name */ + NULL, /* init */ + NULL, /* init_config */ + NULL, /* detect */ + NULL /* data */ }; -static int cmp(const void *p1, const void *p2) +static int cmp(const mavldata_t *p1, const mavldata_t *p2) { - struct cache_item *c1 = (struct cache_item *) p1; - struct cache_item *c2 = (struct cache_item *) p2; + struct cache_item *c1 = (struct cache_item *) p1->ptr; + struct cache_item *c2 = (struct cache_item *) p2->ptr; int r; r = strcmp(c1->capwap, c2->capwap); @@ -96,6 +99,10 @@ struct cw_actiondef *mod_cache_get(const char *capwap, const char *bindings) struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn, struct cw_Mod * capwap_mod, struct cw_Mod *bindings_mod) { + struct cache_item search; + struct cache_item * cached_set; + struct cw_MsgSet * set; + if (!msgset_cache) { msgset_cache = mavl_create(cmp, NULL); if (!msgset_cache) { @@ -105,11 +112,11 @@ struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn, } } - struct cache_item search; + search.capwap = capwap_mod->name; search.bindings = bindings_mod->name; - struct cache_item * cached_set = mavl_get(msgset_cache, &search); + cached_set = mavl_get_ptr(msgset_cache, &search); if (cached_set) { cw_dbg(DBG_INFO, "Using cached message set for %s,%s", capwap_mod->name, bindings_mod->name); return cached_set->msgset; @@ -124,7 +131,7 @@ struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn, } memset(cached_set, 0, sizeof(struct cache_item)); - struct cw_MsgSet * set = cw_msgset_create(); + set = cw_msgset_create(); if (!set) { free(cached_set); cw_log(LOG_ERR, "Can't allocate memory for mod cache item %s", @@ -140,18 +147,16 @@ struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn, if (capwap_mod) { cached_set->capwap = capwap_mod->name; - //c->register_actions(&(i->actions), CW_MOD_MODE_CAPWAP); capwap_mod->register_messages(cached_set->msgset,CW_MOD_MODE_CAPWAP); } if (bindings_mod) { cached_set->bindings = bindings_mod->name; - //b->register_actions(&(i->actions), MOD_MODE_BINDINGS); } - +/* // if (actions_registered_cb) // actions_registered_cb(capwap_mod, bindings_mod, &(cached_set->actions)); - - mavl_add(msgset_cache, cached_set); +*/ + mavl_add_ptr(msgset_cache, cached_set); return cached_set->msgset; } @@ -159,12 +164,20 @@ struct cw_MsgSet *cw_mod_get_msg_set(struct conn *conn, /* static mavl to store modules */ static struct mavl * mods_loaded = NULL; -static int mod_cmp(const void *e1, const void *e2){ +static int mod_cmp_mavl(const mavldata_t *e1, const mavldata_t *e2){ + const struct cw_Mod * m1 = e1->ptr; + const struct cw_Mod * m2 = e2->ptr; + return strcmp(m1->name,m2->name); +} + +static int mod_cmp_mlist(const void *e1, const void *e2){ const struct cw_Mod * m1 = e1; const struct cw_Mod * m2 = e2; return strcmp(m1->name,m2->name); } + + static const char * mod_path="./"; void cw_mod_set_mod_path(const char * path){ @@ -177,11 +190,16 @@ void cw_mod_set_mod_path(const char * path){ * @return a pointer to the module interface */ struct cw_Mod * cw_mod_load(const char * mod_name){ - - + struct cw_Mod search; + struct cw_Mod * mod; + char mod_filename[CW_MOD_MAX_MOD_NAME_LEN+5]; + char * filename; + void * handle; + struct cw_Mod * (*mod_get_interface)(); + /* if modlist is not initialized, initialize ... */ if (mods_loaded==NULL){ - mods_loaded=mavl_create(mod_cmp,NULL); + mods_loaded=mavl_create(mod_cmp_mavl,NULL); if (mods_loaded==NULL){ cw_log(LOG_ERROR, "Can't init modlist, no memory"); return NULL; @@ -190,11 +208,11 @@ 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 */ - struct cw_Mod search; + memset(&search,0,sizeof(search)); search.name=mod_name; - struct cw_Mod * mod; - mod = mavl_find(mods_loaded,&search); + + mod = mavl_find_ptr(mods_loaded,&search); if (mod){ return mod; } @@ -205,17 +223,16 @@ struct cw_Mod * cw_mod_load(const char * mod_name){ return NULL; } - char mod_filename[CW_MOD_MAX_MOD_NAME_LEN+5]; + sprintf(mod_filename,"mod_%s",mod_name); /* we have to load the module dynamically */ - char * filename; + filename = cw_filename(mod_path,mod_filename,".so"); if (filename==NULL) return NULL; -cw_log(LOG_ERROR,"DLOPEN now !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + /* Open the DLL */ - void * handle; handle = dlopen(filename,RTLD_NOW); if (!handle){ @@ -223,9 +240,8 @@ cw_log(LOG_ERROR,"DLOPEN now !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); goto errX; } - struct cw_Mod * (*mod_get_interface)(); - - mod_get_interface = dlsym(handle,mod_filename); + + mod_get_interface = (struct cw_Mod*(*)()) dlsym(handle,mod_filename); if (!mod_get_interface){ cw_log(LOG_ERROR,"Failed to load module: %s",dlerror()); @@ -235,7 +251,7 @@ cw_log(LOG_ERROR,"DLOPEN now !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); mod = mod_get_interface(); mod->dll_handle=handle; - if (!mavl_add(mods_loaded,mod)){ + if (!mavl_add_ptr(mods_loaded,mod)){ dlclose(handle); cw_log(LOG_ERR,"Can' add module %s",mod_name); goto errX; @@ -253,7 +269,7 @@ static struct mlist * mods_list = NULL; struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod ){ if (!mods_list){ - mods_list = mlist_create(mod_cmp); + mods_list = mlist_create(mod_cmp_mlist); if (!mods_list){ cw_log(LOG_ERROR,"Can't init mods_list"); return 0; @@ -266,10 +282,13 @@ struct cw_Mod * cw_mod_detect(struct conn *conn, uint8_t * rawmsg, int len, int elems_len, struct sockaddr *from, int mode){ + + struct mlist_elem * e; + if (mods_list==NULL) return MOD_NULL; - struct mlist_elem * e; + mlist_foreach(e,mods_list){ struct cw_Mod * mod = e->data; cw_dbg(DBG_MOD,"Checking mod: %s",mod->name); diff --git a/src/mod/capwap/Makefile b/src/mod/capwap/Makefile index 08788054..460f4081 100644 --- a/src/mod/capwap/Makefile +++ b/src/mod/capwap/Makefile @@ -6,9 +6,7 @@ include ../../Config.local.mak OBJS=\ mod_capwap_ac.o \ - mod_capwap_wtp.o\ capwap_actions_ac.o \ - capwap_actions_wtp.o \ capwap_in_wtp_board_data.o \ capwap_out_ac_descriptor.o \ capwap_out_get_session_id.o \ diff --git a/src/mod/capwap/capwap_actions_ac.c b/src/mod/capwap/capwap_actions_ac.c index 8db57944..69e34231 100644 --- a/src/mod/capwap/capwap_actions_ac.c +++ b/src/mod/capwap/capwap_actions_ac.c @@ -25,6 +25,7 @@ #include "mod_capwap.h" + static struct cw_ElemHandler handlers[] = { { @@ -33,7 +34,8 @@ static struct cw_ElemHandler handlers[] = { 0,0, /* Vendor / Proto */ 1,1, /* min/max length */ CW_TYPE_BYTE, /* type */ - "discovery_type" /* Key */ + "discovery_type", /* Key */ + cw_in_generic /* get */ } , { @@ -42,9 +44,31 @@ static struct cw_ElemHandler handlers[] = { 0,0, /* Vendor / Proto */ 1,1, /* min/max length */ CW_TYPE_BYTE, /* type */ - "wtp_mac_type" /* Key */ + "wtp_mac_type", /* Key */ + cw_in_generic /* get */ } , + { + "WTP Board Data", /* name */ + CAPWAP_ELEM_WTP_BOARD_DATA, /* Element ID */ + 0,0, /* Vendor / Proto */ + 4,128, /* min/max length */ + NULL, /* type */ + "wtp_board_data", /* Key */ + capwap_in_wtp_board_data /* get */ + } + , + { + "WTP Descriptor", /* name */ + CAPWAP_ELEM_WTP_DESCRIPTOR, /* Element ID */ + 0,0, /* Vendor / Proto */ + 4,128, /* min/max length */ + NULL, /* type */ + "wtp_descriptor", /* Key */ + capwap_in_wtp_descriptor /* get */ + } + , + {0,0,0,0,0,0,0,0} }; @@ -55,8 +79,9 @@ static struct cw_ElemDef discovery_request_elements[] ={ {0,0,CAPWAP_ELEM_DISCOVERY_TYPE, 1, 0}, {0,0,CAPWAP_ELEM_WTP_MAC_TYPE, 1, 0}, {0,0,CAPWAP_ELEM_WTP_BOARD_DATA, 1, 0}, - {0,0,0,00} - + {0,0,CAPWAP_ELEM_WTP_DESCRIPTOR, 1, 0}, + {0,0,0,0,0} + }; static struct cw_MsgDef messages[] = { diff --git a/src/mod/capwap/capwap_in_wtp_board_data.c b/src/mod/capwap/capwap_in_wtp_board_data.c index d79c08cc..293c060a 100644 --- a/src/mod/capwap/capwap_in_wtp_board_data.c +++ b/src/mod/capwap/capwap_in_wtp_board_data.c @@ -16,22 +16,16 @@ */ - #include #include +#include "mod_capwap.h" - -#include "cw/cw.h" -#include "cw/capwap_items.h" - -#include "cw/mbag.h" - -#include "cw/cw_util.h" #include "cw/dbg.h" +#include "cw/cw.h" - +/* static void readsubelems_wtp_board_data(mbag_t itemstore, uint8_t * msgelem, int len) { @@ -89,26 +83,36 @@ static void readsubelems_wtp_board_data(mbag_t itemstore, uint8_t * msgelem, } while (i < len); } +*/ /** * Parse a WTP Board Data messag element and put results to itemstore. */ -int capwap_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data, +int capwap_in_wtp_board_data(struct conn *conn, struct cw_ElemHandler *eh, uint8_t * data, int len, struct sockaddr *from) { +/* if (len < 4) { cw_dbg(DBG_ELEM_ERR, "Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d", a->elem_id, len); return 0; } +*/ + char vendor_key[64]; + + printf("Have to read WTP Board Data\n"); + sprintf(vendor_key,"%s/%s",eh->key,"vendor"); + +/* mbag_t itemstore = conn->incomming; mbag_set_dword(itemstore, CW_ITEM_WTP_BOARD_VENDOR, cw_get_dword(data)); +*/ - readsubelems_wtp_board_data(itemstore, data + 4, len - 4); - +/* readsubelems_wtp_board_data(itemstore, data + 4, len - 4); +*/ return 1; } diff --git a/src/mod/capwap/capwap_in_wtp_descriptor.c b/src/mod/capwap/capwap_in_wtp_descriptor.c index 1f0fe417..1ee3246e 100644 --- a/src/mod/capwap/capwap_in_wtp_descriptor.c +++ b/src/mod/capwap/capwap_in_wtp_descriptor.c @@ -17,17 +17,21 @@ */ - #include "cw/sock.h" #include "cw/cw.h" -int capwap_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data, +#include "mod_capwap.h" + +int capwap_in_wtp_descriptor(struct conn *conn, struct cw_ElemHandler *eh, uint8_t * data, int len, struct sockaddr *from) { + int rc; + printf("WTP Descriptor reader\n"); +/* +// mbag_t mbag = conn->incomming; +*/ + rc =cw_read_wtp_descriptor(conn->remote_cfg, conn, eh, data, len, NULL); - mbag_t mbag = conn->incomming; - - int rc =cw_read_wtp_descriptor(mbag, conn, a, data, len, NULL); return rc; } diff --git a/src/mod/capwap/mod_capwap.h b/src/mod/capwap/mod_capwap.h index 0c90b3cb..368e401b 100644 --- a/src/mod/capwap/mod_capwap.h +++ b/src/mod/capwap/mod_capwap.h @@ -4,13 +4,18 @@ struct cw_Mod *mod_capwap_ac(); struct cw_Mod *mod_capwap_wtp(); +#include "cw/message_set.h" +#include "cw/conn.h" -extern int capwap_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, + +extern int capwap_in_wtp_descriptor(struct conn *conn, struct cw_ElemHandler *eh, uint8_t * data, int len, struct sockaddr *from); -extern int capwap_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, + +extern int capwap_in_wtp_board_data(struct conn *conn, struct cw_ElemHandler *a, uint8_t * data, int len, struct sockaddr *from); +/* extern int capwap_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst); @@ -27,6 +32,7 @@ extern struct mbag_item * capwap_out_get_capwap_timers(struct conn *conn,struct extern int capwap_out_ac_ip_list(struct conn *conn, struct cw_action_out *a, uint8_t * dst); +*/ struct cw_MsgSet * capwap_register_msg_set(struct cw_MsgSet * set, int mode); diff --git a/src/mod/cisco/cisco_actions_ac.c b/src/mod/cisco/cisco_actions_ac.c index b53983f4..a94feaf0 100644 --- a/src/mod/cisco/cisco_actions_ac.c +++ b/src/mod/cisco/cisco_actions_ac.c @@ -44,23 +44,14 @@ #include "cw/cw_types.h" static struct cw_ElemHandler handlers[] = { - { - "Discovery Type", /* name */ - CAPWAP_ELEM_DISCOVERY_TYPE, /* Element ID */ + "WTP Descriptor (Draft 7)", /* name */ + CAPWAP_ELEM_WTP_DESCRIPTOR, /* Element ID */ 0,0, /* Vendor / Proto */ - 1,1, /* min/max length */ - CW_TYPE_BYTE, /* type */ - "discovery_type" /* Key */ - } - , - { - "WTP Mac Type", /* name */ - CAPWAP_ELEM_WTP_MAC_TYPE, /* Element ID */ - 0,0, /* Vendor / Proto */ - 1,1, /* min/max length */ - CW_TYPE_BYTE, /* type */ - "wtp_mac_type" /* Key */ + 4,128, /* min/max length */ + NULL, /* type */ + "wtp_descriptor", /* Key */ + cisco_in_wtp_descriptor /* get */ } , {0,0,0,0,0,0,0,0} @@ -70,7 +61,7 @@ static struct cw_ElemHandler handlers[] = { static int discovery_request_states[] = {CAPWAP_STATE_DISCOVERY,0}; static struct cw_ElemDef discovery_request_elements[] ={ - {0,0,CAPWAP_ELEM_DISCOVERY_TYPE, 1, 0}, + {0,0,CAPWAP_ELEM_WTP_DESCRIPTOR, 1, 0}, {0,0,0,00} }; @@ -136,7 +127,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_DISCOVERY_REQUEST, .vendor_id = CW_VENDOR_ID_CISCO, .elem_id = CW_CISCO_RAD_NAME, - .start=cw_in_generic2, + .start=cw_in_generic, .item_id = "wtp_name", .min_len=1, .max_len=512, @@ -224,7 +215,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_JOIN_REQUEST, .elem_id = CW_ELEM_ECN_SUPPORT, .item_id = CW_ITEM_ECN_SUPPORT, - .start = cw_in_generic2, + .start = cw_in_generic, .mand = 0, .min_len = 1, .max_len = 1 @@ -245,7 +236,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST, .elem_id = CW_ELEM_AC_NAME, .item_id = CW_ITEM_AC_NAME, - .start = cw_in_generic2, + .start = cw_in_generic, .min_len = 0, .max_len = 512, .mand = 1 @@ -273,7 +264,7 @@ static cw_action_in_t actions_in[] = { .vendor_id = CW_VENDOR_ID_CISCO, .elem_id = CW_CISCO_AP_LED_STATE_CONFIG, .item_id = CISCO_ITEM_AP_LED_STATE_CONFIG, - .start = cw_in_generic2 + .start = cw_in_generic } , @@ -285,7 +276,7 @@ static cw_action_in_t actions_in[] = { .vendor_id = CW_VENDOR_ID_CISCO, .elem_id = CW_CISCO_AP_LED_FLASH_CONFIG, .item_id = CISCO_ITEM_AP_LED_FLASH_CONFIG, - .start = cw_in_generic2 + .start = cw_in_generic } , @@ -329,7 +320,7 @@ static cw_action_in_t actions_in[] = { .vendor_id = CW_VENDOR_ID_CISCO, .elem_id = CW_CISCO_AP_MODE_AND_TYPE, .item_id = CISCO_ITEM_AP_MODE_AND_TYPE, - .start = cw_in_generic2 + .start = cw_in_generic } , @@ -341,7 +332,7 @@ static cw_action_in_t actions_in[] = { .vendor_id = CW_VENDOR_ID_CISCO, .elem_id = CW_CISCO_AP_LOG_FACILITY, .item_id = CIPWAP_ITEM_LOG_FACILITY, - .start = cw_in_generic2 + .start = cw_in_generic } , diff --git a/src/mod/cisco/cisco_actions_wtp.c b/src/mod/cisco/cisco_actions_wtp.c index 8e441cee..ca7bba36 100644 --- a/src/mod/cisco/cisco_actions_wtp.c +++ b/src/mod/cisco/cisco_actions_wtp.c @@ -70,7 +70,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_JOIN_RESPONSE, .elem_id = CW_ELEM_ECN_SUPPORT, .item_id = CW_ITEM_ECN_SUPPORT, - .start = cw_in_generic2, + .start = cw_in_generic, .mand = 0, .min_len = 1, .max_len = 1 @@ -103,7 +103,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST, .elem_id = LW_ELEM_LOCATION_DATA, .item_id = CW_ITEM_LOCATION_DATA, - .start = cw_in_generic2, + .start = cw_in_generic, .min_len = 0, .max_len = 1024, .mand = 0 @@ -117,7 +117,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST, .elem_id = CW_CISCO_RAD_NAME, .item_id = CW_ITEM_WTP_NAME, - .start = cw_in_generic2, + .start = cw_in_generic, .min_len = 0, .max_len = 1024, .mand = 0 @@ -132,7 +132,7 @@ static cw_action_in_t actions_in[] = { .msg_id = CAPWAP_MSG_CONFIGURATION_UPDATE_REQUEST, .elem_id = CW_CISCO_AP_GROUP_NAME, .item_id = CIPWAP_ITEM_WTP_GROUP_NAME, - .start = cw_in_generic2, + .start = cw_in_generic, .min_len = 0, .max_len = 1024, .mand = 0 @@ -162,7 +162,7 @@ static cw_action_in_t actions_in[] = { .vendor_id = CW_VENDOR_ID_CISCO, .elem_id = CW_CISCO_AP_MODE_AND_TYPE, .item_id = CISCO_ITEM_AP_MODE_AND_TYPE, - .start = cw_in_generic2 + .start = cw_in_generic } , @@ -250,7 +250,7 @@ static cw_action_in_t actions_in[] = { .vendor_id = LW_VENDOR_ID_CISCO, .elem_id = LW_CISCO_MWAR_HASH_VALUE, .item_id = CIPWAP_ITEM_AC_HASH_VALUE, - .start = cw_in_generic2, //cisco_in_telnet_ssh + .start = cw_in_generic, //cisco_in_telnet_ssh } , @@ -473,7 +473,7 @@ static cw_action_in_t actions80211_in[] = { .vendor_id = LW_VENDOR_ID_CISCO, .elem_id = LW_CISCO_ADD_WLAN, // .item_id = CIPWAP_ITEM_AC_HASH_VALUE, -// .start = cw_in_generic2, //cisco_in_telnet_ssh +// .start = cw_in_generic, //cisco_in_telnet_ssh .start = cisco_in_add_wlan } diff --git a/src/mod/cisco/cisco_in_ac_descriptor.c b/src/mod/cisco/cisco_in_ac_descriptor.c index 832d28d8..684aaba8 100644 --- a/src/mod/cisco/cisco_in_ac_descriptor.c +++ b/src/mod/cisco/cisco_in_ac_descriptor.c @@ -8,7 +8,7 @@ int cisco_in_ac_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len, struct sockaddr *from) { - static struct cw_descriptor_subelem_def allowed[] = { + static struct cw_DescriptorSubelemDef allowed[] = { {CW_VENDOR_ID_CISCO,0, CW_ITEM_AC_HARDWARE_VERSION, 1024,1}, {CW_VENDOR_ID_CISCO,1, CW_ITEM_AC_SOFTWARE_VERSION, 1024,1}, {0,0, NULL,0, 0} diff --git a/src/mod/cisco/cisco_in_wtp_descriptor.c b/src/mod/cisco/cisco_in_wtp_descriptor.c index a559c5c0..83c178d7 100644 --- a/src/mod/cisco/cisco_in_wtp_descriptor.c +++ b/src/mod/cisco/cisco_in_wtp_descriptor.c @@ -22,11 +22,11 @@ #include "cw/capwap_items.h" -int cisco_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data, +int cisco_in_wtp_descriptor(struct conn *conn, struct cw_ElemHandler *eh, uint8_t * data, int len, struct sockaddr *from) { - static struct cw_descriptor_subelem_def allowed[] = { + static struct cw_DescriptorSubelemDef allowed[] = { {CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_ITEM_WTP_HARDWARE_VERSION, 1024,0}, {CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_ITEM_WTP_SOFTWARE_VERSION, 1024.0}, {CW_VENDOR_ID_CISCO,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_ITEM_WTP_BOOTLOADER_VERSION, 1024.0}, @@ -35,7 +35,7 @@ int cisco_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * }; - return cw_read_wtp_descriptor_7(conn->incomming, conn, a, data, len, allowed); + return cw_read_wtp_descriptor_7(conn->incomming, conn, eh, data, len, allowed); } diff --git a/src/mod/cisco/mod_cisco_ac.c b/src/mod/cisco/mod_cisco_ac.c index 3eab725a..4b615083 100644 --- a/src/mod/cisco/mod_cisco_ac.c +++ b/src/mod/cisco/mod_cisco_ac.c @@ -26,14 +26,19 @@ 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"); - struct cw_Mod *cmod = cw_mod_load("capwap");// NULL; //modload_ac("cipwap"); + struct cw_Mod *cmod = cw_mod_load("capwap"); if (!cmod) { cw_log(LOG_ERR, "Can't initialize mod_cisco, failed to load base module mod_cipwap"); return 1; } + +\ cmod->register_messages(set, CW_MOD_MODE_CAPWAP); + + 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); return 0;