2014-07-11 22:12:11 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
#include "wtplist.h"
|
|
|
|
|
|
|
|
#include "capwap.h"
|
2014-07-19 12:36:43 +02:00
|
|
|
#include "sock.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
#include "socklist.h"
|
|
|
|
|
|
|
|
#include "conn.h"
|
|
|
|
#include "wtpman.h"
|
|
|
|
#include "conf.h"
|
|
|
|
#include "cw_log.h"
|
|
|
|
|
|
|
|
#include "dtls.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "conf.h"
|
|
|
|
|
2014-07-26 20:25:06 +02:00
|
|
|
#include "lwmsg.h"
|
2014-08-25 07:56:14 +02:00
|
|
|
#include "lwapp.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
#include "capwap.h"
|
2014-08-23 12:05:45 +02:00
|
|
|
#include "capwap_cisco.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
#include "cw_util.h"
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-07-19 12:36:43 +02:00
|
|
|
/* macro to convert our client ip to a string */
|
2014-07-19 17:17:27 +02:00
|
|
|
#define CLIENT_IP (sock_addrtostr((struct sockaddr*)&wtpman->conn->addr, (char[64]){0},64))
|
2014-07-19 12:36:43 +02:00
|
|
|
|
|
|
|
|
2014-08-22 08:21:38 +02:00
|
|
|
void conn_handle_echo_request(struct conn * conn)
|
|
|
|
{
|
|
|
|
struct cwrmsg * cwrmsg = &conn->cwrmsg;
|
|
|
|
cwsend_echo_response(conn,cwrmsg->seqnum,0);
|
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
void conn_handle_change_state_event_request(struct conn * conn)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
static struct cwrmsg * conn_wait_for_message(struct conn * conn, time_t timer)
|
|
|
|
{
|
|
|
|
struct cwrmsg * cwrmsg;
|
2014-08-23 12:05:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
while (!cw_timer_timeout(timer)){
|
2014-08-17 18:47:24 +02:00
|
|
|
cwrmsg = conn_get_message(conn);
|
2014-08-23 12:05:45 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
if (!cwrmsg){
|
|
|
|
if (!conn_is_error(conn))
|
|
|
|
continue;
|
2014-08-23 12:05:45 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-23 12:05:45 +02:00
|
|
|
|
|
|
|
if (cwrmsg->type & 1){
|
|
|
|
if (conn->request_handler){
|
2014-08-24 15:07:30 +02:00
|
|
|
if (conn->request_handler(conn->request_handler_param))
|
|
|
|
continue;
|
2014-08-17 18:47:24 +02:00
|
|
|
}
|
2014-08-23 12:05:45 +02:00
|
|
|
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
}
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
return cwrmsg;
|
2014-08-17 18:47:24 +02:00
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
}
|
2014-08-17 18:47:24 +02:00
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2014-08-17 18:47:24 +02:00
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
struct rh_param{
|
|
|
|
struct conn * conn;
|
|
|
|
int *msglist;
|
2014-08-24 11:10:46 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static int conn_rh(void *param)
|
|
|
|
{
|
|
|
|
struct rh_param * p = (struct rh_param*)param;
|
|
|
|
int i;
|
|
|
|
int *msglist=p->msglist;
|
|
|
|
|
|
|
|
for (i=0; msglist[i]!=-1; i++){
|
|
|
|
if (msglist[i] == p->conn->cwrmsg.type )
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
/* unexpected response here */
|
|
|
|
cw_log(LOG_ERR,"Unexpected message from %s",sock_addr2str(&p->conn->addr));
|
|
|
|
cwsend_unknown_response(p->conn,p->conn->cwrmsg.seqnum,p->conn->cwrmsg.type);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct cwrmsg * conn_wait_for_request(struct conn * conn, int *msglist, time_t timer)
|
2014-08-24 11:10:46 +02:00
|
|
|
{
|
2014-08-24 15:07:30 +02:00
|
|
|
int (*request_handler_save) (void*);
|
|
|
|
void * request_handler_param_save;
|
|
|
|
|
|
|
|
struct rh_param rh_param;
|
|
|
|
|
|
|
|
|
|
|
|
if (msglist){
|
|
|
|
request_handler_save=conn->request_handler;
|
|
|
|
request_handler_param_save=conn->request_handler_param;
|
|
|
|
rh_param.conn=conn;
|
|
|
|
rh_param.msglist=msglist;
|
|
|
|
conn->request_handler=conn_rh;
|
|
|
|
conn->request_handler_param=&rh_param;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
struct cwrmsg * cwrmsg;
|
2014-08-24 15:07:30 +02:00
|
|
|
while (!cw_timer_timeout(timer)){
|
|
|
|
cwrmsg = conn_wait_for_message(conn,timer);
|
|
|
|
if (!cwrmsg){
|
|
|
|
if (!conn_is_error(conn))
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* response message? no action*/
|
|
|
|
if (! (cwrmsg->type & 1) )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* it's a request message */
|
|
|
|
break;
|
|
|
|
}
|
2014-08-24 11:10:46 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
if (msglist){
|
|
|
|
conn->request_handler=request_handler_save;
|
|
|
|
conn->request_handler_param=request_handler_param_save;
|
|
|
|
}
|
|
|
|
|
|
|
|
return cwrmsg;
|
2014-08-24 11:10:46 +02:00
|
|
|
}
|
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
struct cwrmsg * conn_send_request(struct conn * conn)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
struct cwrmsg * cwrmsg;
|
|
|
|
struct cwmsg * cwmsg = &conn->req_msg;
|
|
|
|
|
2014-08-25 07:56:14 +02:00
|
|
|
printf("Retrans interval = %d\n",conn->retransmit_interval);
|
|
|
|
printf("Current Seqnum = %d\n",conn->seqnum);
|
2014-08-23 12:05:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
for (i=0; i<conn->max_retransmit; i++) {
|
|
|
|
|
|
|
|
time_t r_timer = cw_timer_start(conn->retransmit_interval);
|
|
|
|
if (i!=0)
|
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"Retransmitting message, type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
|
|
|
|
|
|
|
conn_send_cwmsg(conn,&conn->req_msg);
|
|
|
|
cwrmsg = conn_wait_for_message(conn,r_timer);
|
|
|
|
if (cwrmsg){
|
|
|
|
if (cwrmsg->type == conn->req_msg.type+1){
|
|
|
|
printf("YeaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA!!!!!\n");
|
|
|
|
return cwrmsg;
|
|
|
|
}
|
|
|
|
|
|
|
|
// cw_dbg(DBG_CW_MSG_ERR,"Wrong message blablub, type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
|
|
|
return 0;
|
2014-08-17 18:47:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
int wtpman_handle_request(void *p)
|
2014-08-23 12:05:45 +02:00
|
|
|
{
|
|
|
|
struct wtpman * wtpman = (struct wtpman *)p;
|
|
|
|
struct conn * conn = wtpman->conn;
|
|
|
|
struct cwrmsg * cwrmsg = &conn->cwrmsg;
|
|
|
|
switch(conn->cwrmsg.type){
|
|
|
|
case CWMSG_ECHO_REQUEST:
|
|
|
|
conn_handle_echo_request(conn);
|
|
|
|
break;
|
|
|
|
case CWMSG_CHANGE_STATE_EVENT_REQUEST:
|
|
|
|
cwread_change_state_event_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
|
|
|
cwsend_change_state_event_response(wtpman->conn,cwrmsg->seqnum,wtpman->wtpinfo.radioinfo);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("Unhandeleed message %d!!!!!!!!!!!!\n",cwrmsg->type);
|
|
|
|
cwsend_unknown_response(conn,cwrmsg->seqnum,cwrmsg->type);
|
|
|
|
}
|
2014-08-24 15:07:30 +02:00
|
|
|
return 1;
|
2014-08-23 12:05:45 +02:00
|
|
|
}
|
2014-08-17 18:47:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
void send_image_file(struct conn * conn,const char * filename)
|
|
|
|
{
|
|
|
|
FILE * infile;
|
|
|
|
infile = fopen(filename,"rb");
|
|
|
|
if (!infile){
|
|
|
|
cw_log(LOG_ERR,"Can't open image file %s:%s",filename,strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 07:56:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
cw_log(LOG_INFO,"Sending image file %s to %s",filename,sock_addr2str(&conn->addr));
|
|
|
|
|
|
|
|
struct cwrmsg * cwrmsg;
|
|
|
|
uint8_t buffer[1024];
|
|
|
|
struct image_data data;
|
|
|
|
data.data = buffer;
|
|
|
|
|
|
|
|
|
2014-08-25 07:56:14 +02:00
|
|
|
conn->request_handler = conn_handle_echo_request;
|
|
|
|
conn->request_handler_param = conn;
|
|
|
|
|
|
|
|
int bl=0;
|
|
|
|
|
|
|
|
//fseek(infile,2703*1024,SEEK_SET);
|
2014-08-17 18:47:24 +02:00
|
|
|
do{
|
2014-08-25 07:56:14 +02:00
|
|
|
|
2014-08-25 23:40:25 +02:00
|
|
|
data.len = fread(buffer,1,sizeof(buffer),infile);
|
|
|
|
//data.len=0;
|
2014-08-25 07:56:14 +02:00
|
|
|
|
2014-08-25 23:40:25 +02:00
|
|
|
/*
|
|
|
|
memset(buffer,0xff,1024);
|
|
|
|
memset(buffer+100,7,77);
|
|
|
|
memset(buffer+300,251,77);
|
|
|
|
buffer[1000]=99;
|
|
|
|
buffer[777]=99;
|
|
|
|
buffer[778]=199;
|
|
|
|
buffer[178]=199;
|
|
|
|
buffer[179]=199;
|
|
|
|
buffer[279]=199;
|
|
|
|
buffer[319]=219;
|
|
|
|
|
|
|
|
*/
|
2014-08-25 07:56:14 +02:00
|
|
|
int ai;
|
|
|
|
for (ai=0; ai<1024; ai++){
|
|
|
|
printf("%02X ",buffer[ai]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
if (feof(infile))
|
|
|
|
data.type=2;
|
|
|
|
else
|
|
|
|
data.type=1;
|
2014-08-25 07:56:14 +02:00
|
|
|
|
|
|
|
if (data.len==0){
|
|
|
|
printf("*******************************************len0************************************\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Send img data request, block=%d, len=%d, ch=%d\n",bl,data.len,lw_checksum(data.data,data.len));
|
|
|
|
|
|
|
|
//exit(0);
|
|
|
|
|
|
|
|
bl++;
|
|
|
|
|
|
|
|
conn_prepare_image_data_request(conn,&data,0);
|
|
|
|
cwrmsg = conn_send_request(conn);
|
|
|
|
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
if (cwrmsg){
|
|
|
|
printf("Got img data response\n");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
printf("Respnse Timeout\n");
|
2014-08-18 01:45:08 +02:00
|
|
|
exit(0);
|
2014-08-17 18:47:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}while(!feof(infile));
|
|
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
//ACIPLIST * get_aciplist();
|
2014-07-11 22:12:11 +02:00
|
|
|
struct ac_info * get_acinfo();
|
|
|
|
|
|
|
|
static void wtpman_remove(struct wtpman * wtpman)
|
|
|
|
{
|
|
|
|
wtplist_lock();
|
|
|
|
wtplist_remove(wtpman);
|
|
|
|
wtplist_unlock();
|
|
|
|
wtpman_destroy(wtpman);
|
|
|
|
}
|
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Waits for a capwap message until message is received or timeout occurs
|
|
|
|
* Returns NULL if timeout
|
|
|
|
* Returns pointer to cwrms if message is received
|
|
|
|
* Returns EOF in case of any other error
|
|
|
|
*/
|
|
|
|
static struct cwrmsg * wtpman_wait_for_message(struct wtpman * wtpman, time_t timer)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
|
|
|
struct cwrmsg * cwrmsg;
|
2014-08-16 16:09:24 +02:00
|
|
|
do {
|
2014-07-11 22:12:11 +02:00
|
|
|
cwrmsg = conn_get_message(wtpman->conn);
|
2014-08-16 16:09:24 +02:00
|
|
|
if (!cwrmsg && wtpman->conn->dtls_error)
|
|
|
|
return (struct cwrmsg*)EOF;
|
|
|
|
if (!cwrmsg && cw_timer_timeout(timer))
|
|
|
|
return NULL;
|
2014-07-28 07:07:20 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
}while(!cwrmsg);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
cw_dbg(DBG_CW_MSG,"Received message from %s, type=%d - %s"
|
|
|
|
,CLIENT_IP,cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
return cwrmsg;
|
|
|
|
}
|
2014-07-26 20:25:06 +02:00
|
|
|
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
static void wtpman_run_discovery(void *arg)
|
|
|
|
{
|
2014-08-17 18:47:24 +02:00
|
|
|
|
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
struct wtpman * wtpman = (struct wtpman *)arg;
|
|
|
|
struct cwrmsg * cwrmsg;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
time_t timer = cw_timer_start(10);
|
|
|
|
cwrmsg = wtpman_wait_for_message(wtpman, timer);
|
2014-07-28 07:07:20 +02:00
|
|
|
|
2014-08-25 23:40:25 +02:00
|
|
|
if ( !cwrmsg )
|
2014-08-16 16:09:24 +02:00
|
|
|
{
|
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"No complete message from %s received after %d seconds",CLIENT_IP,10);
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
2014-07-28 07:07:20 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
|
|
|
|
if (cwrmsg->type!=CWMSG_DISCOVERY_REQUEST){
|
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"Invalid message in discovery state from %s, type=%s - %s ",
|
|
|
|
CLIENT_IP,cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
2014-07-28 07:07:20 +02:00
|
|
|
|
|
|
|
|
2014-08-25 23:40:25 +02:00
|
|
|
cwread_discovery_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-08-25 23:40:25 +02:00
|
|
|
char wtpinfostr[8192];
|
|
|
|
wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
|
|
|
cw_dbg(DBG_CW_INFO,"Discovery request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
|
|
|
|
2014-09-14 22:46:14 +02:00
|
|
|
//exit(0);
|
2014-07-28 07:07:20 +02:00
|
|
|
|
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
struct radioinfo radioinfo;
|
|
|
|
radioinfo.rid = cwrmsg->rid;
|
|
|
|
memcpy(radioinfo.rmac, cwrmsg->rmac,8);
|
|
|
|
radioinfo.rmac[0]=0;
|
2014-07-28 07:07:20 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
struct ac_info * acinfo = get_acinfo();
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-25 23:40:25 +02:00
|
|
|
/* char wtpinfostr[8192];
|
2014-08-16 16:09:24 +02:00
|
|
|
wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
|
|
|
cw_dbg(DBG_CW_INFO,"Discovery request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
2014-08-25 23:40:25 +02:00
|
|
|
*/
|
2014-08-16 15:13:40 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
cwsend_discovery_response(wtpman->conn,cwrmsg->seqnum,&radioinfo,acinfo,&wtpman->wtpinfo);
|
2014-08-16 15:13:40 +02:00
|
|
|
|
2014-08-16 16:09:24 +02:00
|
|
|
wtpman_remove(wtpman);
|
2014-08-16 15:13:40 +02:00
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-07-19 12:36:43 +02:00
|
|
|
|
2014-08-22 08:21:38 +02:00
|
|
|
static void wtpman_run_run(void *arg)
|
|
|
|
{
|
|
|
|
struct wtpman * wtpman = (struct wtpman *)arg;
|
2014-08-23 12:05:45 +02:00
|
|
|
struct conn * conn = wtpman->conn;
|
|
|
|
|
|
|
|
struct cwrmsg * cwrmsg;
|
|
|
|
|
|
|
|
|
|
|
|
conn->request_handler=wtpman_handle_request;
|
|
|
|
conn->request_handler_param=wtpman;
|
|
|
|
|
|
|
|
|
|
|
|
int i;
|
2014-08-24 11:10:46 +02:00
|
|
|
for (i=0; i<10; i++){
|
2014-08-23 12:05:45 +02:00
|
|
|
time_t t = cw_timer_start(1);
|
|
|
|
printf("Wait...\n");
|
|
|
|
conn_wait_for_message(conn,t);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("Update now?\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
conn_prepare_request(conn,CWMSG_CONFIGURATION_UPDATE_REQUEST);
|
2014-08-24 11:10:46 +02:00
|
|
|
cwmsg_addelem(&conn->req_msg,CWMSGELEM_WTP_NAME,(uint8_t*)"Tube7u83",strlen("Tube7u83")+1);
|
|
|
|
cwmsg_addelem(&conn->req_msg,CWMSGELEM_LOCATION_DATA,(uint8_t*)"Berlin",strlen("Berlin")+1);
|
2014-08-23 12:05:45 +02:00
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
cwmsg_addelem_vendor_specific_payload(&conn->req_msg,CW_VENDOR_ID_CISCO,CWVENDOR_CISCO_RAD_NAME,(uint8_t*)"CiscoClient",strlen("CiscoClient"));
|
2014-08-23 12:05:45 +02:00
|
|
|
|
|
|
|
cwrmsg = conn_send_request(conn);
|
2014-08-22 08:21:38 +02:00
|
|
|
|
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
for (i=0; i<10; i++){
|
2014-08-23 12:05:45 +02:00
|
|
|
time_t t = cw_timer_start(1);
|
|
|
|
printf("Wait...\n");
|
|
|
|
conn_wait_for_message(conn,t);
|
2014-08-22 08:21:38 +02:00
|
|
|
}
|
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
/* conn_prepare_request(conn,CWMSG_RESET_REQUEST);
|
|
|
|
cwmsg_addelem_image_identifier(&conn->req_msg,CW_VENDOR_ID_CISCO,"image00",strlen("image00"));
|
|
|
|
cwrmsg = conn_send_request(conn);
|
|
|
|
*/
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
printf("Set name?\n");
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
2014-08-22 08:21:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
|
|
|
|
static int wtpman_establish_dtls(void *arg)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
|
|
|
struct wtpman * wtpman = (struct wtpman *)arg;
|
2014-08-24 11:10:46 +02:00
|
|
|
|
|
|
|
/* setup cipher */
|
2014-08-16 10:10:00 +02:00
|
|
|
wtpman->conn->dtls_cipher=CAPWAP_CIPHER;
|
2014-08-02 14:22:37 +02:00
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
/* setup DTSL certificates */
|
2014-08-02 14:22:37 +02:00
|
|
|
int dtls_ok=0;
|
|
|
|
if (conf_sslkeyfilename && conf_sslcertfilename){
|
|
|
|
wtpman->conn->dtls_key_file = conf_sslkeyfilename;
|
|
|
|
wtpman->conn->dtls_cert_file = conf_sslcertfilename;
|
|
|
|
wtpman->conn->dtls_key_pass = conf_sslkeypass;
|
2014-08-16 14:05:41 +02:00
|
|
|
wtpman->conn->dtls_verify_peer = conf_dtls_verify_peer;
|
2014-08-02 14:22:37 +02:00
|
|
|
dtls_ok=1;
|
|
|
|
}
|
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
/* setup DTLS psk */
|
2014-08-02 14:22:37 +02:00
|
|
|
if (conf_dtls_psk){
|
|
|
|
wtpman->conn->dtls_psk=conf_dtls_psk;
|
|
|
|
wtpman->conn->dtls_psk_len=strlen(conf_dtls_psk);
|
|
|
|
dtls_ok=1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dtls_ok){
|
2014-08-16 10:10:00 +02:00
|
|
|
cw_log(LOG_ERR,"Can't establish DTLS session, neither psk nor certs set in config file.");
|
2014-08-24 11:10:46 +02:00
|
|
|
return 0;
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
2014-07-28 07:07:20 +02:00
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
/* try to accept the connection */
|
2014-07-11 22:12:11 +02:00
|
|
|
if ( !dtls_accept(wtpman->conn) ){
|
2014-08-16 10:10:00 +02:00
|
|
|
cw_dbg(DBG_DTLS,"Error establishing DTLS session with %s",CLIENT_IP);
|
2014-08-24 11:10:46 +02:00
|
|
|
return 0;
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
2014-07-29 07:50:06 +02:00
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
cw_dbg(DBG_DTLS,"DTLS session established with %s, cipher=%s", CLIENT_IP,dtls_get_cipher(wtpman->conn));
|
|
|
|
/* DTLS handshake done */
|
2014-07-19 12:36:43 +02:00
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
static int wtpman_join(void *arg,time_t timer)
|
2014-08-24 11:10:46 +02:00
|
|
|
{
|
|
|
|
struct wtpman * wtpman = (struct wtpman *)arg;
|
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
/* timer = cw_timer_start(wtpman->conn->wait_join); */
|
2014-08-16 10:10:00 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
int join_msgs[] = { CWMSG_JOIN_REQUEST, -1 };
|
|
|
|
struct cwrmsg * cwrmsg;
|
|
|
|
cwrmsg = conn_wait_for_request(wtpman->conn, join_msgs, timer);
|
2014-08-25 07:56:14 +02:00
|
|
|
|
2014-08-16 15:13:40 +02:00
|
|
|
if (!cwrmsg){
|
2014-08-24 15:07:30 +02:00
|
|
|
if (conn_is_error(wtpman->conn)){
|
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"DTLS connection closed while waiting for join request from %s.",CLIENT_IP);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-16 15:13:40 +02:00
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"No join request from %s after %d seconds, WTP died.",
|
2014-08-24 15:07:30 +02:00
|
|
|
sock_addr2str(&wtpman->conn->addr),wtpman->conn->wait_dtls);
|
|
|
|
return 0;
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
|
|
|
process_join_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
|
|
|
|
2014-08-16 15:13:40 +02:00
|
|
|
{
|
2014-08-16 10:10:00 +02:00
|
|
|
char wtpinfostr[8192];
|
|
|
|
wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
|
|
|
cw_dbg(DBG_CW_INFO,"Join request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
2014-08-16 15:13:40 +02:00
|
|
|
}
|
2014-08-16 10:10:00 +02:00
|
|
|
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
struct radioinfo radioinfo;
|
|
|
|
radioinfo.rid = cwrmsg->rid;
|
2014-07-28 07:07:20 +02:00
|
|
|
memcpy (radioinfo.rmac, cwrmsg->rmac,8);
|
2014-07-11 22:12:11 +02:00
|
|
|
struct ac_info * acinfo = get_acinfo();
|
|
|
|
|
|
|
|
|
2014-08-14 19:37:06 +02:00
|
|
|
int result_code = 0;
|
2014-08-16 10:10:00 +02:00
|
|
|
cw_dbg(DBG_CW_MSG,"Sending join response to %s",CLIENT_IP);
|
2014-07-11 22:12:11 +02:00
|
|
|
cwsend_join_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
|
2014-08-16 15:13:40 +02:00
|
|
|
cw_log(LOG_INFO,"WTP joined, Name = %s, Location = %s, IP = %s",
|
|
|
|
wtpman->wtpinfo.name,wtpman->wtpinfo.location,
|
|
|
|
sock_addr2str(&wtpman->conn->addr));
|
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void wtpman_run(void *arg)
|
|
|
|
{
|
|
|
|
struct wtpman * wtpman = (struct wtpman *)arg;
|
2014-08-25 07:56:14 +02:00
|
|
|
struct cwrmsg * cwrmsg; // = conn_get_message(wtpman->conn);
|
|
|
|
|
|
|
|
wtpman->conn->seqnum=0;
|
2014-08-24 15:07:30 +02:00
|
|
|
|
|
|
|
/* reject connections to our multi- or broadcast sockets */
|
|
|
|
if (socklist[wtpman->socklistindex].type != SOCKLIST_UNICAST_SOCKET){
|
|
|
|
cw_dbg(DBG_DTLS,"Dropping connection from %s to non-unicast socket.", CLIENT_IP);
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
time_t timer = cw_timer_start(wtpman->conn->wait_dtls);
|
|
|
|
|
|
|
|
/* establish dtls session*/
|
|
|
|
if (!wtpman_establish_dtls(wtpman)){
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* dtls is established, goto join state */
|
|
|
|
if (!wtpman_join(wtpman,timer)){
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-25 07:56:14 +02:00
|
|
|
/* here the WTP has joined, now image update or change state event */
|
|
|
|
|
|
|
|
int msgs[] = { CWMSG_IMAGE_DATA_REQUEST, CWMSG_CHANGE_STATE_EVENT_REQUEST, -1 };
|
|
|
|
cwrmsg = conn_wait_for_request(wtpman->conn, msgs, timer);
|
|
|
|
|
|
|
|
if (!cwrmsg){
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (cwrmsg->type){
|
|
|
|
case CWMSG_CHANGE_STATE_EVENT_REQUEST:
|
|
|
|
printf("Change state event\n!");
|
|
|
|
break;
|
|
|
|
case CWMSG_IMAGE_DATA_REQUEST:
|
|
|
|
printf("Image update\n!");
|
|
|
|
cwsend_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_SUCCESS);
|
|
|
|
// send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAO5.tar");
|
|
|
|
// send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-k9w8-tar.124-25e.JAP.tar");
|
|
|
|
send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAP.tar");
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
|
2014-08-16 15:13:40 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
printf("WTP is joined now\n");
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
int result_code = 0;
|
|
|
|
struct radioinfo * radioinfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-16 15:13:40 +02:00
|
|
|
cwrmsg = wtpman_wait_for_message(wtpman,timer);
|
|
|
|
if (!cwrmsg){
|
|
|
|
cw_dbg(DBG_CW_MSG_ERR,"No config or update request from %s after %d seconds, WTP died.",
|
2014-08-18 01:45:08 +02:00
|
|
|
sock_addr2str(&wtpman->conn->addr),wtpman->conn->wait_join);
|
2014-08-16 15:13:40 +02:00
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-24 11:10:46 +02:00
|
|
|
printf("CWR TYPE %d\n",cwrmsg->type);
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
// cwread_configuration_status_request(&wtpman->wtpinfo,cwrmsg->msgelems, cwrmsg->msgelems_len);
|
|
|
|
// cwsend_conf_status_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
|
2014-08-18 01:45:08 +02:00
|
|
|
|
|
|
|
char wtpinfostr[8192];
|
|
|
|
wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
|
|
|
cw_dbg(DBG_ALL,"WTP conf_status\n%s",wtpinfostr);
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
printf("Run run run run run\n");
|
|
|
|
wtpman_run_run(wtpman);
|
|
|
|
exit(0);
|
2014-08-18 01:45:08 +02:00
|
|
|
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
int ii;
|
|
|
|
for (ii=0; ii<3; ii++){
|
2014-08-18 01:45:08 +02:00
|
|
|
cwrmsg = wtpman_wait_for_message(wtpman,timer);
|
|
|
|
if (cwrmsg){
|
|
|
|
if (cwrmsg->type == CWMSG_CHANGE_STATE_EVENT_REQUEST){
|
2014-08-23 12:05:45 +02:00
|
|
|
cwread_change_state_event_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
|
|
|
cwsend_change_state_event_response(wtpman->conn,cwrmsg->seqnum,wtpman->wtpinfo.radioinfo);
|
2014-08-18 01:45:08 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2014-08-23 12:05:45 +02:00
|
|
|
}
|
|
|
|
|
2014-08-18 01:45:08 +02:00
|
|
|
|
2014-08-22 08:21:38 +02:00
|
|
|
wtpman_run_run(wtpman);
|
|
|
|
|
2014-08-18 01:45:08 +02:00
|
|
|
exit(0);
|
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
|
|
|
|
if (cwrmsg->type==CWMSG_IMAGE_DATA_REQUEST){
|
|
|
|
cwread_image_data_request(0,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
2014-08-18 01:45:08 +02:00
|
|
|
cwsend_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_FAILURE);
|
2014-08-17 18:47:24 +02:00
|
|
|
}
|
2014-08-18 01:45:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2014-08-17 18:47:24 +02:00
|
|
|
printf("Sending image file\n");
|
|
|
|
send_image_file(wtpman->conn,"/home/tube/Downloads/c1130-rcvk9w8-tar.124-25e.JAO5.tar");
|
|
|
|
printf("Back from sending image file\n");
|
2014-08-18 01:45:08 +02:00
|
|
|
*/
|
|
|
|
exit(0);
|
2014-08-17 18:47:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
timer = cw_timer_start(30);
|
|
|
|
cwrmsg = wtpman_wait_for_message(wtpman,timer);
|
|
|
|
|
|
|
|
if (cwrmsg)
|
|
|
|
printf("I have got a message of type %d\n",cwrmsg->type);
|
|
|
|
|
|
|
|
if (cwrmsg->type==CWMSG_IMAGE_DATA_REQUEST){
|
|
|
|
cwread_image_data_request(0,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
|
|
|
cwsend_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_FAILURE);
|
|
|
|
}
|
2014-08-16 15:13:40 +02:00
|
|
|
|
2014-08-17 18:47:24 +02:00
|
|
|
|
|
|
|
|
2014-08-16 15:13:40 +02:00
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
// char wtpinfostr[8192];
|
|
|
|
// wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
|
|
|
// cw_log_debug0("WTP joined\n%s",wtpinfostr);
|
2014-07-19 20:35:08 +02:00
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
//exit(0);
|
2014-07-19 20:35:08 +02:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
int msg_counter = 0;
|
|
|
|
while(1){
|
|
|
|
struct cwrmsg * cwrmsg = conn_get_message(wtpman->conn);
|
2014-08-16 10:10:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
if (!cwrmsg) {
|
|
|
|
msg_counter++;
|
|
|
|
if (msg_counter < CAPWAP_ECHO_INTERVAL *2 )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cw_log_debug0("WTP died");
|
|
|
|
wtpman_remove(wtpman);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-16 10:10:00 +02:00
|
|
|
|
2014-08-24 15:07:30 +02:00
|
|
|
/*
|
2014-08-23 12:05:45 +02:00
|
|
|
if (cwrmsg->type == CWMSG_CONFIGURATION_STATUS_REQUEST){
|
2014-08-16 10:10:00 +02:00
|
|
|
process_conf_status_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
|
|
|
{
|
|
|
|
char wtpinfostr[8192];
|
|
|
|
wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
|
|
|
cw_dbg(DBG_CW_INFO,"Join request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
|
|
|
|
|
|
|
cwsend_conf_status_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2014-08-24 15:07:30 +02:00
|
|
|
*/
|
2014-07-11 22:12:11 +02:00
|
|
|
msg_counter=0;
|
|
|
|
|
|
|
|
|
2014-07-26 20:25:06 +02:00
|
|
|
if (cwrmsg->type == CWMSG_ECHO_REQUEST){
|
2014-07-11 22:12:11 +02:00
|
|
|
cwsend_echo_response(wtpman->conn,cwrmsg->seqnum,wtpman->wtpinfo.radioinfo);
|
|
|
|
}
|
2014-08-16 10:10:00 +02:00
|
|
|
// printf("Got msg: %i\n",cwrmsg->type);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// process_discovery(wtpman,cwrmsg);
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
printf("Messag gote ssl\n");
|
|
|
|
|
|
|
|
printf("Precdeis sssl\n");
|
|
|
|
|
|
|
|
printf ("SEQNUM REC: %i\n",cwrmsg->seqnum);
|
|
|
|
|
|
|
|
printf("procdis ende\n");
|
|
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
sem_wait(&wtpman->q_sem);
|
|
|
|
int qrpos = wtpman->qrpos+1;
|
|
|
|
if (qrpos==WTPMAN_QSIZE)
|
|
|
|
qrpos=0;
|
|
|
|
wtpman->qrpos=qrpos;
|
|
|
|
|
|
|
|
uint8_t * packet = wtpman->q[qrpos]+4;
|
|
|
|
int len = *( (uint32_t*)(wtpman->q[qrpos]));
|
|
|
|
*/
|
|
|
|
uint8_t * packet = conn_q_get_packet(wtpman->conn);
|
2014-08-23 12:05:45 +02:00
|
|
|
// int len = *( (uint32_t*)(packet));
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
// conn_process_packet(wtpman->conn,packet+4,len);
|
|
|
|
free(packet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void wtpman_destroy(struct wtpman * wtpman)
|
|
|
|
{
|
|
|
|
if ( wtpman->conn)
|
|
|
|
conn_destroy(wtpman->conn);
|
|
|
|
free (wtpman);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct wtpman * wtpman_create(int socklistindex,struct sockaddr * srcaddr)
|
|
|
|
{
|
|
|
|
struct wtpman * wtpman;
|
|
|
|
wtpman = malloc(sizeof(struct wtpman));
|
|
|
|
if (!wtpman)
|
|
|
|
return 0;
|
|
|
|
memset (wtpman,0,sizeof(struct wtpman));
|
|
|
|
|
|
|
|
int sockfd = socklist[socklistindex].reply_sockfd;
|
|
|
|
|
|
|
|
wtpman->conn=conn_create(sockfd,srcaddr,100);
|
|
|
|
if (!wtpman->conn){
|
|
|
|
wtpman_destroy(wtpman);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wtpman;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wtpman_addpacket(struct wtpman * wtpman,uint8_t *packet,int len)
|
|
|
|
{
|
|
|
|
conn_q_add_packet(wtpman->conn,packet,len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-26 20:25:06 +02:00
|
|
|
void wtpman_lw_addpacket(struct wtpman *wtpman, uint8_t *packet, int len)
|
|
|
|
{
|
2014-08-23 12:05:45 +02:00
|
|
|
// uint8_t * m = packet+12;
|
2014-08-16 16:09:24 +02:00
|
|
|
// int l = LWTH_GET_LENGTH(packet+6);
|
2014-07-26 20:25:06 +02:00
|
|
|
|
|
|
|
uint8_t * msg = packet+12;
|
|
|
|
|
|
|
|
|
|
|
|
int msgtype = LWMSG_GET_TYPE(msg);
|
|
|
|
int msglen = LWMSG_GET_LEN(msg);
|
|
|
|
printf ("Type is %d, Len is %d\n",msgtype,msglen);
|
|
|
|
|
|
|
|
uint8_t * msgdata = LWMSG_GET_DATA(msg);
|
|
|
|
|
|
|
|
/*
|
|
|
|
int c=0;
|
|
|
|
while (c < msglen){
|
|
|
|
int eltype = LWMSGELEM_GET_TYPE(data);
|
|
|
|
int ellen = LWMSGELEM_GET_LEN(data);
|
|
|
|
printf ("ELEM TYPE: %d, LEN: %d\n",eltype,ellen);
|
|
|
|
c+=ellen+3;
|
|
|
|
data=data+ellen+3;
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint8_t * data;
|
|
|
|
|
|
|
|
lw_foreach_msgelem(data,msgdata,msglen){
|
|
|
|
int eltype = LWMSGELEM_GET_TYPE(data);
|
|
|
|
int ellen = LWMSGELEM_GET_LEN(data);
|
|
|
|
uint8_t * eldata = LWMSGELEM_GET_DATA(data);
|
|
|
|
|
|
|
|
wtpinfo_lwreadelem_wtp_descriptor(&wtpman->wtpinfo,eltype,eldata,ellen);
|
|
|
|
|
|
|
|
printf ("ELEM TYPE: %d, LEN: %d\n",eltype,ellen);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
char wi[4096];
|
|
|
|
wtpinfo_print(wi,&wtpman->wtpinfo);
|
|
|
|
printf ("WTPINFO: \n%s\n",wi);
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
// char buffer[2048];
|
|
|
|
// struct lwmsg lwmsg;
|
|
|
|
// lwmsg_init(&lwmsg, buffer,conf_macaddress,LWMSG_DISCOVERY_RESPONSE,conn_get_next_seqnum(wtpman->conn));
|
2014-07-26 20:25:06 +02:00
|
|
|
|
2014-08-23 12:05:45 +02:00
|
|
|
// conn_send_packet(wtpman->conn,buffer,60);
|
2014-07-26 20:25:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
void wtpman_start(struct wtpman * wtpman,int dtlsmode)
|
|
|
|
{
|
2014-07-26 20:25:06 +02:00
|
|
|
if ( dtlsmode ){
|
|
|
|
cw_log_debug1("Starting wtpman in dtls mode");
|
2014-07-11 22:12:11 +02:00
|
|
|
pthread_create (&wtpman->thread, NULL, (void *) &wtpman_run, (void *) wtpman);
|
2014-07-26 20:25:06 +02:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
cw_log_debug1("Starting wtpman in non-dtls mode");
|
2014-07-11 22:12:11 +02:00
|
|
|
pthread_create (&wtpman->thread, NULL, (void *) &wtpman_run_discovery, (void *) wtpman);
|
2014-07-26 20:25:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void wtpman_lw_start(struct wtpman * wtpman)
|
|
|
|
{
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|
2014-07-26 20:25:06 +02:00
|
|
|
|
|
|
|
|