Fix bugs, WTP knows more config items now.
FossilOrigin-Name: ee618e9a725b03b6db1e34d17dd352488a0507acf8588fba20a55bfffb668353
This commit is contained in:
parent
c6524f7b9b
commit
035e0a38c7
@ -386,6 +386,8 @@ extern int wtpinfo_set_radioinfo(struct wtpinfo *wtpinfo, uint8_t * msgelem, int
|
||||
#define CAPWAP_WAIT_DTLS 60
|
||||
#define CAPWAP_WAIT_JOIN 60
|
||||
|
||||
#define CAPWAP_TIMERS ((CAPWAP_DISCOVERY_INTERVAL << 8) | CAPWAP_ECHO_INTERVAL)
|
||||
|
||||
|
||||
//#define CAPWAP_CIPHER "PSK-AES128-CBC-SHA:"
|
||||
//#define CAPWAP_CIPHER "AES128-SHA"
|
||||
|
@ -143,6 +143,21 @@
|
||||
CW_ITEM_RESULT_CODE, /* ID to use store */ \
|
||||
4, 4 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_CAPWAP_TIMERS \
|
||||
CW_ELEM_CAPWAP_TIMERS, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
MBAG_WORD, /* Type of element */ \
|
||||
CW_ITEM_CAPWAP_TIMERS, /* ID to use store */ \
|
||||
2, 2 /* min/max length */
|
||||
|
||||
#define CW_ACTION_IN_IDLE_TIMEOUT \
|
||||
CW_ELEM_IDLE_TIMEOUT, /* Element ID*/ \
|
||||
cw_in_generic, 0, /* start/end callback */ \
|
||||
MBAG_DWORD, /* Type of element */ \
|
||||
CW_ITEM_IDLE_TIMEOUT, /* ID to use store */ \
|
||||
4, 4 /* min/max length */
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -98,6 +98,15 @@ cw_action_in_t capwap_actions_wtp_in[] = {
|
||||
0,0 }
|
||||
,
|
||||
|
||||
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||
CW_ACTION_IN_CAPWAP_TIMERS, 1}
|
||||
,
|
||||
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||
CW_ACTION_IN_IDLE_TIMEOUT, 1}
|
||||
,
|
||||
|
||||
{0, 0, CW_STATE_CONFIGURE, CW_MSG_CONFIGURATION_STATUS_RESPONSE,
|
||||
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD, 0}
|
||||
,
|
||||
@ -110,11 +119,17 @@ cw_action_in_t capwap_actions_wtp_in[] = {
|
||||
,
|
||||
|
||||
|
||||
/* Message Change State Response IN */
|
||||
/* Message Configuration Update Request IN */
|
||||
{0, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST,
|
||||
0, 0,0 }
|
||||
,
|
||||
|
||||
{0, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST,
|
||||
CW_ACTION_IN_CAPWAP_TIMERS, 0}
|
||||
|
||||
,
|
||||
|
||||
|
||||
/* Element: Vendor Specific */
|
||||
{0, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST,
|
||||
CW_ACTION_IN_VENDOR_SPECIFIC_PAYLOAD, 0}
|
||||
@ -182,7 +197,7 @@ cw_action_out_t capwap_actions_wtp_out[] = {
|
||||
|
||||
/* Location Data */
|
||||
{CW_MSG_JOIN_REQUEST, CW_ITEM_LOCATION_DATA, 0,
|
||||
CW_ELEM_LOCATION_DATA, NULL,cw_out_generic, cw_out_get_local,1}
|
||||
CW_ELEM_LOCATION_DATA, NULL,cw_out_generic, cw_out_get_config,1}
|
||||
,
|
||||
|
||||
/* WTP Board Data */
|
||||
|
@ -68,6 +68,7 @@
|
||||
#define CW_CISCO_SPAM_VENDOR_SPECIFIC 104
|
||||
|
||||
#define CW_CISCO_AP_GROUP_NAME 123
|
||||
#define CW_CISCO_SPAM_AP_LED_STATE 125
|
||||
#define CW_CISCO_AP_MODEL 127
|
||||
#define CW_CISCO_AP_RESET_BUTTON_STATE 128
|
||||
|
||||
@ -86,6 +87,7 @@
|
||||
|
||||
#define CW_CISCO_BOARD_DATA_OPTIONS 207
|
||||
#define CW_CISCO_MWAR_TYPE 208
|
||||
#define CW_CISCO_AP_RETRANSMIT_PARAM 240
|
||||
|
||||
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
enum capwap_items {
|
||||
CW_ITEM_NONE=0,
|
||||
CW_ITEM_IDLE_TIMEOUT,
|
||||
CW_ITEM_DISCOVERY_TYPE,
|
||||
CW_ITEM_WTP_NAME,
|
||||
CW_ITEM_WTP_BOARD_VENDOR,
|
||||
@ -25,6 +26,7 @@ enum capwap_items {
|
||||
CW_ITEM_WTP_OTHERSOFTWARE_VERSION,
|
||||
CW_ITEM_WTP_BOARD_DATA,
|
||||
CW_ITEM_WTP_DESCRIPTOR,
|
||||
CW_ITEM_CAPWAP_TIMERS,
|
||||
|
||||
CW_ITEM_AC_NAME,
|
||||
CW_ITEM_AC_DESCRIPTOR,
|
||||
@ -44,6 +46,7 @@ enum capwap_items {
|
||||
CW_ITEM_STATISTICS_TIMER,
|
||||
CW_ITEM_WTP_REBOOT_STATISTICS,
|
||||
CW_ITEM_IMAGE_IDENTIFIER,
|
||||
CW_ITEM_AC_HASH_VALUE,
|
||||
|
||||
|
||||
|
||||
@ -60,7 +63,7 @@ enum capwap_items {
|
||||
/** FILE handle for uploading and downloading images */
|
||||
CW_ITEM_IMAGE_FILEHANDLE,
|
||||
|
||||
CW_ITEM_RADIO_CFG
|
||||
CW_ITEM_RADIO_CFG,
|
||||
|
||||
};
|
||||
|
||||
|
@ -49,9 +49,10 @@ struct cw_str capwap_strings_msg[] = {
|
||||
|
||||
/* Data Transfer Request 21
|
||||
Data Transfer Response 22
|
||||
Clear Configuration Request 23
|
||||
Clear Configuration Response 24
|
||||
Station Configuration Request 25
|
||||
*/
|
||||
{CW_MSG_CLEAR_CONFIGURATION_REQUEST,"Clear Configuration Request"},
|
||||
{CW_MSG_CLEAR_CONFIGURATION_RESPONSE,"Clear Configuration Response"},
|
||||
/* Station Configuration Request 25
|
||||
Station Configuration Response 26
|
||||
*/
|
||||
|
||||
|
@ -31,6 +31,11 @@ cw_action_in_t cipwap_actions_wtp_in[] = {
|
||||
{CW_VENDOR_ID_CISCO, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST, CW_CISCO_RAD_NAME,
|
||||
cw_in_generic, 0, MBAG_BSTR16,CW_ITEM_WTP_NAME,0,512}
|
||||
,
|
||||
{CW_VENDOR_ID_CISCO, 0, CW_STATE_RUN, CW_MSG_CONFIGURATION_UPDATE_REQUEST, CW_CISCO_LOCATION_DATA,
|
||||
cw_in_generic, 0, MBAG_BSTR16,CW_ITEM_LOCATION_DATA,0,512}
|
||||
,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -11,6 +11,6 @@ struct cw_str cipwap_strings_elem[] = {
|
||||
|
||||
{CW_CISCO_AP_GROUP_NAME, "WTP Group Name" },
|
||||
|
||||
{0,"Unknown Element"}
|
||||
{CW_STR_STOP,"Unknown Element"}
|
||||
|
||||
};
|
||||
|
@ -277,7 +277,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,struct
|
||||
/* if we've got a request message, we always have to send a response message */
|
||||
if (as.msg_id & 1) {
|
||||
if (result_code > 0) {
|
||||
/* the end method gave us an result code, so
|
||||
/* the end method gave us an result code>0, so
|
||||
send an error message */
|
||||
cw_send_error_response(conn, rawmsg, result_code);
|
||||
} else if ( result_code == 0 ){
|
||||
@ -285,7 +285,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,struct
|
||||
cw_send_response(conn, rawmsg, len);
|
||||
} else {
|
||||
/* the request message is ignored, no response
|
||||
sent */
|
||||
will be sent */
|
||||
errno=EAGAIN;
|
||||
}
|
||||
} else {
|
||||
|
@ -108,7 +108,10 @@ const char * cw_cisco_id_to_str(int elem_id)
|
||||
case CW_CISCO_SPAM_DOMAIN_SECRET:
|
||||
return "SPAM Domain Secret";
|
||||
|
||||
|
||||
case CW_CISCO_SPAM_AP_LED_STATE:
|
||||
return "SPAM AP LED State";
|
||||
case CW_CISCO_AP_RETRANSMIT_PARAM:
|
||||
return "AP Retransmit Param";
|
||||
default:
|
||||
return "Unknown";
|
||||
|
||||
|
@ -11,6 +11,6 @@ struct cw_str cw_item_strings[] = {
|
||||
{ CW_ITEM_WTP_BOARD_MACADDRESS, "WTP Board MAC Address"},
|
||||
{ CW_ITEM_WTP_BOARD_ID,"WTP Board ID"},
|
||||
{ CW_ITEM_WTP_GROUP_NAME,"WTP Group Name"},
|
||||
{ 0,0}
|
||||
{ CW_STR_STOP,"Unknown"}
|
||||
|
||||
};
|
||||
|
@ -16,6 +16,14 @@ const char * lw_cisco_id_to_str(int elem_id)
|
||||
return "AC IP Addr with Index";
|
||||
case LW_CISCO_AP_SUBMODE:
|
||||
return "AP Submode";
|
||||
case LW_CISCO_SSC_HASH_VALIDATION:
|
||||
return "SSC Hash Validation";
|
||||
|
||||
case LW_CISCO_DOT11R_WLC_MAC_AND_IP:
|
||||
return "802.11r WLC MAC and IP";
|
||||
case LW_CISCO_AP_JOIN_IP_PREF_MODE:
|
||||
return "AP Join IP Pref Mode";
|
||||
|
||||
|
||||
default:
|
||||
return "Unknown";
|
||||
|
@ -28,19 +28,27 @@
|
||||
|
||||
/* Vendor specific message elements LWAPP Cisco */
|
||||
|
||||
#define LW_CISCO_AP_USERNAME_PASSWORD 18
|
||||
|
||||
#define LW_CISCO_AC_IP_ADDR_WITH_INDEX 32
|
||||
#define LW_CISCO_AP_LOGHOST_CONFIG 36
|
||||
enum lwap_cisco_elems {
|
||||
|
||||
#define LW_CISCO_AP_SUBMODE 67
|
||||
LW_CISCO_AP_USERNAME_PASSWORD=18,
|
||||
LW_CISCO_AC_IP_ADDR_WITH_INDEX=32,
|
||||
LW_CISCO_AP_LOGHOST_CONFIG=36,
|
||||
|
||||
#define LW_CISCO_PATH_MTU 73
|
||||
LW_CISCO_AP_SUBMODE=67,
|
||||
|
||||
#define LW_CISCO_ADD_WLAN 128
|
||||
LW_CISCO_PATH_MTU=73,
|
||||
|
||||
#define LW_CISCO_MWAR_HASH_VALUE 134
|
||||
LW_CISCO_ADD_WLAN=128,
|
||||
|
||||
LW_CISCO_SSC_HASH_VALIDATION=133,
|
||||
LW_CISCO_MWAR_HASH_VALUE=134,
|
||||
LW_CISCO_DOT11R_WLC_MAC_AND_IP=135,
|
||||
|
||||
LW_CISCO_AP_JOIN_IP_PREF_MODE=166
|
||||
|
||||
};
|
||||
|
||||
|
||||
/* function proto types */
|
||||
extern int lw_put_cisco_path_mtu(uint8_t *dst, uint16_t max, uint16_t padding);
|
||||
|
@ -14,19 +14,19 @@ static void del(void* d)
|
||||
|
||||
cw_strheap_t cw_strheap_create()
|
||||
{
|
||||
return avltree_create(cmp,del);
|
||||
return mavl_create(cmp,del);
|
||||
}
|
||||
|
||||
const char * cw_strheap_add(cw_strheap_t t, struct cw_str *s)
|
||||
{
|
||||
avltree_del(t,s);
|
||||
return avltree_add(t,s);
|
||||
mavl_del(t,s);
|
||||
return mavl_add(t,s);
|
||||
}
|
||||
|
||||
int cw_strheap_register_strings(cw_strheap_t h, struct cw_str *s)
|
||||
{
|
||||
int n=0;
|
||||
while ( s->id!=0){
|
||||
while ( s->id!=CW_STR_STOP){
|
||||
cw_strheap_add(h,s);
|
||||
s++;
|
||||
n++;
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user