Moved Callbacks to mods
This commit is contained in:
parent
2064f7dba1
commit
5ed35979cd
@ -225,6 +225,10 @@ int main (int argc, char *argv[])
|
|||||||
goto errX;
|
goto errX;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//const char *ttt = cw_cfg_get(global_cfg,"cisco/ssl-cipher",NULL);
|
||||||
|
//printf("CFG: %s\n",ttt);
|
||||||
|
//stop();
|
||||||
|
|
||||||
cw_log_name = "AC-Tube";
|
cw_log_name = "AC-Tube";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -90,3 +90,38 @@ capwap/timers/max-discovery-interval: 10
|
|||||||
capwap/decryption-error-report-period: 120
|
capwap/decryption-error-report-period: 120
|
||||||
capwap/idle-timeout: 300
|
capwap/idle-timeout: 300
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/beacon-period: 100
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/cfg-period: 4
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/beacon-period: 100
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/cfg-period: 4
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/cfg-type: 1
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/country-str1: "DE "
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/country-str2: "DE "
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/occupancy-limit: 100
|
||||||
|
radio-cfg-a/capwap80211/wtp-radio-config/reg: 167772416
|
||||||
|
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/beacon-period: 100
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/cfg-period: 4
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/beacon-period: 100
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/bssid: .x003a9902fac0
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/cfg-period: 4
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/cfg-type: 1
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/cfp-maximum-duration: 60
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/country-str1: "DE "
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/country-str2: "DE "
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/occupancy-limit: 100
|
||||||
|
radio-cfg-b/capwap80211/wtp-radio-config/reg: 167772416
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ static void copy(struct cw_ElemHandlerParams * params)
|
|||||||
cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
|
cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
static int discovery_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data * d)
|
||||||
{
|
{
|
||||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||||
char filename[200];
|
char filename[200];
|
||||||
@ -431,10 +431,16 @@ static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_pt
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
/*
|
||||||
|
static int join_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||||
{
|
{
|
||||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||||
char filename[200];
|
char filename[200];
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = 0;
|
||||||
|
if (d->parent)
|
||||||
|
rc =d->parent->fun(params,d->parent);
|
||||||
|
|
||||||
cw_dbg(DBG_X,"JOIN Callback");
|
cw_dbg(DBG_X,"JOIN Callback");
|
||||||
copy(params);
|
copy(params);
|
||||||
@ -442,9 +448,11 @@ static int join_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, in
|
|||||||
sprintf(filename,"wtp-join-%s.ckv",wtpname);
|
sprintf(filename,"wtp-join-%s.ckv",wtpname);
|
||||||
cw_cfg_save(filename,params->cfg,NULL);
|
cw_cfg_save(filename,params->cfg,NULL);
|
||||||
cw_cfg_clear(params->cfg);
|
cw_cfg_clear(params->cfg);
|
||||||
return 0;
|
return rc;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
static int fill_update_cfg(struct cw_Conn * conn)
|
static int fill_update_cfg(struct cw_Conn * conn)
|
||||||
{
|
{
|
||||||
struct cw_Cfg_iter cfi;
|
struct cw_Cfg_iter cfi;
|
||||||
@ -469,18 +477,21 @@ static int fill_update_cfg(struct cw_Conn * conn)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
static int update_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||||
static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
|
||||||
{
|
{
|
||||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||||
char filename[200];
|
char filename[200];
|
||||||
|
|
||||||
|
int rc = 0;
|
||||||
|
if (d->parent)
|
||||||
|
rc =d->parent->fun(params,d->parent);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_X,"UPDATE Callback");
|
cw_dbg(DBG_X,"UPDATE Callback");
|
||||||
copy(params);
|
//fill_update_cfg(params->conn);
|
||||||
fill_update_cfg(params->conn);
|
|
||||||
|
|
||||||
const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
|
const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
|
||||||
sprintf(filename,"wtp-status-%s.ckv",wtpname);
|
sprintf(filename,"wtp-status-%s.ckv",wtpname);
|
||||||
@ -489,7 +500,7 @@ static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
static int event_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||||
{
|
{
|
||||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||||
struct wtpman * wtpman = (struct wtpman *)conn->data;
|
struct wtpman * wtpman = (struct wtpman *)conn->data;
|
||||||
@ -507,7 +518,7 @@ static int event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, i
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int change_state_event_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
static int change_state_event_cb(struct cw_ElemHandlerParams * params,struct cw_MsgCb_data * d)
|
||||||
{
|
{
|
||||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||||
struct wtpman * wtpman = (struct wtpman *)conn->data;
|
struct wtpman * wtpman = (struct wtpman *)conn->data;
|
||||||
@ -579,6 +590,8 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
|||||||
wtpman_destroy(wtpman);
|
wtpman_destroy(wtpman);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wtpman->conn->global_cfg = global_cfg;
|
wtpman->conn->global_cfg = global_cfg;
|
||||||
wtpman->conn->local_cfg = cw_cfg_create();
|
wtpman->conn->local_cfg = cw_cfg_create();
|
||||||
wtpman->wtp_cfg = cw_cfg_create();
|
wtpman->wtp_cfg = cw_cfg_create();
|
||||||
@ -598,27 +611,6 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
|||||||
sock_copyaddr(&wtpman->conn->data_addr,
|
sock_copyaddr(&wtpman->conn->data_addr,
|
||||||
(struct sockaddr *) &wtpman->conn->addr);
|
(struct sockaddr *) &wtpman->conn->addr);
|
||||||
|
|
||||||
cw_conn_set_msg_cb(wtpman->conn,
|
|
||||||
CAPWAP_MSG_DISCOVERY_REQUEST,
|
|
||||||
discovery_cb);
|
|
||||||
|
|
||||||
cw_conn_set_msg_cb(wtpman->conn,
|
|
||||||
CAPWAP_MSG_JOIN_REQUEST,
|
|
||||||
join_cb);
|
|
||||||
|
|
||||||
cw_conn_set_msg_cb(wtpman->conn,
|
|
||||||
CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
|
|
||||||
update_cb);
|
|
||||||
|
|
||||||
cw_conn_set_msg_cb(wtpman->conn,
|
|
||||||
CAPWAP_MSG_WTP_EVENT_REQUEST,
|
|
||||||
event_cb);
|
|
||||||
|
|
||||||
cw_conn_set_msg_cb(wtpman->conn,
|
|
||||||
CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST,
|
|
||||||
change_state_event_cb);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// wtpman->conn->mods = conf_mods;
|
// wtpman->conn->mods = conf_mods;
|
||||||
@ -658,9 +650,33 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
|||||||
// wtpman->conn->setup_complete(wtpman->conn);
|
// wtpman->conn->setup_complete(wtpman->conn);
|
||||||
|
|
||||||
|
|
||||||
|
cw_conn_register_msg_cb(wtpman->conn,
|
||||||
|
CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||||
|
discovery_cb);
|
||||||
|
|
||||||
|
/* cw_conn_set_msg_cb(wtpman->conn,
|
||||||
|
CAPWAP_MSG_JOIN_REQUEST,
|
||||||
|
join_cb);*/
|
||||||
|
|
||||||
|
/* cw_conn_register_msg_cb(wtpman->conn,
|
||||||
|
CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||||
|
update_cb);*/
|
||||||
|
|
||||||
|
cw_conn_register_msg_cb(wtpman->conn,
|
||||||
|
CAPWAP_MSG_WTP_EVENT_REQUEST,
|
||||||
|
event_cb);
|
||||||
|
|
||||||
|
/* cw_conn_register_msg_cb(wtpman->conn,
|
||||||
|
CAPWAP_MSG_CHANGE_STATE_EVENT_REQUEST,
|
||||||
|
change_state_event_cb);*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
|
cw_dbg(DBG_X,"WTPMAN_CREATED: %p",wtpman);
|
||||||
|
|
||||||
return wtpman;
|
return wtpman;
|
||||||
|
@ -465,9 +465,9 @@ enum cw_reboot_failure_types {
|
|||||||
/**
|
/**
|
||||||
* The Missing AC List Result Code is sent by the
|
* The Missing AC List Result Code is sent by the
|
||||||
* WTP to the AC when the AC List is missing */
|
* WTP to the AC when the AC List is missing */
|
||||||
#define CW_RESULT_MISSING_AC_LIST 1
|
#define CW_RESULT_MISSING_AC_LIST 1
|
||||||
#define CAPWAP_RESULT_SUCCESS_NAT 2
|
#define CAPWAP_RESULT_SUCCESS_NAT 2
|
||||||
#define CW_RESULT_JOIN_FAILURE 3
|
#define CAPWAP_RESULT_JOIN_FAILURE 3
|
||||||
#define CW_RESULT_JOIN_RESOURCE_DEPLETION 4
|
#define CW_RESULT_JOIN_RESOURCE_DEPLETION 4
|
||||||
#define CW_RESULT_JOIN_UNKNOWN_SOURCE 5
|
#define CW_RESULT_JOIN_UNKNOWN_SOURCE 5
|
||||||
#define CW_RESULT_JOIN_INCORRECT_DATA 6
|
#define CW_RESULT_JOIN_INCORRECT_DATA 6
|
||||||
@ -491,7 +491,7 @@ enum cw_reboot_failure_types {
|
|||||||
13 Configuration Failure (Unable to Apply Requested Configuration
|
13 Configuration Failure (Unable to Apply Requested Configuration
|
||||||
- Service Not Provided)
|
- Service Not Provided)
|
||||||
*/
|
*/
|
||||||
#define CAPWAP_RESULT_CONFIGURATION_FAILURE_SERVICE_NOT PROVIDED 13
|
#define CAPWAP_RESULT_CONFIGURATION_FAILURE_SERVICE_NOT_PROVIDED 13
|
||||||
/**
|
/**
|
||||||
* Image Data Error (Invalid Checksum)
|
* Image Data Error (Invalid Checksum)
|
||||||
*/
|
*/
|
||||||
|
17
src/cw/cfg.c
17
src/cw/cfg.c
@ -637,11 +637,15 @@ struct cw_Cfg_entry *cw_cfg_iter_next(struct cw_Cfg_iter *cfi, const char *nnkey
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
d = strchr(e->key, '.');
|
|
||||||
|
if (e->key[bl]!='.' && e->key[bl]!='/')
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
/* d = strchr(e->key, '.');
|
||||||
if (d == NULL)
|
if (d == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (d - e->key != bl)
|
if (d - e->key != bl)
|
||||||
return NULL;
|
return NULL;*/
|
||||||
|
|
||||||
if (strncmp(cfi->base, e->key, bl) != 0)
|
if (strncmp(cfi->base, e->key, bl) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -684,6 +688,14 @@ uint8_t cw_cfg_get_byte_l(cw_Cfg_t ** cfgs, char *key, uint8_t def)
|
|||||||
return v.val.byte;
|
return v.val.byte;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def)
|
||||||
|
{
|
||||||
|
const char *s = cw_cfg_get(cfg,key,NULL);
|
||||||
|
if (s==NULL)
|
||||||
|
return def;
|
||||||
|
return atoi(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, const char *key, uint16_t def)
|
uint16_t cw_cfg_get_word(cw_Cfg_t * cfg, const char *key, uint16_t def)
|
||||||
@ -708,7 +720,6 @@ uint16_t cw_cfg_get_word_l(cw_Cfg_t ** cfg, const char *key, uint16_t def)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
|
int cw_cfg_get_word(cw_Cfg_t * cfg, char *key, const char * def)
|
||||||
{
|
{
|
||||||
|
@ -89,6 +89,7 @@ void cw_cfg_del(cw_Cfg_t * cfg, const char *key);
|
|||||||
int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n);
|
int cw_cfg_get_first_index(cw_Cfg_t * cfg, const char *key, int n);
|
||||||
int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);
|
int cw_cfg_get_first_index_l(cw_Cfg_t ** cfgs, const char *key, int n);
|
||||||
|
|
||||||
|
uint16_t cw_cfg_get_int(cw_Cfg_t * cfg, const char *key, int def);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +24,12 @@
|
|||||||
|
|
||||||
#include "dtls.h"
|
#include "dtls.h"
|
||||||
|
|
||||||
|
#define MAX_MSG_CBS 5
|
||||||
|
|
||||||
struct msg_callback{
|
struct msg_callback{
|
||||||
int type; /**< message type */
|
int type; /**< message type */
|
||||||
cw_MsgCallbackFun fun;
|
struct cw_MsgCb_data data[MAX_MSG_CBS];
|
||||||
|
int count;
|
||||||
};
|
};
|
||||||
|
|
||||||
int msg_callback_cmp(const void *v1,const void *v2)
|
int msg_callback_cmp(const void *v1,const void *v2)
|
||||||
@ -62,19 +63,55 @@ void cw_conn_init(struct cw_Conn * conn)
|
|||||||
conn->remote_cfg = cw_cfg_create();
|
conn->remote_cfg = cw_cfg_create();
|
||||||
conn->local_cfg = cw_cfg_create();
|
conn->local_cfg = cw_cfg_create();
|
||||||
conn->cfg_list[0]=NULL;
|
conn->cfg_list[0]=NULL;
|
||||||
|
|
||||||
|
conn->remote_addr[0]=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
|
|
||||||
|
/**
|
||||||
|
* Register a message callback function.
|
||||||
|
* @param conn the connection the registered cb functions belongs to
|
||||||
|
* @param type The associated msg type. Whenever a message of this type is
|
||||||
|
* received, the callback function will be called
|
||||||
|
* @param fun A pinter to the callback function
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
int cw_conn_register_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun)
|
||||||
{
|
{
|
||||||
struct msg_callback cb;
|
struct msg_callback cb, *result;
|
||||||
int exists;
|
int exists;
|
||||||
|
|
||||||
cb.type = type;
|
cb.type = type;
|
||||||
cb.fun = fun;
|
cb.data[0].fun = fun;
|
||||||
mavl_insert(conn->msg_callbacks,&cb,&exists);
|
cb.data[0].parent = NULL;
|
||||||
|
cb.count = 0;
|
||||||
|
|
||||||
|
|
||||||
|
result = mavl_insert(conn->msg_callbacks,&cb,&exists);
|
||||||
|
|
||||||
|
cw_dbg(DBG_X, "Registering msg callback: %d %p",type,result);
|
||||||
|
|
||||||
|
if (result==NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (exists){
|
||||||
|
if (result->count>=MAX_MSG_CBS){
|
||||||
|
cw_log(LOG_ERROR,"Too many msg callback registrations for msg id %d",type);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
result->count++;
|
||||||
|
result->data[result->count].fun=fun;
|
||||||
|
result->data[result->count].parent=&(result->data[result->count-1]);
|
||||||
|
cw_dbg(DBG_X,"The result exists: %p %p %d %p",result,&cb,result->count,
|
||||||
|
result->data[result->count].parent
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
|
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
|
||||||
{
|
{
|
||||||
struct msg_callback cb,*result;
|
struct msg_callback cb,*result;
|
||||||
@ -83,8 +120,22 @@ cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type)
|
|||||||
if (result == NULL)
|
if (result == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
return result->fun;
|
return result->fun;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
|
||||||
|
int cw_conn_run_msg_cbs(struct cw_Conn * conn, int type, struct cw_ElemHandlerParams *params)
|
||||||
|
{
|
||||||
|
struct msg_callback cb,*result;
|
||||||
|
cb.type=type;
|
||||||
|
result = mavl_get(conn->msg_callbacks,&cb);
|
||||||
|
if (result == NULL)
|
||||||
|
return -1;
|
||||||
|
return result->data[result->count].fun(params,&(result->data[result->count]));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a conn object
|
* Create a conn object
|
||||||
* @param sock a socket
|
* @param sock a socket
|
||||||
@ -106,8 +157,10 @@ struct cw_Conn * cw_conn_create(int sock, struct sockaddr * addr, int qsize)
|
|||||||
|
|
||||||
conn->sock=sock;
|
conn->sock=sock;
|
||||||
|
|
||||||
if (addr)
|
if (addr){
|
||||||
sock_copyaddr(&conn->addr,addr);
|
sock_copyaddr(&conn->addr,addr);
|
||||||
|
sock_addr2str_p(addr, conn->remote_addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
conn->fragman = fragman_create();
|
conn->fragman = fragman_create();
|
||||||
@ -516,12 +569,12 @@ static int process_elements(struct cw_Conn *conn, uint8_t * rawmsg, int len,
|
|||||||
message->postprocess(¶ms,elems_ptr, elems_len);
|
message->postprocess(¶ms,elems_ptr, elems_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_MsgCallbackFun cb_fun = cw_conn_get_msg_cb(conn,message->type);
|
result_code = cw_conn_run_msg_cbs(conn,message->type,¶ms);
|
||||||
if (cb_fun != NULL){
|
|
||||||
result_code = cb_fun(¶ms,elems_ptr, elems_len);
|
// cw_MsgCallbackFun cb_fun = cw_conn_get_msg_cb(conn,message->type);
|
||||||
}
|
if (result_code==-1){
|
||||||
else{
|
|
||||||
cw_cfg_clear(conn->update_cfg);
|
cw_cfg_clear(conn->update_cfg);
|
||||||
|
result_code=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// conn->remote_cfg=params.cfg;
|
// conn->remote_cfg=params.cfg;
|
||||||
|
@ -58,6 +58,8 @@ struct cw_action_in;
|
|||||||
struct cw_Conn {
|
struct cw_Conn {
|
||||||
int sock;
|
int sock;
|
||||||
struct sockaddr_storage addr;
|
struct sockaddr_storage addr;
|
||||||
|
char remote_addr[64]; /* Contains a printfable string, of the connections
|
||||||
|
peer address */
|
||||||
|
|
||||||
struct connlist * connlist;
|
struct connlist * connlist;
|
||||||
|
|
||||||
@ -71,19 +73,19 @@ struct cw_Conn {
|
|||||||
int recv_timeout;
|
int recv_timeout;
|
||||||
|
|
||||||
|
|
||||||
cw_Cfg_t * global_cfg; /**< This should set the global cfg of the program
|
cw_Cfg_t * global_cfg; /**< This should set to the global cfg of the program
|
||||||
which is using this conn object.
|
which is using this conn object.
|
||||||
Teh global_cfg has to be treated read-only. */
|
Teh global_cfg has to be treated read-only. */
|
||||||
|
|
||||||
cw_Cfg_t * local_cfg; /**< local_cfg contains overrides for global_cfg
|
cw_Cfg_t * local_cfg; /**< local_cfg contains overrides for global_cfg
|
||||||
wich are related to this conn object. */
|
wich are related to this conniection. */
|
||||||
|
|
||||||
cw_Cfg_t * remote_cfg; /**< contains the configuration we now from the
|
cw_Cfg_t * remote_cfg; /**< contains the configuration we now from the
|
||||||
device this conn object ist connected to.
|
device this conn object ist connected to.
|
||||||
Typically this is what we have got from discovery
|
Typically this is what we have got from discovery
|
||||||
response or join response in WTP mode.
|
response or join response in WTP mode.
|
||||||
And in AC mode this contains date receive from
|
And in AC mode this contains datia received by
|
||||||
configuration status request. */
|
configuration status and join request. */
|
||||||
|
|
||||||
cw_Cfg_t * update_cfg;
|
cw_Cfg_t * update_cfg;
|
||||||
|
|
||||||
@ -311,7 +313,18 @@ int conn_send_msg(struct cw_Conn *conn, uint8_t * rawmsg);
|
|||||||
void conn_clear_upd(struct cw_Conn*conn, int merge);
|
void conn_clear_upd(struct cw_Conn*conn, int merge);
|
||||||
|
|
||||||
|
|
||||||
int cw_conn_set_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun);
|
|
||||||
|
struct cw_MsgCb_data;
|
||||||
|
//typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len,
|
||||||
|
// struct cw_MsgCb_data *d);
|
||||||
|
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d);
|
||||||
|
|
||||||
|
struct cw_MsgCb_data{
|
||||||
|
cw_MsgCallbackFun fun;
|
||||||
|
struct cw_MsgCb_data * parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
int cw_conn_register_msg_cb(struct cw_Conn *conn, int type, cw_MsgCallbackFun fun);
|
||||||
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type);
|
cw_MsgCallbackFun cw_conn_get_msg_cb(struct cw_Conn *conn, int type);
|
||||||
|
|
||||||
int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
|
int cw_decode_element(struct cw_ElemHandlerParams *params, int proto,
|
||||||
|
@ -3,9 +3,10 @@
|
|||||||
|
|
||||||
#include "dbg.h"
|
#include "dbg.h"
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
#include "cfg.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Detect NAT after a join/discovery request
|
* @brief Detect NAT after a Join Request
|
||||||
* @param conn Connection object
|
* @param conn Connection object
|
||||||
* @retval 1 NAT detected
|
* @retval 1 NAT detected
|
||||||
* @retval 0 no NAT was detected
|
* @retval 0 no NAT was detected
|
||||||
@ -15,7 +16,8 @@ int cw_detect_nat(struct cw_ElemHandlerParams *params)
|
|||||||
const char * remote_str;
|
const char * remote_str;
|
||||||
char local_str[128];
|
char local_str[128];
|
||||||
|
|
||||||
remote_str = cw_cfg_get(params->cfg,"capwap-local-ip-address",NULL);
|
remote_str = cw_cfg_get(params->cfg,"capwap/local-ip-address",NULL);
|
||||||
|
|
||||||
if (remote_str == NULL){
|
if (remote_str == NULL){
|
||||||
cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
|
cw_dbg(DBG_WARN,"Can't detect NAT. No local IP from peer received.");
|
||||||
return 0;
|
return 0;
|
||||||
@ -29,9 +31,12 @@ int cw_detect_nat(struct cw_ElemHandlerParams *params)
|
|||||||
|
|
||||||
/* if connected and sent address is the same, there is
|
/* if connected and sent address is the same, there is
|
||||||
* no NAT */
|
* no NAT */
|
||||||
if (strcmp(remote_str,local_str)==0)
|
if (strcmp(remote_str,local_str)==0){
|
||||||
|
cw_dbg(DBG_INFO,"Connection from %s: no NAT detected.",local_str);
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
/* otherwise ther must be something between AC and WTP */
|
/* otherwise ther must be something between AC and WTP */
|
||||||
|
cw_dbg(DBG_INFO,"Connection from %s: NAT detected.",local_str);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ static struct cw_StrListElem prefix[] = {
|
|||||||
{DBG_RFC, " RFC - "},
|
{DBG_RFC, " RFC - "},
|
||||||
{DBG_DTLS, "DTLS - "},
|
{DBG_DTLS, "DTLS - "},
|
||||||
{DBG_DTLS_DETAIL, "DTLS - "},
|
{DBG_DTLS_DETAIL, "DTLS - "},
|
||||||
{DBG_WARN, " Warning - "},
|
{DBG_WARN, "Warning - "},
|
||||||
{DBG_MOD, "Mod - "},
|
{DBG_MOD, "Mod - "},
|
||||||
{DBG_MOD_DETAIL, "Mod - "},
|
{DBG_MOD_DETAIL, "Mod - "},
|
||||||
{DBG_STATE, "STATEMACHINE - "},
|
{DBG_STATE, "STATEMACHINE - "},
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "cw.h"
|
#include "cw.h"
|
||||||
|
|
||||||
|
#include "capwap80211.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format bytes as hex string.
|
* Format bytes as hex string.
|
||||||
* @param dst Destination buffer
|
* @param dst Destination buffer
|
||||||
@ -87,4 +89,18 @@ int format_hdr_flags(char *dst, uint8_t * th)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char * cw_format_radio_information(char * dst, int ri)
|
||||||
|
{
|
||||||
|
char *d = dst;
|
||||||
|
if (ri & CW_80211_RADIO_TYPE_A)
|
||||||
|
*d++='a';
|
||||||
|
if (ri & CW_80211_RADIO_TYPE_B)
|
||||||
|
*d++='b';
|
||||||
|
if (ri & CW_80211_RADIO_TYPE_G)
|
||||||
|
*d++='g';
|
||||||
|
if (ri & CW_80211_RADIO_TYPE_N)
|
||||||
|
*d++='n';
|
||||||
|
|
||||||
|
*d=0;
|
||||||
|
return dst;
|
||||||
|
}
|
||||||
|
@ -112,6 +112,9 @@ int cw_format_pkt_hdr(char *dst, int incomming, uint8_t * packet, int len,
|
|||||||
struct sockaddr *from);
|
struct sockaddr *from);
|
||||||
int cw_format_version(char *s, const uint8_t * version, int len);
|
int cw_format_version(char *s, const uint8_t * version, int len);
|
||||||
|
|
||||||
|
char * cw_format_radio_information(char * dst, int ri);
|
||||||
|
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,7 +56,7 @@ struct cw_Mod {
|
|||||||
int elems_len, struct sockaddr * from, int mode);
|
int elems_len, struct sockaddr * from, int mode);
|
||||||
|
|
||||||
|
|
||||||
struct cw_MsgSet * (*register_messages)(struct cw_MsgSet * set, int mode);
|
struct cw_MsgSet * (*register_messages)(struct cw_MsgSet * set, int mode );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle returned by dlopen, if this module was loaded
|
* Handle returned by dlopen, if this module was loaded
|
||||||
|
@ -405,7 +405,9 @@ struct cw_MsgData *cw_msgset_get_msgdata(struct cw_MsgSet *set, int type)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
//typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||||
|
//
|
||||||
|
/*
|
||||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
||||||
cw_MsgCallbackFun fun)
|
cw_MsgCallbackFun fun)
|
||||||
|
|
||||||
@ -420,5 +422,5 @@ cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
|||||||
return old_callback;
|
return old_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
@ -146,9 +146,8 @@ struct cw_ElemHandler * cw_msgset_get_elemhandler(struct cw_MsgSet * set,
|
|||||||
#define CW_MSGSET_POSTPROCESS 1
|
#define CW_MSGSET_POSTPROCESS 1
|
||||||
#define CW_MSGSET_PREPROCESS 2
|
#define CW_MSGSET_PREPROCESS 2
|
||||||
|
|
||||||
typedef int (*cw_MsgCallbackFun)(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
//cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
||||||
cw_MsgCallbackFun cw_msgset_set_postprocess(struct cw_MsgSet * set,int msg_id,
|
// cw_MsgCallbackFun fun);
|
||||||
cw_MsgCallbackFun fun);
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -2,7 +2,7 @@ include ../../Defs.mak
|
|||||||
|
|
||||||
|
|
||||||
SOURCES=\
|
SOURCES=\
|
||||||
mod_capwap_ac.c \
|
mod_capwap.c \
|
||||||
capwap_actions.c \
|
capwap_actions.c \
|
||||||
capwap_in_wtp_board_data.c \
|
capwap_in_wtp_board_data.c \
|
||||||
capwap_in_ac_descriptor.c \
|
capwap_in_ac_descriptor.c \
|
||||||
|
@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include "mod_capwap.h"
|
#include "mod_capwap.h"
|
||||||
|
|
||||||
#include "cw/mavltypes.h"
|
|
||||||
|
|
||||||
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len);
|
||||||
|
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
|
|
||||||
#include "cw/mod.h"
|
|
||||||
#include "cw/log.h"
|
|
||||||
#include "cw/dbg.h"
|
|
||||||
#include "cw/val.h"
|
|
||||||
#include "cw/keys.h"
|
|
||||||
#include "cw/dtls.h"
|
|
||||||
#include "cw/cfg.h"
|
|
||||||
|
|
||||||
#include "mod_capwap.h"
|
|
||||||
|
|
||||||
static int init(struct cw_Mod * mod, cw_Cfg_t * global_cfg, int role)
|
|
||||||
{
|
|
||||||
cw_dbg(DBG_INFO,"CAPWAP: Inititalizing mod_capwap.");
|
|
||||||
|
|
||||||
switch (role){
|
|
||||||
case CW_ROLE_AC:{
|
|
||||||
cw_dbg(DBG_MOD, "CAPWAP: Initialiazing mod_capwap in AC mode");
|
|
||||||
cw_cfg_set(global_cfg,
|
|
||||||
"capwap/ac-descriptor/hardware/version",
|
|
||||||
"0.0.0.1");
|
|
||||||
cw_cfg_set(global_cfg,
|
|
||||||
"capwap/ac-descriptor/hardware/vendor","0");
|
|
||||||
cw_cfg_set(global_cfg,
|
|
||||||
"capwap/ac-descriptor/software/version","0.0.0.1");
|
|
||||||
cw_cfg_set(global_cfg,
|
|
||||||
"capwap/ac-descriptor/software/vendor", "0");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
|
||||||
struct sockaddr *from, int mode)
|
|
||||||
{
|
|
||||||
if (mode != CW_MOD_MODE_CAPWAP)
|
|
||||||
return 0;
|
|
||||||
cw_dbg(DBG_MOD,"CAPWAP detected: yes");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int static setup_cfg(struct cw_Conn * conn)
|
|
||||||
{
|
|
||||||
int security;
|
|
||||||
security = cw_setup_dtls(conn,conn->local_cfg,"capwap",CAPWAP_CIPHER);
|
|
||||||
|
|
||||||
|
|
||||||
// stop();
|
|
||||||
cw_cfg_set_int(conn->local_cfg,"ac-descriptor/security",security);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_Mod mod_capwap = {
|
|
||||||
"capwap", /* name */
|
|
||||||
init, /* init */
|
|
||||||
detect, /* detect */
|
|
||||||
capwap_register_msg_set, /* register_messages */
|
|
||||||
NULL, /* dll_handle */
|
|
||||||
NULL, /* data */
|
|
||||||
setup_cfg /* setup_cfg */
|
|
||||||
};
|
|
@ -3,8 +3,7 @@ include ../../Defs.mak
|
|||||||
|
|
||||||
|
|
||||||
SOURCES=\
|
SOURCES=\
|
||||||
mod_cisco_ac.c \
|
mod_cisco.c \
|
||||||
cisco_actions.c \
|
|
||||||
cisco_in_wtp_descriptor.c \
|
cisco_in_wtp_descriptor.c \
|
||||||
cisco_out_wtp_descriptor.c \
|
cisco_out_wtp_descriptor.c \
|
||||||
cisco_in_ac_descriptor.c\
|
cisco_in_ac_descriptor.c\
|
||||||
|
@ -951,12 +951,12 @@ static struct cw_ElemHandler handlers70[] = {
|
|||||||
}
|
}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
"RAD Name -> CAPWAP WTP Name", /* name */
|
"Cisco RAD Name", /* name */
|
||||||
CISCO_ELEM_RAD_NAME, /* Element ID */
|
CISCO_ELEM_RAD_NAME, /* Element ID */
|
||||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||||
1,512, /* min/max length */
|
1,512, /* min/max length */
|
||||||
CW_TYPE_BSTR16, /* type */
|
CW_TYPE_BSTR16, /* type */
|
||||||
"capwap/wtp-name", /* Key */
|
"cisco/rad-name", /* Key */
|
||||||
cw_in_generic, /* get */
|
cw_in_generic, /* get */
|
||||||
cw_out_generic /* put */
|
cw_out_generic /* put */
|
||||||
}
|
}
|
||||||
@ -2323,11 +2323,20 @@ static struct cw_ElemHandler handlers70[] = {
|
|||||||
|
|
||||||
|
|
||||||
static struct cw_ElemDef discovery_request_elements[] ={
|
static struct cw_ElemDef discovery_request_elements[] ={
|
||||||
/* {0,0, CAPWAP_ELEM_WTP_DESCRIPTOR, 1, 0},*/
|
|
||||||
{0,0, CAPWAP_ELEM_WTP_BOARD_DATA, 0, 0},
|
/* This is Cisco's version of WTP Name msg elemnt. */
|
||||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_RAD_NAME, 1, 0},
|
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_RAD_NAME, 1, 0},
|
||||||
{0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 0, 0},
|
|
||||||
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 1, 0},
|
/* Cisco dosn't sends WTP radio information in discovery
|
||||||
|
* requests and no WTP Board Data element, so we make them
|
||||||
|
* non-mandatory here */
|
||||||
|
{0,0, CAPWAP80211_ELEM_WTP_RADIO_INFORMATION, 0, 0},
|
||||||
|
{0,0, CAPWAP_ELEM_WTP_BOARD_DATA, 0, 0},
|
||||||
|
|
||||||
|
/* Instead of WTP Board Data we get Board Data Options from
|
||||||
|
* Ciso's APs */
|
||||||
|
{0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 0, 0},
|
||||||
|
|
||||||
{0,0,0,00}
|
{0,0,0,00}
|
||||||
|
|
||||||
};
|
};
|
||||||
@ -2341,19 +2350,19 @@ static struct cw_ElemDef discovery_response_elements[] ={
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*static uint16_t join_request_states[] = {CAPWAP_STATE_JOIN,0};*/
|
|
||||||
static struct cw_ElemDef join_request_elements[] ={
|
static struct cw_ElemDef join_request_elements[] ={
|
||||||
{0,0, CAPWAP_ELEM_WTP_IPV4_IP_ADDRESS,1,0},
|
{0,0, CAPWAP_ELEM_WTP_IPV4_IP_ADDRESS, 1, 0},
|
||||||
{0,0, CAPWAP_ELEM_WTP_IPV6_IP_ADDRESS,1,0},
|
{0,0, CAPWAP_ELEM_WTP_IPV6_IP_ADDRESS, 1, 0},
|
||||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_GROUP_NAME, 1, 0},
|
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_GROUP_NAME, 1, 0},
|
||||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_ADDR, 1, 0},
|
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_MWAR_ADDR, 1, 0},
|
||||||
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_SPAM_VENDOR_SPECIFIC,0, CW_IGNORE},
|
{0,CW_VENDOR_ID_CISCO, CISCO_ELEM_SPAM_VENDOR_SPECIFIC, 0, CW_IGNORE},
|
||||||
|
|
||||||
|
|
||||||
{0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 1, 0},
|
{0,CW_VENDOR_ID_CISCO, CW_CISCO_BOARD_DATA_OPTIONS, 1, 0},
|
||||||
{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS, 0, CW_DELETE},
|
|
||||||
{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS, 0, CW_DELETE},
|
{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV4_ADDRESS, 0, CW_DELETE},
|
||||||
{0,0, CAPWAP_ELEM_ECN_SUPPORT, 0, CW_DELETE},
|
{0,0,CAPWAP_ELEM_CAPWAP_LOCAL_IPV6_ADDRESS, 0, CW_DELETE},
|
||||||
|
{0,0, CAPWAP_ELEM_ECN_SUPPORT, 0, CW_DELETE},
|
||||||
|
|
||||||
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_PATH_MTU, 0, 0},
|
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_PATH_MTU, 0, 0},
|
||||||
|
|
||||||
@ -3023,7 +3032,6 @@ static int postprocess_discovery(struct cw_ElemHandlerParams * params, uint8_t *
|
|||||||
{
|
{
|
||||||
if (params->conn->role == CW_ROLE_AC ){
|
if (params->conn->role == CW_ROLE_AC ){
|
||||||
set_ac_version(params);
|
set_ac_version(params);
|
||||||
cw_detect_nat(params);
|
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -3032,6 +3040,7 @@ static int postprocess_join_request(struct cw_ElemHandlerParams * params, uint8_
|
|||||||
{
|
{
|
||||||
if (postprocess_join_request_parent!=NULL){
|
if (postprocess_join_request_parent!=NULL){
|
||||||
postprocess_join_request_parent(params,elems_ptr,elems_len);
|
postprocess_join_request_parent(params,elems_ptr,elems_len);
|
||||||
|
cw_detect_nat(params);
|
||||||
}
|
}
|
||||||
postprocess_discovery(params,elems_ptr,elems_len);
|
postprocess_discovery(params,elems_ptr,elems_len);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -26,7 +26,7 @@ cw_dbg(DBG_X,"NUM RADIOS: %d",radios);
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
|
||||||
, uint8_t * dst)
|
, uint8_t * dst)
|
||||||
{
|
{
|
||||||
@ -39,6 +39,6 @@ int cisco_out_radio_info(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
|
|||||||
return cw_out_radio_generic(handler,params,dst);
|
return cw_out_radio_generic(handler,params,dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
3471
src/mod/cisco/mod_cisco.c
Normal file
3471
src/mod/cisco/mod_cisco.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,271 +0,0 @@
|
|||||||
|
|
||||||
#include "cw/cw.h"
|
|
||||||
#include "cw/mod.h"
|
|
||||||
#include "cw/log.h"
|
|
||||||
#include "cw/dbg.h"
|
|
||||||
#include "cw/dtls.h"
|
|
||||||
#include "cw/cfg.h"
|
|
||||||
|
|
||||||
|
|
||||||
/*#include "mod_cisco.h"*/
|
|
||||||
/*#include "../modload.h"*/
|
|
||||||
|
|
||||||
#include "cw/vendors.h"
|
|
||||||
|
|
||||||
#include "mod_cisco.h"
|
|
||||||
#include "capwap_cisco.h"
|
|
||||||
|
|
||||||
/*
|
|
||||||
extern int cisco_register_actions80211_ac(struct cw_actiondef *def);
|
|
||||||
extern int cisco_register_actions_ac(struct cw_actiondef *def);
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*mbag_t cisco_config = NULL;*/
|
|
||||||
|
|
||||||
static struct cw_Mod * capwap_mod = NULL;
|
|
||||||
static struct cw_Mod * capwap80211_mod = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
static int write_header(struct cw_ElemHandler * handler, uint8_t * dst, int len)
|
|
||||||
{
|
|
||||||
if (handler->proto == 0){
|
|
||||||
if (handler->vendor)
|
|
||||||
return len + cw_put_elem_vendor_hdr(dst, handler->vendor, handler->id, len);
|
|
||||||
|
|
||||||
return len + cw_put_elem_hdr(dst, handler->id, len);
|
|
||||||
}
|
|
||||||
/* put the lwap elem header */
|
|
||||||
lw_set_dword(dst + 10, handler->vendor);
|
|
||||||
lw_set_word(dst + 14, handler->id);
|
|
||||||
return len + 6 + cw_put_elem_vendor_hdr(dst, handler->vendor,
|
|
||||||
CISCO_ELEM_SPAM_VENDOR_SPECIFIC, len+6);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static int header_len(struct cw_ElemHandler * handler)
|
|
||||||
{
|
|
||||||
if (handler->proto==0)
|
|
||||||
return handler->vendor ? 10 : 4;
|
|
||||||
|
|
||||||
return 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct cw_MsgSet * register_messages(struct cw_MsgSet *set, int mode)
|
|
||||||
{
|
|
||||||
cw_dbg(DBG_INFO,"CISCO: Register messages");
|
|
||||||
switch (mode) {
|
|
||||||
case CW_MOD_MODE_CAPWAP:
|
|
||||||
{
|
|
||||||
capwap_mod->register_messages(set, CW_MOD_MODE_CAPWAP);
|
|
||||||
|
|
||||||
capwap80211_mod->register_messages(set, CW_MOD_MODE_BINDINGS);
|
|
||||||
cisco_register_msg_set(set,CW_MOD_MODE_CAPWAP);
|
|
||||||
|
|
||||||
set->write_header = write_header;
|
|
||||||
set->header_len = header_len;
|
|
||||||
|
|
||||||
/* cw_dbg(DBG_MOD,"Cisco: loading cisco message set");*/
|
|
||||||
|
|
||||||
/* cw_dbg(DBG_INFO, "Initialized mod_cisco with %d messages", 7);*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case CW_MOD_MODE_BINDINGS:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_dbg(DBG_INFO,"CISCO: Done register messages");
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static void errfunc(cfg_t *cfg, const char *fmt, va_list ap){
|
|
||||||
|
|
||||||
if (cfg && cfg->filename && cfg->line)
|
|
||||||
cw_log(LOG_ERR, "MOD Cisco cfg file in %s:%d: ",
|
|
||||||
cfg->filename, cfg->line);
|
|
||||||
else if (cfg && cfg->filename)
|
|
||||||
cw_log(LOG_ERR, "MOD Cisco cfg file in %s:", cfg->filename);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int init(struct cw_Mod *mod, cw_Cfg_t * global_cfg, int role)
|
|
||||||
{
|
|
||||||
/* uint8_t * str;*/
|
|
||||||
// static char * hardware_version; /*strdup(".x01000001");* /
|
|
||||||
// static char * software_version; /* = NULL; * /
|
|
||||||
/* cfg_t *cfg;*/
|
|
||||||
|
|
||||||
int rc = 1;
|
|
||||||
/* cfg_opt_t opts[] = {
|
|
||||||
CFG_SIMPLE_STR("hardware_version", &hardware_version),
|
|
||||||
CFG_SIMPLE_STR("software_version",&software_version),
|
|
||||||
CFG_END()
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
cw_dbg(DBG_INFO, "CISCO: Initialiazing mod_cisco ...");
|
|
||||||
cw_dbg(DBG_MOD, "CISCO: Loading base module: capwap");
|
|
||||||
|
|
||||||
capwap_mod = cw_mod_load("capwap",global_cfg,role);
|
|
||||||
if (capwap_mod == NULL){
|
|
||||||
cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cw_dbg(DBG_MOD, "CISCO: Loading base module: capwap80211");
|
|
||||||
capwap80211_mod = cw_mod_load("capwap80211", global_cfg,role);
|
|
||||||
if (capwap_mod == NULL){
|
|
||||||
cw_log(LOG_ERR, "CISCO: failed to load base module 'capwap80211");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cw_dbg(DBG_MOD, "CISCO: All base modules are sucessfully loaded.");
|
|
||||||
|
|
||||||
/*cisco_config = mbag_create();*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
cfg = cfg_init(opts, CFGF_NONE);
|
|
||||||
|
|
||||||
cfg_set_error_function(cfg, errfunc);
|
|
||||||
|
|
||||||
char *filename = "cisco.conf";
|
|
||||||
FILE * f = fopen(filename,"r");
|
|
||||||
if (f){
|
|
||||||
fclose(f);
|
|
||||||
if (cfg_parse(cfg, filename)){
|
|
||||||
rc = 0;
|
|
||||||
goto errX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
str = bstr_create_from_cfgstr(hardware_version);
|
|
||||||
mbag_set_bstrv(cisco_config, CW_ITEM_AC_HARDWARE_VERSION,
|
|
||||||
CW_VENDOR_ID_CISCO,
|
|
||||||
bstr_data(str),bstr_len(str)
|
|
||||||
);
|
|
||||||
free(str);
|
|
||||||
|
|
||||||
if (software_version){
|
|
||||||
str = bstr_create_from_cfgstr(software_version);
|
|
||||||
mbag_set_bstrv(cisco_config, CW_ITEM_AC_SOFTWARE_VERSION,
|
|
||||||
CW_VENDOR_ID_CISCO,
|
|
||||||
bstr_data(str),bstr_len(str)
|
|
||||||
);
|
|
||||||
free(str);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/*errX:*/
|
|
||||||
/* if (hardware_version)
|
|
||||||
free (hardware_version);
|
|
||||||
if (software_version)
|
|
||||||
free(software_version);*/
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int detect(struct cw_Conn *conn, const uint8_t * rawmsg, int rawlen, int elems_len,
|
|
||||||
struct sockaddr *from, int mode)
|
|
||||||
{
|
|
||||||
|
|
||||||
int offset = cw_get_hdr_msg_offset(rawmsg);
|
|
||||||
const uint8_t *msg_ptr = rawmsg + offset;
|
|
||||||
|
|
||||||
const uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
|
||||||
const uint8_t *elem;
|
|
||||||
|
|
||||||
|
|
||||||
/* To detect a Cisco AP we look for any vendor
|
|
||||||
* specific payload Cisco identifier */
|
|
||||||
cw_foreach_elem(elem, elems_ptr, elems_len) {
|
|
||||||
int id = cw_get_elem_id(elem);
|
|
||||||
if (id == CAPWAP_ELEM_VENDOR_SPECIFIC_PAYLOAD) {
|
|
||||||
uint32_t vendor_id = cw_get_dword(cw_get_elem_data(elem));
|
|
||||||
if (vendor_id == CW_VENDOR_ID_CISCO) {
|
|
||||||
/* // conn->actions = &actions;*/
|
|
||||||
if (mode == CW_MOD_MODE_CAPWAP) {
|
|
||||||
cw_dbg(DBG_MOD, "CISCO capwap detected: yes");
|
|
||||||
} else {
|
|
||||||
cw_dbg(DBG_MOD, "CISCO bindings detected: yes");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mode == CW_MOD_MODE_CAPWAP) {
|
|
||||||
cw_dbg(DBG_MOD, "CISCO capwap detected: no");
|
|
||||||
} else {
|
|
||||||
cw_dbg(DBG_MOD, "CISCO bindings detected: no");
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
static struct cw_Mod capwap_ac = {
|
|
||||||
.name = "cisco",
|
|
||||||
.init = init,
|
|
||||||
.detect = detect,
|
|
||||||
// .register_actions = register_actions,
|
|
||||||
.register_messages = register_messages
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
int static setup_cfg(struct cw_Conn * conn)
|
|
||||||
{
|
|
||||||
int security;
|
|
||||||
|
|
||||||
// conn->write_header=write_header;
|
|
||||||
// conn->header_len=header_len;
|
|
||||||
|
|
||||||
security = cw_setup_dtls(conn,conn->global_cfg,"cisco",CAPWAP_CIPHER);
|
|
||||||
|
|
||||||
if (conn->role == CW_ROLE_AC){
|
|
||||||
cw_cfg_set_int(conn->local_cfg,"capwap/ac-descriptor/security",security);
|
|
||||||
|
|
||||||
// if (conn->default_cfg==NULL){
|
|
||||||
// conn->default_cfg=cw_cfg_create();
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct cw_Mod mod_cisco = {
|
|
||||||
"cisco", /* name */
|
|
||||||
init, /* init */
|
|
||||||
detect, /* detect */
|
|
||||||
register_messages, /* register_messages */
|
|
||||||
NULL, /* dll_handle */
|
|
||||||
NULL, /* data */
|
|
||||||
setup_cfg /* setup_cfg */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
struct cw_Mod *mod_cisco()
|
|
||||||
{
|
|
||||||
return &cisco_data;
|
|
||||||
}
|
|
||||||
*/
|
|
@ -10,7 +10,7 @@
|
|||||||
#include "wtp.h"
|
#include "wtp.h"
|
||||||
|
|
||||||
|
|
||||||
static int config_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
static int config_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||||
{
|
{
|
||||||
cw_dbg(DBG_X,"*** Configurations Status Response received ****");
|
cw_dbg(DBG_X,"*** Configurations Status Response received ****");
|
||||||
cw_cfg_copy(params->cfg, params->conn->global_cfg,DBG_CFG_UPDATES,"GlbalCfg");
|
cw_cfg_copy(params->cfg, params->conn->global_cfg,DBG_CFG_UPDATES,"GlbalCfg");
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
static int discovery_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||||
{
|
{
|
||||||
struct cw_DiscoveryResults *results = (struct cw_DiscoveryResults *)params->conn->data;
|
struct cw_DiscoveryResults *results = (struct cw_DiscoveryResults *)params->conn->data;
|
||||||
// cw_Cfg_t * cfg = cw_cfg_create();
|
// cw_Cfg_t * cfg = cw_cfg_create();
|
||||||
|
@ -30,7 +30,7 @@ int update =1;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int update_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
static int update_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||||
{
|
{
|
||||||
// cw_dbg(DBG_X," **** Configuration Update Request Received ***");
|
// cw_dbg(DBG_X," **** Configuration Update Request Received ***");
|
||||||
// cw_cfg_dump(params->conn->global_cfg);
|
// cw_cfg_dump(params->conn->global_cfg);
|
||||||
|
Loading…
Reference in New Issue
Block a user