Fix bugs, WTP knows more config items now.
FossilOrigin-Name: ee618e9a725b03b6db1e34d17dd352488a0507acf8588fba20a55bfffb668353
This commit is contained in:
@ -21,6 +21,7 @@
|
||||
int cfg_json_put_bstr16(char *dst,const char * name, mbag_item_t *i,int n);
|
||||
int cfg_json_put_vendorstr(char *dst,const char * name, mbag_item_t *i,int n);
|
||||
int cfg_json_put_dword(char *dst,const char * name, mbag_item_t *i,int n);
|
||||
int cfg_json_put_word(char *dst,const char * name, mbag_item_t *i,int n);
|
||||
|
||||
//static int scn_obj(char *js, jsmntok_t *t, int (vcb)(char*js,jsmntok_t*t,struct mbag_itemdef *defs,mbag_t mbag), struct mbag_itemdef *defs,mbag_t mbag);
|
||||
|
||||
@ -35,6 +36,7 @@ struct mbag_itemdef {
|
||||
typedef struct mbag_itemdef cfg_item_t;
|
||||
|
||||
int cfg_json_get_dword(struct mbag_itemdef *idef,char *js, jsmntok_t *t,mbag_t mbag);
|
||||
int cfg_json_get_word(struct mbag_itemdef *idef,char *js, jsmntok_t *t,mbag_t mbag);
|
||||
|
||||
|
||||
enum {
|
||||
@ -171,6 +173,23 @@ int cfg_json_get_dword(struct mbag_itemdef *idef,char *js, jsmntok_t *t,mbag_t m
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cfg_json_get_word(struct mbag_itemdef *idef,char *js, jsmntok_t *t,mbag_t mbag)
|
||||
{
|
||||
|
||||
struct conn * conn = get_conn();
|
||||
|
||||
int item_id = idef->item_id;
|
||||
*(js+t->end)=0;
|
||||
// char *str = js+t->start;
|
||||
if (t->type != JSMN_STRING){
|
||||
return 0;
|
||||
}
|
||||
*(js+t->end)=0;
|
||||
uint32_t dw = atoi(js+t->start);
|
||||
mbag_set_word(mbag,item_id,dw);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -233,6 +252,13 @@ struct mbag_itemdef general_cfg[] = {
|
||||
{CW_ITEM_WTP_SOFTWARE_VERSION, "software_version",cfg_json_get_vendorstr,cfg_json_put_vendorstr},
|
||||
{CW_ITEM_WTP_BOARD_DATA,"wtp_board_data",wtp_board_data_local,cfg_json_put_obj},
|
||||
{CW_RADIO_BSSID, "bssid",cfg_json_get_bstr16,cfg_json_put_bstr16},
|
||||
{CW_ITEM_CAPWAP_TIMERS, "capwap_timers",cfg_json_get_word,cfg_json_put_word},
|
||||
{CW_ITEM_IDLE_TIMEOUT, "idle_timeout",cfg_json_get_dword,cfg_json_put_dword},
|
||||
|
||||
|
||||
|
||||
{CW_ITEM_AC_HASH_VALUE, "ac_hash_value",cfg_json_get_bstr16,cfg_json_put_bstr16},
|
||||
|
||||
|
||||
|
||||
/* {CW_ITEM_WTP_FRAME_TUNNEL_MODE,"frame_tunnel_mode",byte_local},
|
||||
@ -293,6 +319,20 @@ int cfg_json_put_dword(char *dst,const char * name, mbag_item_t *i,int n)
|
||||
return d-dst;
|
||||
}
|
||||
|
||||
int cfg_json_put_word(char *dst,const char * name, mbag_item_t *i,int n)
|
||||
{
|
||||
// if (i->type != MBAG_BSTR16){
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
char *d = dst;
|
||||
memset(d,'\t',n);
|
||||
d+=n;
|
||||
d+=sprintf(d,"\"%s\":",name);
|
||||
d+=sprintf(d,"\"%d\"",i->word);
|
||||
return d-dst;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -396,7 +436,7 @@ int cfg_json_save()
|
||||
int n = mbag_tojson(dst,conn->config,general_cfg,0);
|
||||
|
||||
|
||||
printf("Json: %s\n",dst);
|
||||
//printf("Json: %s\n",dst);
|
||||
|
||||
cw_save_file("cfg.json",dst,n);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
{
|
||||
"wtp_name":"Tobias-zu-Hause",
|
||||
"idle_timeout":"300",
|
||||
"wtp_name":"Kaffe-Point",
|
||||
"hardware_version":["4232704",".x01000000"],
|
||||
"software_version":["4232704",".x08006e00"],
|
||||
"wtp_board_data":{
|
||||
@ -7,6 +8,7 @@
|
||||
"model_no":"AIR-LAP1131AG-E-K9",
|
||||
"serial_no":"2045"
|
||||
},
|
||||
"location_data":"China",
|
||||
"capwap_timers":"2590",
|
||||
"location_data":"Germany",
|
||||
"bssid":""
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
#include "capwap/dtls.h"
|
||||
#include "capwap/sock.h"
|
||||
#include "capwap/cw_util.h"
|
||||
#include "capwap/capwap_items.h"
|
||||
|
||||
|
||||
#include "wtp_conf.h"
|
||||
@ -33,7 +34,9 @@ int run()
|
||||
conn->capwap_state = CW_STATE_RUN;
|
||||
|
||||
do {
|
||||
time_t timer = cw_timer_start(25);
|
||||
|
||||
int echo_interval = mbag_get_word(conn->config,CW_ITEM_CAPWAP_TIMERS,CAPWAP_TIMERS)&0xff;
|
||||
time_t timer = cw_timer_start(echo_interval);
|
||||
int rc;
|
||||
|
||||
|
||||
|
@ -45,23 +45,18 @@ bstr_t get_base_rmac()
|
||||
int handle_update_req(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from)
|
||||
{
|
||||
printf("There was an config update request\n");
|
||||
MAVLITER_DEFINE(it,conn->incomming);
|
||||
printf("Here are the results\n");
|
||||
|
||||
mavliter_foreach(&it){
|
||||
mbag_item_t * item = mavliter_get(&it);
|
||||
|
||||
printf("MBAG ITEM GOT: %d\n",item->id);
|
||||
// printf("MBAG ITEM GOT: %d\n",item->id);
|
||||
if (item->id == CW_ITEM_WTP_NAME) {
|
||||
printf("Yea! WTP NAME\n");
|
||||
|
||||
printf("The name is %.*s\n",bstr16_len(item->data),bstr16_data(item->data));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cw_dbg(DBG_INFO,"Saving configuration ...");
|
||||
cfg_json_save();
|
||||
return 0;
|
||||
|
||||
@ -122,6 +117,15 @@ mavl_destroy(b);
|
||||
cw_register_actions_cipwap_wtp(&capwap_actions);
|
||||
cw_register_actions_capwap_80211_wtp(&capwap_actions);
|
||||
|
||||
|
||||
/*
|
||||
MAVLITER_DEFINE(it,capwap_actions.strelem);
|
||||
mavliter_foreach(&it){
|
||||
struct cw_str *s = mavliter_get(&it);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
////cw_register_actions_capwap_80211_wtp(&capwap_actions);
|
||||
|
||||
conn->actions = &capwap_actions;
|
||||
@ -164,17 +168,18 @@ conn->config=mbag_create();
|
||||
|
||||
|
||||
cw_set_msg_end_callback(conn,CW_STATE_RUN,CW_MSG_CONFIGURATION_UPDATE_REQUEST,handle_update_req);
|
||||
cw_set_msg_end_callback(conn,CW_STATE_CONFIGURE,CW_MSG_CONFIGURATION_STATUS_RESPONSE,handle_update_req);
|
||||
|
||||
|
||||
|
||||
the_conn->strict_capwap=0;
|
||||
discovery();
|
||||
join();
|
||||
mavl_destroy(conn->incomming);
|
||||
conn->incomming=conn->config;
|
||||
configure();
|
||||
changestate();
|
||||
|
||||
mavl_destroy(conn->incomming);
|
||||
conn->incomming=conn->config;
|
||||
|
||||
run();
|
||||
|
||||
|
Reference in New Issue
Block a user