Work in progress ...

FossilOrigin-Name: a76e8760f309d36aad22507f961ac5a03f46df9ee585c2f8601ee0a5a088738e
This commit is contained in:
7u83@mail.ru
2015-02-01 15:55:45 +00:00
parent 84e6d01348
commit c851831463
23 changed files with 236 additions and 68 deletions

View File

@ -1,4 +1,5 @@
include ../WtpConfig.mak
include ../Macros.mak
ifndef CC
CC=gcc
@ -52,8 +53,8 @@ LIBS+=-lcapwap
#LIBS+=-liw
LIBS+=-lnl-3
LIBS+=-lnl-genl-3
LIBS+=-lssl
LIBS+=-lcrypto
LIBS+=$(OPENSSLLIB)
#LIBS+=-lcrypto
#LIBS+=-lrt
ifdef WITH_UCI
LIBS+=-luci -lubox
@ -73,6 +74,7 @@ CFLAGS += $(HA_INCS)
#CFLAGS += -I../src
#CFLAGS += -I../src/utils
CFLAGS += -I../../src
CFLAGS += -I$(OPENSSLINC)
#CFLAGS += -I/usr/local/include

View File

@ -17,6 +17,8 @@
#include "capwap/cw_log.h"
#include "capwap/bstr.h"
static struct uci_section * get_anon_section(struct uci_package * pkg, const char *type)
{
@ -75,7 +77,7 @@ int read_config(const char * filename){
struct uci_section * section = get_anon_section(pkg,"wtp");
if (!section) {
cw_dbg(DBG_CW_INFO,"No 'wtp' section found, running withou config");
cw_dbg(DBG_CW_INFO,"No 'wtp' section found, running without config");
return 1;
}
@ -85,7 +87,6 @@ int read_config(const char * filename){
if (str)
conf_wtpname = strdup(str);
str = uci_lookup_option_string(ctx,section,"mtu");
if (str)
conf_mtu = atoi(str);
@ -93,7 +94,31 @@ int read_config(const char * filename){
str = uci_lookup_option_string(ctx,section,"mtu_discovery");
if (str)
conf_mtu_discovery = atoi(str);
str = uci_lookup_option_string(ctx,section,"ssl_key");
if (str)
conf_sslkeyfilename=strdup(str);
str = uci_lookup_option_string(ctx,section,"ssl_cert");
if (str)
conf_sslcertfilename=strdup(str);
str = uci_lookup_option_string(ctx,section,"vendor_id");
if (str)
conf_vendor_id=atoi(str);
str = uci_lookup_option_string(ctx,section,"software_version");
if (str){
uint8_t * s = bstr_create_from_cfgstr(str);
bstr_replace(&conf_software_version,s);
}
str = uci_lookup_option_string(ctx,section,"model_no");
if (str){
uint8_t * s = bstr_create_from_cfgstr(str);
bstr_replace(&conf_model_no,s);
}
return 1;

View File

@ -67,10 +67,13 @@ static int msg_cb(void *priv,struct cwrmsg * cwrmsg)
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;
memset(&acinfo,0,sizeof(acinfo));

View File

@ -100,6 +100,10 @@ int join(struct sockaddr *sa)
}
#endif
*/
printf("conf_dtls_cipher %s\n",conf_dtls_cipher);
if (conf_dtls_psk){
conn->dtls_psk=conf_dtls_psk;
conn->dtls_psk_len=strlen(conn->dtls_psk);

View File

@ -60,6 +60,19 @@ int conf_mtu_discovery=CONF_DEFAULT_MTU_DISCOVERY;
int conf_mtu=0;
uint32_t conf_vendor_id;
uint32_t * conf_bootloader_vendor_id;
uint8_t * conf_bootloader_version;
uint32_t * conf_software_vendor_id;
uint8_t * conf_software_version;
uint32_t * conf_hardware_vendor_id;
uint8_t * conf_hardware_version;
uint8_t * conf_model_no;
uint8_t * cont_serial_no;
int wtpconf_primary_if()
@ -177,6 +190,11 @@ int wtpconf_preinit()
conf_control_port=strdup(CAPWAP_CONTROL_PORT_STR);
conf_dtls_cipher=strdup(CONF_DEFAULT_DTLS_CIPHER);
conf_vendor_id = CONF_DEFAULT_VENDOR_ID;
conf_software_version = bstr_create(CONF_DEFAULT_SOFTWARE_VERSION);
}
int wtpconf_init()

View File

@ -13,6 +13,16 @@ extern char * conf_sslcertfilename;
extern char * conf_sslkeypass;
extern uint32_t conf_vendor_id;
extern uint32_t * conf_bootloader_vendor_id;
extern uint8_t * conf_bootloader_version;
extern uint32_t * conf_software_vendor_id;
extern uint8_t * conf_software_version;
extern uint32_t * conf_hardware_vendor_id;
extern uint8_t * conf_hardware_version;
extern uint8_t * conf_model_no;
extern uint8_t * cont_serial_no;
@ -28,6 +38,42 @@ extern uint8_t conf_macaddress[12];
extern uint8_t conf_macaddress_len;
#ifndef CONF_DEFAULT_VENDOR_ID
#define CONF_DEFAULT_VENDOR_ID CW_VENDOR_ID_FSF
#endif
#ifndef CONF_DEFAULT_HARDWARE_VENDOR_ID
#define CONF_DEFAULT_HARDWARE_VENDOR_ID CW_VENDOR_ID_FSF
#endif
#ifndef CONF_DEFAULT_SOFTWARE_VENDOR_ID
#define CONF_DEFAULT_SOFTWARE_VENDOR_ID CW_VENDOR_ID_FSF
#endif
#ifndef CONF_DEFAULT_BOOTLOADER_VENDOR_ID
#define CONF_DEFAULT_BOOTLOADER_VENDOR_ID CW_VENDOR_ID_FSF
#endif
#ifndef CONF_DEFAULT_MODEL_NO
#define CONF_DEFAULT_MODEL_NO "W-FAT"
#endif
#ifndef CONF_DEFAULT_SERIAL_NO
#define CONF_DEFAULT_SERIAL_NO "0000"
#endif
#ifndef CONF_DEFAULT_SOFTWARE_VERSION
#define CONF_DEFAULT_SOFTWARE_VERSION "0.1"
#endif
#ifndef CONF_DEFAULT_HARDWARE_VERSION
#define CONF_DEFAULT_HARDWARE_VERSION "0.1"
#endif
#ifndef CONF_DEFAULT_MAX_DISCOVERY_INTERVAL
#define CONF_DEFAULT_MAX_DISCOVERY_INTERVAL CAPWAP_MAX_DISCOVERY_INTERVAL

View File

@ -27,9 +27,9 @@ struct wtpinfo * get_wtpinfo()
}
*/
wtpinfo->serial_no="123456789";
wtpinfo->vendor_id=909090;
wtpinfo->vendor_id=conf_vendor_id;
wtpinfo->model_no="WNDR 3700";
wtpinfo->model_no=conf_model_no;
wtpinfo->bootloader_version="";
wtpinfo->bootloader_vendor_id=CW_VENDOR_ID_CISCO;
@ -37,7 +37,7 @@ struct wtpinfo * get_wtpinfo()
wtpinfo->hardware_version="\0\0";
wtpinfo->hardware_vendor_id=CW_VENDOR_ID_CISCO;
wtpinfo->software_version="2.23(UJA.6)";
wtpinfo->software_version=conf_software_version;
wtpinfo->software_vendor_id=CW_VENDOR_ID_CISCO;
wtpinfo->macaddress=conf_macaddress;

View File

@ -89,15 +89,21 @@ int do_connect(void *priv,void *data)
return 0;
}
#include "capwap/bstr.h"
int wtp_main(const char *ad)
{
cw_dbg_opt_level = DBG_DTLS | DBG_CW_INFO | DBG_ALL;
gr();
exit(0);
// gr();
// exit(0);
wtpconf_preinit();
if (!read_config("./wtpconf")){
if (!read_config("./wtp_uci.conf")){
return 1;
}
@ -108,11 +114,14 @@ int wtp_main(const char *ad)
// cw_log_debug_level=6; //conf_debug_level;
conf_dtls_psk="Tube";
// conf_dtls_psk=0;
// conf_dtls_psk="Tube";
// conf_sslkeyfilename="../../ssl/wtp.key";
// conf_sslcertfilename="../../ssl/wtp.crt";
// conf_sslkeypass="7u83";
// conf_dtls_psk=0;
// conf_sslkeyfilename="../../ssl/ac_cisco.key";
// conf_sslcertfilename="../../ssl/ac_cisco.pem";
conf_sslkeypass="Tube";

View File

@ -11,5 +11,17 @@ config 'wtp'
# Do MTU discovery (means append mtu discovery
# padding msg element when sendig discovery requests)
option mtu_discovery 1
option mtu_discovery 1
# SSL certificate and key
# (default is empty, you have to specify one)
option ssl_cert
option ssl_key
# vendor id
# set the vendor id as integer value
# default is gnu
option vendor_id