Some imprevements to hte new protocol
FossilOrigin-Name: 6934f0a8e932314676572b629dbbc776facf11cab1e6f87a4fff822e9b9a8a63
This commit is contained in:
parent
6de685e665
commit
0a0ec8141a
@ -3,9 +3,9 @@
|
|||||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
<Project Name="ac" Path="ac.project" Active="No"/>
|
||||||
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
||||||
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
||||||
<Project Name="mod_capwap" Path="mod_capwap.project" Active="Yes"/>
|
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
|
||||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
||||||
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
|
||||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||||
<BuildMatrix>
|
<BuildMatrix>
|
||||||
|
@ -250,12 +250,10 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Detect the connecting AC type */
|
||||||
if (!conn->detected) {
|
if (!conn->detected) {
|
||||||
//struct mod_ac *mod;
|
|
||||||
struct cw_MsgSet *set = load_msg_set(conn, rawmsg, len, elems_len, from);
|
struct cw_MsgSet *set = load_msg_set(conn, rawmsg, len, elems_len, from);
|
||||||
|
|
||||||
|
|
||||||
if (!set) {
|
if (!set) {
|
||||||
//cw_log(LOG_ERR, "Error");
|
//cw_log(LOG_ERR, "Error");
|
||||||
errno = EAGAIN;
|
errno = EAGAIN;
|
||||||
@ -263,20 +261,22 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
|||||||
}
|
}
|
||||||
|
|
||||||
conn->msgset= set;
|
conn->msgset= set;
|
||||||
// conn->actions = ad;
|
|
||||||
conn->detected = 1;
|
conn->detected = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** debug the received message */
|
||||||
cw_dbg_msg(DBG_MSG_IN, conn, rawmsg, len, from);
|
cw_dbg_msg(DBG_MSG_IN, conn, rawmsg, len, from);
|
||||||
|
|
||||||
/* prepare struct for search operation */
|
/* prepare struct for search operation */
|
||||||
struct cw_MsgData search;
|
struct cw_MsgData search;
|
||||||
search.type = cw_get_msg_id(msg_ptr);
|
search.type = cw_get_msg_id(msg_ptr);
|
||||||
|
|
||||||
|
/* Search message */
|
||||||
struct cw_MsgData * message;
|
struct cw_MsgData * message;
|
||||||
/* Search for message combination */
|
|
||||||
message = mavl_get(conn->msgset->messages,&search);
|
message = mavl_get(conn->msgset->messages,&search);
|
||||||
|
|
||||||
int result_code = 0;
|
int result_code = 0;
|
||||||
|
|
||||||
if (!message){
|
if (!message){
|
||||||
/* Message is unknown */
|
/* Message is unknown */
|
||||||
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unknown.",
|
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unknown.",
|
||||||
@ -288,9 +288,10 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Receivers: %d %d\n",message->receiver,conn->receiver);
|
|
||||||
|
|
||||||
/* Throw away unexpected messages */
|
/* Throw away unexpected messages */
|
||||||
|
/* maybe we have to check this too: if (!(message->type & 1))
|
||||||
|
* means unexpected response message
|
||||||
|
* */
|
||||||
if (!(message->receiver & conn->receiver)) {
|
if (!(message->receiver & conn->receiver)) {
|
||||||
cw_dbg(DBG_MSG_ERR,
|
cw_dbg(DBG_MSG_ERR,
|
||||||
"Message type %d (%s) unexpected/illegal in %s State, discarding.",
|
"Message type %d (%s) unexpected/illegal in %s State, discarding.",
|
||||||
@ -320,53 +321,16 @@ printf("Receivers: %d %d\n",message->receiver,conn->receiver);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// afm = cw_actionlist_in_get(conn->actions->in, &as);
|
|
||||||
|
|
||||||
if (!afm) {
|
|
||||||
// Throw away unexpected response messages
|
|
||||||
if (!(as.msg_id & 1)) {
|
|
||||||
cw_dbg(DBG_MSG_ERR,
|
|
||||||
"Message type %d (%s) unexpected/illegal in %s State, discarding.",
|
|
||||||
as.msg_id, cw_strmsg(as.msg_id),
|
|
||||||
cw_strstate(conn->capwap_state));
|
|
||||||
errno = EAGAIN;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Request message not found in current state, check if we know
|
|
||||||
anything else about this message type */
|
|
||||||
// TODO XXXX
|
|
||||||
//const char *str = cw_strheap_get(conn->actions->strmsg, as.msg_id);
|
|
||||||
const char *str = 0;
|
|
||||||
int result_code = 0;
|
|
||||||
if (str) {
|
|
||||||
/* Message found, but it was in wrong state */
|
|
||||||
cw_dbg(DBG_MSG_ERR,
|
|
||||||
"Message type %d (%s) not allowed in %s State.", as.msg_id,
|
|
||||||
cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
|
|
||||||
result_code = CAPWAP_RESULT_MSG_INVALID_IN_CURRENT_STATE;
|
|
||||||
} else {
|
|
||||||
/* Message is unknown */
|
|
||||||
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unknown.",
|
|
||||||
as.msg_id, cw_strmsg(as.msg_id),
|
|
||||||
cw_strstate(as.capwap_state));
|
|
||||||
result_code = CW_RESULT_MSG_UNRECOGNIZED;
|
|
||||||
|
|
||||||
}
|
|
||||||
cw_send_error_response(conn, rawmsg, result_code);
|
|
||||||
errno = EAGAIN;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (conn->msg_start){
|
if (conn->msg_start){
|
||||||
conn->msg_start(conn, afm, rawmsg, len, from);
|
conn->msg_start(conn, afm, rawmsg, len, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Execute start processor for message */
|
/* Execute start processor for message */
|
||||||
if (afm->start) {
|
// if (afm->start) {
|
||||||
afm->start(conn, afm, rawmsg, len, from);
|
// afm->start(conn, afm, rawmsg, len, from);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||||
uint8_t *elem;
|
uint8_t *elem;
|
||||||
@ -382,6 +346,23 @@ printf("Receivers: %d %d\n",message->receiver,conn->receiver);
|
|||||||
as.elem_id = cw_get_elem_id(elem);
|
as.elem_id = cw_get_elem_id(elem);
|
||||||
int elem_len = cw_get_elem_len(elem);
|
int elem_len = cw_get_elem_len(elem);
|
||||||
|
|
||||||
|
cw_elem_handler_t search_eh;
|
||||||
|
memset(&search_eh,0,sizeof(search_eh));
|
||||||
|
struct cw_ElemDef search_elem;
|
||||||
|
search_elem.handler=&search_eh;
|
||||||
|
|
||||||
|
search_eh.id = cw_get_elem_id(elem);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct cw_ElemDef * elem;
|
||||||
|
elem = mavl_find(message->elements_tree,&search_elem);
|
||||||
|
|
||||||
|
|
||||||
|
printf("ElemCHeck %d\n",search_eh.id);
|
||||||
|
if (elem){
|
||||||
|
printf("Elem %d found! %s\n", elem->handler->id , elem->handler->name);
|
||||||
|
}
|
||||||
// TODO XXX
|
// TODO XXX
|
||||||
// af = cw_actionlist_in_get(conn->actions->in, &as);
|
// af = cw_actionlist_in_get(conn->actions->in, &as);
|
||||||
af = 0;
|
af = 0;
|
||||||
|
@ -127,11 +127,12 @@ struct cw_MsgSet {
|
|||||||
|
|
||||||
typedef struct cw_MsgSet cw_MsgSet_t;
|
typedef struct cw_MsgSet cw_MsgSet_t;
|
||||||
|
|
||||||
typedef struct{
|
typedef struct cw_ElemDef{
|
||||||
cw_elem_handler_t * elem;
|
cw_elem_handler_t * handler;
|
||||||
int mand;
|
int mand;
|
||||||
int op;
|
int op;
|
||||||
}cw_msgelemprops_t;
|
};
|
||||||
|
typedef struct cw_ElemDef cw_ElemDef_t;
|
||||||
|
|
||||||
#define CW_RECEIVER_AC 1
|
#define CW_RECEIVER_AC 1
|
||||||
#define CW_RECEIVER_WTP 1
|
#define CW_RECEIVER_WTP 1
|
||||||
@ -141,7 +142,7 @@ struct cw_MsgDef{
|
|||||||
int * states; /**< states in wich the message is allowed */
|
int * states; /**< states in wich the message is allowed */
|
||||||
int receiver; /**< Who can receive this message */
|
int receiver; /**< Who can receive this message */
|
||||||
|
|
||||||
cw_msgelemprops_t * elements;
|
cw_ElemDef_t * elements;
|
||||||
const char * name;
|
const char * name;
|
||||||
};
|
};
|
||||||
typedef struct cw_MsgDef cw_msgdef_t;
|
typedef struct cw_MsgDef cw_msgdef_t;
|
||||||
|
@ -16,8 +16,8 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static inline int cmp_cw_msgelemprops(const void *elem1, const void *elem2){
|
static inline int cmp_cw_msgelemprops(const void *elem1, const void *elem2){
|
||||||
cw_elem_handler_t * e1 = ((cw_msgelemprops_t*)elem1)->elem;
|
cw_elem_handler_t * e1 = ((cw_ElemDef_t*)elem1)->handler;
|
||||||
cw_elem_handler_t * e2 = ((cw_msgelemprops_t*)elem2)->elem;
|
cw_elem_handler_t * e2 = ((cw_ElemDef_t*)elem2)->handler;
|
||||||
int r;
|
int r;
|
||||||
r = e1->id - e2->id;
|
r = e1->id - e2->id;
|
||||||
if (r!=0)
|
if (r!=0)
|
||||||
@ -81,12 +81,12 @@ cw_MsgSet_t * cw_message_set_create(){
|
|||||||
|
|
||||||
static void update_message(message2_t * msg, cw_msgdef_t * src, cw_MsgSet_t * set){
|
static void update_message(message2_t * msg, cw_msgdef_t * src, cw_MsgSet_t * set){
|
||||||
|
|
||||||
cw_msgelemprops_t *md;
|
cw_ElemDef_t *md;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (md = src->elements; md->elem!=0; md++){
|
for (md = src->elements; md->handler!=0; md++){
|
||||||
cw_dbg(DBG_INFO," add element %d - %s, %d",md->elem->id, md->elem->name, md->mand);
|
cw_dbg(DBG_INFO," add element %d - %s, %d",md->handler->id, md->handler->name, md->mand);
|
||||||
mavl_add(msg->elements_tree,md);
|
mavl_add(msg->elements_tree,md);
|
||||||
mavl_add(set->all_elems,md);
|
mavl_add(set->all_elems,md);
|
||||||
mlist_append(msg->elements_list,md);
|
mlist_append(msg->elements_list,md);
|
||||||
|
@ -10,7 +10,7 @@ extern void cw_msgset_add(cw_MsgSet_t * set,
|
|||||||
mlist_t cw_msgset_get_msg(cw_MsgSet_t * set, int type);
|
mlist_t cw_msgset_get_msg(cw_MsgSet_t * set, int type);
|
||||||
|
|
||||||
|
|
||||||
typedef struct cw_MsgData{
|
struct cw_MsgData{
|
||||||
int type;
|
int type;
|
||||||
const char * name;
|
const char * name;
|
||||||
int * states;
|
int * states;
|
||||||
|
@ -104,7 +104,7 @@ static cw_msgdef_t messages[] = {
|
|||||||
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.receiver = CW_RECEIVER_AC,
|
.receiver = CW_RECEIVER_AC,
|
||||||
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
||||||
.elements = (cw_msgelemprops_t []){
|
.elements = (cw_ElemDef_t []){
|
||||||
{&_DISCOVERY_TYPE,1},
|
{&_DISCOVERY_TYPE,1},
|
||||||
{&_WTP_BOARD_DATA,1},
|
{&_WTP_BOARD_DATA,1},
|
||||||
{&_WTP_DESCRIPTOR,1},
|
{&_WTP_DESCRIPTOR,1},
|
||||||
@ -121,7 +121,7 @@ static cw_msgdef_t messages[] = {
|
|||||||
.type = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
.type = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
||||||
.receiver = CW_RECEIVER_WTP,
|
.receiver = CW_RECEIVER_WTP,
|
||||||
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
||||||
.elements = (cw_msgelemprops_t[]){
|
.elements = (cw_ElemDef_t[]){
|
||||||
{&_AC_DESCRIPTOR,1},
|
{&_AC_DESCRIPTOR,1},
|
||||||
{0,0},
|
{0,0},
|
||||||
}
|
}
|
||||||
@ -155,16 +155,16 @@ void test_sets(){
|
|||||||
memset(&el,0,sizeof(el));
|
memset(&el,0,sizeof(el));
|
||||||
el.id=CAPWAP_ELEM_DISCOVERY_TYPE;
|
el.id=CAPWAP_ELEM_DISCOVERY_TYPE;
|
||||||
|
|
||||||
cw_msgelemprops_t search, *result;;
|
cw_ElemDef_t search, *result;;
|
||||||
search.elem = ⪙
|
search.handler = ⪙
|
||||||
|
|
||||||
|
|
||||||
result = mavl_find(set->all_elems,&search);
|
result = mavl_find(set->all_elems,&search);
|
||||||
|
|
||||||
if (result!=NULL){
|
if (result!=NULL){
|
||||||
printf("Found: %d %s %d\n",
|
printf("Found: %d %s %d\n",
|
||||||
result->elem->id,
|
result->handler->id,
|
||||||
result->elem->name,
|
result->handler->name,
|
||||||
result->mand
|
result->mand
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -178,8 +178,8 @@ void test_sets(){
|
|||||||
|
|
||||||
struct mlist_elem * i;
|
struct mlist_elem * i;
|
||||||
mlist_foreach(i,m){
|
mlist_foreach(i,m){
|
||||||
cw_msgelemprops_t * le = i->data;
|
cw_ElemDef_t * le = i->data;
|
||||||
printf("Element: %d %s\n",le->elem->id, le->elem->name, le->mand);
|
printf("Element: %d %s\n",le->handler->id, le->handler->name, le->mand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ static cw_msgdef_t messages[] = {
|
|||||||
.name = "Discovery Request Cisco",
|
.name = "Discovery Request Cisco",
|
||||||
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
||||||
.elements = (cw_msgelemprops_t []){
|
.elements = (cw_ElemDef_t []){
|
||||||
{&_DISCOVERY_TYPE,1},
|
{&_DISCOVERY_TYPE,1},
|
||||||
{0,0},
|
{0,0},
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ static cw_msgdef_t messages[] = {
|
|||||||
.name = "Discovery Response",
|
.name = "Discovery Response",
|
||||||
.type = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
.type = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
||||||
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
||||||
.elements = (cw_msgelemprops_t[]){
|
.elements = (cw_ElemDef_t[]){
|
||||||
{0,0},
|
{0,0},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user