Work in progress
FossilOrigin-Name: 155605fd55cbb193d4f5ac8c704930c050a11cda541f1a5cdb93c57a8c51534f
This commit is contained in:
@ -4,7 +4,10 @@
|
||||
|
||||
uint8_t * bstr16_create_from_str(const char *s)
|
||||
{
|
||||
int l = strlen(s);
|
||||
uint8_t * mem;
|
||||
int msize;
|
||||
int l;
|
||||
l = strlen(s);
|
||||
if (s[0]!='.')
|
||||
return bstr16_create((uint8_t*)s,l);
|
||||
|
||||
@ -19,10 +22,10 @@ uint8_t * bstr16_create_from_str(const char *s)
|
||||
|
||||
/* the string starts with ".x" - read hexbytes */
|
||||
l-=2;
|
||||
int msize=l/2;
|
||||
msize=l/2;
|
||||
if(l&1)
|
||||
msize++;
|
||||
uint8_t * mem = malloc(2+msize);
|
||||
mem = malloc(2+msize);
|
||||
*((uint16_t*)mem)=msize;
|
||||
cw_format_scan_hex_bytes(mem+2,s+2,l);
|
||||
return mem;
|
||||
|
116
src/cw/capwap.h
116
src/cw/capwap.h
@ -188,12 +188,12 @@
|
||||
*/
|
||||
|
||||
|
||||
#define CAPWAP_ELEM_AC_DESCRIPTOR 1 /**< AC Descriptor */
|
||||
#define CAPWAP_ELEM_AC_DESCRIPTOR 1 /**< AC Descriptor */
|
||||
|
||||
#define CAPWAP_ELEM_AC_IPV4_LIST 2 /**< AC IP V4 List */
|
||||
#define CW_ELEM_AC_IPV6_LIST 3 /**< AC IP V6 List */
|
||||
#define CW_ELEM_AC_NAME 4 /**< AC Name */
|
||||
#define CW_ELEM_AC_NAME_WITH_PRIORITY 5
|
||||
#define CAPWAP_ELEM_AC_IPV4_LIST 2 /**< AC IP V4 List */
|
||||
#define CAPWAP_ELEM_AC_IPV6_LIST 3 /**< AC IP V6 List */
|
||||
#define CAPWAP_ELEM_AC_NAME 4 /**< AC Name */
|
||||
#define CW_ELEM_AC_NAME_WITH_PRIORITY 5
|
||||
|
||||
/**
|
||||
* In CAPWAP RFC draft 7 the message element 5 was named
|
||||
@ -380,9 +380,9 @@
|
||||
* @{
|
||||
*/
|
||||
/** X.509 Support */
|
||||
#define CW_FLAG_AC_SECURITY_X 2
|
||||
#define CAPWAP_FLAG_AC_SECURITY_X 2
|
||||
/* PSK Support */
|
||||
#define CW_FLAG_AC_SECURITY_S 4
|
||||
#define CAPWAP_FLAG_AC_SECURITY_S 4
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
@ -432,15 +432,18 @@ struct cwimage_identifier{
|
||||
/*
|
||||
//extern void cwmsg_addelem_wtp_radio_infos(struct cwmsg * cwmsg,struct wtpinfo * wtpinfo);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern void cwmsg_addelem_wtp_radio_infos(struct cwmsg *msg,
|
||||
struct radioinfo *radioinfos);
|
||||
struct radioinfo *radioinfos);*/
|
||||
|
||||
/*
|
||||
//extern void cwmsg_addelem_result_code(struct cwmsg *msg, int rc);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern void cwmsg_addelem_vendor_specific_payload(struct cwmsg *msg, int vendor_id,
|
||||
int type, uint8_t * payload, int len);
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int hdr_print(char *str, uint8_t * packet, int len);
|
||||
@ -464,7 +467,7 @@ extern int cw_readelem_ecn_support(uint8_t * ecn_support, int type, uint8_t * ms
|
||||
// uint8_t * msgelem, int len);
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
extern int cw_readelem_statistics_timer(uint16_t * timer, int type, uint8_t * msgelem,
|
||||
int len);
|
||||
extern int cw_readelem_result_code(uint32_t * result_code, int type, uint8_t * msgelem,
|
||||
@ -473,7 +476,7 @@ extern int cw_readelem_result_code(uint32_t * result_code, int type, uint8_t * m
|
||||
extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elemtype,
|
||||
uint8_t * msgelem, int len);
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -635,6 +638,7 @@ extern struct cw_strlist_elem mbag_item_strings[];
|
||||
#define cw_strerror(rc) cw_strrc(rc)
|
||||
*/
|
||||
|
||||
#include "strheap.h"
|
||||
|
||||
const char * cw_strerror(int rc);
|
||||
int cw_result_is_ok(int rc);
|
||||
@ -658,12 +662,14 @@ extern int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_in_wtp_name(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
*/
|
||||
|
||||
/*
|
||||
//extern int cw_out_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
|
||||
@ -677,21 +683,21 @@ extern int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t *
|
||||
//extern int cw_out_ac_descriptor(struct conn *conn, uint32_t elem_id, uint8_t * dst,
|
||||
//struct mbag_item *item);
|
||||
*/
|
||||
extern int cw_out_ac_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
extern int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a,
|
||||
uint8_t * dst);
|
||||
|
||||
/*
|
||||
//extern int cw_out_capwap_control_ip_addrs(struct conn *conn, uint32_t elem_id,
|
||||
// uint8_t * dst, struct mbag_item *item);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_out_capwap_control_ip_addr_list(struct conn *conn, struct cw_action_out *a,
|
||||
uint8_t * dst);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_put_msg(struct conn *conn, uint8_t * rawout);
|
||||
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
|
||||
*/
|
||||
|
||||
struct cw_ac_status {
|
||||
int stations;
|
||||
@ -732,84 +738,6 @@ enum capwap_states {
|
||||
|
||||
|
||||
|
||||
int cw_register_actions_capwap_ac(struct cw_actiondef *def);
|
||||
int cw_register_actions_cipwap_ac(struct cw_actiondef *def);
|
||||
int cw_register_actions_capwap_wtp(struct cw_actiondef *def);
|
||||
|
||||
|
||||
int cw_in_set_state_none(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len);
|
||||
struct mbag_item *cw_out_get_outgoing(struct conn *conn, struct cw_action_out *a);
|
||||
struct mbag_item *cw_out_get_local(struct conn *conn, struct cw_action_out *a);
|
||||
extern int cw_in_check_join_resp(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
|
||||
extern int cw_in_check_disc_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
int cw_in_check_disc_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
|
||||
|
||||
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
extern int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
int cw_in_check_img_data_resp(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
|
||||
int cw_out_wtp_board_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
|
||||
void cw_init_request(struct conn *conn, int msg_id);
|
||||
struct mbag_item *cw_out_get_session_id(struct conn *conn, struct cw_action_out *a);
|
||||
struct mbag_item *cw_out_get_config(struct conn *conn, struct cw_action_out *a);
|
||||
|
||||
|
||||
extern int cw_in_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
int cw_out_ac_name_with_priority(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
|
||||
int cw_send_request(struct conn *conn, int msg_id);
|
||||
/*
|
||||
//int cw_is_utf8(unsigned char *str, size_t len);
|
||||
*/
|
||||
|
||||
int cw_in_ac_name_with_priority(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
int cw_out_radio_administrative_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
|
||||
int cw_in_radio_administrative_state(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
int cw_in_ac_descriptor(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len,struct sockaddr *from);
|
||||
|
||||
int cw_in_radio_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
/*
|
||||
//int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action, uint8_t * dst);
|
||||
*/
|
||||
|
||||
int cw_in_check_chng_state_evnt_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
|
||||
/*
|
||||
//int cw_out_radio_operational_states(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
*/
|
||||
|
||||
int cw_in_check_cfg_update_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
|
||||
int cw_radio_set_admin_state(mbag_t radios,int rid, int state,int cause);
|
||||
|
||||
int cw_in_radio_administrative_state_wtp(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len,
|
||||
struct sockaddr *from);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -5,8 +5,8 @@ struct cw_strlist_elem capwap_strings_elem[] = {
|
||||
|
||||
{CAPWAP_ELEM_AC_DESCRIPTOR, "AC Descriptor"},
|
||||
{CAPWAP_ELEM_AC_IPV4_LIST, "AC IPv4 List"},
|
||||
{CW_ELEM_AC_IPV6_LIST, "AC IPv6 List"},
|
||||
{CW_ELEM_AC_NAME, "AC Name"},
|
||||
{CAPWAP_ELEM_AC_IPV6_LIST, "AC IPv6 List"},
|
||||
{CAPWAP_ELEM_AC_NAME, "AC Name"},
|
||||
{CW_ELEM_AC_NAME_WITH_PRIORITY, "AC Name with Priority"},
|
||||
// {CW_ELEM_AC_NAME_WITH_INDEX, "AC Name with Index"},
|
||||
{CAPWAP_ELEM_AC_TIMESTAMP, "AC Timestamp"},
|
||||
|
@ -74,6 +74,7 @@ struct conn {
|
||||
|
||||
mavl_t remote_cfg;
|
||||
mavl_t local_cfg;
|
||||
mavl_t global_cfg;
|
||||
|
||||
|
||||
|
||||
|
@ -40,7 +40,7 @@ void conn_init(struct conn * conn)
|
||||
conn->wait_dtls=CAPWAP_WAIT_DTLS;
|
||||
conn->wait_join=CAPWAP_WAIT_JOIN;
|
||||
conn->mtu_discovery=1;
|
||||
conn->capwap_mode = CW_MODE_AUTO;
|
||||
conn->capwap_mode = 0;
|
||||
conn->strict_capwap=1;
|
||||
|
||||
conn->remote = mbag_create();
|
||||
|
@ -116,8 +116,10 @@ void cw_init_data_msg(struct conn *conn)
|
||||
*/
|
||||
int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
{
|
||||
int rc;
|
||||
cw_init_response(conn, rawmsg);
|
||||
if (cw_put_msg(conn, conn->resp_buffer) == -1)
|
||||
rc = cw_put_msg(conn, conn->resp_buffer);
|
||||
if (!cw_result_is_ok(rc))
|
||||
return 0;
|
||||
conn_send_msg(conn, conn->resp_buffer);
|
||||
return 1;
|
||||
@ -125,7 +127,6 @@ int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Special case error message, which is sent when an unexpected messages
|
||||
* was received or something else happened.
|
||||
@ -330,10 +331,10 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
|
||||
|
||||
|
||||
if (conn->msg_start){
|
||||
/* if (conn->msg_start){
|
||||
conn->msg_start(conn, afm, rawmsg, len, from);
|
||||
}
|
||||
|
||||
*/
|
||||
/* Execute start processor for message */
|
||||
/*
|
||||
// if (afm->start) {
|
||||
@ -353,6 +354,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
|
||||
/* iterate through message elements */
|
||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
||||
int rc;
|
||||
|
||||
struct cw_ElemHandlerParams params;
|
||||
int elem_len, elem_id, max_len;
|
||||
@ -377,26 +379,16 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,
|
||||
params.msgdata=message;
|
||||
params.mand_found=mand_found;
|
||||
|
||||
result_code = cw_process_element(¶ms,0,0,elem_id,elem_data,elem_len);
|
||||
rc = cw_process_element(¶ms,0,0,elem_id,elem_data,elem_len);
|
||||
|
||||
|
||||
if (cw_result_is_ok(result_code))
|
||||
if (cw_result_is_ok(rc))
|
||||
continue;
|
||||
|
||||
if (result_code == CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT){
|
||||
if (rc == CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT){
|
||||
mlist_append(unrecognized,&elem);
|
||||
}
|
||||
|
||||
|
||||
continue;
|
||||
exit(0);
|
||||
|
||||
/* if (!check_len(conn, af, cw_get_elem_data(elem), elem_len, from)) {
|
||||
continue;
|
||||
}
|
||||
cw_dbg_elem(DBG_ELEM, conn, as.msg_id, as.elem_id, cw_get_elem_data(elem),
|
||||
elem_len);
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
@ -426,10 +418,7 @@ exit(0);
|
||||
}
|
||||
|
||||
|
||||
mavliter_init(&it,mand_found);
|
||||
mavliter_foreach(&it){
|
||||
printf("MAnd found: %s", mavliter_get_str(&it));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
mlistelem_t *e;
|
||||
@ -445,13 +434,10 @@ exit(0);
|
||||
}
|
||||
|
||||
|
||||
//int result_code = 0;
|
||||
//int unrecognized =3;
|
||||
|
||||
/** int rct = cw_in_check_generic(conn, afm, rawmsg, len, from); */
|
||||
|
||||
int rct = cw_in_check_generic(conn, afm, rawmsg, len, from);
|
||||
|
||||
if (rct && conn->strict_capwap)
|
||||
/* if (rct && conn->strict_capwap)
|
||||
{
|
||||
result_code = rct;
|
||||
}
|
||||
@ -465,11 +451,11 @@ exit(0);
|
||||
conn->msg_end(conn, afm, rawmsg, len, from);
|
||||
}
|
||||
}
|
||||
|
||||
if (unrecognized) {
|
||||
*/
|
||||
/* if (unrecognized) {
|
||||
cw_dbg(DBG_RFC, "Message has %d unrecognized message elements.",
|
||||
unrecognized);
|
||||
/* set only resultcode for request messages */
|
||||
// set only resultcode for request messages
|
||||
|
||||
if ( (!result_code) && ((afm->msg_id & 1))) {
|
||||
if (conn->strict_capwap) {
|
||||
@ -478,14 +464,19 @@ exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/* if we've got a request message, we always have to send a response message */
|
||||
if (as.msg_id & 1) {
|
||||
if (message->type & 1) {
|
||||
if (result_code > 0) {
|
||||
/* the end method gave us an result code>0, so
|
||||
send an error message */
|
||||
printf("Here we are, error response %i %s\n", result_code, cw_strerror(result_code));
|
||||
exit(0);
|
||||
cw_send_error_response(conn, rawmsg, result_code);
|
||||
} else if (result_code == 0) {
|
||||
|
||||
/* All ok, send regular response message */
|
||||
cw_send_response(conn, rawmsg, len);
|
||||
} else {
|
||||
|
@ -53,4 +53,5 @@ int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a, uint8
|
||||
|
||||
return CAPWAP_RESULT_IMAGE_DATA_ERROR;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key, const struct
|
||||
return NULL;
|
||||
}
|
||||
|
||||
printf("Want To Add: %s:%s (%s)\n",key,str,type->name);
|
||||
mresult = type->from_str(&mdata,str);
|
||||
if (!mresult){
|
||||
cw_log(LOG_ERR, "Can't create kvstore element for key %s of type %s: %s",
|
||||
|
30
src/cw/cw_ktv_dump.c
Normal file
30
src/cw/cw_ktv_dump.c
Normal file
@ -0,0 +1,30 @@
|
||||
#include "ktv.h"
|
||||
#include "dbg.h"
|
||||
|
||||
|
||||
void cw_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
||||
const char *header, const char *prefix, const char *footer )
|
||||
{
|
||||
char value[500];
|
||||
struct cw_KTV * data;
|
||||
mavliter_t it;
|
||||
const struct cw_Type * type;
|
||||
|
||||
if (header != NULL)
|
||||
cw_dbg (dbglevel, header);
|
||||
|
||||
mavliter_init(&it,ktv);
|
||||
|
||||
mavliter_foreach(&it){
|
||||
|
||||
data = mavliter_get(&it);
|
||||
type = data->type;
|
||||
type->to_str(data,value,0);
|
||||
|
||||
cw_dbg(dbglevel,"%s%s (%s): %s",prefix,data->key,type->name, value);
|
||||
}
|
||||
|
||||
if (footer != NULL)
|
||||
cw_dbg (dbglevel, footer);
|
||||
|
||||
}
|
11
src/cw/cw_ktv_get_byte.c
Normal file
11
src/cw/cw_ktv_get_byte.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "ktv.h"
|
||||
|
||||
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def)
|
||||
{
|
||||
cw_KTV_t * k;
|
||||
k = cw_ktv_get(ktv,key,CW_TYPE_BYTE);
|
||||
if (k != NULL){
|
||||
return k->val.byte;
|
||||
}
|
||||
return def;
|
||||
}
|
11
src/cw/cw_ktv_get_word.c
Normal file
11
src/cw/cw_ktv_get_word.c
Normal file
@ -0,0 +1,11 @@
|
||||
#include "ktv.h"
|
||||
|
||||
uint16_t cw_ktv_get_word(mavl_t ktv,const char *key, uint16_t def)
|
||||
{
|
||||
cw_KTV_t * k;
|
||||
k = cw_ktv_get(ktv,key,CW_TYPE_WORD);
|
||||
if (k != NULL){
|
||||
return k->val.word;
|
||||
}
|
||||
return def;
|
||||
}
|
@ -27,8 +27,10 @@ int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
||||
if (cwtype != NULL){
|
||||
// printf("Yes! I know the type: %s\n",cwtype->name);
|
||||
}
|
||||
else
|
||||
else {
|
||||
printf("Unknown type: %s\n",typesearch.name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
9
src/cw/cw_ktv_std_types.c
Normal file
9
src/cw/cw_ktv_std_types.c
Normal file
@ -0,0 +1,9 @@
|
||||
#include "ktv.h"
|
||||
|
||||
const cw_Type_t * cw_ktv_std_types[] = {
|
||||
CW_TYPE_BYTE,
|
||||
CW_TYPE_WORD,
|
||||
CW_TYPE_DWORD,
|
||||
CW_TYPE_BSTR16,
|
||||
NULL
|
||||
};
|
@ -1,111 +0,0 @@
|
||||
#include "log.h"
|
||||
#include "mbag.h"
|
||||
#include "conn.h"
|
||||
|
||||
#include "mbag.h"
|
||||
#include "capwap_items.h"
|
||||
#include "cw.h"
|
||||
|
||||
|
||||
int cw_get_out_item(struct conn * conn, struct cw_action_out *a, void *dst, mbagtype_t type)
|
||||
{
|
||||
if (!a->get)
|
||||
return 0;
|
||||
|
||||
/* Get the item */
|
||||
struct mbag_item *item = a->get(conn, a);
|
||||
if (!item)
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
if (item->type != type){
|
||||
return 0;
|
||||
}
|
||||
|
||||
return cw_put_mbag_item(dst,item);
|
||||
}
|
||||
|
||||
int cw_out_wtp_board_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
||||
{
|
||||
|
||||
mbag_t board_data;
|
||||
|
||||
// mbag_get_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA,NULL);
|
||||
|
||||
if (!cw_get_out_item(conn,a,&board_data,MBAG_MBAG)){
|
||||
cw_log(LOG_ERROR,"Can't get item '%s' for msg %d, elem %d",a->item_id,a->msg_id,a->elem_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if (!board_data) {
|
||||
cw_log(LOG_ERR, "Error: Can't send WTP Board Data element. \"%s\" is undefined.",CW_ITEM_WTP_BOARD_DATA);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
struct mbag_item *i;
|
||||
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_VENDOR);
|
||||
if (!i) {
|
||||
cw_log(LOG_ERR,
|
||||
"Error: Can't send WTP Board Data element - no vendor defined");
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t *d = dst + 4;
|
||||
d += cw_put_dword(d, i->u2.dword);
|
||||
|
||||
char buf[90];
|
||||
|
||||
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_MODELNO);
|
||||
if (i) {
|
||||
|
||||
printf("We have got an i %p\n",i);
|
||||
printf("len: %d\n",bstr16_len(i->u2.data));
|
||||
memcpy(buf,bstr16_data(i->u2.data),bstr16_len(i->u2.data));
|
||||
buf[bstr16_len(i->u2.data)]=0;
|
||||
printf("Val: %s\n",buf);
|
||||
|
||||
d += cw_put_word(d, CW_BOARDDATA_MODELNO);
|
||||
d += cw_put_word(d, bstr16_len(i->u2.data));
|
||||
d += cw_put_data(d, bstr16_data(i->u2.data), bstr16_len(i->u2.data));
|
||||
} else {
|
||||
cw_log(LOG_ERR,
|
||||
"Error: Can't set sub-element \"WTP Model Number\" in WTP Board Data.");
|
||||
}
|
||||
|
||||
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_SERIALNO);
|
||||
if (i) {
|
||||
d += cw_put_word(d, CW_BOARDDATA_SERIALNO);
|
||||
d += cw_put_word(d, bstr16_len(i->u2.data));
|
||||
d += cw_put_data(d, bstr16_data(i->u2.data), bstr16_len(i->u2.data));
|
||||
}else {
|
||||
cw_log(LOG_ERR,
|
||||
"Error: Can't set sub-element \"WTP Serial Number\" in WTP Board Data.");
|
||||
}
|
||||
|
||||
|
||||
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_ID);
|
||||
if (i) {
|
||||
d += cw_put_word(d, CW_BOARDDATA_BOARDID);
|
||||
d += cw_put_word(d, bstr16_len(i->u2.data));
|
||||
d += cw_put_data(d, bstr16_data(i->u2.data), bstr16_len(i->u2.data));
|
||||
}
|
||||
|
||||
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_REVISION);
|
||||
if (i) {
|
||||
d += cw_put_word(d, CW_BOARDDATA_REVISION);
|
||||
d += cw_put_word(d, bstr16_len(i->u2.data));
|
||||
d += cw_put_data(d, bstr16_data(i->u2.data), bstr16_len(i->u2.data));
|
||||
}
|
||||
|
||||
i = mbag_get(board_data, CW_ITEM_WTP_BOARD_MACADDRESS);
|
||||
if (i) {
|
||||
d += cw_put_word(d, CW_BOARDDATA_MACADDRESS);
|
||||
d += cw_put_word(d, bstr_len(i->u2.data));
|
||||
d += cw_put_data(d, bstr_data(i->u2.data), bstr_len(i->u2.data));
|
||||
}
|
||||
|
||||
int l = d - dst-4;
|
||||
return l + cw_put_elem_hdr(dst, CAPWAP_ELEM_WTP_BOARD_DATA, l );
|
||||
|
||||
}
|
@ -31,7 +31,7 @@ static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
||||
{
|
||||
|
||||
@ -77,7 +77,8 @@ int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t *
|
||||
else {
|
||||
cw_log(LOG_INFO, "Can't send Other Version in WTP descriptor, not set.");
|
||||
}
|
||||
*/
|
||||
int len = d-dst-4;
|
||||
return len + cw_put_elem_hdr(dst,a->elem_id,len);
|
||||
*
|
||||
// int len = d-dst-4;
|
||||
// return len + cw_put_elem_hdr(dst,a->elem_id,len);
|
||||
}
|
||||
*/
|
@ -10,15 +10,17 @@
|
||||
*/
|
||||
int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s, struct conn * conn)
|
||||
{
|
||||
uint8_t *d = dst;
|
||||
uint8_t *d;
|
||||
|
||||
d = dst;
|
||||
|
||||
d += cw_put_dword(d, (s->stations << 16) | (s->limit));
|
||||
d += cw_put_dword(d, (s->active_wtps << 16) | (s->max_wtps));
|
||||
|
||||
|
||||
int security = 0;
|
||||
security |= conn->dtls_cert_file ? CW_FLAG_AC_SECURITY_X : 0;
|
||||
security |= conn->dtls_psk ? CW_FLAG_AC_SECURITY_S : 0;
|
||||
security |= conn->dtls_cert_file ? CAPWAP_FLAG_AC_SECURITY_X : 0;
|
||||
security |= conn->dtls_psk ? CAPWAP_FLAG_AC_SECURITY_S : 0;
|
||||
|
||||
|
||||
d += cw_put_dword(d,
|
||||
|
@ -44,6 +44,8 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
struct mlistelem * elem;
|
||||
int len,l;
|
||||
|
||||
\
|
||||
|
||||
/* rawout is already initialized, so we can get
|
||||
* msg type from buffer */
|
||||
msgptr = rawout + cw_get_hdr_msg_offset(rawout);
|
||||
@ -53,8 +55,11 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
if (msg == NULL){
|
||||
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
||||
type, cw_strmsg(type));
|
||||
return CAPWAP_RESULT_MSG_UNRECOGNIZED;
|
||||
}
|
||||
|
||||
|
||||
printf("Message to send: %s (elems %d)\n",msg->name, msg->elements_list->count);
|
||||
|
||||
dst = msgptr+8;
|
||||
len =0;
|
||||
mlist_foreach(elem,msg->elements_list){
|
||||
@ -64,7 +69,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
|
||||
data = mlistelem_dataptr(elem);
|
||||
handler = cw_msgset_get_elemhandler(conn->msgset,data->proto,data->vendor,data->id);
|
||||
//printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);
|
||||
printf("Elem: %d %d %d %s\n", data->proto, data->vendor, data->id, handler->name);
|
||||
|
||||
if (handler->put == NULL){
|
||||
if (data->mand){
|
||||
@ -93,7 +98,32 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
|
||||
return len;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
printf("Message to send: %s\n",msg->name);
|
||||
|
||||
|
||||
|
@ -44,13 +44,13 @@ int cw_read_descriptor_subelems(mavl_t cfg, const char * parent_key,
|
||||
|
||||
/* search sub-element */
|
||||
for (i = 0; elems[i].maxlen; i++) {
|
||||
if (elems[i].type == subtype && elems[i].vendor_id==vendor_id)
|
||||
if (elems[i].type == subtype /* && elems[i].vendor_id==vendor_id*/)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!elems[i].maxlen) {
|
||||
cw_dbg_version_subelem(DBG_ELEM_ERR, "Can't handle sub-elem, vendor or type unknonw",
|
||||
cw_dbg_version_subelem(DBG_ELEM_ERR, "Can't handle sub-elem, vendor or type unknown",
|
||||
subtype, vendor_id, data+sub+8, sublen);
|
||||
errors++;
|
||||
} else {
|
||||
|
@ -4,13 +4,14 @@
|
||||
#include "capwap_items.h"
|
||||
#include "dbg.h"
|
||||
#include "ktv.h"
|
||||
#include "keys.h"
|
||||
|
||||
|
||||
static struct cw_DescriptorSubelemDef allowed_default[] = {
|
||||
{0,CW_SUBELEM_WTP_HARDWARE_VERSION, "hardware_version", 1024,1},
|
||||
{0,CW_SUBELEM_WTP_SOFTWARE_VERSION, "software_version", 1024,1},
|
||||
{0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, "bootloader_version", 1024,1},
|
||||
{0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, "other_software_version", 1024,0},
|
||||
{0,CW_SUBELEM_WTP_HARDWARE_VERSION, CW_SKEY_HARDWARE, 1024,1},
|
||||
{0,CW_SUBELEM_WTP_SOFTWARE_VERSION, CW_SKEY_SOFTWARE, 1024,1},
|
||||
{0,CW_SUBELEM_WTP_BOOTLOADER_VERSION, CW_SKEY_BOOTLOADER, 1024,1},
|
||||
{0,CW_SUBELEM_WTP_OTHERSOFTWARE_VERSION, CW_SKEY_OTHER_SOFTWARE, 1024,0},
|
||||
{0,0, NULL, 0,0}
|
||||
};
|
||||
|
||||
@ -19,51 +20,44 @@ int cw_read_wtp_descriptor(mavl_t cfg, struct conn *conn,
|
||||
struct cw_ElemHandler *eh, uint8_t * data, int len,
|
||||
struct cw_DescriptorSubelemDef *allowed)
|
||||
{
|
||||
printf( "toto here cw_read_wtp_descriptor\n");
|
||||
exit(0);
|
||||
|
||||
/*
|
||||
|
||||
|
||||
int ncrypt, pos,i;
|
||||
mavldata_t md;
|
||||
char key[64];
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, "max_radios");
|
||||
md.kv.key=strdup(key);
|
||||
mavl_replace (cfg, cw_type_byte.get(&md,data,1));
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, "radios_in_use");
|
||||
md.kv.key=strdup(key);
|
||||
mavl_replace (cfg, cw_type_byte.get(&md,data+1,1));
|
||||
*/
|
||||
|
||||
|
||||
/* Get number of encryption elements */
|
||||
|
||||
/*
|
||||
ncrypt = cw_get_byte(data + 2);
|
||||
if (ncrypt == 0) {
|
||||
if (conn->strict_capwap) {
|
||||
cw_dbg(DBG_ELEM_ERR,
|
||||
"Bad WTP Descriptor, number of encryption elements is 0.");
|
||||
return 0;
|
||||
return CAPWAP_RESULT_UNRECOGNIZED_MESSAGE_ELEMENT;
|
||||
}
|
||||
cw_dbg(DBG_RFC,
|
||||
"Non standard conform WTP Descriptor, number of encryptoin elements is 0.");
|
||||
}
|
||||
|
||||
pos = 3;
|
||||
*/
|
||||
//
|
||||
// for (i = 0; i < ncrypt; i++) {
|
||||
///* // It's a dummy for now *
|
||||
// pos += 3;
|
||||
// }
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_MAX_RADIOS);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data,1);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key, CW_SKEY_RADIOS_IN_USE);
|
||||
cw_ktv_add(cfg,key,CW_TYPE_BYTE,data+1,1);
|
||||
|
||||
|
||||
|
||||
pos = 3;
|
||||
|
||||
|
||||
for (i = 0; i < ncrypt; i++) {
|
||||
/* It's a dummy for now */
|
||||
pos += 3;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (!allowed) {
|
||||
allowed=allowed_default;
|
||||
}
|
||||
printf("call read subelems\n");
|
||||
|
||||
return cw_read_descriptor_subelems(cfg,eh->key , data + pos, len - pos, allowed);
|
||||
*/
|
||||
}
|
||||
|
@ -2,15 +2,16 @@
|
||||
#include "keys.h"
|
||||
#include "log.h"
|
||||
#include "cw.h"
|
||||
#include "dbg.h"
|
||||
|
||||
int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore,
|
||||
int subelem_id, const char * parent_key)
|
||||
int subelem_id, const char * parent_key )
|
||||
{
|
||||
char key[256];
|
||||
cw_KTV_t * vendor, *version ;
|
||||
uint8_t *d;
|
||||
|
||||
|
||||
|
||||
|
||||
/* d += cw_put_dword(d, bstrv_get_vendor_id(v));
|
||||
d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
|
||||
d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
|
||||
@ -19,7 +20,7 @@ int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore,
|
||||
vendor = cw_ktv_get (ktvstore, key, CW_TYPE_DWORD);
|
||||
|
||||
if (vendor == NULL) {
|
||||
cw_log (LOG_ERR, "Can't put subelem %s, not value found.", key);
|
||||
cw_log (LOG_ERR, "Can't put subelem %s, no value found.", key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -28,7 +29,7 @@ int cw_write_descriptor_subelem (uint8_t *dst, mavl_t ktvstore,
|
||||
version = cw_ktv_get (ktvstore, key, CW_TYPE_BSTR16);
|
||||
|
||||
if (version == NULL) {
|
||||
cw_log (LOG_ERR, "Can't put subelem %s, not value found.", key);
|
||||
cw_log (LOG_ERR, "Can't put subelem %s, no value found.", key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "conn.h"
|
||||
#include "cwmsg.h"
|
||||
|
||||
#include <stdio.h> //Tube
|
||||
#include <stdio.h>
|
||||
|
||||
void cwmsg_addelem_mtu_discovery_padding(struct cwmsg * msg, struct conn* conn)
|
||||
{
|
||||
|
@ -1,13 +1,12 @@
|
||||
#ifndef __KEYS_H
|
||||
#define __KEYS_H
|
||||
|
||||
|
||||
#define CW_KEY_WTP_DESCRIPTOR "wtp-descriptor"
|
||||
|
||||
#define CW_SKEY_HARDWARE "hardware"
|
||||
#define CW_SKEY_SOFTWARE "software"
|
||||
#define CW_SKEY_BOOTLOADER "bootloader"
|
||||
#define CW_SKEY_OTHER_SOFTWARE "other_software"
|
||||
#define CW_SKEY_OTHER_SOFTWARE "other-software"
|
||||
|
||||
#define CW_SKEY_VENDOR "vendor"
|
||||
#define CW_SKEY_VERSION "version"
|
||||
@ -19,9 +18,21 @@
|
||||
#define CW_KEY_WTP_NAME "wtp-name"
|
||||
#define CW_KEY_DISCOVERY_TYPE "discovery-type"
|
||||
#define CW_KEY_WTP_MAC_TYPE "wtp-mac-type"
|
||||
#define CW_KEY_WTP_BOARD_DATA "wtp-board-data"
|
||||
#define CW_KEY_WTP_FRAME_TUNNEL_MODE "wtp-frame-tunnel-mode"
|
||||
|
||||
#define CW_KEY_WTP_BOARD_DATA "wtp-board-data"
|
||||
#define CW_SKEY_MODELNO "model-no"
|
||||
#define CW_SKEY_SERIALNO "serial-no"
|
||||
|
||||
|
||||
#define CW_KEY_AC_DESCRIPTOR "ac-descriptor"
|
||||
#define CW_SKEY_STATION_LIMIT "station-limit"
|
||||
#define CW_SKEY_STATIONS "stations"
|
||||
#define CW_SKEY_ACTIVE_WTPS "active-wtps"
|
||||
#define CW_SKEY_MAX_WTPS "active-wtps"
|
||||
#define CW_SKEY_SECURITY "security"
|
||||
#define CW_SKEY_RMAC_FIELD "rmac-field"
|
||||
#define CW_SKEY_DTLS_POLICY "dtls-policy"
|
||||
|
||||
#endif
|
||||
|
||||
|
13
src/cw/ktv.h
13
src/cw/ktv.h
@ -16,6 +16,7 @@ struct cw_KTV {
|
||||
uint16_t word;
|
||||
uint8_t byte;
|
||||
void *ptr;
|
||||
int boolean;
|
||||
} val;
|
||||
};
|
||||
typedef struct cw_KTV cw_KTV_t;
|
||||
@ -65,6 +66,9 @@ void cw_kvstore_mavl_delete(const void *data);
|
||||
const char *cw_ktv_add(mavl_t kvstore, const char *key, const struct cw_Type *type,
|
||||
const uint8_t * data, int len);
|
||||
|
||||
const char * cw_ktv_add_from_str(mavl_t kvtstore, const char *key, const struct cw_Type *type,
|
||||
const char * str);
|
||||
|
||||
int cw_ktv_mavlcmp(const void *v1, const void *v2);
|
||||
int cw_ktv_mavlcmp_type_by_name(const void *v1,const void *v2);
|
||||
|
||||
@ -79,5 +83,14 @@ void cw_ktv_mavldel(void *data);
|
||||
int cw_ktv_read_line (FILE *f, char * key, char * type, char *val);
|
||||
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types);
|
||||
cw_KTV_t * cw_ktv_get(mavl_t ktv, const char *key, const cw_Type_t * type);
|
||||
uint8_t cw_ktv_get_byte(mavl_t ktv,const char *key, uint8_t def);
|
||||
uint16_t cw_ktv_get_word(mavl_t ktv,const char *key, uint16_t def);
|
||||
|
||||
void cw_ktv_dump(mavl_t ktv, uint32_t dbglevel,
|
||||
const char *header, const char *prefix, const char *footer );
|
||||
|
||||
extern const cw_Type_t * cw_ktv_std_types[];
|
||||
#define CW_KTV_STD_TYPES cw_ktv_std_types
|
||||
|
||||
|
||||
#endif /* __KVT_H */
|
||||
|
@ -44,4 +44,61 @@ int lw_put_sockaddr(uint8_t * dst, struct sockaddr_storage *addr)
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}/*
|
||||
This file is part of libcapwap.
|
||||
|
||||
libcapwap 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/>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
This file is part of libcapwap.
|
||||
|
||||
libcapwap 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/>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
This file is part of libcapwap.
|
||||
|
||||
libcapwap 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/>.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
@ -27,7 +27,7 @@ void lwmsg_init(struct lwmsg * lwmsg, uint8_t * buffer, uint8_t * macaddress,int
|
||||
{
|
||||
lwmsg->buffer=buffer;
|
||||
memcpy (lwmsg->buffer,macaddress,6);
|
||||
lwmsg->trnsprthdr=buffer+0; //+6;
|
||||
lwmsg->trnsprthdr=buffer+0; /*+6;*/
|
||||
LWTH_SET_VERSION(lwmsg->trnsprthdr,LW_VERSION);
|
||||
LWTH_SET_C_FLAG(lwmsg->trnsprthdr,1);
|
||||
lwmsg->ctrlhdr=buffer+14;
|
||||
|
@ -38,7 +38,7 @@ static void mavl_del_all0(struct mavl *t ,struct mavlnode * n)
|
||||
*/
|
||||
void mavl_del_all(struct mavl *t)
|
||||
{
|
||||
mavl_del_all0(t,t->root);
|
||||
mavl_del_all0(t,t->root);
|
||||
t->root=NULL;
|
||||
}
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
#include "mavl.h"
|
||||
#include "mdata.h"
|
||||
|
||||
|
||||
mdata_create(){
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
#ifndef __MDATA_H
|
||||
#define __MDATA_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
union mdata_ElemData {
|
||||
void *raw;
|
||||
uint8_t byte;
|
||||
uint16_t word;
|
||||
uint32_t dword;
|
||||
uint64_t qword;
|
||||
};
|
||||
|
||||
struct mdata_Elem{
|
||||
const char * key;
|
||||
const struct mdata_Type * type;
|
||||
|
||||
union mdata_ElemData data;
|
||||
|
||||
};
|
||||
|
||||
struct mdata_Type{
|
||||
/** A human readable name for this type */
|
||||
const char *name;
|
||||
|
||||
/** A pointer to a function to delete elements of this type */
|
||||
void (*del)(void*);
|
||||
|
||||
/** A method to put this object to a buffer */
|
||||
int (*put)(struct mdata_Elem *i,uint8_t*dst);
|
||||
|
||||
/** The get emthod */
|
||||
struct mdata_Elem * (*get)(const uint8_t*src, int len);
|
||||
|
||||
/** A pointer to a function to convert elements of this type to a string.
|
||||
This function is mainly used to store elements to an SQL database
|
||||
or to json strings */
|
||||
int (*to_str)(const struct mdata_Elem * e,char *dst);
|
||||
|
||||
/** Cereate an item of this type from a string, which was previously
|
||||
created by the #del function. */
|
||||
struct mdata_Elem * (*from_str)(const char *src);
|
||||
|
||||
/*
|
||||
int (*def)(void *, void *);
|
||||
*/
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
struct mdata_Elem *mdata_elem_new( const struct mdata_Type * type );
|
||||
|
||||
|
||||
#endif /* __MDATA_H */
|
||||
|
@ -1,15 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include "mdata.h"
|
||||
|
||||
struct mdata_Elem *mdata_elem_new( const struct mdata_Type * type )
|
||||
{
|
||||
struct mdata_Elem *i= malloc(sizeof(struct mdata_Elem));
|
||||
if (!i)
|
||||
return NULL;
|
||||
|
||||
i->type = type;
|
||||
return i;
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mlist.h"
|
||||
|
||||
|
||||
|
||||
struct mlistelem * mlist_prepend(mlist_t l, void *data){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
struct mlistelem *mlist_find(mlist_t l, struct mlistelem *start, void *data)
|
||||
{
|
||||
/*
|
||||
struct mlistelem *e;
|
||||
if (start)
|
||||
e = start;
|
||||
else
|
||||
e = l->first;
|
||||
|
||||
while (e) {
|
||||
if (l->cmp(e->data, data) == 0)
|
||||
return e;
|
||||
e = e->next;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
struct mlistelem * xmlist_replace(mlist_t l, struct mlistelem *start, void *data)
|
||||
{
|
||||
/*
|
||||
struct mlistelem *e;
|
||||
if (start)
|
||||
e = start;
|
||||
else
|
||||
e = l->first;
|
||||
|
||||
struct mlistelem * f = mlist_find(l,e,data);
|
||||
if (!f)
|
||||
return NULL;
|
||||
|
||||
f->data = data;
|
||||
return f;
|
||||
*/
|
||||
}
|
@ -10,6 +10,7 @@ mlist_t mlist_create(int (*cmp) (const void *v1, const void *v2),
|
||||
/*memset(l, 0, sizeof(struct mlist));*/
|
||||
|
||||
l->cmp = cmp;
|
||||
l->del = del;
|
||||
l->data_size=data_size;
|
||||
l->first=NULL;
|
||||
l->last=NULL;
|
||||
|
@ -193,7 +193,7 @@ void cw_mod_set_path(const char * path){
|
||||
* @param mod_name Name of the module
|
||||
* @return a pointer to the module interface
|
||||
*/
|
||||
struct cw_Mod * cw_mod_load(const char * mod_name){
|
||||
struct cw_Mod * cw_mod_load(const char * mod_name, mavl_t global_cfg, int role){
|
||||
struct cw_Mod search;
|
||||
struct cw_Mod * mod;
|
||||
char mod_filename[CW_MOD_MAX_MOD_NAME_LEN+5];
|
||||
@ -266,7 +266,7 @@ struct cw_Mod * cw_mod_load(const char * mod_name){
|
||||
goto errX;
|
||||
}
|
||||
cw_dbg(DBG_MOD, "MOD: %s sucessfull loaded, calling init now.",filename);
|
||||
mod->init();
|
||||
mod->init(mod,global_cfg,role);
|
||||
errX:
|
||||
free(filename);
|
||||
return mod;
|
||||
|
24
src/cw/mod.h
24
src/cw/mod.h
@ -29,7 +29,7 @@
|
||||
|
||||
#include "sock.h"
|
||||
#include "conn.h"
|
||||
#include "action.h"
|
||||
|
||||
|
||||
struct cw_actiondef;
|
||||
|
||||
@ -39,16 +39,22 @@ enum {
|
||||
CW_MOD_MODE_BINDINGS
|
||||
};
|
||||
|
||||
enum {
|
||||
CW_ROLE_AC=1,
|
||||
CW_ROLE_WTP=2
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct cw_Mod {
|
||||
/** Name of the module */
|
||||
const char *name;
|
||||
|
||||
/** Initializion method */
|
||||
int (*init) ();
|
||||
int (*init) (struct cw_Mod *mod, mavl_t global_cfg, int role);
|
||||
|
||||
/** init_config */
|
||||
int (*init_config) (void * /*mbag_t config*/);
|
||||
/* int (*init_config) (void *);*/
|
||||
|
||||
/** Detect capwap
|
||||
* This function is called after receiving and disassembling a complete
|
||||
@ -57,14 +63,9 @@ struct cw_Mod {
|
||||
* @return 0 if notdetected
|
||||
**/
|
||||
int (*detect) (struct conn * conn, const uint8_t * rawmsg, int rawlen,
|
||||
int elems_len, struct sockaddr * from, int mode);
|
||||
int elems_len, struct sockaddr * from, int mode);
|
||||
|
||||
/** used for private data */
|
||||
void *data;
|
||||
|
||||
/** Register actions */
|
||||
int (*register_actions) (struct cw_actiondef * def,int mode);
|
||||
|
||||
struct cw_MsgSet * (*register_messages)(struct cw_MsgSet * set, int mode);
|
||||
|
||||
/**
|
||||
@ -73,6 +74,9 @@ struct cw_Mod {
|
||||
* linked, dll_handle is NULL.
|
||||
*/
|
||||
void * dll_handle;
|
||||
|
||||
/** used for private data */
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
||||
@ -93,7 +97,7 @@ extern int mod_caching;
|
||||
#define mod_set_caching(var) (mod_caching=var)
|
||||
#define mod_get_caching() (mod_caching)
|
||||
|
||||
struct cw_Mod * cw_mod_load(const char * mod_name);
|
||||
struct cw_Mod * cw_mod_load(const char * mod_name, mavl_t global_cfg, int role);
|
||||
struct cw_Mod * cw_mod_add_to_list(struct cw_Mod * mod );
|
||||
struct cw_Mod * cw_mod_detect(struct conn *conn,
|
||||
uint8_t * rawmsg, int len,
|
||||
|
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup CAPWAPVendors
|
||||
* @defgroup CAPWAPVendors List of known CAPWAP vendors
|
||||
* @{ */
|
||||
|
||||
#ifndef __CW_VENDORS_H
|
||||
|
Reference in New Issue
Block a user