Some improvemts for the ktv file parser
FossilOrigin-Name: 51c8ae52f86aa8fc824e07fe22d35b7ba5e82f5e4d7506cb5ff9c302ef87056a
This commit is contained in:
parent
6722bb159c
commit
5edd4ab621
@ -22,6 +22,7 @@
|
||||
<File Name="src/ac/dataman.h"/>
|
||||
<File Name="src/ac/socklist.h"/>
|
||||
</VirtualDirectory>
|
||||
<File Name="src/wtp/discovery.c"/>
|
||||
</VirtualDirectory>
|
||||
<Description/>
|
||||
<Dependencies/>
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeLite_Workspace Name="actube" Database="">
|
||||
<Project Name="ac" Path="ac.project" Active="No"/>
|
||||
<Project Name="wtp" Path="wtp.project" Active="Yes"/>
|
||||
<Project Name="wtp" Path="wtp.project" Active="No"/>
|
||||
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
|
||||
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
|
||||
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
|
||||
<Project Name="libcw" Path="libcw.project" Active="No"/>
|
||||
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
|
||||
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
|
||||
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
|
||||
<BuildMatrix>
|
||||
|
@ -327,7 +327,6 @@
|
||||
<File Name="src/cw/cw_ktv_get_byte.c"/>
|
||||
<File Name="src/cw/cw_ktv_std_types.c"/>
|
||||
</VirtualDirectory>
|
||||
<File Name="src/mod/capwap/capwap_out_wtp_descriptor.c"/>
|
||||
</VirtualDirectory>
|
||||
<Description/>
|
||||
<Dependencies/>
|
||||
|
@ -20,6 +20,7 @@
|
||||
<File Name="src/mod/capwap/capwap_in_vendor_specific_payload.c"/>
|
||||
<File Name="src/mod/capwap/capwap_in_mtu_discovery_padding.c"/>
|
||||
<File Name="src/mod/capwap/capwap_out_wtp_board_data.c"/>
|
||||
<File Name="src/mod/capwap/capwap_out_wtp_descriptor.c"/>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
</VirtualDirectory>
|
||||
|
131
src/cw/capwap.h
131
src/cw/capwap.h
@ -413,70 +413,6 @@
|
||||
|
||||
|
||||
|
||||
struct cwimage_data {
|
||||
uint8_t *data;
|
||||
uint8_t type;
|
||||
int len;
|
||||
uint32_t vendor_id;
|
||||
uint8_t *identifier;
|
||||
};
|
||||
|
||||
/*
|
||||
struct cwimage_identifier{
|
||||
uint32_t vendor_id;
|
||||
char *name;
|
||||
};
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
//extern void cwmsg_addelem_wtp_radio_infos(struct cwmsg * cwmsg,struct wtpinfo * wtpinfo);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern void cwmsg_addelem_wtp_radio_infos(struct cwmsg *msg,
|
||||
struct radioinfo *radioinfos);*/
|
||||
|
||||
/*
|
||||
//extern void cwmsg_addelem_result_code(struct cwmsg *msg, int rc);
|
||||
*/
|
||||
/*
|
||||
extern void cwmsg_addelem_vendor_specific_payload(struct cwmsg *msg, int vendor_id,
|
||||
int type, uint8_t * payload, int len);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int hdr_print(char *str, uint8_t * packet, int len);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_readelem_ecn_support(uint8_t * ecn_support, int type, uint8_t * msgelem,
|
||||
int len);
|
||||
*/
|
||||
/*
|
||||
//extern int cw_readelem_maximum_message_length(uint16_t * dst, int type, uint8_t * msgelem,
|
||||
// int len);
|
||||
//extern int cw_readelem_ac_name(uint8_t ** dst, int type, uint8_t * msgelem, int len);
|
||||
//extern int cw_readelem_wtp_reboot_statistics(struct wtp_reboot_statistics *s, int type,
|
||||
// uint8_t * msgelem, int len);
|
||||
//extern int cw_readelem_cw_local_ip_addr(struct sockaddr *local_ip, int type,
|
||||
// uint8_t * msgelem, int len);
|
||||
//extern int cw_readelem_radio_administrative_state(struct radioinfo *radioinfo, int type,
|
||||
// uint8_t * msgelem, int len);
|
||||
//extern int cw_readelem_radio_operational_state(struct radioinfo *radioinfo, int type,
|
||||
// uint8_t * msgelem, int len);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_readelem_statistics_timer(uint16_t * timer, int type, uint8_t * msgelem,
|
||||
int len);
|
||||
extern int cw_readelem_result_code(uint32_t * result_code, int type, uint8_t * msgelem,
|
||||
int len);
|
||||
|
||||
extern int cw_readelem_vendor_specific_payload(void *data, int msgtype, int elemtype,
|
||||
uint8_t * msgelem, int len);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@ -585,14 +521,21 @@ enum cw_reboot_failure_types {
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct cwimage_data {
|
||||
uint8_t *data;
|
||||
uint8_t type;
|
||||
int len;
|
||||
uint32_t vendor_id;
|
||||
uint8_t *identifier;
|
||||
};
|
||||
|
||||
extern void cw_read_image_data_request(struct cwimage_data *, uint8_t * msg, int len);
|
||||
|
||||
/*
|
||||
//extern int cw_readelem_ac_descriptor(struct ac_info *acinfo, int type, uint8_t * msgelem,
|
||||
// int len);
|
||||
//extern int cw_readelem_capwap_local_ip_addr(struct sockaddr *local_ip, int type,
|
||||
// uint8_t * msgelem, int len);
|
||||
*/
|
||||
|
||||
|
||||
|
||||
extern int cw_send_echo_response(struct conn *conn, int seqnum,
|
||||
@ -651,54 +594,6 @@ const char *cw_strelemp_(cw_strheap_t h, int msg_id);
|
||||
#define cw_strelemp(p,id) cw_strelemp_((p)->strelem,id)
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
//int cw_process_msg(struct conn *conn, uint8_t * rawmsg, int len);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a,
|
||||
uint8_t * data, int len,struct sockaddr *from);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_in_wtp_name(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
extern int cw_in_wtp_descriptor(struct conn *conn, struct cw_action_in *a, uint8_t * data,
|
||||
int len,struct sockaddr *from);
|
||||
*/
|
||||
|
||||
/*
|
||||
//extern int cw_out_generic(struct conn *conn,struct cw_action_in * a,uint8_t *data,int len);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_out_generic(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
*/
|
||||
|
||||
/*
|
||||
//extern int cw_out_ac_descriptor(struct conn *conn, uint32_t elem_id, uint8_t * dst,
|
||||
//struct mbag_item *item);
|
||||
*/
|
||||
|
||||
/*
|
||||
//extern int cw_out_capwap_control_ip_addrs(struct conn *conn, uint32_t elem_id,
|
||||
// uint8_t * dst, struct mbag_item *item);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_out_capwap_control_ip_addr_list(struct conn *conn, struct cw_action_out *a,
|
||||
uint8_t * dst);
|
||||
*/
|
||||
|
||||
/*
|
||||
extern int cw_put_msg(struct conn *conn, uint8_t * rawout);
|
||||
int cw_out_image_data(struct conn *conn, struct cw_action_out *a, uint8_t * dst);
|
||||
*/
|
||||
|
||||
struct cw_ac_status {
|
||||
int stations;
|
||||
int limit;
|
||||
|
@ -436,6 +436,8 @@ extern int cw_put_local_ip_address(int sock, uint8_t * dst, int ipv4elem_id,
|
||||
extern int cw_put_radio_operational_states(mbag_t radios, uint8_t * dst, int *nerror,
|
||||
int d7mode);
|
||||
|
||||
void cw_init_request(struct conn *conn, int msg_id);
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
@ -463,6 +465,7 @@ int cw_out_radio_generic(struct conn *conn, struct cw_action_out *a, uint8_t * d
|
||||
int cw_put_elem_session_id(uint8_t *dst, uint8_t *session_id, int len);
|
||||
|
||||
int cw_result_is_ok( int rc );
|
||||
int cw_put_msg(struct conn *conn, uint8_t * rawout);
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
@ -1,10 +1,11 @@
|
||||
|
||||
#include "ktv.h"
|
||||
|
||||
|
||||
int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
||||
{
|
||||
char key[256];
|
||||
char xtype[256];
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
char type[256];
|
||||
char val[2048];
|
||||
|
||||
|
||||
@ -13,38 +14,26 @@ int cw_ktv_read_file(FILE * file, mavl_t ktv, mavl_t types)
|
||||
|
||||
|
||||
do {
|
||||
cw_KTV_t nktv, *nres;
|
||||
|
||||
rc = cw_ktv_read_line(file,key,xtype,val);
|
||||
if (rc == 0){
|
||||
printf("Got a line %s:%s:%s\n",key,xtype,val);
|
||||
|
||||
rc = cw_ktv_read_line(file,key,type,val);
|
||||
if (rc != 0){
|
||||
continue;
|
||||
}
|
||||
|
||||
typesearch.name=xtype;
|
||||
/* printf("Searching for type: '%s'\n",xtype);*/
|
||||
typesearch.name=type;
|
||||
|
||||
cwtype = mavl_get_ptr(types,&typesearch);
|
||||
if (cwtype != NULL){
|
||||
// printf("Yes! I know the type: %s\n",cwtype->name);
|
||||
/*// printf("Yes! I know the type: %s\n",cwtype->name);*/
|
||||
}
|
||||
else {
|
||||
printf("Unknown type: %s\n",typesearch.name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
cw_ktv_add_from_str(ktv,key,cwtype,val);
|
||||
|
||||
/* nres = cwtype->from_str(&nktv,val);
|
||||
|
||||
if (nres !=NULL ){
|
||||
// printf("Yea, created from string\n");
|
||||
|
||||
nktv.key=cw_strdup(key);
|
||||
mavl_add(ktv, &nktv, NULL);
|
||||
}
|
||||
*/
|
||||
}while(rc==0);
|
||||
|
||||
return 0;
|
||||
|
@ -6,15 +6,17 @@
|
||||
|
||||
int lw_put_ac_descriptor(uint8_t * dst)
|
||||
{
|
||||
uint8_t *d=dst;
|
||||
d+=lw_put_byte(d,0); /* Cisco MWAR type */
|
||||
/* uint8_t *d=dst;
|
||||
d+=lw_put_byte(d,0); / Cisco MWAR type /
|
||||
|
||||
// d+=lw_put_bstr(d,acinfo->hardware_version); /* length must be 4 */
|
||||
// d+=lw_put_bstr(d,acinfo->software_version); /* length must be 4 */
|
||||
// d+=lw_put_bstr(d,acinfo->hardware_version); / length must be 4
|
||||
// d+=lw_put_bstr(d,acinfo->software_version); / length must be 4
|
||||
d+=lw_put_word(d,200);
|
||||
d+=lw_put_word(d,1000);
|
||||
d+=lw_put_word(d,2);
|
||||
d+=lw_put_word(d,2);
|
||||
//d+=lw_put_byte(d,acinfo->security);
|
||||
return d-dst;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
@ -181,9 +181,9 @@ struct mavliter {
|
||||
typedef struct mavliter mavliter_t;
|
||||
|
||||
|
||||
union mavldata * mavliter_next ( mavliter_t *i );
|
||||
void * mavliter_next ( mavliter_t *i );
|
||||
|
||||
union mavldata * mavliter_seek_set ( struct mavliter *i );
|
||||
void * mavliter_seek_set ( struct mavliter *i );
|
||||
|
||||
void mavliter_init ( mavliter_t *i, mavl_t t );
|
||||
|
||||
@ -192,7 +192,7 @@ void * mavliter_get ( mavliter_t *i );
|
||||
|
||||
void * mavliter_get_ptr(mavliter_t *i);
|
||||
|
||||
extern union mavldata * mavliter_seek ( mavliter_t *i, void *d );
|
||||
void * mavliter_seek ( mavliter_t *i, void *d );
|
||||
|
||||
/**
|
||||
* Define a AVL Iterator varialble and accociate it with
|
||||
|
@ -29,7 +29,7 @@
|
||||
* @return the element or NULL if there is no next elemeent.
|
||||
*/
|
||||
|
||||
union mavldata * mavliter_next ( mavliter_t *i )
|
||||
void * mavliter_next ( mavliter_t *i )
|
||||
{
|
||||
while ( i->stack_ptr ) {
|
||||
i->stack_ptr--;
|
||||
|
@ -31,7 +31,7 @@
|
||||
* @param d element to search for
|
||||
* @return element found or NULL if not found
|
||||
*/
|
||||
union mavldata * mavliter_seek(mavliter_t *i,void *d)
|
||||
void * mavliter_seek(mavliter_t *i,void *d)
|
||||
{
|
||||
int rc;
|
||||
if (!i->root)
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "mavl.h"
|
||||
|
||||
union mavldata * mavliter_seek_set ( struct mavliter *i )
|
||||
void * mavliter_seek_set ( struct mavliter *i )
|
||||
{
|
||||
i->stack_ptr = 0;
|
||||
i->cur = i->root;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "cw/log.h"
|
||||
#include "cw/dbg.h"
|
||||
#include "cw/timer.h"
|
||||
#include "cw/cw.h"
|
||||
|
||||
#include "wtp.h"
|
||||
|
||||
|
@ -24,7 +24,7 @@ int image_update()
|
||||
|
||||
int rc = cw_send_request(conn, CAPWAP_MSG_IMAGE_DATA_REQUEST);
|
||||
|
||||
if (rc < 0) {
|
||||
if (rc < 0) {h
|
||||
}
|
||||
|
||||
if (rc != 0) {
|
||||
|
@ -76,23 +76,32 @@ int main (int argc, char **argv)
|
||||
mavl_t global_cfg, types_tree;
|
||||
const cw_Type_t ** ti;
|
||||
|
||||
/* read command line args, results are in bootcfg */
|
||||
parse_args(argc,argv, &bootcfg);
|
||||
|
||||
|
||||
/* create an empty message set */
|
||||
msgset = cw_msgset_create();
|
||||
if (msgset==NULL){
|
||||
cw_log(LOG_ERR, "Error creating msgset: %s", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* create an empty global config */
|
||||
global_cfg=cw_ktv_create();
|
||||
if (msgset==NULL){
|
||||
cw_log(LOG_ERR, "Error creating global_cfg: %s", strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* create types tree with default types */
|
||||
|
||||
/* create a types tree with default types */
|
||||
types_tree = cw_ktv_create_types_tree();
|
||||
for (ti=CW_KTV_STD_TYPES;*ti;ti++){
|
||||
mavl_add_ptr(types_tree,*ti);
|
||||
}
|
||||
|
||||
/* read the initial config file */
|
||||
file = fopen(bootcfg.cfgfilename,"r");
|
||||
if (file == NULL){
|
||||
cw_log(LOG_ERR,"Cant open file '%s':%s", strerror(errno));
|
||||
@ -100,6 +109,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
cw_ktv_read_file(file,global_cfg,types_tree);
|
||||
|
||||
|
||||
cw_ktv_dump(global_cfg,DBG_INFO,"----- global cfg start -----","","----- global cfg end -----");
|
||||
|
||||
|
||||
@ -119,6 +129,7 @@ int main (int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
conn->detected = 1;
|
||||
conn->dtls_verify_peer=0;
|
||||
conn->dtls_mtu = 12000;
|
||||
|
@ -14,7 +14,6 @@
|
||||
<File Name="src/wtp/conf_uci.c"/>
|
||||
<File Name="src/wtp/dot11.h"/>
|
||||
<File Name="src/wtp/cfg.h"/>
|
||||
<File Name="src/wtp/discovery.c"/>
|
||||
<File Name="src/wtp/nlt_cmdnames.c"/>
|
||||
<File Name="src/wtp/configure.c"/>
|
||||
<File Name="src/wtp/nlt_attrnames.c"/>
|
||||
|
Loading…
Reference in New Issue
Block a user