Checks always for mandatory elements.

FossilOrigin-Name: 2e73b184e82e247388dd98ddcb7b4209a5063d58841d3df4600b71ce5732aad1
This commit is contained in:
7u83@mail.ru
2016-03-19 11:57:47 +00:00
parent cbf74ecb5e
commit 0ec4826478
18 changed files with 273 additions and 49 deletions

View File

@ -151,7 +151,9 @@ CAPWAPOBJS= \
cw_out_wtp_reboot_statistics.o \
cw_in_wtp_reboot_statistics.o\
cw_in_cisco_image_identifier.o\
cw_out_radio_operational_state.o\
cw_out_radio_operational_states.o\
cw_out_radio_operational_states_7.o\
cw_put_radio_operational_states.o \
cw_in_ac_descriptor.o\
cw_read_ac_descriptor.o\
cw_out_capwap_local_ip_address.o\

View File

@ -60,9 +60,9 @@ static inline int cw_action_in_cmp(const void *elem1, const void *elem2)
return 0;
}
//typedef int(*cw_action_fun_t)(struct conn *,struct cw_action_in *,uint8_t*,int,struct sockaddr *);
/*
cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
int capwap_state,int msg_id, cw_action_fun_t callback)
{
@ -83,11 +83,10 @@ cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
cw_action_fun_t old = af->end;
af->end =callback;
return old;
}
*/
cw_action_in_t *cw_actionlist_in_add(cw_actionlist_in_t t, struct cw_action_in * a)

View File

@ -173,6 +173,11 @@ struct cw_actiondef{
extern struct outelem * cw_actionlist_out_get_mlist(cw_actionlist_out_t t, int msg_id);
typedef int(*cw_action_fun_t)(struct conn *,struct cw_action_in *,uint8_t*,int,struct sockaddr *);
cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
int capwap_state,int msg_id, cw_action_fun_t callback);
#define cw_actionlist_get_node(t,a) avltree_get_node(t,a)

View File

@ -228,6 +228,15 @@ static struct cw_actiondef *load_mods(struct conn *conn, uint8_t * rawmsg, int l
*/
}
int cw_in_check_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
if (cw_is_request(a->msg_id)){
return cw_in_check_generic_req(conn,a,data,len,from);
}
return cw_in_check_generic_resp(conn,a,data,len,from);
}
@ -393,9 +402,19 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
by calling the "end" function for the message */
int result_code = 0;
if (afm->end) {
result_code = afm->end(conn, afm, rawmsg, len, from);
int rct = cw_in_check_generic_req(conn, afm, rawmsg, len, from);
if (rct && conn->strict_capwap)
{
result_code = rct;
}
else {
if (afm->end) {
result_code = afm->end(conn, afm, rawmsg, len, from);
}
}
if (unrecognized) {
@ -404,7 +423,9 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
/* set only resultcode for request messages */
if ( (!result_code) && ((afm->msg_id & 1))) {
result_code = CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
if (conn->strict_capwap) {
result_code = CW_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
}
}
}

View File

@ -480,6 +480,10 @@ extern int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_ou
extern int cw_out_wtp_ip_address(struct conn *conn, struct cw_action_out *action,
uint8_t * dst);
extern int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
extern int cw_out_radio_operational_states_7(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
/**
* With this alias for #cw_out_wtp_ip_address we can
* can hav more consitent naming, when implement draft 7
@ -492,6 +496,8 @@ extern int cw_out_wtp_reboot_statistics(struct conn *conn, struct cw_action_out
/* helpers */
extern int cw_put_local_ip_address(int sock, uint8_t *dst, int ipv4elem_id, int ipv6elem_id);
extern int cw_put_radio_operational_states(mbag_t radios, uint8_t * dst, int *nerror, int d7mode);
/**
* @}

View File

@ -10,7 +10,6 @@
int cw_in_check_generic_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len,struct sockaddr *from)
{
cw_action_in_t * mlist[60];
/* Check for mandatory elements */

View File

@ -18,8 +18,6 @@ int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a, uint8_t * d
if (!cw_rcok(jresult->dword)){
return jresult->dword;
}
}

View File

@ -1,3 +1,20 @@
/*
This file is part of actube.
actube is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "cw.h"
#include "capwap_items.h"
@ -6,7 +23,8 @@
#include "log.h"
#include "radio.h"
int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
int iiicw_put_radio_operational_states(struct conn *conn, uint8_t * dst, int *nerrors, int d7mode)
{
uint8_t *d=dst;
@ -33,7 +51,7 @@ int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a,
/* Get the operational state and cause */
uint16_t os = ositem->word;
if ( conn->capwap_mode==CW_MODE_CISCO ){
if ( d7mode ){
/* Isolate Oper Sate from cause */
uint8_t o=os>>8;
@ -55,6 +73,23 @@ int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a,
}
/* if (nerror) {
if (a->mand) {
cw_log(LOG_ERROR,"Could not send Radio Operational State for all radios. Sent %d out of %d.",
conn->radios->count-nerror,conn->radios->count);
}
}
*/
return d-dst;
}
int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
{
int nerror=0;
int l = cw_put_radio_operational_states(conn->radios,dst,&nerror,0);
if (nerror) {
if (a->mand) {
cw_log(LOG_ERROR,"Could not send Radio Operational State for all radios. Sent %d out of %d.",
@ -62,7 +97,6 @@ int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a,
}
}
return d-dst;
return l;
}

View File

@ -33,6 +33,9 @@ const char * lw_cisco_id_to_str(int elem_id)
case LW_CISCO_AP_DTLS_DATA_CFG:
return "AP DTLS Data Config";
case LW_CISCO_PRIMED_JOIN_TIMEOUT:
return "Primed Join Timeout";
default:
return "Unknown";