diff --git a/src/ac/ac.default.conf b/src/ac/ac.default.conf index 487b5f42..5c354a6d 100644 --- a/src/ac/ac.default.conf +++ b/src/ac/ac.default.conf @@ -198,7 +198,8 @@ # dbg += dtls # Messages concerning DTLS # dbg += dtls_detail # DTLS in more detail # dbg += dtls_bio # DTLS BIO operations -# dbg += dtls_bio_dmp # Hey dump data in BIO operations +# dbg += dtls_bio_dmp # HeXy dump data in BIO operations +# dbg += warn # misc warnings # # dbg += all # all of the above # dbg += err # Same as dbg_err and pkt_err diff --git a/src/capwap/Makefile b/src/capwap/Makefile index 4b0295a9..aebfcc16 100644 --- a/src/capwap/Makefile +++ b/src/capwap/Makefile @@ -63,6 +63,7 @@ UTILOBJS= \ intavltree.o \ cw_util.o \ send.o \ + cw_read_wtp_descriptor.o \ cw_read_wtp_descriptor_7.o \ cw_read_wtp_descriptor_versions.o diff --git a/src/capwap/cw.h b/src/capwap/cw.h index 1f131c5c..e051c321 100644 --- a/src/capwap/cw.h +++ b/src/capwap/cw.h @@ -5,6 +5,10 @@ #include "conn.h" #include "action.h" + +extern int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, + struct cw_action_in *a, uint8_t * data, int len); + extern int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn, struct cw_action_in *a, uint8_t * data, int len); diff --git a/src/capwap/cw_check_missing_mand.c b/src/capwap/cw_check_missing_mand.c index 2948f071..ccfd6468 100644 --- a/src/capwap/cw_check_missing_mand.c +++ b/src/capwap/cw_check_missing_mand.c @@ -2,54 +2,6 @@ #include "capwap.h" #include "dbg.h" - - -struct args { - cw_action_in_t *a; - cw_action_in_t **out; - struct avltree *mand; - int n; -}; -/* -static int check_mand_cb(void *priv, void *val) -{ - - - cw_action_in_t *a = (cw_action_in_t*)val; - struct args *args = (struct args*) priv; - -printf("Na?\n"); -return 1; - - if ( (args->a->msg_id != a->msg_id) || (args->a->capwap_state != a->capwap_state)) - { - printf ("Was soll das denn?\n"); - printf("End of fun\n"); - - return 0; - } - -printf("Nu?\n"); -return 1; - - printf("Found wat %d %d %c\n",a->msg_id,a->elem_id, a->mand ? '*':'-'); - if (a->mand) { - int i = a->item_id; - void * rc = avltree_del(args->mand,&i); - if (!rc) { - if (args->out) - args->out[args->n]=a; - args->n++; - } - - - } - - return 1; -} - -*/ - int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_in_t *a) { @@ -62,11 +14,9 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i as.elem_id = 0; as.proto=0; - DEFINE_AVLITER(it,conn->actions->in); int n=0; avliter_foreach_from(&it,&as) { -// avliter_foreach(&it) { cw_action_in_t * ai = avliter_get(&it); if (ai->msg_id != as.msg_id && ai->capwap_state != as.capwap_state) @@ -74,26 +24,12 @@ int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_i if (!ai->mand) continue; -// int i = (intptr_t)ai->item_id; void * rc = mavl_get(conn->mand,(void*)ai->item_id); if (!rc) { out[n++]=ai; } } - - - -/* - - struct args args; - args.a = &as; - args.mand=conn->mand; - args.out=out; - args.n=0; - - avltree_foreach_from_asc(conn->actions->in,&as,check_mand_cb,&args); -*/ return n; } diff --git a/src/capwap/cw_in_vendor_specific_payload.c b/src/capwap/cw_in_vendor_specific_payload.c index b6b20c1c..3d30c5d9 100644 --- a/src/capwap/cw_in_vendor_specific_payload.c +++ b/src/capwap/cw_in_vendor_specific_payload.c @@ -2,7 +2,7 @@ #include "capwap.h" #include "dbg.h" #include "log.h" -#include "sock.h" //Tube + /** * @file * @brief Implementation of Vendor Specific Payload @@ -13,15 +13,15 @@ */ int cw_in_vendor_specific_payload(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from) { + cw_action_in_t as,*af; as = *a; as.vendor_id = cw_get_dword(data); as.elem_id = cw_get_word(data+4); - af = cw_actionlist_in_get(conn->actions->in,&as); -//cw_dbg(DBG_ELEM,"From might be: %s\n",sock_addr2str(&conn->addr)); + af = cw_actionlist_in_get(conn->actions->in,&as); if (!af) { cw_dbg(DBG_WARN,"Can't handle Vendor Specific Payload %s/%d, in msg %d (%s) in %s state.", @@ -31,10 +31,15 @@ int cw_in_vendor_specific_payload(struct conn *conn,struct cw_action_in * a,uint } if (af->start) { - af->start(conn,af,data+6,len-6,from); + int afrc = af->start(conn,af,data+6,len-6,from); + if (af->mand && afrc) { + /* add found mandatory message element + to mand list */ + stravltree_add(conn->mand, af->item_id); + } + return afrc; } return 1; } - diff --git a/src/mod/capwap/capwap_actions_ac.c b/src/mod/capwap/capwap_actions_ac.c index 97f7b37b..1a14a42e 100644 --- a/src/mod/capwap/capwap_actions_ac.c +++ b/src/mod/capwap/capwap_actions_ac.c @@ -51,6 +51,29 @@ cw_action_in_t _capwap_actions_ac_in[] = { } , + /* Element WTP Board Data */ + { + .capwap_state = CW_STATE_DISCOVERY, + .msg_id = CW_MSG_DISCOVERY_REQUEST, + .elem_id = CW_ELEM_WTP_BOARD_DATA, + .start = capwap_in_wtp_board_data, + .item_id = "wtp_board_data", + .mand = 1, + } + , + + /* Element WTP Descriptor */ + { + .capwap_state = CW_STATE_DISCOVERY, + .msg_id = CW_MSG_DISCOVERY_REQUEST, + .elem_id = CW_ELEM_WTP_DESCRIPTOR, + .start = capwap_in_wtp_descriptor, + .item_id = "wtp_descriptor", + .mand = 1, + } + , + + /* Element WTP Frame Tunnel Mode */ { .capwap_state = CW_STATE_DISCOVERY, @@ -78,45 +101,17 @@ cw_action_in_t _capwap_actions_ac_in[] = { , - /* Element WTP Descriptor */ - { - .capwap_state = CW_STATE_DISCOVERY, - .msg_id = CW_MSG_DISCOVERY_REQUEST, - .elem_id = CW_ELEM_WTP_DESCRIPTOR, - .start = capwap_in_wtp_descriptor, - .item_id = "wtp_descriptor", - .mand = 1, - } - - , - - /* Element WTP Board Data */ - { - .capwap_state = CW_STATE_DISCOVERY, - .msg_id = CW_MSG_DISCOVERY_REQUEST, - .elem_id = CW_ELEM_WTP_BOARD_DATA, - .start = capwap_in_wtp_board_data, - .item_id = "wtp_board_data", - .mand = 1, - } -// , - - /* Element WTP Board Data */ -// {0, 0, CW_STATE_CONFIGURE, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA, -// 1} - , - - /* Vendor Specific Payload */ { .capwap_state = CW_STATE_DISCOVERY, .msg_id = CW_MSG_DISCOVERY_REQUEST, .elem_id = CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, + .start = cw_in_vendor_specific_payload }, /* Element WTP Name */ - { +/* { .capwap_state = CW_STATE_DISCOVERY, .msg_id = CW_MSG_DISCOVERY_REQUEST, .elem_id = CW_ELEM_WTP_NAME, @@ -127,6 +122,7 @@ cw_action_in_t _capwap_actions_ac_in[] = { .max_len = 1024 } , +*/ /* End of list */ {0, 0} diff --git a/src/mod/capwap/capwap_in_wtp_descriptor.c b/src/mod/capwap/capwap_in_wtp_descriptor.c index 85f7baab..c8da48b2 100644 --- a/src/mod/capwap/capwap_in_wtp_descriptor.c +++ b/src/mod/capwap/capwap_in_wtp_descriptor.c @@ -17,140 +17,11 @@ */ -#include "capwap/capwap.h" -#include "capwap/capwap_items.h" - - -#include "capwap/cw_util.h" -#include "capwap/dbg.h" #include "capwap/sock.h" +#include "capwap/cw.h" -static int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, - int len, int silent) -{ - int i = 0; - while (i len) { - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "WTP descriptor sub-element too long, length=%d>%d", - i + 8, len); - return 0; - } - - uint32_t vendor_id = cw_get_dword(data + i); - uint32_t val = cw_get_dword(data + i + 4); - - int subtype = (val >> 16) & 0xffff; - int sublen = val & 0xffff; - i += 8; - - if (sublen + i > len) { - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "WTP Descriptor sub-element too long, length = %d", - sublen); - return 0; - } - - if (!silent) { - char *dmp; - char *dmpmem = NULL; - if (cw_dbg_is_level(DBG_SUBELEM_DMP)) { - dmpmem = cw_dbg_mkdmp(data + i, sublen); - dmp = dmpmem; - } else - dmp = ""; - cw_dbg(DBG_SUBELEM, "WTP Descriptor subtype=%d,len=%d%s", subtype, - sublen, dmp); - - if (dmpmem) - free(dmpmem); - } - - switch (subtype) { - case CW_SUBELEM_WTP_HARDWARE_VERSION: - - mbag_set_vendorstr(mbag, - CW_ITEM_WTP_HARDWARE_VERSION, - vendor_id, data + i, sublen); - - break; - case CW_SUBELEM_WTP_SOFTWARE_VERSION: - - mbag_set_vendorstr(mbag, - CW_ITEM_WTP_SOFTWARE_VERSION, - vendor_id, data + i, sublen); - break; - case CW_SUBELEM_WTP_BOOTLOADER_VERSION: - - mbag_set_vendorstr(mbag, - CW_ITEM_WTP_BOOTLOADER_VERSION, - vendor_id, data + i, sublen); - -/* - mbag_set_dword(mbag, - CW_ITEM_WTP_BOOTLOADER_VENDOR, - vendor_id); - mbag_set_bstrn(mbag, - CW_ITEM_WTP_BOOTLOADER_VERSION, - data + i, sublen); -*/ - break; - default: - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "Unknown WTP descriptor subelement, type = %d", - subtype); - break; - } - i += sublen; - - } //while (i < len); - - return 1; - -} - -static int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn, - struct cw_action_in *a, uint8_t * data, int len, - int silent) -{ - - - 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) { - if (!silent) - cw_dbg(DBG_ELEM_ERR, - "Bad WTP Descriptor, number of encryption elements is 0."); - return 0; - } - if (!silent) - 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; - } - - return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos, silent); - -} - int capwap_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data, @@ -159,7 +30,7 @@ int capwap_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t mbag_t mbag = conn->incomming; - int rc =cw_read_wtp_descriptor(mbag, conn, a, data, len, 0); + int rc =cw_read_wtp_descriptor(mbag, conn, a, data, len); return rc; } diff --git a/src/mod/cisco/cisco_actions_ac.c b/src/mod/cisco/cisco_actions_ac.c index 00eec86b..757a3652 100644 --- a/src/mod/cisco/cisco_actions_ac.c +++ b/src/mod/cisco/cisco_actions_ac.c @@ -50,6 +50,7 @@ static cw_action_in_t actions_in[] = { } , + /* Element Cisco RAD Name */ { .capwap_state = CW_STATE_DISCOVERY, .msg_id = CW_MSG_DISCOVERY_REQUEST, @@ -58,7 +59,8 @@ static cw_action_in_t actions_in[] = { .start=cw_in_generic2, .item_id = "wtp_name", .min_len=1, - .max_len=512 + .max_len=512, + .mand=1 } , @@ -73,11 +75,12 @@ static cw_action_in_t actions_in[] = { static struct cw_itemdef _capwap_itemdefs[] = { - {"wtp_name",CW_ITEM_NONE,MBAG_STR}, - {"wtp_mac_type",CW_ITEM_NONE,MBAG_BYTE}, + {"wtp_name_cisco",CW_ITEM_NONE,MBAG_STR}, + + /* {"wtp_mac_type",CW_ITEM_NONE,MBAG_BYTE}, {"discovery_type",CW_ITEM_NONE,MBAG_BYTE}, {"wtp_frame_tunnel_mode",CW_ITEM_NONE,MBAG_BYTE}, - {CW_ITEM_NONE} +*/ {CW_ITEM_NONE} }; @@ -104,7 +107,7 @@ int cisco_register_actions_ac(struct cw_actiondef *def) rc += cw_strheap_register_strings(def->strmsg, capwap_strings_msg); rc += cw_strheap_register_strings(def->strelem, capwap_strings_elem); -// rc += cw_itemdefheap_register(def->items, _capwap_itemdefs); + rc += cw_itemdefheap_register(def->items, _capwap_itemdefs); rc += cw_itemdefheap_register(def->radioitems, capwap_radioitemdefs); intavltree_add(def->wbids, 0);