VM
FossilOrigin-Name: 4bbb8402b5110003c6d19908b6fa9b4a7a6b5903ba1fa691eb93a49aa0f089f4
This commit is contained in:
parent
a4175d4cce
commit
4c0d06e21d
@ -14,7 +14,7 @@ USE_CONTRIB_GNUTLS=1
|
||||
|
||||
# Compiler to use
|
||||
CC=clang
|
||||
#CC=gcca
|
||||
#CC=gcc
|
||||
#CC=mips-openwrt-linux-uclibc-gcc
|
||||
#LD=mips-openwrt-linux-uclibc-ld
|
||||
#AR=mips-openwrt-linux-uclibc-ar
|
||||
|
@ -11,7 +11,7 @@ ifndef ARCH
|
||||
endif
|
||||
|
||||
LDFLAGS+=-g -D_REENTRANT -L/usr/local/lib -L../capwap/$(ARCH)
|
||||
CFLAGS += -Wall -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../capwap
|
||||
CFLAGS += -Wall -g -O0 -D_REENTRANT -DIPV6 -I/usr/local/include -I../
|
||||
|
||||
|
||||
LIBS+=-lcapwap
|
||||
|
@ -3,11 +3,11 @@
|
||||
|
||||
#include "ac.h"
|
||||
#include "conf.h"
|
||||
#include "capwap.h"
|
||||
#include "capwap_items.h"
|
||||
#include "aciplist.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
#include "capwap/aciplist.h"
|
||||
#include "socklist.h"
|
||||
#include "sock.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
struct cw_ac_status ac_status;
|
||||
|
||||
@ -93,11 +93,14 @@ int ac_global_init()
|
||||
ac_status.dtls_policy = CW_FLAG_DTLS_POLICY_C | CW_FLAG_DTLS_POLICY_D;
|
||||
|
||||
|
||||
cw_itemstore_set_version(ac_config, CW_ITEM_AC_HARDWARE_VERSION, 0,
|
||||
cw_itemstore_set_vendorstr(ac_config, CW_ITEM_AC_HARDWARE_VERSION, 0,
|
||||
bstr_data(conf_hardware_version), bstr_len(conf_hardware_version));
|
||||
cw_itemstore_set_version(ac_config, CW_ITEM_AC_SOFTWARE_VERSION, 0,
|
||||
cw_itemstore_set_vendorstr(ac_config, CW_ITEM_AC_SOFTWARE_VERSION, 0,
|
||||
bstr_data(conf_software_version), bstr_len(conf_software_version));
|
||||
|
||||
|
||||
cw_itemstore_set_str(ac_config,CW_ITEM_AC_IMAGE_DIR,conf_image_dir);
|
||||
|
||||
// cw_itemstore_set_avltree(ac_config, CW_ITEM_AC_IP_LIST, aciplist);
|
||||
|
||||
|
||||
|
@ -4,15 +4,15 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "sock.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
#include "socklist.h"
|
||||
#include "acinfo.h"
|
||||
#include "capwap/acinfo.h"
|
||||
#include "conf.h"
|
||||
|
||||
#include "capwap.h"
|
||||
#include "capwap_80211.h"
|
||||
#include "aciplist.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/capwap_80211.h"
|
||||
#include "capwap/aciplist.h"
|
||||
|
||||
|
||||
|
||||
|
@ -27,18 +27,19 @@
|
||||
|
||||
#include "actube.h"
|
||||
#include "wtplist.h"
|
||||
#include "dtls.h"
|
||||
#include "cw_log.h"
|
||||
#include "capwap/dtls.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "conf.h"
|
||||
#include "sock.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
#include "socklist.h"
|
||||
|
||||
#include "db.h"
|
||||
#include "capwap_items.h"
|
||||
#include "capwap_cisco.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
#include "capwap/capwap_cisco.h"
|
||||
|
||||
#include "ac.h"
|
||||
#include "capwap/format.h"
|
||||
|
||||
int ac_run();
|
||||
|
||||
@ -50,7 +51,7 @@ void alive_thread(void *data)
|
||||
}
|
||||
}
|
||||
|
||||
#include "action.h"
|
||||
#include "capwap/action.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -98,20 +99,13 @@ int readelem_cisco_rad_name(struct conn *conn,struct cw_action * a,uint8_t *data
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
int avlprint(void *priv, void *data)
|
||||
{
|
||||
struct cw_str * d = (struct cw_str*) data;
|
||||
printf("String: %d - %s\n",d->id,d->str);
|
||||
}
|
||||
*/
|
||||
#include "capwap/capwap_crypto.h"
|
||||
|
||||
|
||||
|
||||
int main (int argc, const char * argv[])
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
cw_log_name="AC-Tube";
|
||||
|
||||
read_config("ac.conf");
|
||||
|
@ -21,13 +21,13 @@
|
||||
|
||||
#include <confuse.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "sock.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include "cw_log.h"
|
||||
#include "cw_util.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/cw_util.h"
|
||||
|
||||
uint8_t conf_macaddress[12];
|
||||
uint8_t conf_macaddress_len=0;
|
||||
@ -391,7 +391,7 @@ static char * conf_default_mcast_groups_ipv6[] = {
|
||||
#endif
|
||||
|
||||
//#include "avltree"
|
||||
#include "stravltree.h"
|
||||
#include "capwap/stravltree.h"
|
||||
|
||||
|
||||
|
||||
@ -568,6 +568,12 @@ int read_config(const char * filename){
|
||||
if (!init_control_port())
|
||||
return 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
cfg_opt_t opts[] = {
|
||||
CFG_STR_LIST("dbg", "{}", CFGF_NONE),
|
||||
CFG_STR_LIST("listen", "{}", CFGF_NONE),
|
||||
|
@ -26,9 +26,9 @@
|
||||
#include <net/if.h>
|
||||
|
||||
|
||||
#include "capwap.h"
|
||||
#include "lwapp.h"
|
||||
#include "bstr.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/lwapp.h"
|
||||
#include "capwap/bstr.h"
|
||||
|
||||
#ifndef CONF_DEFAULT_ACNAME
|
||||
#define CONF_DEFAULT_ACNAME "AC"
|
||||
|
@ -1,7 +1,7 @@
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
#include "cw_log.h"
|
||||
#include "capwap/cw_log.h"
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include <pthread.h>
|
||||
|
||||
|
||||
#include "cw_log.h"
|
||||
#include "sock.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
|
||||
#include "socklist.h"
|
||||
|
@ -30,12 +30,12 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wtplist.h"
|
||||
#include "conn.h"
|
||||
#include "sock.h"
|
||||
#include "capwap/conn.h"
|
||||
#include "capwap/sock.h"
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
#include "cw_log.h"
|
||||
#include "capwap/cw_log.h"
|
||||
|
||||
/*
|
||||
static struct wtpman ** wtplist = 0;
|
||||
|
344
src/ac/wtpman.c
344
src/ac/wtpman.c
@ -7,36 +7,34 @@
|
||||
|
||||
#include "wtplist.h"
|
||||
|
||||
#include "capwap.h"
|
||||
#include "sock.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/sock.h"
|
||||
#include "socklist.h"
|
||||
|
||||
#include "conn.h"
|
||||
#include "capwap/conn.h"
|
||||
#include "wtpman.h"
|
||||
#include "conf.h"
|
||||
#include "cw_log.h"
|
||||
|
||||
#include "dtls.h"
|
||||
|
||||
#include "capwap/cw_log.h"
|
||||
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
#include "lwmsg.h"
|
||||
#include "lwapp.h"
|
||||
#include "capwap/lwmsg.h"
|
||||
#include "capwap/lwapp.h"
|
||||
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "capwap_80211.h"
|
||||
#include "capwap_cisco.h"
|
||||
#include "capwap/capwap_80211.h"
|
||||
#include "capwap/capwap_cisco.h"
|
||||
|
||||
#include "cw_util.h"
|
||||
#include "capwap/cw_util.h"
|
||||
|
||||
#include "capwap_items.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
#include "ac.h"
|
||||
|
||||
#include "capwap/dtls.h"
|
||||
|
||||
|
||||
extern struct cw_actiondef capwap_actions;
|
||||
|
||||
@ -62,7 +60,7 @@ void conn_handle_change_state_event_request(struct conn * conn)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
static struct cwrmsg *xconn_wait_for_message(struct conn *conn, time_t timer)
|
||||
{
|
||||
struct cwrmsg *cwrmsg;
|
||||
@ -93,7 +91,7 @@ static struct cwrmsg * xconn_wait_for_message(struct conn * conn, time_t timer)
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
struct rh_param {
|
||||
struct conn *conn;
|
||||
@ -122,7 +120,10 @@ printf("Param %p\n",param);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct cwrmsg * zconn_wait_for_request(struct conn * conn, int *msglist, time_t timer)
|
||||
|
||||
/*
|
||||
static struct cwrmsg *zconn_wait_for_request(struct conn *conn, int *msglist,
|
||||
time_t timer)
|
||||
{
|
||||
int (*request_handler_save) (void *);
|
||||
void *request_handler_param_save;
|
||||
@ -149,11 +150,9 @@ static struct cwrmsg * zconn_wait_for_request(struct conn * conn, int *msglist,
|
||||
break;
|
||||
}
|
||||
|
||||
/* response message? no action*/
|
||||
if (!(cwrmsg->type & 1))
|
||||
continue;
|
||||
|
||||
/* it's a request message */
|
||||
break;
|
||||
}
|
||||
|
||||
@ -165,10 +164,10 @@ static struct cwrmsg * zconn_wait_for_request(struct conn * conn, int *msglist,
|
||||
return cwrmsg;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
struct cwrmsg *xconn_send_request(struct conn *conn)
|
||||
{
|
||||
int i;
|
||||
@ -184,7 +183,8 @@ printf("Current Seqnum = %d\n",conn->seqnum);
|
||||
|
||||
time_t r_timer = cw_timer_start(conn->retransmit_interval);
|
||||
if (i != 0)
|
||||
cw_dbg(DBG_MSG_ERR,"Retransmitting message, type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
||||
cw_dbg(DBG_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);
|
||||
@ -193,20 +193,23 @@ printf("Current Seqnum = %d\n",conn->seqnum);
|
||||
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_MSG_ERR,"Max retransmit's reached, message type=%d,seq=%d",cwmsg->type,cwmsg->seqnum);
|
||||
cw_dbg(DBG_MSG_ERR, "Max retransmit's reached, message type=%d,seq=%d",
|
||||
cwmsg->type, cwmsg->seqnum);
|
||||
return 0;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
int wtpman_handle_request(void *p)
|
||||
{
|
||||
|
||||
/*
|
||||
struct wtpman *wtpman = (struct wtpman *) p;
|
||||
struct conn *conn = wtpman->conn;
|
||||
struct cwrmsg *cwrmsg = &conn->cwrmsg;
|
||||
@ -215,14 +218,18 @@ int wtpman_handle_request(void *p)
|
||||
cw_handle_echo_request(conn);
|
||||
break;
|
||||
case CW_MSG_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);
|
||||
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);
|
||||
}
|
||||
return 1;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@ -240,7 +247,8 @@ void usend_image_file(struct conn * conn,const char * filename)
|
||||
|
||||
|
||||
|
||||
cw_log(LOG_INFO,"Sending image file %s to %s",filename,sock_addr2str(&conn->addr));
|
||||
cw_log(LOG_INFO, "Sending image file %s to %s", filename,
|
||||
sock_addr2str(&conn->addr));
|
||||
|
||||
struct cwrmsg *cwrmsg;
|
||||
uint8_t buffer[1024];
|
||||
@ -286,23 +294,24 @@ for (ai=0; ai<1024; ai++){
|
||||
data.type = 1;
|
||||
|
||||
if (data.len == 0) {
|
||||
printf("*******************************************len0************************************\n");
|
||||
printf
|
||||
("*******************************************len0************************************\n");
|
||||
}
|
||||
|
||||
printf("Send img data request, block=%d, len=%d, ch=%d\n",bl,data.len,lw_checksum(data.data,data.len));
|
||||
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);
|
||||
// cwrmsg = conn_send_request(conn);
|
||||
|
||||
|
||||
if (cwrmsg) {
|
||||
printf("Got img data response\n");
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
printf("Respnse Timeout\n");
|
||||
exit(0);
|
||||
}
|
||||
@ -335,6 +344,8 @@ static void wtpman_remove(struct wtpman * wtpman)
|
||||
* 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)
|
||||
{
|
||||
struct cwrmsg *cwrmsg;
|
||||
@ -347,15 +358,27 @@ static struct cwrmsg * wtpman_wait_for_message(struct wtpman * wtpman, time_t ti
|
||||
|
||||
} while (!cwrmsg);
|
||||
|
||||
cw_dbg(DBG_MSG,"Received message from %s, type=%d - %s"
|
||||
,CLIENT_IP,cwrmsg->type,cw_msgtostr(cwrmsg->type));
|
||||
cw_dbg(DBG_MSG, "Received message from %s, type=%d - %s", CLIENT_IP, cwrmsg->type,
|
||||
cw_msgtostr(cwrmsg->type));
|
||||
|
||||
return cwrmsg;
|
||||
}
|
||||
*/
|
||||
|
||||
int conn_msg_processor(struct conn *conn);
|
||||
//int conn_msg_processor(struct conn *conn);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int check_discovery(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len)
|
||||
{
|
||||
printf("Discovery END!!!\n");
|
||||
conn->capwap_state=CW_STATE_NONE;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void wtpman_run_discovery(void *arg)
|
||||
{
|
||||
|
||||
@ -370,12 +393,19 @@ extern cw_actionlist_in_t the_tree;
|
||||
wtpman->conn->capwap_state = CW_STATE_DISCOVERY;
|
||||
wtpman->conn->actions = &capwap_actions;
|
||||
|
||||
/*
|
||||
cw_actionlist_in_set_msg_end_callback(capwap_actions.in, CW_STATE_DISCOVERY,
|
||||
CW_MSG_DISCOVERY_REQUEST, check_discovery);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
wtpman->conn->local = ac_config;
|
||||
wtpman->conn->remote = cw_itemstore_create();
|
||||
|
||||
while ( !cw_timer_timeout(timer) && wtpman->conn->capwap_state==CW_STATE_DISCOVERY){
|
||||
conn_msg_processor(wtpman->conn);
|
||||
while (!cw_timer_timeout(timer)
|
||||
&& wtpman->conn->capwap_state == CW_STATE_DISCOVERY) {
|
||||
cw_read_messages(wtpman->conn);
|
||||
}
|
||||
|
||||
struct cw_item *wn = cw_itemstore_get(wtpman->conn->remote, CW_ITEM_WTP_NAME);
|
||||
@ -395,22 +425,25 @@ extern cw_actionlist_in_t the_tree;
|
||||
timer = cw_timer_start(10);
|
||||
cwrmsg = wtpman_wait_for_message(wtpman, timer);
|
||||
|
||||
if ( !cwrmsg )
|
||||
{
|
||||
cw_dbg(DBG_MSG_ERR,"No complete message from %s received after %d seconds",CLIENT_IP,10);
|
||||
if (!cwrmsg) {
|
||||
cw_dbg(DBG_MSG_ERR,
|
||||
"No complete message from %s received after %d seconds", CLIENT_IP,
|
||||
10);
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (cwrmsg->type != CW_MSG_DISCOVERY_REQUEST) {
|
||||
cw_dbg(DBG_MSG_ERR,"Invalid message in discovery state from %s, type=%s - %s ",
|
||||
cw_dbg(DBG_MSG_ERR,
|
||||
"Invalid message in discovery state from %s, type=%s - %s ",
|
||||
CLIENT_IP, cwrmsg->type, cw_msgtostr(cwrmsg->type));
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
|
||||
cwread_discovery_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
||||
cwread_discovery_request(&wtpman->wtpinfo, cwrmsg->msgelems,
|
||||
cwrmsg->msgelems_len);
|
||||
|
||||
|
||||
// printf("RMAC-LEN:%d\n",cwrmsg->rmac[0]);
|
||||
@ -423,7 +456,8 @@ extern cw_actionlist_in_t the_tree;
|
||||
|
||||
char wtpinfostr[8192];
|
||||
wtpinfo_print(wtpinfostr, &wtpman->wtpinfo);
|
||||
cw_dbg(DBG_CW_INFO,"Discovery request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
||||
cw_dbg(DBG_CW_INFO, "Discovery request gave us the follwing WTP Info:\n%s",
|
||||
wtpinfostr);
|
||||
|
||||
|
||||
struct radioinfo radioinfo;
|
||||
@ -442,7 +476,8 @@ extern cw_actionlist_in_t the_tree;
|
||||
cw_dbg(DBG_CW_INFO,"Discovery request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
||||
*/
|
||||
|
||||
cwsend_discovery_response(wtpman->conn,cwrmsg->seqnum,&radioinfo,acinfo,&wtpman->wtpinfo);
|
||||
cwsend_discovery_response(wtpman->conn, cwrmsg->seqnum, &radioinfo, acinfo,
|
||||
&wtpman->wtpinfo);
|
||||
wtpman_remove(wtpman);
|
||||
}
|
||||
|
||||
@ -450,7 +485,7 @@ extern cw_actionlist_in_t the_tree;
|
||||
static void wtpman_run_run(void *arg)
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
struct wtpman *wtpman = (struct wtpman *) arg;
|
||||
struct conn *conn = wtpman->conn;
|
||||
|
||||
@ -469,7 +504,7 @@ static void wtpman_run_run(void *arg)
|
||||
}
|
||||
|
||||
printf("Update now?\n");
|
||||
|
||||
*/
|
||||
|
||||
/*
|
||||
conn_prepare_request(conn,CW_MSG_CONFIGURATION_UPDATE_REQUEST);
|
||||
@ -488,7 +523,7 @@ static void wtpman_run_run(void *arg)
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
printf("Adding WLAN\n");
|
||||
struct cwwlan wlan;
|
||||
memset(&wlan, 0, sizeof(wlan));
|
||||
@ -503,7 +538,7 @@ printf("Adding WLAN\n");
|
||||
cwrmsg = conn_send_request(conn);
|
||||
|
||||
printf("WLAN CONF sent\n");
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -513,6 +548,7 @@ printf("WLAN CONF sent\n");
|
||||
cwrmsg = conn_send_request(conn);
|
||||
*/
|
||||
|
||||
/*
|
||||
for (i = 0; i < 100; i++) {
|
||||
time_t t = cw_timer_start(1);
|
||||
printf("Wait...\n");
|
||||
@ -521,7 +557,7 @@ printf("WLAN CONF sent\n");
|
||||
|
||||
printf("Set name?\n");
|
||||
exit(0);
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@ -544,7 +580,8 @@ static int wtpman_establish_dtls(void *arg)
|
||||
wtpman->conn->dtls_key_pass = conf_sslkeypass;
|
||||
wtpman->conn->dtls_verify_peer = conf_dtls_verify_peer;
|
||||
cw_dbg(DBG_DTLS, "DTLS - Using key file %s", wtpman->conn->dtls_key_file);
|
||||
cw_dbg(DBG_DTLS,"DTLS - Using cert file %s",wtpman->conn->dtls_cert_file);
|
||||
cw_dbg(DBG_DTLS, "DTLS - Using cert file %s",
|
||||
wtpman->conn->dtls_cert_file);
|
||||
dtls_ok = 1;
|
||||
}
|
||||
|
||||
@ -556,7 +593,8 @@ static int wtpman_establish_dtls(void *arg)
|
||||
}
|
||||
|
||||
if (!dtls_ok) {
|
||||
cw_log(LOG_ERR,"Can't establish DTLS session, neither psk nor certs set in config file.");
|
||||
cw_log(LOG_ERR,
|
||||
"Can't establish DTLS session, neither psk nor certs set in config file.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -566,10 +604,10 @@ static int wtpman_establish_dtls(void *arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_DTLS,"DTLS session established with %s, cipher=%s", CLIENT_IP,dtls_get_cipher(wtpman->conn));
|
||||
cw_dbg(DBG_DTLS, "DTLS session established with %s, cipher=%s", CLIENT_IP,
|
||||
dtls_get_cipher(wtpman->conn));
|
||||
/* DTLS handshake done */
|
||||
|
||||
|
||||
int cert_len;
|
||||
struct dtls_ssl_cert cert;
|
||||
|
||||
@ -584,7 +622,6 @@ static int wtpman_establish_dtls(void *arg)
|
||||
fwrite(cert.data, 1, cert.size, f);
|
||||
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -605,79 +642,23 @@ wtpman->conn->capwap_state=CW_STATE_JOIN;
|
||||
wtpman->conn->remote = cw_itemstore_create();
|
||||
|
||||
while (!cw_timer_timeout(timer) && wtpman->conn->capwap_state == CW_STATE_JOIN) {
|
||||
int rc = conn_msg_processor(wtpman->conn);
|
||||
int rc = cw_read_messages(wtpman->conn);
|
||||
if (rc < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
printf("Breaked\n");
|
||||
exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* timer = cw_timer_start(wtpman->conn->wait_join); */
|
||||
|
||||
int join_msgs[] = { CW_MSG_JOIN_REQUEST, -1 };
|
||||
struct cwrmsg * cwrmsg;
|
||||
cwrmsg = conn_wait_for_request(wtpman->conn, join_msgs, timer);
|
||||
|
||||
if (!cwrmsg){
|
||||
if (conn_is_error(wtpman->conn)){
|
||||
cw_dbg(DBG_MSG_ERR,"DTLS connection closed while waiting for join request from %s.",CLIENT_IP);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (wtpman->conn->capwap_state==CW_STATE_JOIN){
|
||||
cw_dbg(DBG_MSG_ERR, "No join request from %s after %d seconds, WTP died.",
|
||||
sock_addr2str(&wtpman->conn->addr), wtpman->conn->wait_dtls);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
process_join_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
||||
conn_detect_capwap(wtpman->conn,&wtpman->wtpinfo);
|
||||
|
||||
{
|
||||
char wtpinfostr[8192];
|
||||
wtpinfo_print(wtpinfostr,&wtpman->wtpinfo);
|
||||
cw_dbg(DBG_CW_INFO,"Join request gave us the follwing WTP Info:\n%s",wtpinfostr);
|
||||
}
|
||||
|
||||
|
||||
struct radioinfo radioinfo;
|
||||
radioinfo.rid = cwrmsg->rid;
|
||||
// memcpy (radioinfo.rmac, cwrmsg->rmac,8);
|
||||
struct ac_info * acinfo = get_acinfo();
|
||||
|
||||
|
||||
int result_code = 0;
|
||||
cw_dbg(DBG_MSG,"Sending join response to %s",CLIENT_IP);
|
||||
printf("SLeep befor join resp\n");
|
||||
printf("Slept befor join resp\n");
|
||||
|
||||
cwsend_join_response(wtpman->conn,cwrmsg->seqnum,result_code,&radioinfo,acinfo,&wtpman->wtpinfo);
|
||||
cw_log(LOG_INFO,"WTP joined, Name = %s, Location = %s, IP = %s",
|
||||
wtpman->wtpinfo.name,wtpman->wtpinfo.location,
|
||||
sock_addr2str(&wtpman->conn->addr));
|
||||
|
||||
//exit(0);
|
||||
return 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -694,7 +675,8 @@ static int wtpman_send_image_file(struct wtpman * wtpman,struct cwrmsg * cwrmsg)
|
||||
cw_read_image_data_request(&data, cwrmsg->msgelems, cwrmsg->msgelems_len);
|
||||
if (!strlen(id)) {
|
||||
cw_dbg(DBG_MSG_ERR, "No image identifier in image data request");
|
||||
cw_send_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_FAILURE);
|
||||
cw_send_image_data_response(wtpman->conn, cwrmsg->seqnum,
|
||||
CW_RESULT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -703,8 +685,10 @@ static int wtpman_send_image_file(struct wtpman * wtpman,struct cwrmsg * cwrmsg)
|
||||
FILE *infile;
|
||||
infile = fopen(filename, "rb");
|
||||
if (infile) {
|
||||
cw_send_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_SUCCESS);
|
||||
cw_log(LOG_INFO, "Sending image file %s to %s", filename, sock_addr2str(&wtpman->conn->addr));
|
||||
cw_send_image_data_response(wtpman->conn, cwrmsg->seqnum,
|
||||
CW_RESULT_SUCCESS);
|
||||
cw_log(LOG_INFO, "Sending image file %s to %s", filename,
|
||||
sock_addr2str(&wtpman->conn->addr));
|
||||
cw_send_image_file(wtpman->conn, infile);
|
||||
return 1;
|
||||
}
|
||||
@ -725,7 +709,8 @@ static void wtpman_run(void *arg)
|
||||
|
||||
/* 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);
|
||||
cw_dbg(DBG_DTLS, "Dropping connection from %s to non-unicast socket.",
|
||||
CLIENT_IP);
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
@ -750,22 +735,54 @@ static void wtpman_run(void *arg)
|
||||
|
||||
|
||||
/* here the WTP has joined, now we assume an image data request
|
||||
or an configuration status request. Nothing else. i
|
||||
or an configuration status request. Nothing else.
|
||||
State is Image update
|
||||
*/
|
||||
|
||||
|
||||
while (!cw_timer_timeout(timer) && wtpman->conn->capwap_state == CW_STATE_CONFIGURE) {
|
||||
int rc = cw_read_messages(wtpman->conn);
|
||||
if (rc < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
exit(0);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
do {
|
||||
int cfg_status_msgs[] = { CW_MSG_IMAGE_DATA_REQUEST, CW_MSG_CONFIGURATION_STATUS_REQUEST, -1 };
|
||||
int cfg_status_msgs[] =
|
||||
{ CW_MSG_IMAGE_DATA_REQUEST, CW_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
-1 };
|
||||
cwrmsg = conn_wait_for_request(wtpman->conn, cfg_status_msgs, timer);
|
||||
|
||||
if (!cwrmsg) {
|
||||
cw_dbg(DBG_MSG_ERR,"No conf status or img data request from %s after %d seconds, WTP died.",
|
||||
sock_addr2str(&wtpman->conn->addr),wtpman->conn->wait_join);
|
||||
cw_dbg(DBG_MSG_ERR,
|
||||
"No conf status or img data request from %s after %d seconds, WTP died.",
|
||||
sock_addr2str(&wtpman->conn->addr),
|
||||
wtpman->conn->wait_join);
|
||||
wtpman_remove(wtpman);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Image data request, the WTP wants an update */
|
||||
// Image data request, the WTP wants an update
|
||||
if (cwrmsg->type == CW_MSG_IMAGE_DATA_REQUEST) {
|
||||
int rc = wtpman_send_image_file(wtpman, cwrmsg);
|
||||
if (rc) {
|
||||
@ -780,16 +797,19 @@ static void wtpman_run(void *arg)
|
||||
|
||||
|
||||
printf("Have Masseg %d\n", cwrmsg->type);
|
||||
cwread_configuration_status_request(&wtpman->wtpinfo,cwrmsg->msgelems, cwrmsg->msgelems_len);
|
||||
cwread_configuration_status_request(&wtpman->wtpinfo, cwrmsg->msgelems,
|
||||
cwrmsg->msgelems_len);
|
||||
int result_code = 0;
|
||||
struct ac_info *acinfo = get_acinfo();
|
||||
struct radioinfo rinf;
|
||||
cwsend_conf_status_response(wtpman->conn,cwrmsg->seqnum,result_code,&rinf,acinfo,&wtpman->wtpinfo);
|
||||
cwsend_conf_status_response(wtpman->conn, cwrmsg->seqnum, result_code, &rinf,
|
||||
acinfo, &wtpman->wtpinfo);
|
||||
printf("Send the respi but sleep\n");
|
||||
|
||||
|
||||
printf("Next thoing\n");
|
||||
int change_status_msgs[] = { CW_MSG_IMAGE_DATA_REQUEST,CW_MSG_CHANGE_STATE_EVENT_REQUEST, -1 };
|
||||
int change_status_msgs[] =
|
||||
{ CW_MSG_IMAGE_DATA_REQUEST, CW_MSG_CHANGE_STATE_EVENT_REQUEST, -1 };
|
||||
cwrmsg = conn_wait_for_request(wtpman->conn, change_status_msgs, timer);
|
||||
printf("Done\n");
|
||||
|
||||
@ -805,7 +825,8 @@ printf("Done\n");
|
||||
{
|
||||
printf("Change state event\n!");
|
||||
struct radioinfo ri;
|
||||
cwsend_change_state_event_response(wtpman->conn,cwrmsg->seqnum,&ri);
|
||||
cwsend_change_state_event_response(wtpman->conn,
|
||||
cwrmsg->seqnum, &ri);
|
||||
}
|
||||
break;
|
||||
case CW_MSG_IMAGE_DATA_REQUEST:
|
||||
@ -827,6 +848,7 @@ printf("Done\n");
|
||||
|
||||
|
||||
printf("WTP is joined now\n");
|
||||
*/
|
||||
|
||||
/*
|
||||
struct radioinfo * radioinfo;
|
||||
@ -849,6 +871,7 @@ printf("Done\n");
|
||||
// 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);
|
||||
|
||||
/*
|
||||
char wtpinfostr[8192];
|
||||
wtpinfo_print(wtpinfostr, &wtpman->wtpinfo);
|
||||
cw_dbg(DBG_ALL, "WTP conf_status\n%s", wtpinfostr);
|
||||
@ -856,6 +879,7 @@ printf("Done\n");
|
||||
printf("Run run run run run\n");
|
||||
wtpman_run_run(wtpman);
|
||||
exit(0);
|
||||
*/
|
||||
|
||||
/*
|
||||
int ii;
|
||||
@ -871,6 +895,7 @@ for (ii=0; ii<3; ii++){
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
wtpman_run_run(wtpman);
|
||||
|
||||
exit(0);
|
||||
@ -878,10 +903,11 @@ exit(0);
|
||||
|
||||
if (cwrmsg->type == CW_MSG_IMAGE_DATA_REQUEST) {
|
||||
cwread_image_data_request(0, cwrmsg->msgelems, cwrmsg->msgelems_len);
|
||||
cwsend_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_FAILURE);
|
||||
cwsend_image_data_response(wtpman->conn, cwrmsg->seqnum,
|
||||
CW_RESULT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -894,6 +920,7 @@ exit(0);
|
||||
exit(0);
|
||||
|
||||
|
||||
/*
|
||||
timer = cw_timer_start(30);
|
||||
cwrmsg = wtpman_wait_for_message(wtpman, timer);
|
||||
|
||||
@ -902,12 +929,12 @@ exit(0);
|
||||
|
||||
if (cwrmsg->type == CW_MSG_IMAGE_DATA_REQUEST) {
|
||||
cwread_image_data_request(0, cwrmsg->msgelems, cwrmsg->msgelems_len);
|
||||
cwsend_image_data_response(wtpman->conn,cwrmsg->seqnum,CW_RESULT_FAILURE);
|
||||
cwsend_image_data_response(wtpman->conn, cwrmsg->seqnum,
|
||||
CW_RESULT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
exit(0);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -917,7 +944,7 @@ exit(0);
|
||||
// cw_log_debug0("WTP joined\n%s",wtpinfostr);
|
||||
|
||||
//exit(0);
|
||||
|
||||
/*
|
||||
int msg_counter = 0;
|
||||
while (1) {
|
||||
struct cwrmsg *cwrmsg = conn_get_message(wtpman->conn);
|
||||
@ -937,7 +964,7 @@ exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
/*
|
||||
if (cwrmsg->type == CWMSG_CONFIGURATION_STATUS_REQUEST){
|
||||
process_conf_status_request(&wtpman->wtpinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
||||
@ -952,12 +979,17 @@ if (cwrmsg->type == CWMSG_CONFIGURATION_STATUS_REQUEST){
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
msg_counter = 0;
|
||||
|
||||
|
||||
if (cwrmsg->type == CW_MSG_ECHO_REQUEST) {
|
||||
cwsend_echo_response(wtpman->conn,cwrmsg->seqnum,wtpman->wtpinfo.radioinfo);
|
||||
cwsend_echo_response(wtpman->conn, cwrmsg->seqnum,
|
||||
wtpman->wtpinfo.radioinfo);
|
||||
}
|
||||
*/
|
||||
|
||||
// printf("Got msg: %i\n",cwrmsg->type);
|
||||
|
||||
}
|
||||
@ -966,35 +998,10 @@ if (cwrmsg->type == CWMSG_CONFIGURATION_STATUS_REQUEST){
|
||||
|
||||
|
||||
// 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]));
|
||||
*/
|
||||
while (1) {
|
||||
uint8_t *packet = conn_q_get_packet(wtpman->conn);
|
||||
// int len = *( (uint32_t*)(packet));
|
||||
|
||||
@ -1002,7 +1009,9 @@ if (cwrmsg->type == CWMSG_CONFIGURATION_STATUS_REQUEST){
|
||||
// conn_process_packet(wtpman->conn,packet+4,len);
|
||||
free(packet);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
void wtpman_destroy(struct wtpman *wtpman)
|
||||
{
|
||||
@ -1101,11 +1110,12 @@ void wtpman_start(struct wtpman * wtpman,int dtlsmode)
|
||||
{
|
||||
if (dtlsmode) {
|
||||
cw_dbg(DBG_CW_INFO, "Starting wtpman in DTLS mode");
|
||||
pthread_create (&wtpman->thread, NULL, (void *) &wtpman_run, (void *) wtpman);
|
||||
}
|
||||
else{
|
||||
pthread_create(&wtpman->thread, NULL, (void *) &wtpman_run,
|
||||
(void *) wtpman);
|
||||
} else {
|
||||
cw_dbg(DBG_CW_INFO, "Starting wtpman in non-dtls mode");
|
||||
pthread_create (&wtpman->thread, NULL, (void *) &wtpman_run_discovery, (void *) wtpman);
|
||||
pthread_create(&wtpman->thread, NULL, (void *) &wtpman_run_discovery,
|
||||
(void *) wtpman);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1114,5 +1124,3 @@ void wtpman_lw_start(struct wtpman * wtpman)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include <semaphore.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "fragman.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/fragman.h"
|
||||
|
||||
#define WTPMAN_QSIZE 1024
|
||||
|
||||
|
@ -98,7 +98,6 @@ CAPWAPOBJS= \
|
||||
cwmsg_addelem_ac_descriptor.o \
|
||||
cwmsg_addelem_wtp_descriptor.o \
|
||||
cwmsg_addelem_wtp_radio_infos.o \
|
||||
cwmsg_addelem_wtp_board_data.o \
|
||||
cwmsg_addelem_cw_local_ip_addr.o \
|
||||
cwmsg_addelem_mtu_discovery_padding.o \
|
||||
cwmsg_addelem_ac_timestamp.o \
|
||||
@ -121,11 +120,9 @@ CAPWAPOBJS= \
|
||||
cw_handle_echo_request.o \
|
||||
cwsend_conf_status_response.o\
|
||||
cwread_configuration_status_request.o\
|
||||
cwread_discovery_request.o\
|
||||
cwread_change_state_event_request.o\
|
||||
cwread_wtp_event_request.o \
|
||||
process_conf_status_request.o \
|
||||
wtpinfo_readelem_wtp_board_data.o \
|
||||
wtpinfo_readelem_wtp_mac_type.o \
|
||||
wtpinfo_readelem_wtp_radio_info.o \
|
||||
cw_readelem_80211_wtp_radio_info.o \
|
||||
@ -172,20 +169,27 @@ CAPWAPOBJS= \
|
||||
cw_in_wtp_board_data.o \
|
||||
cw_in_check_disc_req.o \
|
||||
cw_in_check_join_req.o \
|
||||
cw_in_check_img_data_req.o \
|
||||
cw_out_generic.o \
|
||||
cw_out_ac_descriptor.o \
|
||||
cw_out_cisco_ac_descriptor.o \
|
||||
cw_out_cisco_ap_timesync.o \
|
||||
cw_in_cisco_image_identifier.o\
|
||||
cw_out_capwap_control_ip_addrs.o \
|
||||
strheap.o \
|
||||
cw_check_missing_mand.o \
|
||||
dbg.o
|
||||
dbg.o \
|
||||
md5sum.o \
|
||||
format.o
|
||||
|
||||
|
||||
#cw_in_wtp_name.o \
|
||||
#cw_msgtostr.o \
|
||||
#cw_msgelemtostr.o \
|
||||
#cwmsg_addelem_ctrl_ip_addrs.o \
|
||||
#process_join_request.o \
|
||||
#cwmsg_addelem_wtp_board_data.o \
|
||||
#wtpinfo_readelem_wtp_board_data.o \
|
||||
|
||||
#cw_ianavendoridtostr.o \
|
||||
#cwmsg_addelem_result_code.o \
|
||||
@ -202,6 +206,7 @@ CAPWAPOBJS= \
|
||||
# cwmsg_set_control_header.o
|
||||
# process_msgelems.o \
|
||||
# cwsend_join_response.o \
|
||||
# cwread_discovery_request.o\
|
||||
|
||||
#
|
||||
# SSL objects
|
||||
@ -243,7 +248,6 @@ CONNOBJS= conn_create.o \
|
||||
connlist.o \
|
||||
conn_create_noq.o \
|
||||
conn_send_response.o \
|
||||
conn_get_message.o \
|
||||
conn_get_response.o \
|
||||
conn_prepare_configuration_update_request.o \
|
||||
cw_prepare_configuration_status_request.o \
|
||||
@ -255,6 +259,7 @@ CONNOBJS= conn_create.o \
|
||||
conn_wait_for_request.o \
|
||||
conn_init.o \
|
||||
conn_send_msg.o
|
||||
#conn_get_message.o \
|
||||
|
||||
|
||||
|
||||
@ -269,8 +274,10 @@ FRAGOBJS=fragman.o
|
||||
CWACTION=action.o \
|
||||
cw_process_msg.o \
|
||||
capwap_actions_ac.o \
|
||||
capwap_actions_wtp.o \
|
||||
cw_in_generic.o \
|
||||
cw_in_wtp_descriptor.o \
|
||||
cw_out_wtp_board_data.o \
|
||||
cipwap_actions_ac.o \
|
||||
cipwap_strings_elem.o \
|
||||
cw_put_msg.o \
|
||||
@ -291,7 +298,7 @@ O:=$(OBJS);
|
||||
OBJS:=$(patsubst %.o,$(ARCH)/%.o,$(OBJS))
|
||||
|
||||
CFLAGS = -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I /usr/local/include
|
||||
#CFLAGS += -Wall -g -O0 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I/usr/local/include
|
||||
CFLAGS = -Wall -O3 -D_REENTRANT -DWITH_IPV6 -DWITH_RMAC_SUPPORT -I/usr/local/include
|
||||
|
||||
CFLAGS += $(GNUTLS_CFLAGS) \
|
||||
-DWITH_CW_LOG \
|
||||
|
@ -37,11 +37,11 @@ static inline int cw_action_in_cmp(const void *elem1,const void *elem2)
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = e1->capwap_state - e2->capwap_state;
|
||||
r = e1->elem_id - e2->elem_id;
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
r = e1->elem_id - e2->elem_id;
|
||||
r = e1->capwap_state - e2->capwap_state;
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
@ -168,5 +168,24 @@ cw_action_out_t * cw_actionlist_out_add(cw_actionlist_out_t t, struct cw_action_
|
||||
|
||||
|
||||
|
||||
cw_action_in_t *cw_actionlist_in_set_msg_end_callback(cw_actionlist_in_t a,
|
||||
uint8_t capwap_state,
|
||||
uint32_t msg_id,
|
||||
int (*fun) (struct conn * conn,
|
||||
struct cw_action_in * a, uint8_t * data,
|
||||
int len))
|
||||
{
|
||||
cw_action_in_t as,*ar;
|
||||
as.vendor_id=0;
|
||||
as.proto=0;
|
||||
as.elem_id=-1;
|
||||
as.msg_id=msg_id;
|
||||
as.capwap_state=capwap_state;
|
||||
|
||||
ar = cw_actionlist_in_get(a,&as);
|
||||
if (!ar)
|
||||
return NULL;
|
||||
|
||||
ar->end=fun;
|
||||
return ar;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ struct cw_action_in{
|
||||
uint16_t item_id;
|
||||
uint16_t min_len;
|
||||
uint16_t max_len;
|
||||
uint8_t mand;
|
||||
};
|
||||
|
||||
|
||||
@ -58,6 +59,12 @@ extern cw_actionlist_in_t cw_actionlist_in_create();
|
||||
extern cw_action_in_t * cw_actionlist_in_get(cw_actionlist_in_t t,cw_action_in_t *a);
|
||||
extern cw_action_in_t * cw_actionlist_in_add(cw_actionlist_in_t t,cw_action_in_t *a);
|
||||
extern int cw_actionlist_in_register_actions(cw_actionlist_in_t t,cw_action_in_t * actions);
|
||||
extern cw_action_in_t *cw_actionlist_in_set_msg_end_callback(cw_actionlist_in_t a,
|
||||
uint8_t capwap_state,
|
||||
uint32_t msg_id,
|
||||
int (*fun) (struct conn * conn,
|
||||
struct cw_action_in * a, uint8_t * data,
|
||||
int len));
|
||||
|
||||
|
||||
/* Definitions for outgoing messages */
|
||||
@ -69,9 +76,12 @@ struct cw_action_out{
|
||||
|
||||
int (*out)(struct conn * conn, struct cw_action_out *a, uint8_t * dst);
|
||||
struct cw_item *(*get)(struct conn *conn,struct cw_action_out *a);
|
||||
|
||||
uint8_t mand;
|
||||
uint8_t itemtype;
|
||||
void *defval;
|
||||
|
||||
};
|
||||
|
||||
typedef struct cw_action_out cw_action_out_t;
|
||||
|
||||
typedef struct avltree *cw_actionlist_out_t;
|
||||
|
@ -91,6 +91,7 @@ static inline void avltree_destroy(struct avltree *t)
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define avltree_find(t,d) avltree_get(t,d)
|
||||
#define avltree_insert(t,d) avltree_add(t,d)
|
||||
//#define avltree_walk(t,dir) avltree_foreach(t,dir)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#ifndef __BSTR_H
|
||||
#define __BSTR_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@ -46,7 +47,7 @@ extern int bstr_to_str(char *dst, bstr_t str,char * def);
|
||||
/**
|
||||
* Return the length of a bstr_t string.
|
||||
*/
|
||||
#define bstr_len(s) (*(s))
|
||||
#define bstr_len(s) (*((uint8_t*)(s)))
|
||||
|
||||
/**
|
||||
* Return the data of a bstr_t string.
|
||||
@ -77,6 +78,53 @@ static inline int bstr16_ncpy(uint8_t *dst,uint8_t*src,uint16_t len)
|
||||
return len+2;
|
||||
}
|
||||
|
||||
static inline uint8_t * bstr16_create(uint8_t *data, uint16_t len)
|
||||
{
|
||||
uint8_t * str = malloc(2+len*sizeof(uint8_t));
|
||||
if (!str)
|
||||
return 0;
|
||||
*((uint16_t*)str)=len;
|
||||
memcpy(str+2,data,len);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#define vendorstr_get_vendor_id(str)\
|
||||
( *((uint32_t*)((str)+2)))
|
||||
|
||||
#define vendorstr_set_vendor_id(str,id)\
|
||||
( *((uint32_t*)((str)+2)) = id)
|
||||
|
||||
#define vendorstr_len(str)\
|
||||
(*((uint16_t*)((str)+0)))
|
||||
|
||||
#define vendorstr_set_len(str,len)\
|
||||
(*((uint16_t*)((str)+0))=len)
|
||||
|
||||
#define vendorstr_data(str)\
|
||||
(((uint8_t*)(str))+6)
|
||||
|
||||
#define vendorstr_size(n)\
|
||||
(1+6+(len)*sizeof(uint8_t))
|
||||
|
||||
|
||||
static inline uint8_t * vendorstr_create(uint32_t vendor_id, uint8_t *data, uint8_t len)
|
||||
{
|
||||
uint8_t * str = malloc(vendorstr_size(len));
|
||||
if (!str)
|
||||
return 0;
|
||||
|
||||
vendorstr_set_vendor_id(str,vendor_id);
|
||||
vendorstr_set_len(str,len);
|
||||
memcpy(vendorstr_data(str),data,len);
|
||||
*(vendorstr_data(str)+vendorstr_len(str))=0;
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
*/
|
||||
uint8_t * bstr_create(uint8_t *data, uint8_t len)
|
||||
{
|
||||
uint8_t * str = malloc(len*sizeof(uint8_t));
|
||||
uint8_t * str = malloc(1+len*sizeof(uint8_t));
|
||||
if (!str)
|
||||
return 0;
|
||||
*str=len;
|
||||
|
@ -65,7 +65,7 @@ enum capwap_states {
|
||||
CW_STATE_DISCOVERY,
|
||||
CW_STATE_JOIN,
|
||||
CW_STATE_CONFIGURE,
|
||||
CW_STATE_IMAGE,
|
||||
CW_STATE_IMAGE_DATA,
|
||||
CW_STATE_UPDATE,
|
||||
CW_STATE_RUN
|
||||
};
|
||||
@ -227,7 +227,7 @@ struct capwap_ctrlhdr
|
||||
#define CW_ELEM_WTP_NAME 45
|
||||
#define CW_ELEM_RESERVED_46 46
|
||||
#define CW_ELEM_WTP_RADIO_STATISTICS 47
|
||||
#define CWMSGELEM_WTP_REBOOT_STATISTICS 48
|
||||
#define CW_ELEM_WTP_REBOOT_STATISTICS 48
|
||||
#define CW_ELEM_WTP_STATIC_IP_ADDRESS_INFORMATION 49
|
||||
#define CW_ELEM_WTP_STATIC_IP_ADDR_INFO 49
|
||||
|
||||
@ -247,11 +247,11 @@ struct capwap_ctrlhdr
|
||||
|
||||
|
||||
/* wtp board data subelements */
|
||||
#define CWBOARDDATA_MODELNO 0
|
||||
#define CWBOARDDATA_SERIALNO 1
|
||||
#define CWBOARDDATA_BOARDID 2
|
||||
#define CWBOARDDATA_REVISION 3
|
||||
#define CWBOARDDATA_MACADDRESS 4
|
||||
#define CW_BOARDDATA_MODELNO 0
|
||||
#define CW_BOARDDATA_SERIALNO 1
|
||||
#define CW_BOARDDATA_BOARDID 2
|
||||
#define CW_BOARDDATA_REVISION 3
|
||||
#define CW_BOARDDATA_MACADDRESS 4
|
||||
|
||||
|
||||
/* AC Security flags for authentication */
|
||||
@ -397,7 +397,7 @@ extern void cwsend_join_response(struct conn *conn, int seqnum, int rc,
|
||||
struct wtpinfo *wtpinfo);
|
||||
|
||||
|
||||
extern void cwread_discovery_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len);
|
||||
//extern void cwread_discovery_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len);
|
||||
extern void process_join_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len);
|
||||
extern void process_conf_status_request(struct wtpinfo *wtpinfo, uint8_t * msg, int len);
|
||||
|
||||
@ -477,18 +477,18 @@ extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elem
|
||||
|
||||
14 Image Data Error (Invalid Checksum)
|
||||
|
||||
15 Image Data Error (Invalid Data Length)
|
||||
|
||||
16 Image Data Error (Other Error)
|
||||
*/
|
||||
#define CW_RESULT_IMAGE_DATA_IVALID_LENGTH 15 //Image Data Error (Invalid Data Length)
|
||||
|
||||
#define CW_RESULT_IMAGE_DATA_OTHER_ERROR 16 //Image Data Error (Other Error)
|
||||
/*
|
||||
17 Image Data Error (Image Already Present)
|
||||
|
||||
18 Message Unexpected (Invalid in Current State)
|
||||
|
||||
19 Message Unexpected (Unrecognized Request)
|
||||
*/
|
||||
|
||||
#define CW_RESULT_MSG_INVALID_IN_CURRENT_STATE 18
|
||||
#define CW_RESULT_MSG_UNRECOGNIZED 19
|
||||
#define CW_RESULT_MISSING_MAND_ELEM 20
|
||||
|
||||
/*
|
||||
21 Failure - Unrecognized Message Element
|
||||
|
||||
@ -579,6 +579,33 @@ static inline void cw_set_hdr_hlen(uint8_t *th,int hlen){
|
||||
cw_set_dword(th,d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the WBID field of a CAWAP Header
|
||||
* @param th pointer to the header
|
||||
* @param hlen velue to set (max. 5 bits)
|
||||
*/
|
||||
static inline void cw_set_hdr_wbid(uint8_t *th,int wbid){
|
||||
uint32_t d = cw_get_dword(th);
|
||||
d &= (0x1f << 9) ^ 0xffffffff;
|
||||
d |= ((wbid) & 0x1f) <<9;
|
||||
cw_set_dword(th,d);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the RID field of a CAWAP Header
|
||||
* @param th pointer to the header
|
||||
* @param hlen velue to set (max. 5 bits)
|
||||
*/
|
||||
static inline void cw_set_hdr_rid(uint8_t *th,int rid){
|
||||
uint32_t d = cw_get_dword(th);
|
||||
d &= (0x1f << 9) ^ 0xffffffff;
|
||||
d |= ((rid) & 0x1f) <<14;
|
||||
cw_set_dword(th,d);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set CAPWAP header flags
|
||||
* @param th pointer to header
|
||||
@ -718,7 +745,7 @@ static inline int cw_addelem_bstr(uint8_t * dst, uint16_t type, const bstr_t bst
|
||||
}
|
||||
|
||||
|
||||
static inline int cw_addelem_result_code(uint8_t * dst, uint32_t code)
|
||||
static inline int cw_put_elem_result_code(uint8_t * dst, uint32_t code)
|
||||
{
|
||||
cw_put_dword(dst + 4, code);
|
||||
return 4 + cw_put_elem_hdr(dst, CW_ELEM_RESULT_CODE, 4);
|
||||
@ -778,6 +805,12 @@ extern int cw_send_configuration_update_response(struct conn *conn, int seqnum,
|
||||
|
||||
|
||||
/* cwmsg methods */
|
||||
static inline int cw_addelem_result_code(uint8_t * dst, uint32_t code)
|
||||
{
|
||||
cw_put_dword(dst + 4, code);
|
||||
return 4 + cw_put_elem_hdr(dst, CW_ELEM_RESULT_CODE, 4);
|
||||
}
|
||||
|
||||
|
||||
#define cwmsg_addelem_vendor_specific_payload(cwmsg,vendor_id, type, data,len) \
|
||||
(cwmsg)->pos+=cw_addelem_vendor_specific_payload((cwmsg)->msgelems+(cwmsg)->pos,vendor_id,type,data,len)
|
||||
@ -811,7 +844,14 @@ extern struct cw_str capwap_strings_elem[];
|
||||
#define cw_strvendor(id) cw_strlist_get_str(capwap_strings_vendor,id)
|
||||
|
||||
|
||||
#define cw_strelemp(p,id) cw_strheap_get((p)->strelem,id)
|
||||
static inline const char * cw_strelemp_(cw_strheap_t h, int msg_id) {
|
||||
const char * rc = cw_strheap_get(h,msg_id);
|
||||
if (rc)
|
||||
return rc;
|
||||
return cw_strheap_get(h,0);
|
||||
}
|
||||
|
||||
#define cw_strelemp(p,id) cw_strelemp_((p)->strelem,id)
|
||||
|
||||
extern const char *cw_strlist_get_str(struct cw_str *s, int id);
|
||||
|
||||
@ -875,13 +915,12 @@ static inline int cw_put_ac_status(uint8_t *dst, struct cw_ac_status *s){
|
||||
}
|
||||
|
||||
|
||||
static inline int cw_put_version(uint8_t *dst,uint16_t subelem_id, uint32_t vendor_id,bstr16_t data)
|
||||
static inline int cw_put_version(uint8_t *dst,uint16_t subelem_id, uint8_t *v)
|
||||
{
|
||||
|
||||
uint8_t *d=dst;
|
||||
d += cw_put_dword(d,vendor_id);
|
||||
d += cw_put_dword(d, (subelem_id<<16) | bstr16_len(data));
|
||||
d += cw_put_data(d,bstr16_data(data),bstr16_len(data));
|
||||
d += cw_put_dword(d,vendorstr_get_vendor_id(v));
|
||||
d += cw_put_dword(d, (subelem_id<<16) | vendorstr_len(v));
|
||||
d += cw_put_data(d,vendorstr_data(v),vendorstr_len(v));
|
||||
return d-dst;
|
||||
}
|
||||
|
||||
@ -889,9 +928,20 @@ static inline int cw_put_version(uint8_t *dst,uint16_t subelem_id, uint32_t vend
|
||||
|
||||
int cw_register_actions_capwap_ac(struct cw_actiondef *def);
|
||||
int cw_register_actions_cipwap_ac(struct cw_actiondef *def);
|
||||
int cw_register_actions_capwap_wtp(struct cw_actiondef *def);
|
||||
|
||||
|
||||
int cw_in_set_state_none(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
|
||||
struct cw_item *cw_out_get_local(struct conn *conn, struct cw_action_out *a);
|
||||
extern int cw_in_check_disc_req(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
|
||||
int cw_check_missing_mand(cw_action_in_t ** out, struct conn * conn, cw_action_in_t *a);
|
||||
int cw_in_check_join_req(struct conn *conn, struct cw_action_in *a, uint8_t * data, int len);
|
||||
int cw_in_check_img_data_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len);
|
||||
|
||||
int cw_out_wtp_board_data(struct conn *conn,struct cw_action_out * a,uint8_t *dst) ;
|
||||
|
||||
void cw_init_request(struct conn *conn,int msg_id);
|
||||
|
||||
|
||||
|
||||
|
@ -46,6 +46,35 @@
|
||||
CW_ITEM_SESSION_ID, /* ID to use store */ \
|
||||
16, 16 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_IMAGE_IDENTIFIER \
|
||||
CW_ELEM_IMAGE_IDENTIFIER, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
CW_ITEMTYPE_VENDORSTR, /* Type of element */ \
|
||||
CW_ITEM_IMAGE_IDENTIFIER, /* ID to use store */ \
|
||||
5, 4096 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_AC_NAME \
|
||||
CW_ELEM_AC_NAME, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
CW_ITEMTYPE_STR, /* Type of element */ \
|
||||
CW_ITEM_AC_NAME, /* ID to use store */ \
|
||||
1, 1024 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_STATISTICS_TIMER \
|
||||
CW_ELEM_STATISTICS_TIMER, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
CW_ITEMTYPE_DWORD, /* Type of element */ \
|
||||
CW_ITEM_STATISTICS_TIMER, /* ID to use store */ \
|
||||
1, 1024 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_WTP_REBOOT_STATISTICS \
|
||||
CW_ELEM_WTP_REBOOT_STATISTICS, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
CW_ITEMTYPE_DATA, /* Type of element */ \
|
||||
CW_ITEM_WTP_REBOOT_STATISTICS, /* ID to use store */ \
|
||||
15, 15 /* min/max length */
|
||||
|
||||
|
||||
#define CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE \
|
||||
CW_ELEM_WTP_FRAME_TUNNEL_MODE, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
@ -63,16 +92,24 @@
|
||||
|
||||
#define CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD \
|
||||
CW_ELEM_VENDOR_SPECIFIC_PAYLOAD, /* Element ID */ \
|
||||
cw_in_vendor_specific_payload, 0 /* start/end callback*/ \
|
||||
|
||||
cw_in_vendor_specific_payload,0, /* start/end callback*/ \
|
||||
0, \
|
||||
0, \
|
||||
0,0
|
||||
|
||||
#define CW_ACTION_IN_WTP_BOARD_DATA \
|
||||
CW_ELEM_WTP_BOARD_DATA, /* Element ID */ \
|
||||
cw_in_wtp_board_data, 0 /* start/end callback */ \
|
||||
cw_in_wtp_board_data, 0, /* start/end callback */ \
|
||||
0, \
|
||||
CW_ITEM_WTP_BOARD_DATA, \
|
||||
0,0
|
||||
|
||||
#define CW_ACTION_IN_WTP_DESCRIPTOR \
|
||||
CW_ELEM_WTP_DESCRIPTOR, /* Element ID */ \
|
||||
cw_in_wtp_descriptor, 0 /* start/end callback */ \
|
||||
cw_in_wtp_descriptor, 0, /* start/end callback */ \
|
||||
0, \
|
||||
CW_ITEM_WTP_DESCRIPTOR, \
|
||||
0,0
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -31,114 +31,124 @@ cw_action_in_t capwap_actions_ac_in[] = {
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
||||
/* Message Discovery Request */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, -1,
|
||||
0, cw_in_set_state_none}
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, 0,
|
||||
0, cw_in_check_disc_req}
|
||||
,
|
||||
|
||||
/* Element Discovery Type */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ELEM_DISCOVERY_TYPE,
|
||||
cw_in_generic, 0, CW_ITEMTYPE_BYTE, CW_ITEM_DISCOVERY_TYPE, 1, 1}
|
||||
cw_in_generic, 0, CW_ITEMTYPE_BYTE, CW_ITEM_DISCOVERY_TYPE, 1, 1, 1}
|
||||
,
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA }
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA,
|
||||
1}
|
||||
,
|
||||
/* Element WTP Descriptor */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_DESCRIPTOR }
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_DESCRIPTOR,
|
||||
1}
|
||||
,
|
||||
/* Element Frame Tunnel Mode */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE}
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST,
|
||||
CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE, 1}
|
||||
,
|
||||
/* Element WTP Mac Tpe */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_MAC_TYPE}
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_MAC_TYPE, 1}
|
||||
,
|
||||
/* Vendor Specific Payload */
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD}
|
||||
{0, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST,
|
||||
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD}
|
||||
,
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
||||
/* Message: Join Request */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, -1,
|
||||
0, 0}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, 0,
|
||||
0, cw_in_check_join_req}
|
||||
,
|
||||
|
||||
/* Element Location Data */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_LOCATION_DATA}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_LOCATION_DATA, 1}
|
||||
,
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA, 1}
|
||||
,
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_DESCRIPTOR}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_DESCRIPTOR, 1}
|
||||
,
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_NAME}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_NAME, 1}
|
||||
,
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_SESSION_ID}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_SESSION_ID, 1}
|
||||
,
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_FRAME_TUNNEL_MODE, 1}
|
||||
,
|
||||
/* Element WTP MAC Type */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_MAC_TYPE}
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_WTP_MAC_TYPE, 1}
|
||||
,
|
||||
/* Element Vendor Specific Payload */
|
||||
{0, 0, CW_STATE_JOIN, CW_MSG_JOIN_REQUEST, CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD}
|
||||
,
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
||||
/* Message: Configuration Status Request */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_REQUEST, 0,
|
||||
0, cw_in_check_join_req}
|
||||
,
|
||||
/* Element: AC Name */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
CW_ACTION_IN_AC_NAME, 1}
|
||||
,
|
||||
/* Element: Statistics Timer */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
CW_ACTION_IN_STATISTICS_TIMER, 1}
|
||||
,
|
||||
|
||||
/*
|
||||
{0, 1, 1, CW_MSG_DISCOVERY_RESPONSE, 0,
|
||||
0, 0}
|
||||
/* Element: Statistics Timer */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
CW_ACTION_IN_WTP_REBOOT_STATISTICS, 1}
|
||||
,
|
||||
|
||||
|
||||
{0, 1, 1, CW_MSG_DISCOVERY_RESPONSE, CW_ELEM_AC_NAME,
|
||||
cw_out_generic, 0, CW_ITEMTYPE_DATA,CW_ITEM_AC_NAME}
|
||||
/* Element Vendor Specific Payload */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD}
|
||||
,
|
||||
|
||||
{0, 1, 2, CW_MSG_DISCOVERY_RESPONSE, 0,
|
||||
0, 0}
|
||||
/* Element WTP Board Data */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_DISCOVERY_REQUEST, CW_ACTION_IN_WTP_BOARD_DATA,
|
||||
1}
|
||||
,
|
||||
|
||||
|
||||
*/
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/*
|
||||
{CW_VENDOR_ID_CISCO, 0, CW_STATE_DISCOVERY, CW_MSG_DISCOVERY_REQUEST, CW_CISCO_RAD_NAME,
|
||||
cw_in_wtp_name, 0}
|
||||
/* Message: Image Data Request - in Config State */
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_REQUEST, 0,
|
||||
0, cw_in_check_img_data_req}
|
||||
,
|
||||
*/
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_REQUEST,
|
||||
CW_ACTION_IN_IMAGE_IDENTIFIER,
|
||||
0}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
{0, 0, 0}
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
int cw_out_ac_name(uint8_t * dst, struct cw_item *item)
|
||||
{
|
||||
|
||||
printf("Putting out the AC name %s\n", item->data);
|
||||
|
||||
uint8_t *data = item->data;
|
||||
int len = cw_put_data(dst + 4, data, strlen((char *) data));
|
||||
return len + cw_put_elem_hdr(dst, CW_ELEM_AC_NAME, len);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
cw_action_out_t capwap_actions_ac_out[] = {
|
||||
{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_NONE}
|
||||
,
|
||||
|
||||
/* AC Descriptor */
|
||||
{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_DESCRIPTOR, 0
|
||||
,CW_ELEM_AC_DESCRIPTOR, cw_out_ac_descriptor, 0}
|
||||
{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_DESCRIPTOR, 0, CW_ELEM_AC_DESCRIPTOR,
|
||||
cw_out_ac_descriptor, 0}
|
||||
,
|
||||
|
||||
/* AC Name */
|
||||
@ -160,17 +170,36 @@ cw_action_out_t capwap_actions_ac_out[] = {
|
||||
|
||||
/* Result Code */
|
||||
{CW_MSG_JOIN_RESPONSE, CW_ITEM_RESULT_CODE, 0,
|
||||
CW_ELEM_RESULT_CODE, cw_out_generic, cw_out_get_local}
|
||||
CW_ELEM_RESULT_CODE, cw_out_generic, cw_out_get_local, 1}
|
||||
,
|
||||
|
||||
/* AC Descriptor */
|
||||
{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_DESCRIPTOR, 0
|
||||
,CW_ELEM_AC_DESCRIPTOR, cw_out_ac_descriptor, 0}
|
||||
{CW_MSG_JOIN_RESPONSE, CW_ITEM_AC_DESCRIPTOR, 0, CW_ELEM_AC_DESCRIPTOR,
|
||||
cw_out_ac_descriptor, 0, 1}
|
||||
,
|
||||
|
||||
/* AC Name */
|
||||
{CW_MSG_JOIN_RESPONSE, CW_ITEM_AC_NAME, 0,
|
||||
CW_ELEM_AC_NAME, cw_out_generic, cw_out_get_local}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------------------
|
||||
* Image Data Response OUT
|
||||
*/
|
||||
{CW_MSG_IMAGE_DATA_RESPONSE, CW_ITEM_NONE}
|
||||
,
|
||||
|
||||
/* Result Code */
|
||||
{CW_MSG_IMAGE_DATA_RESPONSE, CW_ITEM_RESULT_CODE, 0,
|
||||
CW_ELEM_RESULT_CODE, cw_out_generic, cw_out_get_local, 1}
|
||||
,
|
||||
|
||||
|
||||
|
||||
/* End of list */
|
||||
{0, 0}
|
||||
|
||||
};
|
||||
|
@ -191,6 +191,7 @@ int cw_readelem_cisco_wtp_radio_cfg(int elem_id,uint8_t *elem, int len,struct ra
|
||||
int cw_addelem_cisco_wtp_radio_cfg(uint8_t*dst,struct radioinfo * ri);
|
||||
|
||||
extern int cw_out_cisco_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst) ;
|
||||
int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
|
||||
|
||||
|
||||
|
||||
|
@ -23,6 +23,8 @@ enum capwap_items {
|
||||
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||
CW_ITEM_WTP_OTHERSOFTWARE_VENDOR,
|
||||
CW_ITEM_WTP_OTHERSOFTWARE_VERSION,
|
||||
CW_ITEM_WTP_BOARD_DATA,
|
||||
CW_ITEM_WTP_DESCRIPTOR,
|
||||
|
||||
CW_ITEM_AC_NAME,
|
||||
CW_ITEM_AC_DESCRIPTOR,
|
||||
@ -39,12 +41,20 @@ enum capwap_items {
|
||||
CW_ITEM_SESSION_ID,
|
||||
|
||||
CW_ITEM_AC_TIMESTAMP,
|
||||
CW_ITEM_STATISTICS_TIMER,
|
||||
CW_ITEM_WTP_REBOOT_STATISTICS,
|
||||
CW_ITEM_IMAGE_IDENTIFIER,
|
||||
|
||||
|
||||
|
||||
/* CIPWAP and Cisco */
|
||||
CW_ITEM_WTP_GROUP_NAME
|
||||
CW_ITEM_WTP_GROUP_NAME,
|
||||
|
||||
|
||||
/* Other Items */
|
||||
CW_ITEM_AC_IMAGE_DIR, /* Path where image WTP images are stored */
|
||||
CW_ITEM_WTP_IMAGE_FILENAME /* Full path of image filename */
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ struct cw_str capwap_strings_elem[] = {
|
||||
{CW_ELEM_WTP_NAME, "WTP Name"},
|
||||
{CW_ELEM_RESERVED_46, "Reserved 46"},
|
||||
{CW_ELEM_WTP_RADIO_STATISTICS, "WTP Radio Statistics"},
|
||||
{CWMSGELEM_WTP_REBOOT_STATISTICS, "WTP Reboot Statistics"},
|
||||
{CW_ELEM_WTP_REBOOT_STATISTICS, "WTP Reboot Statistics"},
|
||||
{CW_ELEM_WTP_STATIC_IP_ADDRESS_INFORMATION, "WTP Static IP Address Information"},
|
||||
|
||||
|
||||
|
@ -9,6 +9,12 @@
|
||||
*brief CIPWAP Actions
|
||||
*/
|
||||
|
||||
#define CW_ACTION_IN_CISCO_IMAGE_IDENTIFIER \
|
||||
CW_ELEM_IMAGE_IDENTIFIER, /* Element ID*/ \
|
||||
cw_in_cisco_image_identifier, 0, /* start/end callback */ \
|
||||
CW_ITEMTYPE_VENDORSTR, /* Type of element */ \
|
||||
CW_ITEM_IMAGE_IDENTIFIER, /* ID to use store */ \
|
||||
1, 4096 /* min/max length */
|
||||
|
||||
|
||||
cw_action_in_t cipwap_actions_ac_in[] = {
|
||||
@ -26,6 +32,15 @@ cw_action_in_t cipwap_actions_ac_in[] = {
|
||||
cw_in_generic, 0, CW_ITEMTYPE_STR,CW_ITEM_WTP_GROUP_NAME,1,512}
|
||||
,
|
||||
|
||||
/* -------------------------------------------------------------------------------
|
||||
* Image Data Request - Conig State
|
||||
*/
|
||||
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_IMAGE_DATA_REQUEST,
|
||||
CW_ACTION_IN_CISCO_IMAGE_IDENTIFIER,
|
||||
0}
|
||||
,
|
||||
|
||||
|
||||
|
||||
{0,0,0}
|
||||
@ -39,7 +54,6 @@ cw_action_out_t cipwap_actions_ac_out[] = {
|
||||
* Discovery Response OUT
|
||||
*/
|
||||
|
||||
|
||||
/* AC Descriptor (Cisco) */
|
||||
{CW_MSG_DISCOVERY_RESPONSE, CW_ITEM_AC_DESCRIPTOR, 0 ,
|
||||
CW_ELEM_AC_DESCRIPTOR, cw_out_cisco_ac_descriptor, 0}
|
||||
@ -51,6 +65,17 @@ cw_action_out_t cipwap_actions_ac_out[] = {
|
||||
CW_CISCO_AP_TIMESYNC, cw_out_cisco_ap_timesync, 0}
|
||||
,
|
||||
|
||||
/* -------------------------------------------------------------------------------
|
||||
* Join Response OUT
|
||||
*/
|
||||
|
||||
/* AC Descriptor (Cisco) */
|
||||
{CW_MSG_JOIN_RESPONSE, CW_ITEM_AC_DESCRIPTOR, 0 ,
|
||||
CW_ELEM_AC_DESCRIPTOR, cw_out_cisco_ac_descriptor, 0}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
{0,0,0}
|
||||
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "action.h"
|
||||
|
||||
#include "itemstore.h"
|
||||
#include "intavltree.h"
|
||||
|
||||
/**
|
||||
* Connection Object
|
||||
@ -53,6 +54,9 @@ struct conn {
|
||||
A WTP holds here data about it's AC */
|
||||
cw_itemstore_t remote;
|
||||
|
||||
/** Counter for mandatory message elements */
|
||||
struct avltree *mand;
|
||||
|
||||
|
||||
struct cw_actiondef *actions;
|
||||
|
||||
@ -227,5 +231,9 @@ struct cwrmsg *conn_wait_for_request(struct conn *conn, int *msglist, time_t tim
|
||||
|
||||
void conn_init(struct conn *conn);
|
||||
|
||||
extern int cw_read_messages(struct conn *conn);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* __CONLIST_H */
|
||||
|
@ -232,8 +232,8 @@ void conn_process_packet(struct conn * conn, uint8_t *packet, int len,int (*cb)(
|
||||
// extern int cw_process_msg(struct conn * conn,uint8_t*msg,int len);
|
||||
// cw_process_msg(conn,f+4,*(uint32_t*)f);
|
||||
|
||||
printf("Received a fragmented packetm should process it");
|
||||
exit(0);
|
||||
//printf("Received a fragmented packetm should process it");
|
||||
//exit(0);
|
||||
|
||||
/*
|
||||
if (!cwrmsg_init_ctrlhdr(conn,&cwrmsg,f+4,*(uint32_t*)f)){
|
||||
@ -261,3 +261,23 @@ exit(0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used as main message loop
|
||||
*/
|
||||
int cw_read_messages(struct conn *conn)
|
||||
{
|
||||
uint8_t buf[2024];
|
||||
int len = 2024;
|
||||
|
||||
int n = conn->read(conn, buf, len);
|
||||
if (n<0 )
|
||||
return n;
|
||||
|
||||
if (n > 0)
|
||||
conn_process_packet(conn, buf, n, cw_process_msg, conn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
#include "cw_log.h"
|
||||
#include "capwap.h"
|
||||
#include "capwap_cisco.h"
|
||||
|
@ -2,34 +2,21 @@
|
||||
#include "action.h"
|
||||
#include "cw_log.h"
|
||||
#include "itemstore.h"
|
||||
#include "capwap.h"
|
||||
|
||||
|
||||
|
||||
int cw_itemstore_set(cw_itemstore_t itemstore, uint32_t item_id, int item_type, uint8_t *data, int len)
|
||||
{
|
||||
switch (item_type) {
|
||||
case CW_ITEMTYPE_BYTE:
|
||||
cw_itemstore_set_byte(itemstore,item_id,*data);
|
||||
break;
|
||||
|
||||
case CW_ITEMTYPE_STR:
|
||||
cw_itemstore_set_strn(itemstore,item_id,(char*)data,len);
|
||||
break;
|
||||
case CW_ITEMTYPE_BSTR:
|
||||
cw_itemstore_set_bstrn(itemstore,item_id,data,len);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cw_in_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len)
|
||||
{
|
||||
if (len<a->min_len) {
|
||||
cw_dbg(DBG_ELEM_ERR,"Message element too short, %d < %d", len,a->min_len);
|
||||
return 0;
|
||||
}
|
||||
if (len>a->max_len) {
|
||||
cw_dbg(DBG_ELEM_ERR,"Message element too big, %d > %d", len,a->max_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
cw_itemstore_set(conn->remote,a->item_id,a->itemtype,data,len);
|
||||
|
||||
|
@ -54,25 +54,25 @@ static void readsubelems_wtp_board_data(cw_itemstore_t itemstore, uint8_t * msge
|
||||
sublen);
|
||||
|
||||
switch (subtype) {
|
||||
case CWBOARDDATA_MODELNO:
|
||||
case CW_BOARDDATA_MODELNO:
|
||||
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_MODELNO,
|
||||
msgelem + i, sublen);
|
||||
break;
|
||||
case CWBOARDDATA_SERIALNO:
|
||||
case CW_BOARDDATA_SERIALNO:
|
||||
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_SERIALNO,
|
||||
msgelem + i, sublen);
|
||||
|
||||
break;
|
||||
case CWBOARDDATA_MACADDRESS:
|
||||
case CW_BOARDDATA_MACADDRESS:
|
||||
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_MACADDRESS,
|
||||
msgelem + i, sublen);
|
||||
|
||||
break;
|
||||
case CWBOARDDATA_BOARDID:
|
||||
case CW_BOARDDATA_BOARDID:
|
||||
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_ID,
|
||||
msgelem + i, sublen);
|
||||
break;
|
||||
case CWBOARDDATA_REVISION:
|
||||
case CW_BOARDDATA_REVISION:
|
||||
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_REVISION,
|
||||
msgelem + i, sublen);
|
||||
default:
|
||||
|
@ -361,6 +361,7 @@ void lw_dbg_elem_(int msg_id, int elem_id, const uint8_t * elem_data, int elem_l
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
void cw_dbg_missing_mand_elems_(struct conn *conn, int msgtype, int *mand)
|
||||
{
|
||||
if (!cw_dbg_is_level(DBG_CW_RFC))
|
||||
@ -372,3 +373,4 @@ void cw_dbg_missing_mand_elems_(struct conn *conn, int msgtype, int *mand)
|
||||
cw_dbg(DBG_CW_RFC, "Missing msgelems in %s: %s", cw_strmsg(msgtype), str);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -32,6 +32,4 @@ void cw_init_response(struct conn * conn, uint8_t *req)
|
||||
cw_set_msg_type(dmsgptr,cw_get_msg_type(msgptr)+1);
|
||||
cw_set_msg_seqnum(dmsgptr,cw_get_msg_seqnum(msgptr));
|
||||
cw_set_msg_flags(dmsgptr,0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst
|
||||
i = cw_itemstore_get(conn->local,CW_ITEM_AC_HARDWARE_VERSION);
|
||||
|
||||
if ( i ) {
|
||||
d += cw_put_version(d,CW_SUBELEM_AC_HARDWARE_VERSION,*((uint32_t*)(i->data)),i->data+4);
|
||||
d += cw_put_version(d,CW_SUBELEM_AC_HARDWARE_VERSION,i->data);
|
||||
}
|
||||
else {
|
||||
cw_dbg(DBG_ELEM_ERR, "Can't send hard version in AC descriptor, not set.");
|
||||
@ -48,7 +48,7 @@ int cw_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst
|
||||
i = cw_itemstore_get(conn->local,CW_ITEM_AC_SOFTWARE_VERSION);
|
||||
|
||||
if ( i ) {
|
||||
d += cw_put_version(d,CW_SUBELEM_AC_SOFTWARE_VERSION,*((uint32_t*)(i->data)),i->data+4);
|
||||
d += cw_put_version(d,CW_SUBELEM_AC_SOFTWARE_VERSION,i->data);
|
||||
}
|
||||
else {
|
||||
cw_dbg(DBG_ELEM_ERR, "Can't send software version in AC descriptor, not set.");
|
||||
|
@ -24,7 +24,7 @@ int cw_out_cisco_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_
|
||||
i = cw_itemstore_get(conn->local,CW_ITEM_AC_SOFTWARE_VERSION);
|
||||
|
||||
if ( i ) {
|
||||
d += cw_put_version(d,CW_SUBELEM_AC_SOFTWARE_VERSION,*((uint32_t*)(i->data)),i->data+4);
|
||||
d += cw_put_version(d,1,i->data);
|
||||
}
|
||||
else {
|
||||
cw_dbg(DBG_ELEM_ERR, "Can't send software version in AC descriptor, not set.");
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include "capwap.h"
|
||||
#include "capwap_items.h"
|
||||
|
||||
#include "cw_log.h"
|
||||
|
||||
|
||||
int cw_put_item(uint8_t *dst,struct cw_item*item)
|
||||
{
|
||||
@ -31,7 +33,6 @@ int cw_out_generic(struct conn *conn,struct cw_action_out *a,uint8_t *dst) // ,s
|
||||
item = a->get (conn,a);
|
||||
}
|
||||
|
||||
printf("Out generic item %p\n",item);
|
||||
|
||||
/* Size for msg elem header depends on
|
||||
vendor specific payload */
|
||||
@ -39,13 +40,14 @@ int cw_out_generic(struct conn *conn,struct cw_action_out *a,uint8_t *dst) // ,s
|
||||
|
||||
|
||||
int len;
|
||||
if ( !item )
|
||||
len=0;
|
||||
if ( !item ){
|
||||
if (a->mand){
|
||||
cw_log(LOG_ERR,"Cannot send mandatory message element %d",a->elem_id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
printf("Putting it\n");
|
||||
printf("To put: %d %s\n",len,item->data);
|
||||
len = cw_put_item(dst+start,item);
|
||||
printf("Putted: %d %s\n",len,item->data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,13 +61,32 @@ void cw_init_response(struct conn * conn, uint8_t *req)
|
||||
cw_set_msg_flags(dmsgptr, 0);
|
||||
}
|
||||
|
||||
void cw_init_request(struct conn *conn, int msg_id)
|
||||
{
|
||||
uint8_t *buffer = conn->req_buffer;
|
||||
|
||||
cw_put_dword(buffer + 0, 0);
|
||||
cw_put_dword(buffer + 4, 0);
|
||||
cw_set_hdr_preamble(buffer, 0);
|
||||
cw_set_hdr_hlen(buffer, 2);
|
||||
cw_set_hdr_wbid(buffer, 1);
|
||||
cw_set_hdr_rid(buffer, 0);
|
||||
uint8_t *msgptr = cw_get_hdr_msg_offset(buffer) + buffer;
|
||||
cw_set_msg_type(msgptr, msg_id);
|
||||
cw_set_msg_flags(msgptr, 0);
|
||||
cw_set_msg_elems_len(msgptr, 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* send a response
|
||||
*/
|
||||
int cw_send_response(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
{
|
||||
cw_init_response(conn, rawmsg);
|
||||
cw_put_msg(conn,conn->resp_buffer);
|
||||
if (cw_put_msg(conn, conn->resp_buffer) == -1)
|
||||
return 0;
|
||||
conn_send_msg(conn, conn->resp_buffer);
|
||||
return 1;
|
||||
}
|
||||
@ -147,8 +166,10 @@ int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
if (!afm) {
|
||||
/* Throw away unexpected response messages */
|
||||
if (!(as.msg_id & 1)) {
|
||||
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unexpected, discarding.",
|
||||
as.msg_id, cw_strmsg(as.msg_id));
|
||||
cw_dbg(DBG_MSG_ERR,
|
||||
"Message type %d (%s) unexpected/illigal in %s State, discarding.",
|
||||
as.msg_id, cw_strmsg(as.msg_id),
|
||||
cw_strstate(conn->capwap_state));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -158,14 +179,15 @@ int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
int result_code = 0;
|
||||
if (str) {
|
||||
/* Message found, but it was in wrong state */
|
||||
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) not allowed in %s State.",
|
||||
as.msg_id, cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
|
||||
cw_dbg(DBG_MSG_ERR,
|
||||
"Message type %d (%s) not allowed in %s State.", as.msg_id,
|
||||
cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
|
||||
result_code = CW_RESULT_MSG_INVALID_IN_CURRENT_STATE;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* Message is unknown */
|
||||
cw_dbg(DBG_MSG_ERR, "Message type %d (%s) unknown.",
|
||||
as.msg_id, cw_strmsg(as.msg_id), cw_strstate(as.capwap_state));
|
||||
as.msg_id, cw_strmsg(as.msg_id),
|
||||
cw_strstate(as.capwap_state));
|
||||
result_code = CW_RESULT_MSG_UNRECOGNIZED;
|
||||
|
||||
}
|
||||
@ -182,6 +204,7 @@ int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||
uint8_t *elem;
|
||||
|
||||
/* avltree to bag the found mandatory elements */
|
||||
conn->mand = intavltree_create();
|
||||
|
||||
/* iterate through message elements */
|
||||
@ -190,7 +213,8 @@ int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
as.elem_id = cw_get_elem_id(elem);
|
||||
int elem_len = cw_get_elem_len(elem);
|
||||
|
||||
cw_dbg_elem(conn,as.msg_id, as.elem_id, cw_get_elem_data(elem), elem_len);
|
||||
cw_dbg_elem(conn, as.msg_id, as.elem_id, cw_get_elem_data(elem),
|
||||
elem_len);
|
||||
|
||||
|
||||
af = cw_actionlist_in_get(conn->actions->in, &as);
|
||||
@ -224,8 +248,7 @@ int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len)
|
||||
/* the end method gave us an result code, so
|
||||
send an error message */
|
||||
cw_send_error_response(conn, rawmsg, result_code);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
/* regular response message */
|
||||
cw_send_response(conn, rawmsg, len);
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "capwap_items.h"
|
||||
#include "conn.h"
|
||||
|
||||
#include "cw_log.h"
|
||||
|
||||
struct args{
|
||||
struct conn * conn;
|
||||
uint32_t msg_id;
|
||||
@ -48,6 +50,7 @@ static int action_cb(void *args_param, void *a_param)
|
||||
|
||||
if (a->item_id == CW_ITEM_NONE) {
|
||||
/* Start of message */
|
||||
args->len=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -94,7 +97,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
args.conn = conn;
|
||||
args.msg_id = as.msg_id;
|
||||
args.dst = msgptr+8;
|
||||
args.len=0;
|
||||
args.len=-1;
|
||||
|
||||
avltree_foreach_from_asc(conn->actions->out, &as, action_cb, &args);
|
||||
|
||||
@ -104,6 +107,13 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
|
||||
printf ("Total elems len = %d\n",args.len);
|
||||
printf("Total msg len = %d\n",cw_get_hdr_msg_total_len(rawout));
|
||||
*/
|
||||
|
||||
if (args.len==-1) {
|
||||
cw_log(LOG_ERR,"Error: Can't create message of type %d (%s) - no definition found.",
|
||||
args.msg_id,cw_strmsg(args.msg_id));
|
||||
|
||||
}
|
||||
|
||||
return args.len;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
int cw_readelem_wtp_reboot_statistics(struct wtp_reboot_statistics *s, int type,uint8_t *msgelem, int len)
|
||||
{
|
||||
if (type != CWMSGELEM_WTP_REBOOT_STATISTICS)
|
||||
if (type != CW_ELEM_WTP_REBOOT_STATISTICS)
|
||||
return 0;
|
||||
|
||||
s->reboot_count=ntohs(*((uint16_t*)(msgelem+0)));
|
||||
|
@ -55,6 +55,7 @@ void cw_get_missing_mand_elems(char *dst, int *l)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
int cw_is_missing_mand_elems(int *l)
|
||||
{
|
||||
int i;
|
||||
@ -66,4 +67,4 @@ int cw_is_missing_mand_elems(int *l)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
@ -56,7 +56,7 @@ extern int cw_rand(uint8_t*dst, int len);
|
||||
|
||||
/* functions used to "rfc-verify" message elements */
|
||||
void cw_mand_elem_found(int *l,int type);
|
||||
int cw_is_missing_mand_elems(int *l);
|
||||
//int cw_is_missing_mand_elems(int *l);
|
||||
void cw_get_missing_mand_elems(char *dst, int *l);
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ void cwread_configuration_status_request(struct wtpinfo * wtpinfo, uint8_t * msg
|
||||
{
|
||||
int mand[] = {
|
||||
CW_ELEM_AC_NAME,
|
||||
CWMSGELEM_WTP_REBOOT_STATISTICS,
|
||||
CW_ELEM_WTP_REBOOT_STATISTICS,
|
||||
CWMSGELEM_RADIO_ADMINISTRATIVE_STATE,
|
||||
CW_ELEM_STATISTICS_TIMER,
|
||||
-1};
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "conn.h"
|
||||
|
||||
void cw_dbg_elem_(struct conn * conn, int msg, int msgelem, const uint8_t * msgbuf, int len);
|
||||
void cw_dbg_missing_mand(int level,struct conn *conn,cw_action_in_t ** ml,int n,cw_action_in_t *a);
|
||||
|
||||
|
||||
#ifdef WITH_CW_LOG_DEBUG
|
||||
|
@ -15,11 +15,13 @@
|
||||
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
*/
|
||||
#ifndef __CW_DTLS_H
|
||||
#define __CW_DTLS_H
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include "conn.h"
|
||||
|
||||
#ifndef __DTLS_H
|
||||
#define __DTLS_H
|
||||
|
||||
struct dtls_ssl_cert
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "itemstore.h"
|
||||
#include "capwap.h"
|
||||
|
||||
|
||||
|
||||
@ -13,7 +14,8 @@ static inline void cw_itemstore_del_data(void *e)
|
||||
case CW_ITEMTYPE_DATA:
|
||||
case CW_ITEMTYPE_STR:
|
||||
case CW_ITEMTYPE_BSTR:
|
||||
case CW_ITEMTYPE_VERSION:
|
||||
case CW_ITEMTYPE_BSTR16:
|
||||
case CW_ITEMTYPE_VENDORSTR:
|
||||
case CW_ITEMTYPE_FUN:
|
||||
free(item->data);
|
||||
break;
|
||||
@ -104,12 +106,28 @@ int cw_itemstore_set_str(cw_itemstore_t s, uint32_t id, const char *str)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cw_itemstore_set_strn(cw_itemstore_t s, uint32_t id, const char *str, int n)
|
||||
int cw_itemstore_set_data(cw_itemstore_t s, uint32_t id, const uint8_t *data, int len)
|
||||
{
|
||||
struct cw_item *i = cw_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->type = CW_ITEMTYPE_DATA;
|
||||
i->data = malloc(len);
|
||||
if(!i->data)
|
||||
return 1;
|
||||
memcpy(i->data,data,len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int cw_itemstore_set_strn(cw_itemstore_t s, uint32_t id, const char *str, int n)
|
||||
{
|
||||
struct cw_item *i = cw_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->type = CW_ITEMTYPE_STR;
|
||||
i->data = strndup(str, n);
|
||||
return 1;
|
||||
}
|
||||
@ -134,6 +152,20 @@ int cw_itemstore_set_bstrn(cw_itemstore_t s, uint32_t id, uint8_t * data, int le
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cw_itemstore_set_bstr16n(cw_itemstore_t s, uint32_t id, uint8_t * data, int len)
|
||||
{
|
||||
struct cw_item *i = cw_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->type = CW_ITEMTYPE_BSTR16;
|
||||
i->data = bstr16_create(data, len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int cw_itemstore_set_const_ptr(cw_itemstore_t s, uint32_t id, void *ptr)
|
||||
{
|
||||
@ -145,23 +177,15 @@ int cw_itemstore_set_const_ptr(cw_itemstore_t s, uint32_t id, void *ptr)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cw_itemstore_set_version(cw_itemstore_t s, uint32_t id, uint32_t vendor_id,
|
||||
uint8_t * versionstr, int len)
|
||||
int cw_itemstore_set_vendorstr(cw_itemstore_t s, uint32_t id, uint32_t vendor_id,
|
||||
uint8_t * vendorstr, int len)
|
||||
{
|
||||
struct cw_item *i = cw_item_create(s, id);
|
||||
if (!i)
|
||||
return 0;
|
||||
i->type = CW_ITEMTYPE_VERSION;
|
||||
|
||||
uint8_t *ptr = malloc(bstr16_size(len) + 4);
|
||||
i->data = ptr;
|
||||
|
||||
if (!ptr)
|
||||
return 1;
|
||||
|
||||
*((uint32_t *) ptr) = vendor_id;
|
||||
bstr16_ncpy(ptr + 4, versionstr, len);
|
||||
|
||||
i->type = CW_ITEMTYPE_VENDORSTR;
|
||||
i->data = vendorstr_create(vendor_id,vendorstr,len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -239,3 +263,33 @@ void cw_item_release_data_ptr(struct cw_item *item, void *data)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int cw_itemstore_set(cw_itemstore_t itemstore, uint32_t item_id, int item_type, uint8_t *data, int len)
|
||||
{
|
||||
switch (item_type) {
|
||||
case CW_ITEMTYPE_BYTE:
|
||||
cw_itemstore_set_byte(itemstore,item_id,*data);
|
||||
break;
|
||||
|
||||
case CW_ITEMTYPE_STR:
|
||||
cw_itemstore_set_strn(itemstore,item_id,(char*)data,len);
|
||||
break;
|
||||
case CW_ITEMTYPE_BSTR:
|
||||
cw_itemstore_set_bstrn(itemstore,item_id,data,len);
|
||||
break;
|
||||
case CW_ITEMTYPE_DATA:
|
||||
cw_itemstore_set_data(itemstore,item_id,data,len);
|
||||
break;
|
||||
case CW_ITEMTYPE_VENDORSTR:
|
||||
cw_itemstore_set_vendorstr(itemstore,item_id,
|
||||
cw_get_dword(data),data+4,len-4);
|
||||
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -26,6 +26,9 @@
|
||||
#include "avltree.h"
|
||||
#include "bstr.h"
|
||||
|
||||
/**
|
||||
* Item types supported in item store
|
||||
*/
|
||||
enum cw_cfgtem_types {
|
||||
CW_ITEMTYPE_NONE = 0,
|
||||
CW_ITEMTYPE_BYTE,
|
||||
@ -35,7 +38,10 @@ enum cw_cfgtem_types{
|
||||
CW_ITEMTYPE_CONST_DATA,
|
||||
CW_ITEMTYPE_STR,
|
||||
CW_ITEMTYPE_BSTR,
|
||||
CW_ITEMTYPE_VERSION,
|
||||
CW_ITEMTYPE_BSTR16,
|
||||
/** Vendor string contains a Vendor ID, followed by bstr16 data, containing
|
||||
the string. */
|
||||
CW_ITEMTYPE_VENDORSTR,
|
||||
CW_ITEMTYPE_AVLTREE,
|
||||
CW_ITEMTYPE_FUN,
|
||||
|
||||
@ -69,8 +75,35 @@ extern int cw_itemstore_set_str(cw_itemstore_t s,uint32_t id,const char *str);
|
||||
extern int cw_itemstore_set_ptr(cw_itemstore_t s, uint32_t id, void *ptr);
|
||||
extern int cw_itemstore_set_bstrn(cw_itemstore_t s, uint32_t id, uint8_t * data, int len);
|
||||
extern int cw_itemstore_set_dword(cw_itemstore_t s, uint32_t id, uint32_t dword);
|
||||
extern int cw_itemstore_set_word(cw_itemstore_t s, uint32_t id, uint32_t word);
|
||||
extern int cw_itemstore_set_byte(cw_itemstore_t s, uint32_t id, uint8_t byte);
|
||||
extern int cw_itemstore_set_version(cw_itemstore_t s, uint32_t id, uint32_t vendor_id, uint8_t * versionstr, int len);
|
||||
extern int cw_itemstore_set_vendorstr(cw_itemstore_t s, uint32_t id,
|
||||
uint32_t vendor_id, uint8_t * vendorstr,
|
||||
int len);
|
||||
int cw_itemstore_set_avltree(cw_itemstore_t s, uint32_t id, struct avltree *t);
|
||||
int cw_itemstore_set_bstr16n(cw_itemstore_t s, uint32_t id, uint8_t * data, int len);
|
||||
|
||||
|
||||
extern int cw_itemstore_set_data(cw_itemstore_t s, uint32_t id, const uint8_t * data,
|
||||
int len);
|
||||
|
||||
static inline char * cw_itemstore_get_str(cw_itemstore_t s,uint32_t id) {
|
||||
struct cw_item *i = cw_itemstore_get(s,id);
|
||||
if (!i)
|
||||
return NULL;
|
||||
return i->data;
|
||||
|
||||
};
|
||||
|
||||
static inline struct avltree * cw_itemstore_get_avltree(cw_itemstore_t s,uint32_t id){
|
||||
struct cw_item *i = cw_itemstore_get(s,id);
|
||||
if (!i)
|
||||
return NULL;
|
||||
if (i->type!=CW_ITEMTYPE_AVLTREE)
|
||||
return NULL;
|
||||
return i->data;
|
||||
}
|
||||
|
||||
|
||||
extern void *cw_item_get_data_ptr(struct cw_item *item);
|
||||
extern void cw_item_release_data_ptr(struct cw_item *item, void *data);
|
||||
@ -80,5 +113,6 @@ int cw_itemstore_set_fun(cw_itemstore_t s, uint32_t id,
|
||||
void *(*funget) (void *arg),
|
||||
void (*funfree) (void *arg, void *data), void *arg);
|
||||
|
||||
int cw_itemstore_set(cw_itemstore_t itemstore, uint32_t item_id, int item_type, uint8_t *data, int len);
|
||||
|
||||
#endif
|
||||
|
@ -17,14 +17,13 @@ extern cw_strheap_t cw_strheap_create();
|
||||
extern int cw_strheap_register_strings(cw_strheap_t h, struct cw_str *s);
|
||||
|
||||
static inline const char * cw_strheap_get(cw_strheap_t h, int id) {
|
||||
struct cw_str s, *rc;
|
||||
struct cw_str s;
|
||||
s.id=id;
|
||||
rc = avltree_get(h,&s);
|
||||
if (rc)
|
||||
return rc->str;
|
||||
return cw_strheap_get(h,0);
|
||||
struct cw_str *r = avltree_get(h,&s);
|
||||
if (r)
|
||||
return r->str;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -6,7 +6,7 @@ ifndef CC
|
||||
endif
|
||||
|
||||
|
||||
|
||||
V=0
|
||||
|
||||
CFLAGS+=-DWITH_RMAC_SUPPORT
|
||||
CFLAGS+=-DWITH_IPV6
|
||||
@ -21,6 +21,7 @@ endif
|
||||
|
||||
|
||||
CFLAGS += -Os -Wall -g
|
||||
CFLAGS += -Os -Wall
|
||||
LDFLAGS += -L../../src/capwap/$(ARCH)
|
||||
|
||||
|
||||
@ -103,7 +104,7 @@ ALL=wtp
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
Q=
|
||||
Q=@
|
||||
E=echo
|
||||
ifeq ($(V), 1)
|
||||
Q=
|
||||
@ -111,8 +112,8 @@ E=true
|
||||
endif
|
||||
|
||||
%.o: %.c
|
||||
$(Q)$(CC) -c -o $@ $(CFLAGS) $<
|
||||
@$(E) " CC " $<
|
||||
$(Q)$(CC) -c -o $@ $(CFLAGS) $<
|
||||
|
||||
|
||||
wtp: $(BCHECK) $(OBJS)
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
int configure()
|
||||
{
|
||||
/*
|
||||
struct conn * conn = get_conn();
|
||||
struct wtpinfo * wtpinfo = get_wtpinfo();
|
||||
|
||||
@ -22,7 +23,7 @@ int configure()
|
||||
|
||||
|
||||
printf("Got change resp %p\n",cwrmsg);
|
||||
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -25,252 +25,54 @@
|
||||
|
||||
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/wtpinfo.h"
|
||||
#include "capwap/acinfo.h"
|
||||
#include "capwap/sock.h"
|
||||
#include "capwap/cw_util.h"
|
||||
|
||||
|
||||
#include "wtp.h"
|
||||
#include "wtp_conf.h"
|
||||
#include "wtp_interface.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
struct discovery_info{
|
||||
ACIPLIST * aciplist;
|
||||
struct conn * conn;
|
||||
int response_count;
|
||||
};
|
||||
|
||||
static int acprint(void *p,void*d) //,int ctr)
|
||||
|
||||
static int run_discovery(struct conn *conn)
|
||||
{
|
||||
conn->capwap_state=CW_STATE_DISCOVERY;
|
||||
cw_itemstore_set_byte(conn->local,CW_ITEM_DISCOVERY_TYPE,CW_DISCOVERY_TYPE_UNKNOWN);
|
||||
|
||||
|
||||
ACIP * ip = (ACIP*)d;
|
||||
char str[100];
|
||||
sock_addrtostr((struct sockaddr*)&ip->ip,str,100);
|
||||
printf("ACIP: %s\n",str);
|
||||
printf("CTR: %i\n",ip->wtp_count);
|
||||
return 1;
|
||||
cw_init_request(conn,CW_MSG_DISCOVERY_REQUEST);
|
||||
cw_put_msg(conn,conn->req_buffer);
|
||||
conn_send_msg(conn,conn->req_buffer);
|
||||
|
||||
|
||||
time_t timer = cw_timer_start(10);
|
||||
|
||||
while (!cw_timer_timeout(timer)
|
||||
&& conn->capwap_state == CW_STATE_DISCOVERY) {
|
||||
cw_read_messages(conn);
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct ac_info wtp_acinfo;
|
||||
|
||||
|
||||
static int msg_cb(void *priv,struct cwrmsg * cwrmsg)
|
||||
{
|
||||
if (cwrmsg->type != CW_MSG_DISCOVERY_RESPONSE){
|
||||
cw_dbg(DBG_ERR,"Expected discovery response, but received %i",cwrmsg->type);
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct discovery_info * di = (struct discovery_info*)priv;
|
||||
|
||||
/*
|
||||
if (di->conn->seqnum != cwrmsg->seqnum){
|
||||
cw_log_debug0("Ignoring discovery respone, seqnum=%i, expected seqnum %i",cwrmsg->seqnum,di->conn->seqnum);
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
struct ac_info * acinfo = &wtp_acinfo;
|
||||
memset(acinfo,0,sizeof(struct ac_info));
|
||||
|
||||
acinfo->aciplist = di->aciplist;
|
||||
|
||||
|
||||
|
||||
|
||||
cwread_discovery_response(acinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char ai [4096];
|
||||
acinfo_print(ai,acinfo);
|
||||
printf("AC INFO\n%s",ai);
|
||||
|
||||
|
||||
//printf("CWRHW: %s\n",sock_hwaddr2str(bstr_data(cwrmsg->rmac),bstr_len(cwrmsg->rmac)));
|
||||
///exit(0);
|
||||
|
||||
|
||||
/*
|
||||
printf("AC NAME %s\n",acinfo.ac_name);
|
||||
printf("AC Software version %s\n",acinfo.software_version);
|
||||
printf("AC Hardwareversion %s\n",acinfo.hardware_version);
|
||||
|
||||
printf("Active wtps: %i\n",acinfo.active_wtps);
|
||||
printf("Active max wtps: %i\n",acinfo.max_wtps);
|
||||
|
||||
|
||||
printf("Got Discovery response\n");
|
||||
|
||||
printf("ACL COUNT: %i\n",acinfo.aciplist->count);
|
||||
*/
|
||||
aciplist_foreach(acinfo->aciplist,acprint,0);
|
||||
|
||||
// responses++;
|
||||
//
|
||||
di->response_count++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void rand_sleep(int seconds)
|
||||
{
|
||||
int usecs = seconds * 1000;
|
||||
uint16_t rnd;
|
||||
cw_rand((uint8_t*)&rnd,sizeof(rnd));
|
||||
uint16_t max = 0-1;
|
||||
int r = (rnd * usecs) / max;
|
||||
cw_dbg(DBG_CW_INFO,"Sleeping for %u milliseconds\n",r);
|
||||
usleep(r*1000);
|
||||
}
|
||||
|
||||
|
||||
static int do_discover_conn(struct conn * conn,struct discovery_info * di)
|
||||
{
|
||||
rand_sleep(conf_max_discovery_interval);
|
||||
|
||||
|
||||
struct wtpinfo * wtpinfo;
|
||||
wtpinfo = get_wtpinfo();
|
||||
// wtpinfo_print(wtpinfo);
|
||||
|
||||
|
||||
// struct timespec tstart,tcur;
|
||||
struct radioinfo ri;
|
||||
memset(&ri,0,sizeof(ri));
|
||||
|
||||
struct radioinfo * rip = &wtpinfo->radioinfo[0];
|
||||
|
||||
/*
|
||||
ri.rmac[0]=6;
|
||||
ri.rmac[2]=14;
|
||||
ri.rmac[3]=14;
|
||||
ri.rmac[4]=14;
|
||||
ri.rmac[5]=14;
|
||||
ri.rmac[6]=14;
|
||||
ri.rmac[7]=14;
|
||||
*/
|
||||
|
||||
#ifdef WITH_CW_LOG_DEBUG
|
||||
char str[100];
|
||||
sock_addrtostr((struct sockaddr*)&conn->addr,str,100);
|
||||
// cw_log_debug0("Sending discovery request to %s",str);
|
||||
#endif
|
||||
|
||||
int rc;
|
||||
|
||||
do {
|
||||
conn->capwap_mode=CWMODE_CISCO;
|
||||
rc = cwsend_discovery_request(conn,rip,wtpinfo);
|
||||
if (rc<0){
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EMSGSIZE){
|
||||
conn->mtu-=4;
|
||||
// cw_log_debug2("Setting mtu to %i",conn->mtu);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}while (rc<0);
|
||||
|
||||
|
||||
if (rc < 0 )
|
||||
{
|
||||
char str[100];
|
||||
sock_addrtostr((struct sockaddr*)&conn->addr,str,100);
|
||||
cw_log(LOG_ERR,"Error sending discovery request to %s: %s",str,strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct connlist * connlist;
|
||||
connlist = connlist_create(30);
|
||||
|
||||
// clock_gettime(CLOCK_REALTIME,&tstart);
|
||||
//
|
||||
int tstart = time(0);
|
||||
int treset = 0;
|
||||
do {
|
||||
char buf[2048];
|
||||
int buflen=2048;
|
||||
struct sockaddr_storage sa;
|
||||
socklen_t fromlen=sizeof(struct sockaddr_storage);
|
||||
rc = recvfrom(conn->sock,buf,buflen,0,(struct sockaddr*)&sa,&fromlen);
|
||||
if (rc<0){
|
||||
if (errno==EINTR)
|
||||
rc=0;
|
||||
if (errno==EAGAIN)
|
||||
rc=0;
|
||||
if (errno==EWOULDBLOCK)
|
||||
rc=0;
|
||||
}
|
||||
if (rc>0) {
|
||||
#ifdef WITH_CW_LOG_DEBUG
|
||||
char str[100];
|
||||
sock_addrtostr((struct sockaddr*)&sa,str,100);
|
||||
// cw_log_debug0("Received packet from %s",str);
|
||||
#endif
|
||||
|
||||
struct conn * rconn;
|
||||
rconn = connlist_get(connlist,(struct sockaddr*)&sa);
|
||||
|
||||
if (!rconn){
|
||||
rconn = conn_create_noq(conn->sock,(struct sockaddr*)&sa); //msg_cb,NULL,0);
|
||||
// rconn->pmsgarg=conn->pmsgarg;
|
||||
rconn->mtu = conn->mtu;
|
||||
rconn->seqnum=conn->seqnum;
|
||||
connlist_add(connlist,rconn);
|
||||
}
|
||||
|
||||
conn_process_packet(rconn,(uint8_t*)buf,rc,msg_cb,di);
|
||||
}
|
||||
|
||||
/* reset discovery timer after we have received the first response */
|
||||
if ( di->response_count == 1 && !treset ){
|
||||
tstart=time(0);
|
||||
treset=1;
|
||||
}
|
||||
|
||||
//clock_gettime(CLOCK_REALTIME,&tcur);
|
||||
// printf("TTSub: %i %i\n",time(0)-tstart, conf_discovery_interval);
|
||||
}while(time(0)-tstart < conf_discovery_interval && rc>=0 );
|
||||
|
||||
|
||||
if (rc <0){
|
||||
char str[100];
|
||||
sock_addrtostr((struct sockaddr*)&conn->addr,str,100);
|
||||
cw_log(LOG_ERR,"Error sendings discovery request to %s: %s",str,strerror(errno));
|
||||
}
|
||||
|
||||
connlist_destroy(connlist);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static int discovery_count;
|
||||
|
||||
ACIPLIST * do_discovery(const char *acaddr)
|
||||
/**
|
||||
* Run discovery for on address (eg broadcast 255.255.255.255)
|
||||
*/
|
||||
static int cw_run_discovery(struct conn *conn, const char *acaddr)
|
||||
{
|
||||
|
||||
/* get an partially intialized connection object
|
||||
* (seqnum should be set)
|
||||
* */
|
||||
struct conn * conn = get_conn();
|
||||
if (!conn){
|
||||
cw_log(LOG_ERR,"Can't create conn for %s: %s",acaddr,strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* get addr of destination */
|
||||
struct addrinfo hints;
|
||||
struct addrinfo * res,*res0;
|
||||
@ -285,21 +87,8 @@ ACIPLIST * do_discovery(const char *acaddr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct discovery_info di;
|
||||
memset (&di,0,sizeof(struct discovery_info));
|
||||
di.aciplist = aciplist_create();
|
||||
di.response_count=0;
|
||||
|
||||
|
||||
for(res=res0; res; res=res->ai_next)
|
||||
{
|
||||
if ( discovery_count >= conf_max_discoveries){
|
||||
sulking_state();
|
||||
discovery_count=0;
|
||||
// cw_log_debug0("Entering discovery state");
|
||||
}
|
||||
discovery_count++;
|
||||
|
||||
|
||||
int sockfd;
|
||||
int opt;
|
||||
@ -311,39 +100,30 @@ ACIPLIST * do_discovery(const char *acaddr)
|
||||
|
||||
opt = 1;
|
||||
if (setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &opt, sizeof(opt))<0){
|
||||
cw_log(LOG_ERR,"Cant set broadcast sockopt");
|
||||
cw_log(LOG_ERR,"Can't set broadcast sockopt");
|
||||
}
|
||||
sock_set_recvtimeout(sockfd,1);
|
||||
|
||||
sock_set_dontfrag(sockfd,0);
|
||||
|
||||
di.conn=conn;
|
||||
|
||||
sock_copyaddr(&conn->addr,res->ai_addr);
|
||||
conn->sock=sockfd;
|
||||
|
||||
do_discover_conn(conn,&di);
|
||||
|
||||
|
||||
if ( di.aciplist->count != 0){
|
||||
set_sock(sockfd);
|
||||
break;
|
||||
}
|
||||
run_discovery(conn);
|
||||
|
||||
close(sockfd);
|
||||
|
||||
|
||||
}
|
||||
|
||||
freeaddrinfo(res0);
|
||||
|
||||
if (di.aciplist->count){
|
||||
cw_dbg(DBG_CW_INFO,"Discovery responses received: %i\n",di.response_count);
|
||||
return di.aciplist;
|
||||
|
||||
}
|
||||
|
||||
aciplist_destroy(di.aciplist);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int discovery()
|
||||
{
|
||||
struct conn * conn = get_conn();
|
||||
cw_run_discovery(conn,"255.255.255.255");
|
||||
return 0;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "capwap/sock.h"
|
||||
#include "capwap/dtls.h"
|
||||
|
||||
|
||||
/*
|
||||
#define acinfo_log acinfo_log_
|
||||
|
||||
void acinfo_log_(int level,const struct ac_info *acinfo,const char * xstr)
|
||||
@ -175,3 +175,6 @@ printf("Joined with conn %p\n",conn);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include "wtp_conf.h"
|
||||
|
||||
/*
|
||||
static int echo_interval_timer;
|
||||
|
||||
struct cwrmsg * get_response(struct conn * conn, int type,int seqnum)
|
||||
@ -34,9 +35,10 @@ struct cwrmsg * get_response(struct conn * conn, int type,int seqnum)
|
||||
return 0;
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
struct cwrmsg * send_request(struct conn * conn,struct cwmsg *cwmsg)
|
||||
{
|
||||
int i;
|
||||
@ -61,10 +63,11 @@ struct cwrmsg * send_request(struct conn * conn,struct cwmsg *cwmsg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//extern struct conn * get_conn();
|
||||
|
||||
extern struct conn * get_conn();
|
||||
|
||||
/*
|
||||
int run(struct conn * conn)
|
||||
{
|
||||
|
||||
@ -135,4 +138,4 @@ printf("Error !\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
@ -1,7 +1,15 @@
|
||||
#ifndef __WTP_H
|
||||
#define __WTP_H
|
||||
|
||||
#include "capwap/conn.h"
|
||||
|
||||
|
||||
|
||||
extern int sulking_state();
|
||||
extern int join();
|
||||
extern int discovery();
|
||||
|
||||
|
||||
struct conn * get_conn();
|
||||
|
||||
#endif
|
||||
|
@ -142,6 +142,8 @@ typedef struct {
|
||||
extern LONGSTRS conf_timer_cfgstrs[];
|
||||
|
||||
|
||||
int wtpconf_preinit();
|
||||
int wtpconf_init();
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "wtp_conf.h"
|
||||
#include "wtp_interface.h"
|
||||
|
||||
|
||||
/*
|
||||
struct wtpinfo * get_wtpinfo()
|
||||
{
|
||||
struct wtpinfo * wtpinfo;
|
||||
@ -125,3 +125,8 @@ struct conn * get_conn()
|
||||
printf("Get conn returns %p\n",conn);
|
||||
return conn;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -3,116 +3,26 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
//#include <iwlib.h>
|
||||
|
||||
#include "capwap/sock.h"
|
||||
#include "capwap/conn.h"
|
||||
#include "capwap/dtls.h"
|
||||
#include "capwap/avltree.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/capwap.h"
|
||||
#include "capwap/cw_util.h"
|
||||
#include "capwap/wtpinfo.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
#include "capwap/conn.h"
|
||||
#include "capwap/cw_log.h"
|
||||
#include "capwap/dtls.h"
|
||||
|
||||
#include "wtp.h"
|
||||
#include "wtp_conf.h"
|
||||
|
||||
|
||||
|
||||
struct wtpinfo wtpinfo;
|
||||
|
||||
//int conf_rids[2];
|
||||
//int conf_rids_len[2];
|
||||
|
||||
//int responses = 0;
|
||||
|
||||
struct avltree * aclist =0;
|
||||
/** The one and only connection object */
|
||||
struct conn *the_conn;
|
||||
struct cw_actiondef capwap_actions;
|
||||
|
||||
|
||||
extern struct wpa_driver_ops *wpa_drivers[];
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
//struct sockaddr conf_preferred_ac;
|
||||
|
||||
|
||||
|
||||
static void * drv_priv[2];
|
||||
static void * drv_glob[2];
|
||||
|
||||
const char * interfaces[]={
|
||||
"wlan0",
|
||||
"wlan1-1"
|
||||
};
|
||||
|
||||
/*static int drv_init()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
|
||||
|
||||
wtp_main();
|
||||
}
|
||||
|
||||
|
||||
#include <time.h>
|
||||
|
||||
int pmu;
|
||||
|
||||
//#include <openssl/ssl.h>
|
||||
|
||||
int do_connect(void *priv,void *data)
|
||||
{
|
||||
ACIP * ip = (ACIP*)data;
|
||||
// char str[100];
|
||||
// sock_addrtostr((struct sockaddr*)&ip->ip,str,100);
|
||||
|
||||
sock_setport(&ip->ip,atoi(conf_control_port));
|
||||
// printf("Would connect to %s\n",str);
|
||||
|
||||
|
||||
printf("Sleep 5000\n");
|
||||
printf("slept\n");
|
||||
|
||||
int rc;
|
||||
rc = join(&ip->ip);
|
||||
if (!rc)
|
||||
return 1;
|
||||
|
||||
printf("Sleep after oin\n");
|
||||
printf("Go conf\n");
|
||||
// extern struct conn * get_conn();
|
||||
// extern join_state(struct conn * conn);
|
||||
// struct conn * conn = get_conn();
|
||||
//printf("Join conn = %p\n",conn);
|
||||
|
||||
// join_state(conn);
|
||||
|
||||
|
||||
// rc = join(&ip->ip);
|
||||
// if (!rc)
|
||||
// return 1;
|
||||
|
||||
rc = configure();
|
||||
|
||||
run (get_conn());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#include "capwap/bstr.h"
|
||||
|
||||
int wtp_main(const char *ad)
|
||||
{
|
||||
wtpconf_preinit();
|
||||
|
||||
if (!read_config("./wtp_uci.conf")) {
|
||||
@ -126,56 +36,38 @@ int wtp_main(const char *ad)
|
||||
cw_dbg_opt_detail = DBG_DETAIL_ASC_DMP;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// cw_log_debug_level=6; //conf_debug_level;
|
||||
|
||||
// conf_dtls_psk="Tube";
|
||||
// conf_sslkeyfilename="../../ssl/wtp.key";
|
||||
// conf_sslcertfilename="../../ssl/wtp.crt";
|
||||
// conf_dtls_psk=0;
|
||||
|
||||
// conf_sslkeyfilename="../../ssl/ac_cisco.key";
|
||||
// conf_sslcertfilename="../../ssl/ac_cisco.pem";
|
||||
conf_sslkeypass="Tube";
|
||||
|
||||
|
||||
|
||||
#ifdef WITH_DTLS
|
||||
dtls_init();
|
||||
#endif
|
||||
|
||||
//drv_init();
|
||||
the_conn = conn_create_noq(-1, NULL);
|
||||
struct conn *conn = the_conn;
|
||||
|
||||
|
||||
while (1){
|
||||
ACIPLIST * aciplist=0;
|
||||
int i;
|
||||
cw_register_actions_capwap_wtp(&capwap_actions);
|
||||
conn->actions = &capwap_actions;
|
||||
conn->remote = cw_itemstore_create();
|
||||
conn->local = cw_itemstore_create();
|
||||
|
||||
cw_dbg(DBG_CW_INFO,"Entering discovery state");
|
||||
cw_itemstore_t board_data = cw_itemstore_create();
|
||||
cw_itemstore_set_dword(board_data, CW_ITEM_WTP_BOARD_VENDOR, conf_vendor_id);
|
||||
|
||||
do {
|
||||
for (i=0; i<conf_ac_list_len; i++){
|
||||
if ((aciplist = do_discovery(conf_ac_list[i])))
|
||||
break;
|
||||
}
|
||||
}while (!aciplist);
|
||||
|
||||
// cw_log_debug0("Entering join state");
|
||||
if (!aciplist){
|
||||
// cw_log_debug0("Don't got any discovery response");
|
||||
exit(0);
|
||||
}
|
||||
cw_itemstore_set_bstrn(board_data, CW_ITEM_WTP_BOARD_MACADDRESS, conf_macaddress,
|
||||
conf_macaddress_len);
|
||||
cw_itemstore_set_bstr16n(board_data, CW_ITEM_WTP_BOARD_SERIALNO,
|
||||
bstr_data(conf_serial_no), bstr_len(conf_serial_no));
|
||||
|
||||
aciplist_foreach(aciplist,do_connect,0);
|
||||
|
||||
aciplist_destroy(aciplist);
|
||||
|
||||
|
||||
cw_itemstore_set_avltree(conn->local, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||
|
||||
discovery();
|
||||
|
||||
|
||||
}
|
||||
exit(0);
|
||||
|
||||
|
||||
return 0;
|
||||
struct conn *get_conn()
|
||||
{
|
||||
return the_conn;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user