Discovery cache is working now!
FossilOrigin-Name: 9f539a60054a9669d1adabcc68060b61dce7e995347fcda7a5f2f0173e9d15d3
This commit is contained in:
parent
13b53ee3bc
commit
56e0f3548b
@ -11,15 +11,12 @@
|
||||
#include "cw/dbg.h"
|
||||
|
||||
#include "wtpman.h"
|
||||
|
||||
/*struct cw_ac_status ac_status;*/
|
||||
|
||||
|
||||
|
||||
|
||||
#include "discovery_cache.h"
|
||||
|
||||
mavl_t actube_global_cfg;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
cw_aciplist_t get_aciplist()
|
||||
{
|
||||
@ -104,37 +101,18 @@ int handle_echo_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
struct cw_DiscoveryCache * discovery_cache;
|
||||
|
||||
int ac_global_init()
|
||||
{
|
||||
/*// mod_set_actions_registered_cb(setup_actions);
|
||||
*/
|
||||
|
||||
/*
|
||||
ac_config = mbag_create();
|
||||
mbag_set_str(ac_config, CW_ITEM_AC_NAME, conf_acname);
|
||||
mbag_set_ptr(ac_config, CW_ITEM_AC_STATUS, &ac_status);
|
||||
|
||||
ac_status.stations = 0;
|
||||
ac_status.limit = 1000;
|
||||
ac_status.active_wtps = 10;
|
||||
ac_status.max_wtps = 200;
|
||||
ac_status.security = CW_FLAG_AC_SECURITY_X | CW_FLAG_AC_SECURITY_S;
|
||||
ac_status.rmac_field = CW_FLAG_RMAC_SUPPORTED;
|
||||
ac_status.dtls_policy = CAPWAP_FLAG_DTLS_POLICY_C; // | CW_FLAG_DTLS_POLICY_D;
|
||||
/* initialize discovery cache */
|
||||
discovery_cache = discovery_cache_create(100);
|
||||
if (discovery_cache==NULL)
|
||||
goto errX;
|
||||
|
||||
|
||||
mbag_set_bstrv(ac_config, CW_ITEM_AC_HARDWARE_VERSION, 0,
|
||||
bstr_data(conf_hardware_version), bstr_len(conf_hardware_version));
|
||||
mbag_set_bstrv(ac_config, CW_ITEM_AC_SOFTWARE_VERSION, 0,
|
||||
bstr_data(conf_software_version), bstr_len(conf_software_version));
|
||||
|
||||
|
||||
mbag_set_str(ac_config,CW_ITEM_AC_IMAGE_DIR,conf_image_dir);
|
||||
|
||||
// mbag_set_avltree(ac_config, CW_ITEM_AC_IP_LIST, aciplist);
|
||||
|
||||
|
||||
mbag_set_fun(ac_config, CW_ITEM_CAPWAP_CONTROL_IP_ADDRESS_LIST, get_iplist,release_iplist,(void*)771);
|
||||
*/
|
||||
return 1;
|
||||
errX:
|
||||
return 0;
|
||||
}
|
||||
|
122
src/ac/ac_main.c
122
src/ac/ac_main.c
@ -57,6 +57,7 @@ static void *alive_thread (void *data)
|
||||
sleep (5);
|
||||
db_ping();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -187,50 +188,7 @@ int stcmp (const void * sa1, const void *sa2)
|
||||
return rc;
|
||||
}
|
||||
*/
|
||||
|
||||
#include "discovery_cache.h"
|
||||
tester()
|
||||
{
|
||||
struct cw_DiscoveryCache * cache;
|
||||
struct sockaddr_storage a1,a2,a3,a4,a5,a6;
|
||||
|
||||
cache = discovery_cache_create(10);
|
||||
|
||||
sock_strtoaddr("192.168.0.2:11",(struct sockaddr*)&a1);
|
||||
|
||||
sock_strtoaddr("192.168.0.1:3",(struct sockaddr*)&a3);
|
||||
sock_strtoaddr("192.168.0.1:6",(struct sockaddr*)&a4);
|
||||
sock_strtoaddr("192.168.0.1:9",(struct sockaddr*)&a5);
|
||||
sock_strtoaddr("192.168.0.1:1",(struct sockaddr*)&a6);
|
||||
sock_strtoaddr("192.168.0.1:2",(struct sockaddr*)&a2);
|
||||
|
||||
discovery_cache_add(cache, (struct sockaddr*)&a1,"capwap","ciscon");
|
||||
|
||||
discovery_cache_add(cache, (struct sockaddr*)&a3,"capwap","ciscoc");
|
||||
discovery_cache_add(cache, (struct sockaddr*)&a4,"capwap","ciscod");
|
||||
discovery_cache_add(cache, (struct sockaddr*)&a5,"capwap","ciscoe");
|
||||
discovery_cache_add(cache, (struct sockaddr*)&a6,"capwap","ciscof");
|
||||
discovery_cache_add(cache, (struct sockaddr*)&a2,"capwap","ciscob");
|
||||
|
||||
{
|
||||
struct cw_DiscoveryCacheElem * elem;
|
||||
struct sockaddr_storage s;
|
||||
|
||||
sock_strtoaddr("192.168.0.1:800", (struct sockaddr*)&s);
|
||||
|
||||
|
||||
elem = discovery_cache_get(cache,(struct sockaddr*)&s);
|
||||
if (elem){
|
||||
printf("Found = %s %s\n", elem->mod_capwap, elem->mod_bindings);
|
||||
}
|
||||
else{
|
||||
printf("no elem\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
static int ibcmp(const void *v1, const void *v2)
|
||||
{
|
||||
int *i1,*i2;
|
||||
@ -238,40 +196,30 @@ static int ibcmp(const void *v1, const void *v2)
|
||||
|
||||
return *i1-*i2;
|
||||
}
|
||||
*/
|
||||
|
||||
#include "discovery_cache.h"
|
||||
void tester1()
|
||||
{
|
||||
mavl_t tree;
|
||||
int val;
|
||||
mavliter_t it;
|
||||
struct cw_DiscoveryCache * cache;
|
||||
struct sockaddr_storage addr;
|
||||
int rc;
|
||||
const char *c,*b;
|
||||
|
||||
cache = discovery_cache_create(1);
|
||||
|
||||
sock_strtoaddr("192.168.0.12:1234",(struct sockaddr*)&addr);
|
||||
discovery_cache_add(cache,(struct sockaddr*)&addr,"Nase","Loeffel");
|
||||
|
||||
sock_strtoaddr("192.168.0.13:1234",(struct sockaddr*)&addr);
|
||||
discovery_cache_add(cache,(struct sockaddr*)&addr,"Nase","Loeffel");
|
||||
|
||||
tree = mavl_create(ibcmp,NULL,sizeof(int));
|
||||
val = 3;
|
||||
mavl_add(tree,&val,NULL);
|
||||
val = 7;
|
||||
mavl_add(tree,&val,NULL);
|
||||
|
||||
val = 2;
|
||||
mavl_add(tree,&val,NULL);
|
||||
rc = discovery_cache_get(cache,(struct sockaddr*)&addr,&c,&b);
|
||||
|
||||
mavliter_init(&it,tree);
|
||||
mavliter_foreach(&it){
|
||||
int *result;
|
||||
result = mavliter_get(&it);
|
||||
printf("Result: %i\n",*result);
|
||||
if (rc) {
|
||||
printf("RC: %d, %s %s\n",rc,c,b);
|
||||
}
|
||||
|
||||
val = 2;
|
||||
mavl_del(tree,&val);
|
||||
|
||||
|
||||
mavliter_init(&it,tree);
|
||||
mavliter_foreach(&it){
|
||||
int *result;
|
||||
result = mavliter_get(&it);
|
||||
printf("Result: %i\n",*result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -282,11 +230,6 @@ int main (int argc, char *argv[])
|
||||
FILE * file;
|
||||
mavl_t types_tree, global_cfg;
|
||||
const cw_Type_t **ti;
|
||||
tester1();
|
||||
exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
/* parse arguments */
|
||||
parse_args (argc, argv, &bootcfg);
|
||||
@ -376,10 +319,7 @@ exit(0);
|
||||
|
||||
/* Init DTLS library */
|
||||
dtls_init();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ac_global_init();
|
||||
|
||||
if (!socklist_init())
|
||||
@ -626,7 +566,7 @@ void process_cw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
|
||||
if (!wtpman) {
|
||||
|
||||
wtpman = wtpman_create (index, addr);
|
||||
wtpman = wtpman_create (index, addr, preamble & 0xf);
|
||||
|
||||
|
||||
if (!wtpman) {
|
||||
@ -652,10 +592,10 @@ void process_cw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void process_lw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, int len)
|
||||
{
|
||||
/*//int sock = socklist[index].reply_sockfd;*/
|
||||
//int sock = socklist[index].reply_sockfd;
|
||||
|
||||
uint8_t *m = buffer + 6;
|
||||
uint32_t val = ntohl (* ( (uint32_t *) (m)));
|
||||
@ -665,11 +605,11 @@ void process_lw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
|
||||
|
||||
|
||||
/* first of all check preamble */
|
||||
// first of all check preamble
|
||||
int version = LWTH_GET_VERSION (m);
|
||||
|
||||
if (version != LW_VERSION) {
|
||||
/*// cw_log_debug1("Discarding LWAPP packet, wrong verson");*/
|
||||
// cw_log_debug1("Discarding LWAPP packet, wrong verson");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -677,7 +617,7 @@ void process_lw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
printf ("LEN = %d\n", l);
|
||||
|
||||
if (l + 12 != len) {
|
||||
/* // cw_log_debug1("Discarding LWAPP packet, wrong length");*/
|
||||
// cw_log_debug1("Discarding LWAPP packet, wrong length");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -703,14 +643,14 @@ void process_lw_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer,
|
||||
return;
|
||||
};
|
||||
|
||||
/*//wtpman_lw_start(wtpman);*/
|
||||
//wtpman_lw_start(wtpman);
|
||||
}
|
||||
|
||||
/*//wtpman_lw_addpacket(wtpman,buffer,len);*/
|
||||
//wtpman_lw_addpacket(wtpman,buffer,len);
|
||||
wtplist_unlock();
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -721,8 +661,8 @@ void process_ctrl_packet (int index, struct sockaddr *addr, uint8_t * buffer, in
|
||||
process_cw_ctrl_packet (index, addr, buffer, len);
|
||||
return;
|
||||
|
||||
case AC_PROTO_LWAPP:
|
||||
/*case AC_PROTO_LWAPP:
|
||||
process_lw_ctrl_packet (index, addr, buffer, len);
|
||||
return;
|
||||
return;*/
|
||||
}
|
||||
}
|
||||
|
@ -1,2 +1,6 @@
|
||||
|
||||
#define AC_MAX_LISTEN_SOCKETS 32
|
||||
|
||||
#include "discovery_cache.h"
|
||||
|
||||
extern struct cw_DiscoveryCache * discovery_cache;
|
@ -3,8 +3,14 @@
|
||||
#include "cw/sock.h"
|
||||
#include "cw/mlist.h"
|
||||
#include "cw/mavl.h"
|
||||
#include "cw/mod.h"
|
||||
|
||||
#include "discovery_cache.h"
|
||||
struct cw_DiscoveryCacheElem{
|
||||
struct sockaddr_storage addr;
|
||||
struct cw_Mod *cmod, *bmod;
|
||||
uint32_t ctrlo, ctrhi;
|
||||
};
|
||||
|
||||
struct cw_DiscoveryCache{
|
||||
int len;
|
||||
@ -74,7 +80,7 @@ struct cw_DiscoveryCache * discovery_cache_create(int len)
|
||||
goto errX;
|
||||
|
||||
for (i=0; i<len; i++){
|
||||
cache->queue[i].mod_capwap=NULL;
|
||||
cache->queue[i].cmod=NULL;
|
||||
}
|
||||
|
||||
cache->byaddr = mavl_create_ptr(cmpaddr,NULL);
|
||||
@ -97,18 +103,19 @@ errX:
|
||||
}
|
||||
|
||||
void discovery_cache_add(struct cw_DiscoveryCache *cache,
|
||||
struct sockaddr * addr, const char * mod_capwap, const char * mod_bindings)
|
||||
struct sockaddr * addr, struct cw_Mod * mod_capwap, struct cw_Mod * mod_bindings)
|
||||
{
|
||||
struct cw_DiscoveryCacheElem * cur = cache->queue+cache->qpos;
|
||||
if (cur->mod_capwap==NULL){
|
||||
if (cur->cmod!=NULL){
|
||||
/* delete here */
|
||||
mavl_del(cache->byaddr,cur);
|
||||
mavl_del(cache->byaddr,cur);
|
||||
void * ptr = &cur;
|
||||
mavl_del(cache->byaddr,ptr);
|
||||
mavl_del(cache->byaddr,ptr);
|
||||
|
||||
}
|
||||
|
||||
cur->mod_capwap=mod_capwap;
|
||||
cur->mod_bindings=mod_bindings;
|
||||
cur->cmod=mod_capwap;
|
||||
cur->bmod=mod_bindings;
|
||||
sock_copyaddr(&cur->addr,addr);
|
||||
|
||||
cur->ctrhi=cache->ctrhi;
|
||||
@ -127,35 +134,50 @@ void discovery_cache_add(struct cw_DiscoveryCache *cache,
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct cw_DiscoveryCacheElem * discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr)
|
||||
int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
|
||||
struct cw_Mod ** modcapwap, struct cw_Mod **modbindings)
|
||||
{
|
||||
struct cw_DiscoveryCacheElem * elem, ** result, *search_ptr, search;
|
||||
sock_copyaddr(&search.addr,addr);
|
||||
search.ctrhi=search.ctrlo=0;
|
||||
|
||||
search_ptr = &search;
|
||||
result = mavl_get(cache->byaddrp ,&search_ptr);
|
||||
if (result != NULL){
|
||||
elem = *result;
|
||||
if (elem != NULL){
|
||||
mavl_del(cache->byaddr,result);
|
||||
mavl_del(cache->byaddrp,result);
|
||||
*modcapwap=elem->cmod;
|
||||
*modbindings=elem->bmod;
|
||||
|
||||
elem->cmod=NULL;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
elem = mavl_get_ptr(cache->byaddrp ,&search);
|
||||
if (elem != NULL)
|
||||
return elem;
|
||||
|
||||
search.mod_capwap="hallo";
|
||||
search_ptr = &search;
|
||||
/*elem = *((struct cw_DiscoveryCacheElem **)
|
||||
*/
|
||||
result = mavl_get_first(cache->byaddr, &search_ptr);
|
||||
if (result == NULL)
|
||||
return NULL;
|
||||
|
||||
return 0;
|
||||
|
||||
elem = *result;
|
||||
if (elem != NULL){
|
||||
if (sock_cmpaddr((struct sockaddr*)&elem->addr,addr,0)!=0)
|
||||
return NULL;
|
||||
return 0;
|
||||
|
||||
mavl_del(cache->byaddr,result);
|
||||
mavl_del(cache->byaddrp,result);
|
||||
|
||||
*modcapwap=elem->cmod;
|
||||
*modbindings=elem->bmod;
|
||||
|
||||
elem->cmod=NULL;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
@ -2,23 +2,16 @@
|
||||
#define __DISCOVERY_CACHE_H
|
||||
|
||||
|
||||
extern struct cw_DiscoveryCache;
|
||||
struct cw_DiscoveryCacheElem{
|
||||
struct sockaddr_storage addr;
|
||||
const char *mod_capwap;
|
||||
const char *mod_bindings;
|
||||
uint32_t ctrlo, ctrhi;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct cw_DiscoveryCache * discovery_cache_create(int len);
|
||||
void discovery_cache_add(struct cw_DiscoveryCache *cache,
|
||||
struct sockaddr * addr, const char * mod_capwap, const char * mod_bindings);
|
||||
|
||||
struct cw_DiscoveryCacheElem * discovery_cache_get(
|
||||
struct cw_DiscoveryCache * cache,struct sockaddr *addr);
|
||||
|
||||
|
||||
void discovery_cache_add(struct cw_DiscoveryCache *cache,
|
||||
struct sockaddr * addr, struct cw_Mod * mod_capwap, struct cw_Mod * mod_bindings);
|
||||
|
||||
int discovery_cache_get(struct cw_DiscoveryCache * cache,struct sockaddr *addr,
|
||||
struct cw_Mod ** modcapwap, struct cw_Mod **modbindings);
|
||||
|
||||
#endif
|
116
src/ac/wtpman.c
116
src/ac/wtpman.c
@ -43,6 +43,8 @@
|
||||
#include "wtplist.h"
|
||||
#include "cw/ktv.h"
|
||||
|
||||
#include "actube.h"
|
||||
|
||||
static void reset_echointerval_timer(struct wtpman *wtpman)
|
||||
{
|
||||
/* char sock_buf[SOCK_ADDR_BUFSIZE];*/
|
||||
@ -97,6 +99,15 @@ static void wtpman_run_discovery(void *arg)
|
||||
rc = cw_read_messages(wtpman->conn);
|
||||
if (cw_result_is_ok(rc)){
|
||||
wtpman->conn->capwap_state=CAPWAP_STATE_JOIN;
|
||||
|
||||
cw_dbg(DBG_INFO,"Discovery has detected mods: %s %s",
|
||||
wtpman->conn->bmod->name,wtpman->conn->cmod->name);
|
||||
|
||||
wtplist_lock();
|
||||
discovery_cache_add(discovery_cache,(struct sockaddr*)&wtpman->conn->addr,
|
||||
wtpman->conn->bmod,wtpman->conn->cmod);
|
||||
wtplist_unlock();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -283,10 +294,10 @@ static void wtpman_image_data(struct wtpman *wtpman)
|
||||
|
||||
|
||||
|
||||
void wtpman_run_data(void *wtpman_arg)
|
||||
void * wtpman_run_data(void *wtpman_arg)
|
||||
{
|
||||
|
||||
return;
|
||||
return NULL;
|
||||
/*
|
||||
struct wtpman *wtpman = (struct wtpman *) wtpman_arg;
|
||||
struct conn *conn = wtpman->conn;
|
||||
@ -308,8 +319,9 @@ void wtpman_run_data(void *wtpman_arg)
|
||||
|
||||
|
||||
|
||||
static void wtpman_run(void *arg)
|
||||
static void * wtpman_run(void *arg)
|
||||
{
|
||||
mavl_t r;
|
||||
int rc ;
|
||||
time_t timer;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
@ -320,15 +332,12 @@ static void wtpman_run(void *arg)
|
||||
wtpman->conn->seqnum = 0;
|
||||
conn = wtpman->conn;
|
||||
|
||||
|
||||
/* We were invoked with an unencrypted packet,
|
||||
* so assume, it is a discovery request */
|
||||
if (!wtpman->dtlsmode){
|
||||
wtpman_run_discovery(arg);
|
||||
if (conn->capwap_state==CAPWAP_STATE_DISCOVERY){
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
wtpman_remove(wtpman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -339,44 +348,33 @@ static void wtpman_run(void *arg)
|
||||
CLIENT_IP);
|
||||
*/ wtpman_remove(wtpman);
|
||||
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_INFO,"Wait for next packedt");
|
||||
/* wait for next packet */
|
||||
rc = conn_q_wait_packet(conn,30);
|
||||
if (rc != 0){
|
||||
cw_dbg(DBG_INFO,"Wait for next packedt no next remove");
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
timer = cw_timer_start(wtpman->conn->wait_dtls);
|
||||
|
||||
cw_dbg(DBG_INFO,"Establish DTSL Timer done");
|
||||
|
||||
/* establish dtls session */
|
||||
if (!wtpman_establish_dtls(wtpman)) {
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
cw_dbg(DBG_INFO,"Establish DTSL Timer xxx");
|
||||
|
||||
|
||||
/* dtls is established, goto join state */
|
||||
if (!wtpman_join(wtpman, timer)) {
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
conn->msg_start = msg_start_handler;
|
||||
|
||||
|
||||
/*
|
||||
cw_dbg(DBG_INFO, "WTP from %s has joined with session id: %s",
|
||||
sock_addr2str_p(&conn->addr,sock_buf),
|
||||
format_bin2hex(conn->session_id,16));
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -387,7 +385,7 @@ cw_dbg(DBG_INFO,"Establish DTSL Timer xxx");
|
||||
*/
|
||||
|
||||
/* here the WTP has joined, now we assume an image data request
|
||||
or an configuration status request. Nothing else.
|
||||
or a configuration status request. Nothing else.
|
||||
*/
|
||||
|
||||
rc = 0;
|
||||
@ -403,14 +401,14 @@ cw_dbg(DBG_INFO,"Establish DTSL Timer xxx");
|
||||
if (!cw_result_is_ok(rc)) {
|
||||
cw_dbg(DBG_INFO, "WTP Problem: %s", cw_strrc(rc));
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (conn->capwap_state == CW_STATE_IMAGE_DATA) {
|
||||
wtpman_image_data(wtpman);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -437,14 +435,14 @@ cw_dbg(DBG_INFO,"Establish DTSL Timer xxx");
|
||||
|
||||
/*// cw_dbg(DBG_X, "Time left: %d",
|
||||
//*/
|
||||
cw_timer_timeleft(wtpman->echointerval_timer);
|
||||
/*cw_timer_timeleft(wtpman->echointerval_timer);*/
|
||||
|
||||
if (cw_timer_timeout(wtpman->echointerval_timer)) {
|
||||
|
||||
cw_dbg(DBG_INFO, "Lost connection to WTP:%s",
|
||||
sock_addr2str_p(&conn->addr,sock_buf));
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
// mavl_del_all(conn->outgoing);
|
||||
// conn_clear_upd(conn,1);
|
||||
@ -454,7 +452,7 @@ cw_dbg(DBG_INFO,"Establish DTSL Timer xxx");
|
||||
*/
|
||||
|
||||
|
||||
mavl_t r;
|
||||
|
||||
r = db_get_update_tasks(conn, sock_addr2str(&conn->addr,sock_buf));
|
||||
if (r) {
|
||||
|
||||
@ -512,7 +510,7 @@ cw_dbg(DBG_INFO,"Establish DTSL Timer xxx");
|
||||
|
||||
db_ping_wtp(sock_addr2str_p(&conn->addr,sock_buf), "");
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -552,18 +550,19 @@ void wtpman_destroy(struct wtpman *wtpman)
|
||||
|
||||
|
||||
|
||||
struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr)
|
||||
struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr, int dtlsmode)
|
||||
{
|
||||
int sockfd, replyfd;;
|
||||
struct sockaddr dbgaddr;
|
||||
socklen_t dbgaddrl;
|
||||
int sockfd, replyfd;
|
||||
char sock_buf[SOCK_ADDR_BUFSIZE];
|
||||
|
||||
struct wtpman *wtpman;
|
||||
wtpman = malloc(sizeof(struct wtpman));
|
||||
if (!wtpman)
|
||||
return 0;
|
||||
memset(wtpman, 0, sizeof(struct wtpman));
|
||||
|
||||
|
||||
|
||||
if (socklist[socklistindex].type != SOCKLIST_UNICAST_SOCKET) {
|
||||
|
||||
int port = sock_getport(&socklist[socklistindex].addr);
|
||||
@ -579,35 +578,52 @@ struct wtpman *wtpman_create(int socklistindex, struct sockaddr *srcaddr)
|
||||
replyfd = socklist[socklistindex].sockfd;
|
||||
}
|
||||
|
||||
sockfd = replyfd; /*//socklist[socklistindex].reply_sockfd;
|
||||
*/
|
||||
sockfd = replyfd; /*//socklist[socklistindex].reply_sockfd;*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct sockaddr dbgaddr;
|
||||
socklen_t dbgaddrl = sizeof(dbgaddr);
|
||||
|
||||
dbgaddrl = sizeof(dbgaddr);
|
||||
getsockname(sockfd, &dbgaddr, &dbgaddrl);
|
||||
|
||||
cw_dbg(DBG_INFO, "Creating wtpman on socket %d, %s:%d", sockfd,
|
||||
sock_addr2str(&dbgaddr,sock_buf), sock_getport(&dbgaddr));
|
||||
|
||||
/*
|
||||
//extern int conn_process_packet2(struct conn *conn, uint8_t * packet, int len,
|
||||
// struct sockaddr *from);
|
||||
*/
|
||||
|
||||
|
||||
wtpman->conn = conn_create(sockfd, srcaddr, 100);
|
||||
wtpman->conn->role = CW_ROLE_AC;
|
||||
|
||||
wtpman->conn->data_sock = socklist[socklistindex].data_sockfd;
|
||||
sock_copyaddr(&wtpman->conn->data_addr, (struct sockaddr *) &wtpman->conn->addr);
|
||||
|
||||
|
||||
/*
|
||||
// wtpman->conn->process_packet = conn_process_packet2;
|
||||
*/
|
||||
if (!wtpman->conn) {
|
||||
wtpman_destroy(wtpman);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* when created caused by a packet in DTLS mode, we try
|
||||
* to find out the modules to load, for detected connection
|
||||
* from discovery request */
|
||||
if (dtlsmode){
|
||||
int rc;
|
||||
struct cw_Mod *cmod, *bmod;
|
||||
|
||||
rc = discovery_cache_get(discovery_cache,srcaddr,&cmod,&bmod);
|
||||
if (rc){
|
||||
cw_dbg(DBG_INFO, "Initializing with mod %s %s",cmod,bmod);
|
||||
wtpman->conn->msgset = cw_mod_get_msg_set(wtpman->conn,cmod,bmod);
|
||||
wtpman->conn->detected=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
wtpman->conn->mods = conf_mods;
|
||||
|
||||
wtpman->conn->strict_capwap = conf_strict_capwap;
|
||||
@ -642,7 +658,7 @@ void wtpman_start(struct wtpman *wtpman, int dtlsmode)
|
||||
{
|
||||
cw_dbg(DBG_INFO, "Starting wtpman, DTLS mode = %d",dtlsmode);
|
||||
wtpman->dtlsmode=dtlsmode;
|
||||
pthread_create(&wtpman->thread, NULL, (void *) wtpman_run,
|
||||
pthread_create(&wtpman->thread, NULL, wtpman_run,
|
||||
(void *) wtpman);
|
||||
return;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ struct wtp{
|
||||
|
||||
struct wtpman * wtpman_create();
|
||||
|
||||
struct wtpman * wtpman_create(int socklistindex,struct sockaddr * srcaddr);
|
||||
struct wtpman * wtpman_create(int socklistindex,struct sockaddr * srcaddr, int dtlsmode);
|
||||
|
||||
extern void wtpman_addpacket(struct wtpman * wtpman,uint8_t *packet,int len);
|
||||
extern void wtpman_destroy(struct wtpman * wtpman);
|
||||
|
@ -178,6 +178,7 @@ struct conn {
|
||||
char *dtls_psk;
|
||||
int dtls_psk_len;
|
||||
|
||||
struct cw_Mod *cmod, *bmod;
|
||||
|
||||
char *dtls_cert_file;
|
||||
char *dtls_key_file;
|
||||
|
@ -173,11 +173,11 @@ static struct cw_MsgSet *load_msg_set(struct conn *conn, uint8_t * rawmsg, int l
|
||||
bmod =
|
||||
cw_mod_detect(conn, rawmsg, len, elems_len, from, CW_MOD_MODE_BINDINGS);
|
||||
|
||||
|
||||
cw_dbg(DBG_INFO, "Mods deteced: %s,%s", cmod->name, bmod->name);
|
||||
|
||||
/*
|
||||
// struct cw_actiondef *ad = mod_cache_add(conn,cmod, bmod);
|
||||
*/
|
||||
conn->cmod = cmod;
|
||||
conn->bmod = bmod;
|
||||
|
||||
return cw_mod_get_msg_set(conn,cmod,bmod);
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
capwap/ssl-certfile:Str:"../../ssl/certs/wtp.crt"
|
||||
capwap/ssl-keyfile:Str:"../../ssl/certs/wtp.key"
|
||||
capwap/ssl-cipher:Str:NORMAL
|
||||
capwap/ssl-cipher:Str:ALL
|
||||
|
||||
cisco/ssl-certfile:Str:"../../ssl/certs/wtp.crt"
|
||||
cisco/ssl-keyfile:Str:"../../ssl/certs/wtp.key"
|
||||
|
Loading…
Reference in New Issue
Block a user