WTP can join and send cfg request
This commit is contained in:
@ -10,11 +10,23 @@
|
||||
#include "cfg.h"
|
||||
|
||||
|
||||
static int config_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_ptr, int elems_len)
|
||||
{
|
||||
struct cw_DiscoveryResults *results = (struct cw_DiscoveryResults *)params->conn->data;
|
||||
cw_dbg(DBG_X,"Configurations status response received");
|
||||
cw_cfg_dump(params->cfg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int configure(struct cw_Conn * conn)
|
||||
{
|
||||
char sockbuff[SOCK_ADDR_BUFSIZE];
|
||||
|
||||
cw_dbg_ktv_dump(conn->local_cfg,DBG_INFO,"KTV DUMP ----------------","LOCAL:", "DUMP done -------");
|
||||
// cw_dbg_ktv_dump(conn->local_cfg,DBG_INFO,"KTV DUMP ----------------","LOCAL:", "DUMP done -------");
|
||||
|
||||
cw_conn_set_msg_cb(conn,CAPWAP_MSG_CONFIGURATION_STATUS_RESPONSE,config_cb);
|
||||
|
||||
int rc;
|
||||
rc = cw_send_request(conn, CAPWAP_MSG_CONFIGURATION_STATUS_REQUEST);
|
||||
@ -35,7 +47,7 @@ int configure(struct cw_Conn * conn)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"Config ***","CFG: ", "End config ***");
|
||||
// cw_dbg_ktv_dump(conn->remote_cfg,DBG_INFO,"Config ***","CFG: ", "End config ***");
|
||||
|
||||
// cw_ktv_set_byte(conn->remote_cfg,"
|
||||
/*exit(0);*/
|
||||
|
@ -29,7 +29,6 @@ static int discovery_cb(struct cw_ElemHandlerParams * params, uint8_t * elems_pt
|
||||
// cw_cfg_copy(params->cfg,cfg);
|
||||
|
||||
cw_discovery_results_add(results,params->cfg,params->conn->global_cfg);
|
||||
printf("Have Discovery %d\n",results->nr);
|
||||
|
||||
// cw_cfg_dump(params->cfg);
|
||||
// mlist_append_ptr(dis->results, cfg);
|
||||
@ -46,9 +45,9 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
|
||||
results = cw_discovery_results_create();
|
||||
|
||||
|
||||
min = cw_cfg_get_byte(conn->local_cfg,"capwap-timers/min-discovery-interval",
|
||||
min = cw_cfg_get_byte(conn->global_cfg,"capwap-timers/min-discovery-interval",
|
||||
CAPWAP_MIN_DISCOVERY_INTERVAL);
|
||||
max = cw_cfg_get_byte(conn->local_cfg,"capwap-timers/max-discovery-interval",
|
||||
max = cw_cfg_get_byte(conn->global_cfg,"capwap-timers/max-discovery-interval",
|
||||
CAPWAP_MAX_DISCOVERY_INTERVAL);
|
||||
|
||||
delay = cw_randint(min,max);
|
||||
@ -60,15 +59,12 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
|
||||
|
||||
conn->capwap_state = CAPWAP_STATE_DISCOVERY;
|
||||
|
||||
conn->remote_cfg=cw_cfg_create();
|
||||
/* create and send a discovery request message */
|
||||
cw_init_request(conn, CAPWAP_MSG_DISCOVERY_REQUEST);
|
||||
cw_assemble_message(conn, conn->req_buffer);
|
||||
cw_compose_message(conn, conn->req_buffer);
|
||||
|
||||
|
||||
conn_send_msg(conn, conn->req_buffer);
|
||||
cw_cfg_destroy(conn->remote_cfg);
|
||||
conn->remote_cfg=NULL;
|
||||
|
||||
|
||||
|
||||
@ -85,7 +81,6 @@ static struct cw_DiscoveryResults * run_discovery(struct cw_Conn *conn)
|
||||
while (!cw_timer_timeout(timer)
|
||||
&& conn->capwap_state == CAPWAP_STATE_DISCOVERY) {
|
||||
int rc;
|
||||
cw_dbg(DBG_X,"READ NOW");
|
||||
// conn->remote_cfg = cw_ktv_create();
|
||||
// if (conn->remote_cfg == NULL) {
|
||||
// cw_log_errno("Can't allocate memory for remote_cfg");
|
||||
|
@ -154,10 +154,10 @@ static int run_join_d(struct cw_Conn * conn, struct sockaddr *sa,cw_Cfg_t * cfg)
|
||||
cw_dbg(DBG_DTLS, "DTLS Connection successful established with %s",
|
||||
sock_addr2str(sa,addrstr));
|
||||
|
||||
conn->remote_cfg=cfg;
|
||||
run_join(conn);
|
||||
conn->remote_cfg=NULL;
|
||||
return 1;
|
||||
// conn->remote_cfg=cfg;
|
||||
rc = run_join(conn);
|
||||
// conn->remote_cfg=NULL;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -214,53 +214,16 @@ int join(struct cw_Conn * conn, struct cw_DiscoveryResults * results)
|
||||
|
||||
sock_strtoaddr(e->ip,(struct sockaddr*)(&sockaddr));
|
||||
sock_setport((struct sockaddr*)&sockaddr,5246);
|
||||
|
||||
cw_cfg_clear(conn->remote_cfg);
|
||||
cw_cfg_copy(e->cfg,conn->remote_cfg);
|
||||
rc = run_join_d(conn,(struct sockaddr*)(&sockaddr),e->cfg);
|
||||
if (rc)
|
||||
return 1;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
stop();
|
||||
/*
|
||||
mavliter_t ii;
|
||||
mavliter_init(&ii,dis->prio_ip);
|
||||
|
||||
mavliter_foreach(&ii){
|
||||
int rc;
|
||||
cw_Val_t * val,*ac;
|
||||
mavl_t rcfg;
|
||||
char * rk;
|
||||
char ipstr[100];
|
||||
char ac_name[CAPWAP_MAX_AC_NAME_LEN];
|
||||
struct sockaddr_storage sockaddr;
|
||||
|
||||
val = mavliter_get(&ii);
|
||||
rk = val->key;
|
||||
val = val->val.ptr;
|
||||
val->type->to_str(val, ipstr, 100);
|
||||
|
||||
rcfg = cw_ktv_get_sysptr(dis->prio_ac,rk,NULL);
|
||||
|
||||
ac=cw_ktv_get(rcfg,"ac-name",CW_TYPE_BSTR16);
|
||||
if (ac != NULL){
|
||||
ac->type->to_str(ac,ac_name,sizeof(ac_name));
|
||||
}
|
||||
else{
|
||||
strcpy(ac_name,"");
|
||||
}
|
||||
|
||||
|
||||
cw_dbg(DBG_INFO, "Going to join CAPWAP controller '%s' at %s.",ac_name,ipstr);
|
||||
|
||||
conn->remote_cfg=rcfg;
|
||||
|
||||
sock_strtoaddr(ipstr,(struct sockaddr*)(&sockaddr));
|
||||
sock_setport((struct sockaddr*)&sockaddr,5246);
|
||||
rc = run_join_d(conn,(struct sockaddr*)(&sockaddr));
|
||||
if (rc)
|
||||
return 1;
|
||||
|
||||
}*/
|
||||
return 0;
|
||||
}
|
||||
|
@ -145,7 +145,6 @@ int main (int argc, char **argv)
|
||||
conn->dtls_mtu = 1200;
|
||||
conn->msgset=msgset;
|
||||
conn->global_cfg = global_cfg;
|
||||
conn->local_cfg = cw_cfg_create();
|
||||
//conn->remote_cfg = cw_cfg_create();
|
||||
|
||||
conn->role = CW_ROLE_WTP;
|
||||
@ -183,17 +182,19 @@ int main (int argc, char **argv)
|
||||
results = cw_run_discovery(conn, "255.255.255.255","192.168.0.14");
|
||||
|
||||
// mavl_del_all(conn->remote_cfg);
|
||||
join(conn,results);
|
||||
|
||||
cw_discovery_results_destroy(results);
|
||||
|
||||
|
||||
printf("JOIN CONF\n");
|
||||
rc = 0;
|
||||
printf("Goto errx 0");
|
||||
goto errX;
|
||||
if (!join(conn,results)){
|
||||
cw_discovery_results_destroy(results);
|
||||
goto errX;
|
||||
}
|
||||
|
||||
configure(conn);
|
||||
|
||||
cw_discovery_results_destroy(results);
|
||||
rc = 0;
|
||||
printf("Goto errx 0\n");
|
||||
goto errX;
|
||||
|
||||
|
||||
clean_cfg(conn->remote_cfg);
|
||||
mavl_merge(conn->local_cfg,conn->remote_cfg);
|
||||
|
||||
|
Reference in New Issue
Block a user