diff --git a/src/cw/capwap.h b/src/cw/capwap.h index dbebcb0b..3c17fefb 100644 --- a/src/cw/capwap.h +++ b/src/cw/capwap.h @@ -575,10 +575,10 @@ extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elem #define CW_RESULT_MSG_UNRECOGNIZED 19 #define CW_RESULT_MISSING_MAND_ELEM 20 -/* - 21 Failure - Unrecognized Message Element - 22 Data Transfer Error (No Information to Transfer) +#define CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT 21 + +/* 22 Data Transfer Error (No Information to Transfer) */ diff --git a/src/cw/capwap_strings_result.c b/src/cw/capwap_strings_result.c index f747c756..fe143e19 100644 --- a/src/cw/capwap_strings_result.c +++ b/src/cw/capwap_strings_result.c @@ -11,7 +11,7 @@ struct cw_strlist_elem capwap_strings_result[] = { {CW_RESULT_IMAGE_DATA_ERROR,"Image Data Error (Unspecified)"}, /* 16 */ {CW_RESULT_MSG_INVALID_IN_CURRENT_STATE,"Message unexpected (Invalid in current state)"}, /* 18 */ {CW_RESULT_MISSING_MAND_ELEM,"Missing Mandatory Message Element"}, /* 20 */ - + {CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT,"Unrecognized Message Element"}, /* 21 */ {CW_STR_STOP,"Unknown Result Code"} }; diff --git a/src/cw/conn_process_packet.c b/src/cw/conn_process_packet.c index cbf85795..69b374d3 100644 --- a/src/cw/conn_process_packet.c +++ b/src/cw/conn_process_packet.c @@ -261,6 +261,8 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, /* Create an avltree to catch the found mandatory elements */ conn->mand = stravltree_create(); + int unrecognized=0; + /* iterate through message elements */ cw_foreach_elem(elem, elems_ptr, elems_len) { @@ -274,6 +276,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, af = cw_actionlist_in_get(conn->actions->in, &as); if (!af) { + unrecognized++; cw_dbg(DBG_ELEM_ERR, "Element %d (%s) not allowed in msg of type %d (%s), ignoring.", as.elem_id, cw_strelemp(conn->actions, as.elem_id), @@ -304,6 +307,14 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len, result_code = afm->end(conn, afm, rawmsg, len, from); } + if (unrecognized){ + cw_dbg(DBG_RFC,"Message has %d unrecognized message elements.",unrecognized); + if (!result_code) { + result_code = CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT; + } + + } + /* if we've got a request message, we always have to send a response message */ if (as.msg_id & 1) { if (result_code > 0) {