WTP can save json now.
FossilOrigin-Name: 9670c29689c90b8e4378e10b56682028dd690d58e1a69da0f584c4c770cd2110
This commit is contained in:
parent
32fa2ae608
commit
8314c3aa98
@ -109,7 +109,6 @@ LWAPPCISCOOBJS = \
|
|||||||
|
|
||||||
|
|
||||||
CAPWAPOBJS= \
|
CAPWAPOBJS= \
|
||||||
wtpinfo.o \
|
|
||||||
aciplist.o \
|
aciplist.o \
|
||||||
lwmsg_init.o \
|
lwmsg_init.o \
|
||||||
wtpinfo_lwreadelem_wtp_descriptor.o \
|
wtpinfo_lwreadelem_wtp_descriptor.o \
|
||||||
@ -160,6 +159,7 @@ CAPWAPOBJS= \
|
|||||||
avliter_seek.o \
|
avliter_seek.o \
|
||||||
|
|
||||||
|
|
||||||
|
# wtpinfo.o \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,6 +59,36 @@ static inline int cw_action_in_cmp(const void *elem1, const void *elem2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
|
||||||
|
int capwap_state,int msg_id, cw_action_fun_t callback)
|
||||||
|
{
|
||||||
|
cw_action_in_t as;
|
||||||
|
/* prepare struct for search operation */
|
||||||
|
as.capwap_state = capwap_state;
|
||||||
|
as.msg_id = msg_id;
|
||||||
|
as.vendor_id = 0;
|
||||||
|
as.elem_id = 0;
|
||||||
|
as.proto = 0;
|
||||||
|
|
||||||
|
cw_action_in_t *af;
|
||||||
|
|
||||||
|
|
||||||
|
af = cw_actionlist_in_get(conn->actions->in, &as);
|
||||||
|
if (!af)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
cw_action_fun_t old = af->end;
|
||||||
|
af->end =callback;
|
||||||
|
return old;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
cw_action_in_t *cw_actionlist_in_add(cw_actionlist_in_t t, struct cw_action_in * a)
|
cw_action_in_t *cw_actionlist_in_add(cw_actionlist_in_t t, struct cw_action_in * a)
|
||||||
{
|
{
|
||||||
return cw_actionlist_add(t, a, sizeof(struct cw_action_in));
|
return cw_actionlist_add(t, a, sizeof(struct cw_action_in));
|
||||||
@ -190,3 +220,8 @@ cw_action_in_t *cw_actionlist_in_set_msg_end_callback(cw_actionlist_in_t a,
|
|||||||
ar->end=fun;
|
ar->end=fun;
|
||||||
return ar;
|
return ar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@
|
|||||||
#include "intavltree.h"
|
#include "intavltree.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Generic functions and structs */
|
/* Generic functions and structs */
|
||||||
void * cw_actionlist_add(struct avltree *t, void *a, size_t s);
|
void * cw_actionlist_add(struct avltree *t, void *a, size_t s);
|
||||||
|
|
||||||
@ -51,9 +53,13 @@ struct cw_action_in{
|
|||||||
uint8_t mand;
|
uint8_t mand;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef int(*cw_action_fun_t)(struct conn *,struct cw_action_in *,uint8_t*,int ,struct sockaddr *);
|
||||||
|
|
||||||
typedef struct cw_action_in cw_action_in_t;
|
typedef struct cw_action_in cw_action_in_t;
|
||||||
|
|
||||||
|
extern cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
|
||||||
|
int capwap_state,int msg_id, cw_action_fun_t callback);
|
||||||
|
|
||||||
|
|
||||||
typedef struct avltree * cw_actionlist_in_t;
|
typedef struct avltree * cw_actionlist_in_t;
|
||||||
|
|
||||||
@ -69,6 +75,9 @@ extern cw_action_in_t *cw_actionlist_in_set_msg_end_callback(cw_actionlist_in_t
|
|||||||
int len,struct sockaddr *from));
|
int len,struct sockaddr *from));
|
||||||
|
|
||||||
|
|
||||||
|
cw_action_fun_t cw_set_msg_end_callback(struct conn *conn,
|
||||||
|
int capwap_state,int msg_id, cw_action_fun_t callback);
|
||||||
|
|
||||||
/* Definitions for outgoing messages */
|
/* Definitions for outgoing messages */
|
||||||
struct cw_action_out{
|
struct cw_action_out{
|
||||||
uint32_t msg_id;
|
uint32_t msg_id;
|
||||||
|
@ -542,10 +542,10 @@ extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elem
|
|||||||
|
|
||||||
13 Configuration Failure (Unable to Apply Requested Configuration
|
13 Configuration Failure (Unable to Apply Requested Configuration
|
||||||
- Service Not Provided)
|
- Service Not Provided)
|
||||||
|
|
||||||
14 Image Data Error (Invalid Checksum)
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#define CW_RESULT_IMAGE_DATA_INVALID_CHECKSUM 14 //Image Data Error (Invalid Checksum)
|
||||||
|
|
||||||
|
|
||||||
#define CW_RESULT_IMAGE_DATA_IVALID_LENGTH 15 //Image Data Error (Invalid Data Length)
|
#define CW_RESULT_IMAGE_DATA_IVALID_LENGTH 15 //Image Data Error (Invalid Data Length)
|
||||||
|
|
||||||
#define CW_RESULT_IMAGE_DATA_ERROR 16 //Image Data Error (Other Error)
|
#define CW_RESULT_IMAGE_DATA_ERROR 16 //Image Data Error (Other Error)
|
||||||
|
@ -6,6 +6,7 @@ struct cw_str capwap_strings_result[] = {
|
|||||||
{CW_RESULT_SUCCESS,"Success"}, /* 0 */
|
{CW_RESULT_SUCCESS,"Success"}, /* 0 */
|
||||||
{CW_RESULT_MISSING_AC_LIST,"AC List Message Element MUST be Present"}, /* 1 */
|
{CW_RESULT_MISSING_AC_LIST,"AC List Message Element MUST be Present"}, /* 1 */
|
||||||
{CW_RESULT_SUCCESS_NAT,"Success - NAT Detected"}, /* 2 */
|
{CW_RESULT_SUCCESS_NAT,"Success - NAT Detected"}, /* 2 */
|
||||||
|
{CW_RESULT_IMAGE_DATA_INVALID_CHECKSUM,"Image Data Error (Invalid Checksum)"}, /* 14 */
|
||||||
{CW_RESULT_IMAGE_DATA_ERROR,"Image Data Error (Unspecified)"}, /* 16 */
|
{CW_RESULT_IMAGE_DATA_ERROR,"Image Data Error (Unspecified)"}, /* 16 */
|
||||||
{CW_RESULT_MISSING_MAND_ELEM,"Missing Mandatory Message Element"}, /* 20 */
|
{CW_RESULT_MISSING_MAND_ELEM,"Missing Mandatory Message Element"}, /* 20 */
|
||||||
|
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
cw_action_in_t cipwap_actions_wtp_in[] = {
|
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}
|
||||||
|
,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{0, 0, 0}
|
{0, 0, 0}
|
||||||
|
@ -229,7 +229,7 @@ static int process_elements(struct conn *conn, uint8_t * rawmsg, int len,struct
|
|||||||
uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
uint8_t *elems_ptr = cw_get_msg_elems_ptr(msg_ptr);
|
||||||
uint8_t *elem;
|
uint8_t *elem;
|
||||||
|
|
||||||
/* avltree to bag the found mandatory elements */
|
/* Create an avltree to catch the found mandatory elements */
|
||||||
conn->mand = intavltree_create();
|
conn->mand = intavltree_create();
|
||||||
|
|
||||||
/* iterate through message elements */
|
/* iterate through message elements */
|
||||||
|
@ -47,6 +47,12 @@ int cw_in_generic(struct conn *conn, struct cw_action_in *a, uint8_t * data, int
|
|||||||
mbag_set_bstrn(itemstore, a->item_id, data, len);
|
mbag_set_bstrn(itemstore, a->item_id, data, len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a->itemtype == MBAG_BSTR16) {
|
||||||
|
mbag_set_bstr16n(itemstore, a->item_id, data, len);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* if (a->itemtype == MBAG_DATA) {
|
/* if (a->itemtype == MBAG_DATA) {
|
||||||
mbag_set_data(itemstore, a->item_id, data, len);
|
mbag_set_data(itemstore, a->item_id, data, len);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -389,7 +389,7 @@ int mbag_tojson(char *dst, mbag_t m, struct mbag_itemdef *defs, int n)
|
|||||||
return d-dst;
|
return d-dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tester()
|
int cfg_json_save()
|
||||||
{
|
{
|
||||||
struct conn * conn = get_conn();
|
struct conn * conn = get_conn();
|
||||||
char dst[4096];
|
char dst[4096];
|
||||||
@ -398,8 +398,7 @@ int tester()
|
|||||||
|
|
||||||
printf("Json: %s\n",dst);
|
printf("Json: %s\n",dst);
|
||||||
|
|
||||||
cw_save_file("cfg.save.json",dst,n);
|
cw_save_file("cfg.json",dst,n);
|
||||||
exit(0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,12 @@
|
|||||||
{
|
{
|
||||||
"wtp_name":"TubeWTPx",
|
"wtp_name":"Tobias-zu-Hause",
|
||||||
"hardware_version":["4232704",".x01000000"],
|
"hardware_version":["4232704",".x01000000"],
|
||||||
"software_version":["4232704",".x08006e00"],
|
"software_version":["4232704",".x08006e00"],
|
||||||
|
"wtp_board_data":{
|
||||||
|
"vendor_id":"4232704",
|
||||||
|
"model_no":"AIR-LAP1131AG-E-K9",
|
||||||
|
"serial_no":"2045"
|
||||||
|
},
|
||||||
"location_data":"China",
|
"location_data":"China",
|
||||||
"bssid": ".x003a9902fac0",
|
"bssid":""
|
||||||
|
}
|
||||||
"wtp_board_data" : {
|
|
||||||
"vendor_id": "4232704",
|
|
||||||
"model_no": "AIR-LAP1131AG-E-K9",
|
|
||||||
"serial_no": "2045"
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
"acname_with_priority": {
|
|
||||||
"1":"Master-AC",
|
|
||||||
"2":"Cisco-AC"
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -17,6 +17,7 @@
|
|||||||
#include "wtp_conf.h"
|
#include "wtp_conf.h"
|
||||||
|
|
||||||
#include "capwap/dbg.h"
|
#include "capwap/dbg.h"
|
||||||
|
#include "capwap/mavl.h"
|
||||||
|
|
||||||
#include "jsmn.h"
|
#include "jsmn.h"
|
||||||
|
|
||||||
@ -41,6 +42,33 @@ 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);
|
||||||
|
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));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg_json_save();
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -133,11 +161,21 @@ conn->config=mbag_create();
|
|||||||
mbag_set_byte(conn->local,CW_ITEM_WTP_FRAME_TUNNEL_MODE,0);
|
mbag_set_byte(conn->local,CW_ITEM_WTP_FRAME_TUNNEL_MODE,0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cw_set_msg_end_callback(conn,CW_STATE_RUN,CW_MSG_CONFIGURATION_UPDATE_REQUEST,handle_update_req);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
the_conn->strict_capwap=0;
|
the_conn->strict_capwap=0;
|
||||||
discovery();
|
discovery();
|
||||||
join();
|
join();
|
||||||
configure();
|
configure();
|
||||||
changestate();
|
changestate();
|
||||||
|
|
||||||
|
mavl_destroy(conn->incomming);
|
||||||
|
conn->incomming=conn->config;
|
||||||
|
|
||||||
run();
|
run();
|
||||||
|
|
||||||
//image_update();
|
//image_update();
|
||||||
|
Loading…
Reference in New Issue
Block a user