In strict mode messages with unknown elements are now rejected.
FossilOrigin-Name: b94b0107e8abfbe9074e34243918018afe0df89e44042a48ed0b100220504850
This commit is contained in:
parent
5567ba34d3
commit
49745425d4
@ -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_MSG_UNRECOGNIZED 19
|
||||||
#define CW_RESULT_MISSING_MAND_ELEM 20
|
#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)
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ struct cw_strlist_elem capwap_strings_result[] = {
|
|||||||
{CW_RESULT_IMAGE_DATA_ERROR,"Image Data Error (Unspecified)"}, /* 16 */
|
{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_MSG_INVALID_IN_CURRENT_STATE,"Message unexpected (Invalid in current state)"}, /* 18 */
|
||||||
{CW_RESULT_MISSING_MAND_ELEM,"Missing Mandatory Message Element"}, /* 20 */
|
{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"}
|
{CW_STR_STOP,"Unknown Result Code"}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -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 */
|
/* Create an avltree to catch the found mandatory elements */
|
||||||
conn->mand = stravltree_create();
|
conn->mand = stravltree_create();
|
||||||
|
|
||||||
|
int unrecognized=0;
|
||||||
|
|
||||||
/* iterate through message elements */
|
/* iterate through message elements */
|
||||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
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);
|
af = cw_actionlist_in_get(conn->actions->in, &as);
|
||||||
|
|
||||||
if (!af) {
|
if (!af) {
|
||||||
|
unrecognized++;
|
||||||
cw_dbg(DBG_ELEM_ERR,
|
cw_dbg(DBG_ELEM_ERR,
|
||||||
"Element %d (%s) not allowed in msg of type %d (%s), ignoring.",
|
"Element %d (%s) not allowed in msg of type %d (%s), ignoring.",
|
||||||
as.elem_id, cw_strelemp(conn->actions, as.elem_id),
|
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);
|
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 we've got a request message, we always have to send a response message */
|
||||||
if (as.msg_id & 1) {
|
if (as.msg_id & 1) {
|
||||||
if (result_code > 0) {
|
if (result_code > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user