Work on cs_MsgSet
FossilOrigin-Name: 22ea5e3947fb5fa1b70d9384d7120ff5ae65eeb8924b724afebc0170a8f4fe3f
This commit is contained in:
parent
f4723a33da
commit
8ec78cea1b
@ -21,7 +21,6 @@
|
|||||||
<File Name="src/ac/ac.h"/>
|
<File Name="src/ac/ac.h"/>
|
||||||
<File Name="src/ac/dataman.h"/>
|
<File Name="src/ac/dataman.h"/>
|
||||||
<File Name="src/ac/socklist.h"/>
|
<File Name="src/ac/socklist.h"/>
|
||||||
<File Name="src/mod/capwap/capwap_actions_ac.c"/>
|
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
<Description/>
|
<Description/>
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
<File Name="src/mod/capwap/capwap_in_session_id.c"/>
|
<File Name="src/mod/capwap/capwap_in_session_id.c"/>
|
||||||
<File Name="src/mod/capwap/capwap_out_get_session_id.c"/>
|
<File Name="src/mod/capwap/capwap_out_get_session_id.c"/>
|
||||||
<File Name="src/mod/capwap/capwap_out_get_idle_timeout.c"/>
|
<File Name="src/mod/capwap/capwap_out_get_idle_timeout.c"/>
|
||||||
|
<File Name="src/mod/capwap/capwap_actions_ac.c"/>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
|
@ -242,7 +242,11 @@
|
|||||||
#define CW_ELEM_RETURNED_MESSAGE_ELEMENT 34
|
#define CW_ELEM_RETURNED_MESSAGE_ELEMENT 34
|
||||||
#define CW_ELEM_SESSION_ID 35
|
#define CW_ELEM_SESSION_ID 35
|
||||||
#define CW_ELEM_STATISTICS_TIMER 36
|
#define CW_ELEM_STATISTICS_TIMER 36
|
||||||
#define CW_ELEM_VENDOR_SPECIFIC_PAYLOAD 37
|
/**
|
||||||
|
* The Vendor Specific Payload allows tronasport of
|
||||||
|
* vebdor defined data.*/
|
||||||
|
#define CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD 37
|
||||||
|
|
||||||
#define CAPWAP_ELEM_WTP_BOARD_DATA 38
|
#define CAPWAP_ELEM_WTP_BOARD_DATA 38
|
||||||
/**
|
/**
|
||||||
* The WTP Descriptor message element conteins information
|
* The WTP Descriptor message element conteins information
|
||||||
|
@ -43,7 +43,7 @@ struct cw_strlist_elem capwap_strings_elem[] = {
|
|||||||
{CW_ELEM_RETURNED_MESSAGE_ELEMENT, "Returned Message Element"},
|
{CW_ELEM_RETURNED_MESSAGE_ELEMENT, "Returned Message Element"},
|
||||||
{CW_ELEM_SESSION_ID, "Session ID"},
|
{CW_ELEM_SESSION_ID, "Session ID"},
|
||||||
{CW_ELEM_STATISTICS_TIMER, "Statistics Timer"},
|
{CW_ELEM_STATISTICS_TIMER, "Statistics Timer"},
|
||||||
{CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, "Vendor Specific Payload"},
|
{CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, "Vendor Specific Payload"},
|
||||||
{CAPWAP_ELEM_WTP_BOARD_DATA, "WTP Board Data"},
|
{CAPWAP_ELEM_WTP_BOARD_DATA, "WTP Board Data"},
|
||||||
{CAPWAP_ELEM_WTP_DESCRIPTOR, "WTP Descriptor"},
|
{CAPWAP_ELEM_WTP_DESCRIPTOR, "WTP Descriptor"},
|
||||||
{CW_ELEM_WTP_FALLBACK, "WTP Fallback"},
|
{CW_ELEM_WTP_FALLBACK, "WTP Fallback"},
|
||||||
|
30
src/cw/cw.h
30
src/cw/cw.h
@ -104,36 +104,34 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct{
|
|
||||||
int proto;
|
|
||||||
int vendor;
|
|
||||||
int id;
|
|
||||||
int mand;
|
|
||||||
}cw_messagedef_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int type;
|
|
||||||
int * states;
|
|
||||||
cw_messagedef_t * elements;
|
|
||||||
const char * name;
|
const char * name;
|
||||||
}cw_message_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int proto;
|
int proto;
|
||||||
int vendor;
|
int vendor;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
int min_len;
|
int min_len;
|
||||||
int max_len;
|
int max_len;
|
||||||
const char * name;
|
}cw_msgelemdef_t;
|
||||||
}cw_message_element_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mavl_t messages;
|
mavl_t messages;
|
||||||
mavl_t all_elems;
|
mavl_t all_elems;
|
||||||
}cw_message_set_t;
|
}cw_message_set_t;
|
||||||
|
|
||||||
|
typedef struct{
|
||||||
|
cw_msgelemdef_t * elem;
|
||||||
|
int mand;
|
||||||
|
}cw_msgelemprops_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int type;
|
||||||
|
int * states;
|
||||||
|
cw_msgelemprops_t * elements;
|
||||||
|
const char * name;
|
||||||
|
}cw_msgdef_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get length wireless specific data
|
* Get length wireless specific data
|
||||||
@ -390,7 +388,7 @@ static inline int cw_put_elem_vendor_hdr(uint8_t * dst, uint32_t vendorid,
|
|||||||
uint16_t elemid, uint16_t len)
|
uint16_t elemid, uint16_t len)
|
||||||
{
|
{
|
||||||
|
|
||||||
cw_put_elem_hdr(dst, CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, len + 6);
|
cw_put_elem_hdr(dst, CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, len + 6);
|
||||||
cw_put_dword(dst + 4, vendorid);
|
cw_put_dword(dst + 4, vendorid);
|
||||||
cw_put_word(dst + 8, elemid);
|
cw_put_word(dst + 8, elemid);
|
||||||
return 10;
|
return 10;
|
||||||
|
@ -42,7 +42,7 @@ int cw_addelem_vendor_specific_payload(uint8_t * dst, uint32_t vendor_id,
|
|||||||
d += cw_put_data(d, data, len);
|
d += cw_put_data(d, data, len);
|
||||||
|
|
||||||
int l = d - dst;
|
int l = d - dst;
|
||||||
cw_put_elem_hdr(dst, CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, l - 4);
|
cw_put_elem_hdr(dst, CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD, l - 4);
|
||||||
return l;
|
return l;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
|||||||
|
|
||||||
uint8_t *dst = msgptr+8;
|
uint8_t *dst = msgptr+8;
|
||||||
|
|
||||||
mlist_t *m = cw_actionlist_out_get(conn->actions->out,cw_get_msg_type(msgptr));
|
mlist_t m = cw_actionlist_out_get(conn->actions->out,cw_get_msg_type(msgptr));
|
||||||
|
|
||||||
if (!m){
|
if (!m){
|
||||||
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
||||||
@ -69,7 +69,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
|||||||
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
for (e=m->list; e; e=e->next) {
|
for (e=m->first; e; e=e->next) {
|
||||||
cw_action_out_t *ae=(cw_action_out_t*)e->data;
|
cw_action_out_t *ae=(cw_action_out_t*)e->data;
|
||||||
|
|
||||||
//printf("Put %d %i %s\n",ae->msg_id,ae->elem_id,ae->item_id);
|
//printf("Put %d %i %s\n",ae->msg_id,ae->elem_id,ae->item_id);
|
||||||
|
@ -549,7 +549,7 @@ void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgelem,
|
|||||||
char vendor_details[265];
|
char vendor_details[265];
|
||||||
*vendor_details = 0;
|
*vendor_details = 0;
|
||||||
|
|
||||||
if (msgelem == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
if (msgelem == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
||||||
uint32_t vendor_id = ntohl(*((uint32_t *) msgbuf));
|
uint32_t vendor_id = ntohl(*((uint32_t *) msgbuf));
|
||||||
int type = ntohs(*((uint16_t *) (msgbuf + 4)));
|
int type = ntohs(*((uint16_t *) (msgbuf + 4)));
|
||||||
cw_format_vendor(vendor_details, vendor_id, type, msgbuf);
|
cw_format_vendor(vendor_details, vendor_id, type, msgbuf);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
#include "mavl.h"
|
#include "mavl.h"
|
||||||
|
#include "cw/dbg.h"
|
||||||
|
|
||||||
#include "message_set.h"
|
#include "message_set.h"
|
||||||
|
|
||||||
@ -12,9 +13,9 @@ typedef struct {
|
|||||||
mlist_t elements_list;
|
mlist_t elements_list;
|
||||||
}message2_t;
|
}message2_t;
|
||||||
|
|
||||||
static inline int cmp_cw_message_element(const void *elem1, const void *elem2){
|
static inline int cmp_cw_msgelemprops(const void *elem1, const void *elem2){
|
||||||
cw_message_element_t * e1 = (cw_message_element_t*)elem1;
|
cw_msgelemdef_t * e1 = ((cw_msgelemprops_t*)elem1)->elem;
|
||||||
cw_message_element_t * e2 = (cw_message_element_t*)elem2;
|
cw_msgelemdef_t * e2 = ((cw_msgelemprops_t*)elem2)->elem;
|
||||||
int r;
|
int r;
|
||||||
r = e1->id - e2->id;
|
r = e1->id - e2->id;
|
||||||
if (r!=0)
|
if (r!=0)
|
||||||
@ -58,7 +59,7 @@ cw_message_set_t * cw_message_set_create(){
|
|||||||
memset(set,0,sizeof(cw_message_set_t));
|
memset(set,0,sizeof(cw_message_set_t));
|
||||||
|
|
||||||
/* create mavl for all_elems */
|
/* create mavl for all_elems */
|
||||||
set->all_elems = mavl_create(cmp_cw_message_element,NULL);
|
set->all_elems = mavl_create(cmp_cw_msgelemprops,NULL);
|
||||||
if (set->all_elems==NULL){
|
if (set->all_elems==NULL){
|
||||||
cw_message_set_destroy(set);
|
cw_message_set_destroy(set);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -76,25 +77,85 @@ cw_message_set_t * cw_message_set_create(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void update_message(message2_t * msg, cw_msgdef_t * src, cw_message_set_t * set){
|
||||||
|
|
||||||
|
cw_msgelemprops_t *md;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
for (md = src->elements; md->elem!=0; md++){
|
||||||
|
cw_dbg(DBG_INFO," add element %d - %s, %d",md->elem->id, md->elem->name, md->mand);
|
||||||
|
mavl_add(msg->elements_tree,md);
|
||||||
|
mavl_add(set->all_elems,md);
|
||||||
|
mlist_append(msg->elements_list,md);
|
||||||
|
mlist_replace(msg->elements_list,NULL,md);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cw_message_set_add(cw_message_set_t * set,
|
void cw_message_set_add(cw_message_set_t * set,
|
||||||
cw_message_t messages[],
|
cw_msgdef_t messages[]){
|
||||||
cw_message_element_t elements[]){
|
|
||||||
|
|
||||||
cw_message_element_t * e;
|
cw_msgdef_t * m;
|
||||||
for (e=elements; e->id!=0; e++){
|
|
||||||
mavl_replace(set->all_elems, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
cw_message_t * m;
|
|
||||||
for (m=messages; m->type !=0; m++){
|
for (m=messages; m->type !=0; m++){
|
||||||
printf("MESS: %d %s",m->type, m->name);
|
message2_t search, *next;
|
||||||
|
|
||||||
|
search.type = m->type;
|
||||||
|
|
||||||
|
cw_dbg(DBG_INFO,"Add message: Type:%d - %s",m->type,m->name);
|
||||||
|
|
||||||
|
next = mavl_find(set->messages,&search);
|
||||||
|
|
||||||
|
/** message not already in memory,
|
||||||
|
* create a new one */
|
||||||
|
if (next == NULL){
|
||||||
|
next = malloc (sizeof(message2_t));
|
||||||
|
if (next == NULL)
|
||||||
|
return;
|
||||||
|
next->elements_tree = mavl_create(cmp_cw_msgelemprops,NULL);
|
||||||
|
if (next->elements_tree==NULL){
|
||||||
|
free(next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
next->elements_list = mlist_create(cmp_cw_msgelemprops);
|
||||||
|
if (next->elements_list == NULL){
|
||||||
|
mavl_destroy(next->elements_tree);
|
||||||
|
free(next);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
next->type=m->type;
|
||||||
|
mavl_add(set->messages,next);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* massage is alreaddy in there */
|
||||||
|
if (m->name)
|
||||||
|
next->name=m->name;
|
||||||
|
if (m->states)
|
||||||
|
next->states=m->states;
|
||||||
|
|
||||||
|
update_message(next,m, set);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_message_element_t * cw_message_set_find_element(
|
cw_msgelemdef_t * cw_message_set_find_element(
|
||||||
cw_message_set_t * set,
|
cw_message_set_t * set,
|
||||||
cw_message_element_t * element){
|
cw_msgelemdef_t * element){
|
||||||
return mavl_find(set->all_elems,element);
|
return mavl_find(set->all_elems,element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
mlist_t cw_msgset_get_msg(cw_message_set_t * set, int type){
|
||||||
|
message2_t search;
|
||||||
|
search.type = type;
|
||||||
|
message2_t * result = mavl_find(set->messages,&search);
|
||||||
|
if (!result){
|
||||||
|
printf ("no result\n");
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
}
|
||||||
|
return result->elements_list;
|
||||||
|
}
|
@ -6,6 +6,6 @@
|
|||||||
extern void cw_message_set_destroy(cw_message_set_t * set);
|
extern void cw_message_set_destroy(cw_message_set_t * set);
|
||||||
extern cw_message_set_t * cw_message_set_create();
|
extern cw_message_set_t * cw_message_set_create();
|
||||||
extern void cw_message_set_add(cw_message_set_t * set,
|
extern void cw_message_set_add(cw_message_set_t * set,
|
||||||
cw_message_t messages[],
|
cw_msgdef_t messages[]);
|
||||||
cw_message_element_t elements[]);
|
mlist_t cw_msgset_get_msg(cw_message_set_t * set, int type);
|
||||||
#endif
|
#endif
|
@ -1,22 +1,22 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
#include "mlist.h"
|
#include "mlist.h"
|
||||||
|
|
||||||
mlist_t *mlist_create(int (*cmp) (void *v1, void *v2))
|
mlist_t mlist_create(int (*cmp) (const void *v1, const void *v2))
|
||||||
{
|
{
|
||||||
mlist_t *l = malloc(sizeof(mlist_t));
|
struct mlist * l = malloc(sizeof(struct mlist));
|
||||||
if (!l)
|
if (!l)
|
||||||
return NULL;
|
return NULL;
|
||||||
memset(l, 0, sizeof(mlist_t));
|
memset(l, 0, sizeof(struct mlist));
|
||||||
l->cmp = cmp;
|
l->cmp = cmp;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mlist_elem *mlist_append(mlist_t * l, void *data)
|
struct mlist_elem * mlist_append(mlist_t l, void *data)
|
||||||
{
|
{
|
||||||
struct mlist_elem **n = &l->list;
|
|
||||||
|
struct mlist_elem **n = &l->first;
|
||||||
while (*n != NULL)
|
while (*n != NULL)
|
||||||
n = &(*n)->next;
|
n = &(*n)->next;
|
||||||
*n = malloc(sizeof(struct mlist_elem));
|
*n = malloc(sizeof(struct mlist_elem));
|
||||||
@ -29,13 +29,13 @@ struct mlist_elem *mlist_append(mlist_t * l, void *data)
|
|||||||
return *n;
|
return *n;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct mlist_elem *mlist_find(mlist_t * l, struct mlist_elem *start, void *data)
|
struct mlist_elem *mlist_find(mlist_t l, struct mlist_elem *start, void *data)
|
||||||
{
|
{
|
||||||
struct mlist_elem *e;
|
struct mlist_elem *e;
|
||||||
if (start)
|
if (start)
|
||||||
e = start;
|
e = start;
|
||||||
else
|
else
|
||||||
e = l->list;
|
e = l->first;
|
||||||
|
|
||||||
while (e) {
|
while (e) {
|
||||||
if (l->cmp(e->data, data) == 0)
|
if (l->cmp(e->data, data) == 0)
|
||||||
@ -47,13 +47,13 @@ struct mlist_elem *mlist_find(mlist_t * l, struct mlist_elem *start, void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct mlist_elem *mlist_replace(mlist_t *l, struct mlist_elem *start, void *data)
|
struct mlist_elem * mlist_replace(mlist_t l, struct mlist_elem *start, void *data)
|
||||||
{
|
{
|
||||||
struct mlist_elem *e;
|
struct mlist_elem *e;
|
||||||
if (start)
|
if (start)
|
||||||
e = start;
|
e = start;
|
||||||
else
|
else
|
||||||
e = l->list;
|
e = l->first;
|
||||||
|
|
||||||
struct mlist_elem * f = mlist_find(l,e,data);
|
struct mlist_elem * f = mlist_find(l,e,data);
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -46,22 +46,23 @@ struct mlist_elem {
|
|||||||
|
|
||||||
struct mlist {
|
struct mlist {
|
||||||
void *data;
|
void *data;
|
||||||
int (*cmp) (void *d1, void *d2);
|
int (*cmp) (const void *d1, const void *d2);
|
||||||
struct mlist_elem *list;
|
struct mlist_elem *first;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct mlist mlist_t;
|
typedef struct mlist * mlist_t;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* defgroup MLIST_FUNCTIONS
|
* defgroup MLIST_FUNCTIONS
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
extern mlist_t *mlist_create(int (*cmp) (void *v1, void *v2));
|
extern mlist_t mlist_create(int (*cmp) (const void *v1, const void *v2));
|
||||||
extern struct mlist_elem *mlist_append(mlist_t * l, void *data);
|
extern struct mlist_elem *mlist_append(mlist_t l, void *data);
|
||||||
extern struct mlist_elem *mlist_find(mlist_t * l, struct mlist_elem *start, void *data);
|
extern struct mlist_elem *mlist_find(mlist_t l, struct mlist_elem *start, void *data);
|
||||||
extern struct mlist_elem *mlist_replace(mlist_t *l, struct mlist_elem *start, void *data);
|
extern struct mlist_elem *mlist_replace(mlist_t l, struct mlist_elem *start, void *data);
|
||||||
|
|
||||||
|
#define mlist_add mlist_append
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*/
|
*/
|
||||||
@ -70,7 +71,7 @@ extern struct mlist_elem *mlist_replace(mlist_t *l, struct mlist_elem *start, vo
|
|||||||
|
|
||||||
|
|
||||||
#define mlist_foreach(i,l)\
|
#define mlist_foreach(i,l)\
|
||||||
for (i=l->data; i; i=i->next)
|
for (i=l->first; i; i=i->next)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include "mod_capwap.h"
|
#include "mod_capwap.h"
|
||||||
|
|
||||||
static cw_message_element_t _DISCOVERY_TYPE = {
|
static cw_msgelemdef_t _DISCOVERY_TYPE = {
|
||||||
.name = "Discovery Type",
|
.name = "Discovery Type",
|
||||||
.id = CAPWAP_ELEM_DISCOVERY_TYPE,
|
.id = CAPWAP_ELEM_DISCOVERY_TYPE,
|
||||||
//.start = cw_in_generic2,
|
//.start = cw_in_generic2,
|
||||||
@ -37,21 +37,21 @@ static cw_message_element_t _DISCOVERY_TYPE = {
|
|||||||
.min_len = 1,
|
.min_len = 1,
|
||||||
.max_len = 1
|
.max_len = 1
|
||||||
};
|
};
|
||||||
static cw_message_element_t _WTP_BOARD_DATA = {
|
static cw_msgelemdef_t _WTP_BOARD_DATA = {
|
||||||
.name = "WTP Board Data",
|
.name = "WTP Board Data",
|
||||||
.id = CAPWAP_ELEM_WTP_BOARD_DATA,
|
.id = CAPWAP_ELEM_WTP_BOARD_DATA,
|
||||||
// .start = cw_in_wtp_board_data,
|
// .start = cw_in_wtp_board_data,
|
||||||
// .item_id = CW_ITEM_WTP_BOARD_DATA,
|
// .item_id = CW_ITEM_WTP_BOARD_DATA,
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_message_element_t _WTP_DESCRIPTOR = {
|
static cw_msgelemdef_t _WTP_DESCRIPTOR = {
|
||||||
.id = CAPWAP_ELEM_WTP_DESCRIPTOR,
|
.id = CAPWAP_ELEM_WTP_DESCRIPTOR,
|
||||||
.name = "WTP Descriptor",
|
.name = "WTP Descriptor",
|
||||||
//.start = capwap_in_wtp_descriptor,
|
//.start = capwap_in_wtp_descriptor,
|
||||||
//.item_id = "wtp_descriptor",
|
//.item_id = "wtp_descriptor",
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_message_element_t _WTP_FRAME_TUNNEL_MODE = {
|
static cw_msgelemdef_t _WTP_FRAME_TUNNEL_MODE = {
|
||||||
.id = CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE,
|
.id = CAPWAP_ELEM_WTP_FRAME_TUNNEL_MODE,
|
||||||
.name = "WTP Frame Tunnel Mode",
|
.name = "WTP Frame Tunnel Mode",
|
||||||
// .start = cw_in_generic2,
|
// .start = cw_in_generic2,
|
||||||
@ -60,7 +60,7 @@ static cw_message_element_t _WTP_FRAME_TUNNEL_MODE = {
|
|||||||
.max_len = 1
|
.max_len = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_message_element_t _WTP_MAC_TYPE = {
|
static cw_msgelemdef_t _WTP_MAC_TYPE = {
|
||||||
.id = CAPWAP_ELEM_WTP_MAC_TYPE,
|
.id = CAPWAP_ELEM_WTP_MAC_TYPE,
|
||||||
.name = "WTP Mac Type",
|
.name = "WTP Mac Type",
|
||||||
// .start = cw_in_generic2,
|
// .start = cw_in_generic2,
|
||||||
@ -70,13 +70,13 @@ static cw_message_element_t _WTP_MAC_TYPE = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* MTU Discovery Padding */
|
/* MTU Discovery Padding */
|
||||||
static cw_message_element_t _MTU_DISCOVERY_PADDING = {
|
static cw_msgelemdef_t _MTU_DISCOVERY_PADDING = {
|
||||||
.id = CW_ELEM_MTU_DISCOVERY_PADDING,
|
.id = CW_ELEM_MTU_DISCOVERY_PADDING,
|
||||||
.name = "MTU Discovery Padding"
|
.name = "MTU Discovery Padding"
|
||||||
// .start = cw_in_mtu_discovery_padding,
|
// .start = cw_in_mtu_discovery_padding,
|
||||||
};
|
};
|
||||||
|
|
||||||
static cw_message_element_t _VENDOR_SPECIFIC_PAYLOAD = {
|
static cw_msgelemdef_t _VENDOR_SPECIFIC_PAYLOAD = {
|
||||||
.name = "Vendor Specific Payload",
|
.name = "Vendor Specific Payload",
|
||||||
.id = CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
.id = CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ static cw_message_element_t _VENDOR_SPECIFIC_PAYLOAD = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* AC Descriptor - Discovery Response */
|
/* AC Descriptor - Discovery Response */
|
||||||
static cw_message_element_t _AC_DESCRIPTOR = {
|
static cw_msgelemdef_t _AC_DESCRIPTOR = {
|
||||||
.name = "AC Descriptor",
|
.name = "AC Descriptor",
|
||||||
.id = CAPWAP_ELEM_AC_DESCRIPTOR,
|
.id = CAPWAP_ELEM_AC_DESCRIPTOR,
|
||||||
//.item_id = CW_ITEM_AC_DESCRIPTOR,
|
//.item_id = CW_ITEM_AC_DESCRIPTOR,
|
||||||
@ -96,14 +96,14 @@ static cw_message_element_t _AC_DESCRIPTOR = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static cw_message_t messages[] = {
|
static cw_msgdef_t messages[] = {
|
||||||
|
|
||||||
/* Discovery Request Message*/
|
/* Discovery Request Message*/
|
||||||
{
|
{
|
||||||
.name = "Discovery Request",
|
.name = "Discovery Request",
|
||||||
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.type = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
.states = (int[]){CAPWAP_STATE_DISCOVERY,0},
|
||||||
.elements = (cw_messagedef_t []){
|
.elements = (cw_msgelemprops_t []){
|
||||||
{&_DISCOVERY_TYPE,1},
|
{&_DISCOVERY_TYPE,1},
|
||||||
{&_WTP_BOARD_DATA,1},
|
{&_WTP_BOARD_DATA,1},
|
||||||
{&_WTP_DESCRIPTOR,1},
|
{&_WTP_DESCRIPTOR,1},
|
||||||
@ -119,7 +119,7 @@ static cw_message_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_messagedef_t[]){
|
.elements = (cw_msgelemprops_t[]){
|
||||||
{&_AC_DESCRIPTOR,1},
|
{&_AC_DESCRIPTOR,1},
|
||||||
{0,0},
|
{0,0},
|
||||||
}
|
}
|
||||||
@ -137,22 +137,40 @@ void test_sets(){
|
|||||||
|
|
||||||
cw_message_set_add(set,messages);
|
cw_message_set_add(set,messages);
|
||||||
|
|
||||||
cw_message_element_t el, *result;
|
cw_msgelemdef_t el;
|
||||||
memset(&el,0,sizeof(el));
|
memset(&el,0,sizeof(el));
|
||||||
el.id=CAPWAP_ELEM_DISCOVERY_TYPE;
|
el.id=CAPWAP_ELEM_DISCOVERY_TYPE;
|
||||||
|
|
||||||
result = mavl_find(set->all_elems,&el);
|
cw_msgelemprops_t search, *result;;
|
||||||
|
search.elem = ⪙
|
||||||
|
|
||||||
|
|
||||||
|
result = mavl_find(set->all_elems,&search);
|
||||||
|
|
||||||
if (result!=NULL){
|
if (result!=NULL){
|
||||||
printf("Found: %d %s\n",
|
printf("Found: %d %s %d\n",
|
||||||
result->id,
|
result->elem->id,
|
||||||
result->name
|
result->elem->name,
|
||||||
|
result->mand
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
printf("not found\n");
|
printf("not found\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mlist_t m;
|
||||||
|
m = cw_msgset_get_msg(set,CAPWAP_MSG_DISCOVERY_REQUEST);
|
||||||
|
printf("Hey: %p\n",m);
|
||||||
|
|
||||||
|
struct mlist_elem * i;
|
||||||
|
mlist_foreach(i,m){
|
||||||
|
cw_msgelemprops_t * le = i->data;
|
||||||
|
printf("Element: %d %s\n",le->elem->id, le->elem->name, le->mand);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
{
|
{
|
||||||
.capwap_state = CAPWAP_STATE_DISCOVERY,
|
.capwap_state = CAPWAP_STATE_DISCOVERY,
|
||||||
.msg_id = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
.msg_id = CAPWAP_MSG_DISCOVERY_RESPONSE,
|
||||||
.elem_id = CW_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
.elem_id = CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
||||||
.start = cw_in_vendor_specific_payload
|
.start = cw_in_vendor_specific_payload
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
@ -299,7 +299,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
{
|
{
|
||||||
.capwap_state = CW_STATE_CONFIGURE,
|
.capwap_state = CW_STATE_CONFIGURE,
|
||||||
.msg_id = CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
.msg_id = CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||||
.elem_id = CW_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
.elem_id = CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
||||||
.start = cw_in_vendor_specific_payload
|
.start = cw_in_vendor_specific_payload
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
@ -370,7 +370,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
{
|
{
|
||||||
.capwap_state = CW_STATE_RUN,
|
.capwap_state = CW_STATE_RUN,
|
||||||
.msg_id = CW_MSG_ECHO_RESPONSE,
|
.msg_id = CW_MSG_ECHO_RESPONSE,
|
||||||
.elem_id = CW_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
.elem_id = CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
||||||
.start = cw_in_vendor_specific_payload
|
.start = cw_in_vendor_specific_payload
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
@ -435,7 +435,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
{
|
{
|
||||||
.capwap_state = CW_STATE_RUN,
|
.capwap_state = CW_STATE_RUN,
|
||||||
.msg_id = CW_MSG_CONFIGURATION_UPDATE_REQUEST,
|
.msg_id = CW_MSG_CONFIGURATION_UPDATE_REQUEST,
|
||||||
.elem_id = CW_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
.elem_id = CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD,
|
||||||
.start = cw_in_vendor_specific_payload
|
.start = cw_in_vendor_specific_payload
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
@ -140,7 +140,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
|
|||||||
* specific payload Cisco identifier */
|
* specific payload Cisco identifier */
|
||||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||||
int id = cw_get_elem_id(elem);
|
int id = cw_get_elem_id(elem);
|
||||||
if (id == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
||||||
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
||||||
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
||||||
// conn->actions = &actions;
|
// conn->actions = &actions;
|
||||||
|
@ -127,7 +127,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
|
|||||||
* specific payload Cisco identifier */
|
* specific payload Cisco identifier */
|
||||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||||
int id = cw_get_elem_id(elem);
|
int id = cw_get_elem_id(elem);
|
||||||
if (id == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
||||||
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
||||||
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
||||||
// conn->actions = &actions;
|
// conn->actions = &actions;
|
||||||
|
@ -39,7 +39,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
|
|
||||||
/* Message Discovery Request */
|
/* Message Discovery Request */
|
||||||
{
|
{
|
||||||
.capwap_state = CW_STATE_DISCOVERY,
|
.capwap_state = CAPWAP_STATE_DISCOVERY,
|
||||||
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.end = cw_in_check_disc_req
|
.end = cw_in_check_disc_req
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
#if 0
|
#if 0
|
||||||
/* Element WTP Descriptor */
|
/* Element WTP Descriptor */
|
||||||
{
|
{
|
||||||
.capwap_state = CW_STATE_DISCOVERY,
|
.capwap_state = CAPWAP_STATE_DISCOVERY,
|
||||||
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.elem_id = CW_ELEM_WTP_DESCRIPTOR,
|
.elem_id = CW_ELEM_WTP_DESCRIPTOR,
|
||||||
.start = cisco_in_wtp_descriptor,
|
.start = cisco_in_wtp_descriptor,
|
||||||
@ -58,7 +58,7 @@ static cw_action_in_t actions_in[] = {
|
|||||||
|
|
||||||
/* Element Cisco RAD Name */
|
/* Element Cisco RAD Name */
|
||||||
{
|
{
|
||||||
.capwap_state = CW_STATE_DISCOVERY,
|
.capwap_state = CAPWAP_STATE_DISCOVERY,
|
||||||
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.vendor_id = CW_VENDOR_ID_CISCO,
|
.vendor_id = CW_VENDOR_ID_CISCO,
|
||||||
.elem_id = CW_CISCO_RAD_NAME,
|
.elem_id = CW_CISCO_RAD_NAME,
|
||||||
@ -249,7 +249,7 @@ static cw_action_in_t actions80211_in[] = {
|
|||||||
/* Cisco doe't sned this message element in discovery request,
|
/* Cisco doe't sned this message element in discovery request,
|
||||||
so make it non-mandatory */
|
so make it non-mandatory */
|
||||||
|
|
||||||
.capwap_state = CW_STATE_DISCOVERY,
|
.capwap_state = CAPWAP_STATE_DISCOVERY,
|
||||||
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
.msg_id = CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
|
.elem_id = CW_ELEM80211_WTP_RADIO_INFORMATION,
|
||||||
.item_id = "radio_information",
|
.item_id = "radio_information",
|
||||||
|
@ -81,7 +81,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
|
|||||||
* specific payload Fortinet identifier */
|
* specific payload Fortinet identifier */
|
||||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||||
int id = cw_get_elem_id(elem);
|
int id = cw_get_elem_id(elem);
|
||||||
if (id == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
||||||
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
||||||
if (vendor_id == CW_VENDOR_ID_FORTINET) {
|
if (vendor_id == CW_VENDOR_ID_FORTINET) {
|
||||||
// conn->actions = &actions;
|
// conn->actions = &actions;
|
||||||
|
@ -126,7 +126,7 @@ static int detect(struct conn *conn, const uint8_t * rawmsg, int rawlen, int ele
|
|||||||
* specific payload Fortinet identifier */
|
* specific payload Fortinet identifier */
|
||||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||||
int id = cw_get_elem_id(elem);
|
int id = cw_get_elem_id(elem);
|
||||||
if (id == CW_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
||||||
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
||||||
if (vendor_id == CW_VENDOR_ID_FORTINET) {
|
if (vendor_id == CW_VENDOR_ID_FORTINET) {
|
||||||
// conn->actions = &actions;
|
// conn->actions = &actions;
|
||||||
|
Loading…
Reference in New Issue
Block a user