'CFG atcher' in wtpman
This commit is contained in:
parent
20bd835f63
commit
0078c07e58
@ -53,6 +53,13 @@ actube/rpc/listen: tcp:127.0.0.1:5000
|
||||
actube/rpc/enable: true
|
||||
actube/rpc/macros-dir: ./rpc-macros
|
||||
|
||||
#
|
||||
# This catches the initial config af a connecting WTP
|
||||
# From Discovery to CFG Update
|
||||
# The config is saved to a file named
|
||||
# wtp-<wtpname-or-ip>.cfg
|
||||
#
|
||||
actube/save-initial-wtp-config: true
|
||||
|
||||
capwap/ac-descriptor/dtls-policy: 1
|
||||
capwap/ac-descriptor/hardware/vendor: 4232704
|
||||
|
107
src/ac/wtpman.c
107
src/ac/wtpman.c
@ -415,42 +415,70 @@ static void copy(struct cw_ElemHandlerParams * params)
|
||||
cw_cfg_copy(params->cfg, params->conn->remote_cfg,DBG_CFG_UPDATES,"GlobalCfg");
|
||||
}
|
||||
|
||||
static void catch_cfg(struct cw_ElemHandlerParams * params, int create, const char *format, ...)
|
||||
{
|
||||
const char *wtpname;
|
||||
char filename[200];
|
||||
FILE *f;
|
||||
cw_Cfg_t * cfg_list[3];
|
||||
|
||||
if (!cw_cfg_get_bool(params->conn->global_cfg,"actube/save-initial-wtp-config",0))
|
||||
return;
|
||||
|
||||
cfg_list[0]=params->cfg;
|
||||
cfg_list[1]=params->conn->remote_cfg;
|
||||
cfg_list[2]=NULL;
|
||||
|
||||
wtpname = cw_cfg_get_l(cfg_list,"capwap/wtp-name","default");
|
||||
sprintf(filename,"wtp-initial-%s.ckv",wtpname);
|
||||
|
||||
if (create)
|
||||
f = fopen(filename,"w");
|
||||
else
|
||||
f = fopen(filename,"a");
|
||||
if (f==NULL)
|
||||
return;
|
||||
|
||||
if (create)
|
||||
fprintf(f,"#\n# Initial config for WTP '%s' - catched by ACTube\n#\n\n",wtpname);
|
||||
|
||||
if (format !=NULL){
|
||||
va_list args;
|
||||
va_start(args,format);
|
||||
vfprintf(f,format,args);
|
||||
va_end(args);
|
||||
}
|
||||
cw_cfg_write_to_file(f, params->cfg);
|
||||
fclose(f);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int discovery_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data * d)
|
||||
{
|
||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||
char filename[200];
|
||||
|
||||
cw_dbg(DBG_X,"DISCOVERY Callback");
|
||||
copy(params);
|
||||
catch_cfg(params,1,"\n#\n# Discovery Request\n#\n");
|
||||
|
||||
const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
|
||||
sprintf(filename,"wtp-discovery-%s.ckv",wtpname);
|
||||
cw_cfg_save(filename,params->cfg,NULL);
|
||||
cw_cfg_clear(params->cfg);
|
||||
|
||||
if (d->parent)
|
||||
return d->parent->fun(params,d->parent);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
static int join_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||
{
|
||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||
char filename[200];
|
||||
int rc;
|
||||
|
||||
rc = 0;
|
||||
catch_cfg(params,0,"\n#\n# Join Request\n#\n");
|
||||
if (d->parent)
|
||||
rc =d->parent->fun(params,d->parent);
|
||||
|
||||
cw_dbg(DBG_X,"JOIN Callback");
|
||||
copy(params);
|
||||
const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
|
||||
sprintf(filename,"wtp-join-%s.ckv",wtpname);
|
||||
cw_cfg_save(filename,params->cfg,NULL);
|
||||
cw_cfg_clear(params->cfg);
|
||||
return rc;
|
||||
return d->parent->fun(params,d->parent);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
static int fill_update_cfg(struct cw_Conn * conn)
|
||||
@ -479,24 +507,11 @@ static int fill_update_cfg(struct cw_Conn * conn)
|
||||
}
|
||||
*/
|
||||
|
||||
static int update_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||
static int cfg_status_cb(struct cw_ElemHandlerParams * params, struct cw_MsgCb_data *d)
|
||||
{
|
||||
struct cw_Conn * conn = (struct cw_Conn*)params->conn;
|
||||
char filename[200];
|
||||
|
||||
int rc = 0;
|
||||
catch_cfg(params,0,"\n#\n# Configuration Status Request\n#\n");
|
||||
if (d->parent)
|
||||
rc =d->parent->fun(params,d->parent);
|
||||
|
||||
|
||||
|
||||
cw_dbg(DBG_X,"UPDATE Callback");
|
||||
//fill_update_cfg(params->conn);
|
||||
|
||||
const char * wtpname = cw_cfg_get(conn->remote_cfg,"capwap/wtp-name","default");
|
||||
sprintf(filename,"wtp-status-%s.ckv",wtpname);
|
||||
cw_cfg_save(filename,params->cfg,NULL);
|
||||
//stop();
|
||||
return d->parent->fun(params,d->parent);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -591,6 +606,10 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cw_conn_register_msg_cb(wtpman->conn,
|
||||
CAPWAP_MSG_DISCOVERY_REQUEST,
|
||||
discovery_cb);
|
||||
|
||||
|
||||
wtpman->conn->global_cfg = global_cfg;
|
||||
wtpman->conn->local_cfg = cw_cfg_create();
|
||||
@ -651,16 +670,12 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
|
||||
|
||||
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);*/
|
||||
join_cb);
|
||||
|
||||
/* cw_conn_register_msg_cb(wtpman->conn,
|
||||
cw_conn_register_msg_cb(wtpman->conn,
|
||||
CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
update_cb);*/
|
||||
cfg_status_cb);
|
||||
|
||||
cw_conn_register_msg_cb(wtpman->conn,
|
||||
CAPWAP_MSG_WTP_EVENT_REQUEST,
|
||||
@ -685,7 +700,7 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr,
|
||||
|
||||
void wtpman_addpacket(struct wtpman *wtpman, uint8_t * packet, int len)
|
||||
{
|
||||
// cw_dbg(DBG_X,"ADD PACKET DETECTED %d",wtpman->conn->detected);
|
||||
cw_dbg(DBG_X,"ADD PACKET DETECTED %d",wtpman->conn->detected);
|
||||
conn_q_add_packet(wtpman->conn, packet, len);
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,11 @@ struct wtpman {
|
||||
|
||||
cw_Cfg_t * wtp_cfg;
|
||||
|
||||
cw_Cfg_t * discovery_cfg;
|
||||
cw_Cfg_t * join_cfg;
|
||||
cw_Cfg_t * config_status_cfg;
|
||||
|
||||
|
||||
int update;
|
||||
int ctr;
|
||||
};
|
||||
|
@ -90,6 +90,7 @@ 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_int(cw_Cfg_t * cfg, const char *key, int def);
|
||||
int cw_cfg_write_to_file(FILE *f, cw_Cfg_t * cfg);
|
||||
|
||||
|
||||
|
||||
|
@ -16,10 +16,17 @@ int cisco_out_lw_path_mtu(struct cw_ElemHandler * eh,
|
||||
int len,max;
|
||||
|
||||
int hl = params->msgset->header_len(eh);
|
||||
|
||||
/* get the current length of message */
|
||||
int cl = dst-params->rawmsg;
|
||||
|
||||
|
||||
|
||||
int wl = 1400-cl-hl;
|
||||
|
||||
printf("HL:%d CL:%d WL: %d\n",hl,cl,wl);
|
||||
if (wl<=40)
|
||||
return 0;
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,"len");
|
||||
len = cw_cfg_get_word_l(params->cfg_list,key,0);
|
||||
|
@ -678,26 +678,26 @@ static cw_ValStruct_t dtls_data_cfg[]={
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
static cw_ValStruct_t cisco_add_wlan[]={
|
||||
{CW_TYPE_BYTE,"radio-id",1,-1},
|
||||
{CW_TYPE_WORD,"wlan-capability",2,-1},
|
||||
{CW_TYPE_WORD,"capwap80211/capability",2,-1},
|
||||
{CW_TYPE_BYTE,"wlan-id",1,-1},
|
||||
{CW_TYPE_DWORD,"encryption-policy",4,-1},
|
||||
{CW_TYPE_DWORD,"cisco/encryption-policy",4,-1},
|
||||
|
||||
{CW_TYPE_BSTR16,"wep-key",13,9},
|
||||
{CW_TYPE_BYTE,"encryption",1,42},
|
||||
{CW_TYPE_BSTR16,"cisco/wep-key",13,9},
|
||||
{CW_TYPE_BYTE,"cisco/wep-encryption",1,42},
|
||||
|
||||
{CW_TYPE_BOOL,"broadcast-ssid",1,426},
|
||||
{CW_TYPE_WORD,"session-timout",2,475},
|
||||
{CW_TYPE_BYTE, "dtim-period",1,541},
|
||||
{CW_TYPE_STR, "ssid-a",30,545},
|
||||
{CW_TYPE_BYTE, "allow-aaa-override",1,578},
|
||||
{CW_TYPE_BYTE, "max-stations",1,580},
|
||||
{CW_TYPE_BOOL,"cisco/broadcast-ssid",1,426},
|
||||
{CW_TYPE_WORD,"cisco/session-timout",2,475},
|
||||
{CW_TYPE_BYTE, "cisco/dtim-period",1,541},
|
||||
{CW_TYPE_STR, "cisco/ssid-a",30,545},
|
||||
{CW_TYPE_BYTE, "cisco/allow-aaa-override",1,578},
|
||||
{CW_TYPE_BYTE, "cisco/max-stations",1,580},
|
||||
|
||||
{NULL,NULL,0,0}
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
static cw_ValStruct_t cisco_add_wlan70[]={
|
||||
{CW_TYPE_BYTE,"radio-id",1,-1},
|
||||
@ -966,7 +966,7 @@ static struct cw_ElemHandler handlers70[] = {
|
||||
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
|
||||
1,512, /* min/max length */
|
||||
CW_TYPE_BSTR16, /* type */
|
||||
"cisco/rad-name", /* Key */
|
||||
"capwap/wtp-name", /* Key */
|
||||
cw_in_generic, /* get */
|
||||
cw_out_generic /* put */
|
||||
}
|
||||
@ -2479,9 +2479,10 @@ static struct cw_ElemDef configuration_status_request_elements[] ={
|
||||
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_HARDWARE_INFO, 0, 0},
|
||||
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_ROUGE_DETECTION, 0, 0},
|
||||
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_DTLS_DATA_CFG, 0, 0},
|
||||
// {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},
|
||||
|
||||
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_DISCOVERY_PROTOCOL, 1, 0},
|
||||
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_RAD_EXTENDED_CONFIG, 0, 0},
|
||||
{0,0,0,00}
|
||||
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user