Some auto-configuration added to WTP.
FossilOrigin-Name: 713e47f5aebc856271a50620b23ca95262511da28c4ae2c0fee9696b28caa1ff
This commit is contained in:
parent
f1888d2503
commit
dfbb71cb29
@ -142,6 +142,7 @@ CAPWAPOBJS= \
|
||||
cw_in_check_img_data_req_ac.o \
|
||||
cw_in_check_img_data_req_wtp.o \
|
||||
cw_in_check_img_data_resp.o \
|
||||
cw_in_check_generic_resp.o \
|
||||
cw_out_generic.o \
|
||||
cw_out_wtp_descriptor.o \
|
||||
cw_in_cisco_image_identifier.o\
|
||||
|
@ -53,15 +53,16 @@ static inline int cw_put_version(uint8_t * dst, uint16_t subelem_id, bstrv_t v)
|
||||
|
||||
|
||||
extern int cw_read_wtp_descriptor(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len);
|
||||
struct cw_action_in *a, uint8_t * data, int len);
|
||||
|
||||
extern int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
|
||||
struct cw_action_in *a, uint8_t * data, int len);
|
||||
|
||||
extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
||||
int len);
|
||||
extern int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len);
|
||||
|
||||
|
||||
extern int cw_in_check_generic_resp(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len, struct sockaddr *from);
|
||||
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@ static cw_action_in_t actions_in[] = {
|
||||
{
|
||||
.capwap_state = CW_STATE_JOIN,
|
||||
.msg_id = CW_MSG_JOIN_RESPONSE,
|
||||
.end = cw_in_check_join_resp
|
||||
.end = cw_in_check_generic_resp
|
||||
}
|
||||
,
|
||||
/* Result Code - Join Response */
|
||||
@ -101,7 +101,30 @@ static cw_action_in_t actions_in[] = {
|
||||
}
|
||||
,
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* Message Configuration Status Response - IN
|
||||
*/
|
||||
{
|
||||
.capwap_state = CW_STATE_CONFIGURE,
|
||||
.msg_id = CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||
.end = cw_in_check_generic_resp
|
||||
}
|
||||
,
|
||||
|
||||
/* Result Code - Config Status Resp */
|
||||
{
|
||||
.capwap_state = CW_STATE_CONFIGURE,
|
||||
.msg_id = CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||
.elem_id = CW_ELEM_RESULT_CODE,
|
||||
.item_id = CW_ITEM_RESULT_CODE,
|
||||
.start = cw_in_generic2,
|
||||
.min_len = 4,
|
||||
.max_len = 4,
|
||||
.mand = 0
|
||||
}
|
||||
,
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -249,6 +272,19 @@ static cw_action_out_t actions_out[] = {
|
||||
,
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------
|
||||
* Configuration Status Request - Out
|
||||
*/
|
||||
{
|
||||
.msg_id = CW_MSG_CONFIGURATION_STATUS_REQUEST,
|
||||
.elem_id = CW_ELEM_AC_NAME,
|
||||
.item_id = CW_ITEM_AC_NAME,
|
||||
.out = cw_out_generic,
|
||||
.get = cw_out_get_local,
|
||||
.mand = 1
|
||||
}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -98,6 +98,7 @@ OBJS += run.o
|
||||
OBJS += sulking.o
|
||||
OBJS += configure.o
|
||||
OBJS += changestate.o
|
||||
OBJS += setup_conf.o
|
||||
OBJS += $(CONFOBJS)
|
||||
|
||||
|
||||
|
@ -1,10 +1,3 @@
|
||||
#include "cw/mbag.h"
|
||||
#include "cw/capwap_items.h"
|
||||
#include "cw/radio.h"
|
||||
|
||||
#include "cw/conn.h"
|
||||
#include "cw/bstr.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@ -15,11 +8,14 @@
|
||||
#include "cw/mavl.h"
|
||||
#include "cw/format.h"
|
||||
#include "cw/file.h"
|
||||
//#include "cw/aciplist.h"
|
||||
//#include "cw/acpriolist.h"
|
||||
#include "cw/sock.h"
|
||||
#include "cw/item.h"
|
||||
#include "cw/action.h"
|
||||
#include "cw/mbag.h"
|
||||
#include "cw/capwap_items.h"
|
||||
#include "cw/radio.h"
|
||||
#include "cw/conn.h"
|
||||
#include "cw/bstr.h"
|
||||
|
||||
|
||||
|
||||
@ -59,8 +55,6 @@ void set_cfg(mbag_t mbag, cw_itemdefheap_t defs, const char *id, const char *sub
|
||||
if (idef)
|
||||
dyn=1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (!idef) {
|
||||
@ -246,16 +240,12 @@ int cfg_json_put_radios(char *dst, const char *name, mbag_item_t * i, int n)
|
||||
const char *comma = "";
|
||||
mavliter_foreach(&radios) {
|
||||
mbag_item_t *i = mavliter_get(&radios);
|
||||
// int rid = i->iid;
|
||||
//mbag_t radio = i->data;
|
||||
|
||||
d += sprintf(d, "%s", comma);
|
||||
comma = ",\n";
|
||||
memset(d, '\t', n + 1);
|
||||
d += n + 1;
|
||||
d += sprintf(d, "\"%d\":", i->iid);
|
||||
|
||||
//d += mbag_tojson(d, i->data, radio_cfg, n + 1);
|
||||
}
|
||||
|
||||
d += sprintf(d, "\n");
|
||||
|
@ -1,10 +1,10 @@
|
||||
{
|
||||
"location_data":"Superposition",
|
||||
"wtp_bootloader_version":"11591,W-FAT-BL-0.1",
|
||||
"wtp_hardware_version":"11591,0.1",
|
||||
"wtp_name":"WFAT-004A9902FAC0",
|
||||
"wtp_software_version":"11591,0.1",
|
||||
"radios":{
|
||||
"0":{
|
||||
|
||||
},
|
||||
"1":{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -43,15 +43,12 @@ static struct uci_section * get_anon_section(struct uci_package * pkg, const ch
|
||||
|
||||
static void set_dbg_opt(struct uci_context *ctx,struct uci_section * section,int opt,const char * optstr)
|
||||
{
|
||||
printf("Setting debug opt: %s %d - ",optstr, opt);
|
||||
|
||||
const char *str = uci_lookup_option_string(ctx,section,optstr);
|
||||
if (!str){
|
||||
printf("no\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%s\n",str);
|
||||
if ((strcmp(str,"1")==0) || (strcmp(str,"true")==0))
|
||||
//conf_dbg_level |= opt;
|
||||
cw_dbg_set_level(opt,1);
|
||||
|
@ -146,4 +146,7 @@ int wtpconf_preinit();
|
||||
int wtpconf_init();
|
||||
|
||||
|
||||
#define WTP_DEFAULT_NAME_PREFIX "WFAT-"
|
||||
#define WTP_DEFAULT_LOCATION_DATA "Superposition"
|
||||
|
||||
#endif
|
||||
|
@ -9,122 +9,15 @@
|
||||
#include "wtp_conf.h"
|
||||
#include "wtp_interface.h"
|
||||
|
||||
/*
|
||||
struct wtpinfo * get_wtpinfo()
|
||||
{
|
||||
struct wtpinfo * wtpinfo;
|
||||
|
||||
|
||||
wtpinfo=malloc(sizeof(struct wtpinfo));
|
||||
memset(wtpinfo,0,sizeof(struct wtpinfo));
|
||||
|
||||
wtpinfo->name = conf_wtpname;
|
||||
|
||||
wtpinfo->location = (uint8_t*)"default location";
|
||||
|
||||
wtpinfo->max_radios=wtpdrv_get_num_radios();
|
||||
int i;
|
||||
for (i=0; i<wtpdrv_get_num_radios(); i++){
|
||||
wtpdrv_get_radioinfo(i,&(wtpinfo->radioinfo[i]));
|
||||
|
||||
}
|
||||
|
||||
wtpinfo->radios_in_use=2;
|
||||
|
||||
wtpinfo->encryption_cap=1;
|
||||
|
||||
wtpinfo->serial_no=conf_serial_no;
|
||||
wtpinfo->vendor_id=conf_vendor_id;
|
||||
|
||||
wtpinfo->model_no=conf_model_no;
|
||||
|
||||
wtpinfo->bootloader_version="";
|
||||
wtpinfo->bootloader_vendor_id=CW_VENDOR_ID_CISCO;
|
||||
|
||||
wtpinfo->hardware_version="\0\0";
|
||||
wtpinfo->hardware_vendor_id=CW_VENDOR_ID_CISCO;
|
||||
|
||||
wtpinfo->software_version=conf_software_version;
|
||||
wtpinfo->hardware_version=conf_hardware_version;
|
||||
wtpinfo->bootloader_version=conf_bootloader_version;
|
||||
|
||||
|
||||
wtpinfo->board_id = conf_board_id;
|
||||
wtpinfo->board_revision = conf_board_revision;
|
||||
|
||||
wtpinfo->software_vendor_id=CW_VENDOR_ID_CISCO;
|
||||
|
||||
wtpinfo->macaddress=conf_macaddress;
|
||||
wtpinfo->macaddress_len=conf_macaddress_len;
|
||||
|
||||
|
||||
|
||||
|
||||
wtpinfo->max_msg_len=14000;
|
||||
|
||||
wtpinfo->mac_type=1;
|
||||
|
||||
|
||||
// wtpinfo->session_id = malloc(8);
|
||||
// wtpinfo->session_id_len = cw_rand(wtpinfo->session_id,8);
|
||||
|
||||
uint8_t sessid[4];
|
||||
memset(sessid,0,4);
|
||||
int sidl = cw_rand(sessid+2,2);
|
||||
|
||||
wtpinfo->session_id = bstr_create(sessid,4);
|
||||
|
||||
wtpinfo->frame_tunnel_mode=4;
|
||||
return wtpinfo;
|
||||
}
|
||||
|
||||
void destroy_wtpinfo(struct wtpinfo* wtpinfo)
|
||||
|
||||
|
||||
|
||||
bstr_t get_base_rmac()
|
||||
{
|
||||
// static uint8_t rm[8]={0x00,0x4a,0x99,0x02,0xfa,0xc0};
|
||||
|
||||
static uint8_t rm[8] = { 0x00, 0x4a, 0x99, 0x02, 0xfa, 0xc0 };
|
||||
return bstr_create(rm, 6);
|
||||
}
|
||||
|
||||
|
||||
ACIPLIST * order_aciplist(ACIPLIST *aciplistin)
|
||||
{
|
||||
// ACIPLIST * aciplist = aciplist_create();
|
||||
|
||||
// aciplist_foreach(aciplistin);
|
||||
|
||||
return aciplistin;
|
||||
}
|
||||
|
||||
|
||||
static int sockfd = -1;
|
||||
int get_sock()
|
||||
{
|
||||
return sockfd;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int set_sock(int sock)
|
||||
{
|
||||
sockfd = sock;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static struct conn * conn=0;
|
||||
struct conn * get_conn()
|
||||
{
|
||||
if (!conn){
|
||||
conn = conn_create_noq(-1,0);
|
||||
if (conf_mtu){
|
||||
conn->mtu=conf_mtu;
|
||||
}
|
||||
conn->mtu_discovery=conf_mtu_discovery;
|
||||
}
|
||||
printf("Get conn returns %p\n",conn);
|
||||
return conn;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
#ifndef __WTP_INTERFACE_H
|
||||
#define __WTP_INTERFACE_H
|
||||
|
||||
|
||||
#include "cw/bstr.h"
|
||||
|
||||
extern struct conn * get_conn();
|
||||
extern bstr_t get_base_rmac();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -36,14 +36,6 @@ struct conn *the_conn;
|
||||
struct cw_actiondef capwap_actions;
|
||||
|
||||
|
||||
bstr_t get_base_rmac()
|
||||
{
|
||||
// static uint8_t rm[8]={0x00,0x4a,0x99,0x02,0xfa,0xc0};
|
||||
|
||||
static uint8_t rm[8] = { 0x00, 0x4a, 0x99, 0x02, 0xfa, 0xc0 };
|
||||
return bstr_create(rm, 6);
|
||||
}
|
||||
|
||||
|
||||
int handle_update_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len, struct sockaddr *from)
|
||||
@ -142,9 +134,10 @@ mavl_destroy(b);
|
||||
conn->outgoing = mbag_create();
|
||||
conn->incomming = mbag_create();
|
||||
conn->local = mbag_create();
|
||||
conn->base_rmac = get_base_rmac();
|
||||
|
||||
conn->capwap_mode = CW_MODE_CAPWAP;
|
||||
// conn->base_rmac = get_base_rmac();
|
||||
|
||||
// conn->capwap_mode = CW_MODE_CAPWAP;
|
||||
//conn->capwap_mode = CW_MODE_CISCO;
|
||||
|
||||
the_conn->strict_capwap = 1;
|
||||
@ -152,8 +145,8 @@ mavl_destroy(b);
|
||||
|
||||
conn->config = mbag_create();
|
||||
|
||||
// setup_conf(conn);
|
||||
cfg_from_json(conn);
|
||||
setup_conf(conn);
|
||||
cfg_to_json();
|
||||
|
||||
mbag_t board_data = mbag_create();
|
||||
@ -173,23 +166,6 @@ mavl_destroy(b);
|
||||
mbag_set_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||
|
||||
|
||||
mbag_set_bstrv(conn->config, CW_ITEM_WTP_HARDWARE_VERSION,
|
||||
0,
|
||||
bstr16_data(conf_hardware_version),
|
||||
bstr16_len(conf_hardware_version));
|
||||
|
||||
mbag_set_bstrv(conn->config, CW_ITEM_WTP_SOFTWARE_VERSION,
|
||||
0,
|
||||
bstr16_data(conf_software_version),
|
||||
bstr16_len(conf_software_version));
|
||||
|
||||
mbag_set_bstrv(conn->config, CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||
0,
|
||||
bstr16_data(conf_bootloader_version),
|
||||
bstr16_len(conf_bootloader_version));
|
||||
|
||||
|
||||
|
||||
// mbag_set_bstrv(conn->config, CW_ITEM_WTP_SOFTWARE_VERSION, sw);
|
||||
|
||||
printf("Board_data %p\n", board_data);
|
||||
@ -203,8 +179,8 @@ mavl_destroy(b);
|
||||
cw_acpriolist_set(acprios, "AC8new", strlen("AC8new"), 12);
|
||||
|
||||
|
||||
mbag_set_str(conn->config,CW_ITEM_LOCATION_DATA,"Berlin");
|
||||
mbag_set_str(conn->config,CW_ITEM_WTP_NAME,"WTP Tube");
|
||||
//mbag_set_str(conn->config,CW_ITEM_LOCATION_DATA,"Berlin");
|
||||
//mbag_set_str(conn->config,CW_ITEM_WTP_NAME,"WTP Tube");
|
||||
|
||||
mbag_set_byte(conn->local, CW_ITEM_WTP_MAC_TYPE, 0);
|
||||
mbag_set_byte(conn->local, CW_ITEM_WTP_FRAME_TUNNEL_MODE, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user