Renamed vendrostr_t to bstr_t
FossilOrigin-Name: 34e1a661db71756f6c03fb4f21434179f25cd4c48a2407b22f8ca0a8396d79e1
This commit is contained in:
parent
f261fc12fc
commit
f29d758df4
@ -90,9 +90,9 @@ int ac_global_init()
|
|||||||
ac_status.dtls_policy = CW_FLAG_DTLS_POLICY_C | CW_FLAG_DTLS_POLICY_D;
|
ac_status.dtls_policy = CW_FLAG_DTLS_POLICY_C | CW_FLAG_DTLS_POLICY_D;
|
||||||
|
|
||||||
|
|
||||||
mbag_set_vendorstr(ac_config, CW_ITEM_AC_HARDWARE_VERSION, 0,
|
mbag_set_bstrv(ac_config, CW_ITEM_AC_HARDWARE_VERSION, 0,
|
||||||
bstr_data(conf_hardware_version), bstr_len(conf_hardware_version));
|
bstr_data(conf_hardware_version), bstr_len(conf_hardware_version));
|
||||||
mbag_set_vendorstr(ac_config, CW_ITEM_AC_SOFTWARE_VERSION, 0,
|
mbag_set_bstrv(ac_config, CW_ITEM_AC_SOFTWARE_VERSION, 0,
|
||||||
bstr_data(conf_software_version), bstr_len(conf_software_version));
|
bstr_data(conf_software_version), bstr_len(conf_software_version));
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,14 +32,23 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup BSTRTypes Types
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bstr type
|
* bstr type
|
||||||
*
|
*
|
||||||
* bstr_t serves as binary string where the first byte contains
|
* bstr_t serves as binary string, where the first byte contains
|
||||||
* the length of the string.
|
* the length of the string.
|
||||||
*/
|
*/
|
||||||
typedef uint8_t* bstr_t;
|
typedef uint8_t* bstr_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@}
|
||||||
|
*/
|
||||||
|
|
||||||
extern uint8_t * bstr_create(uint8_t *data, uint8_t len);
|
extern uint8_t * bstr_create(uint8_t *data, uint8_t len);
|
||||||
extern uint8_t * bstr_create_from_cfgstr(const char * s);
|
extern uint8_t * bstr_create_from_cfgstr(const char * s);
|
||||||
extern uint8_t * bstr_replace( bstr_t * dst, uint8_t * bstr);
|
extern uint8_t * bstr_replace( bstr_t * dst, uint8_t * bstr);
|
||||||
@ -64,7 +73,7 @@ extern int bstr_to_str(char *dst, bstr_t str,char * def);
|
|||||||
#define bstr_size(len) (len+1)
|
#define bstr_size(len) (len+1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*@defgroup BstrConstants Types & Constants
|
*@defgroup BSTRConstants Constants
|
||||||
*@{
|
*@{
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -73,6 +82,13 @@ extern int bstr_to_str(char *dst, bstr_t str,char * def);
|
|||||||
*/
|
*/
|
||||||
#define BSTR_MAX_LEN 254
|
#define BSTR_MAX_LEN 254
|
||||||
|
|
||||||
|
/**@}*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@addtogroup BSTRTypes
|
||||||
|
*@{
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The same as #bstr_t, but there are two bytes used
|
* The same as #bstr_t, but there are two bytes used
|
||||||
@ -80,7 +96,9 @@ extern int bstr_to_str(char *dst, bstr_t str,char * def);
|
|||||||
*/
|
*/
|
||||||
typedef uint8_t *bstr16_t;
|
typedef uint8_t *bstr16_t;
|
||||||
|
|
||||||
/**@}*/
|
/**
|
||||||
|
*@}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -125,42 +143,57 @@ static inline uint8_t * bstr16_create(uint8_t *data, uint16_t len)
|
|||||||
uint8_t * bstr16_create_from_str(const char *s);
|
uint8_t * bstr16_create_from_str(const char *s);
|
||||||
|
|
||||||
|
|
||||||
typedef uint8_t * vendorstr_t;
|
/**
|
||||||
|
*@addtogroup BSTRTypes
|
||||||
|
*@{
|
||||||
|
*/
|
||||||
|
|
||||||
#define vendorstr_get_vendor_id(str)\
|
/**
|
||||||
|
* The bstrv_t type is basicly a #bstr16_t and can be
|
||||||
|
* handeld like a bstr16_t.
|
||||||
|
* The difference is, that the first four bytes of the
|
||||||
|
* string data containing a vendor id.
|
||||||
|
*/
|
||||||
|
typedef uint8_t * bstrv_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define bstrv_get_vendor_id(str)\
|
||||||
( *((uint32_t*)((str)+2)))
|
( *((uint32_t*)((str)+2)))
|
||||||
|
|
||||||
#define vendorstr_set_vendor_id(str,id)\
|
#define bstrv_set_vendor_id(str,id)\
|
||||||
( *((uint32_t*)((str)+2)) = id)
|
( *((uint32_t*)((str)+2)) = id)
|
||||||
|
|
||||||
#define vendorstr_len(str)\
|
#define bstrv_len(str)\
|
||||||
(*((uint16_t*)((str)+0)))
|
(*((uint16_t*)((str)+0)))
|
||||||
|
|
||||||
#define vendorstr_set_len(str,len)\
|
#define bstrv_set_len(str,len)\
|
||||||
(*((uint16_t*)((str)+0))=len)
|
(*((uint16_t*)((str)+0))=len)
|
||||||
|
|
||||||
#define vendorstr_data(str)\
|
#define bstrv_data(str)\
|
||||||
(((uint8_t*)(str))+6)
|
(((uint8_t*)(str))+6)
|
||||||
|
|
||||||
#define vendorstr_size(n)\
|
#define bstrv_size(n)\
|
||||||
(1+6+(n)*sizeof(uint8_t))
|
(1+6+(n)*sizeof(uint8_t))
|
||||||
|
|
||||||
|
|
||||||
static inline uint8_t * vendorstr_create(uint32_t vendor_id, uint8_t *data, uint8_t len)
|
static inline uint8_t * bstrv_create(uint32_t vendor_id, uint8_t *data, uint8_t len)
|
||||||
{
|
{
|
||||||
uint8_t * str = malloc(vendorstr_size(len));
|
uint8_t * str = malloc(bstrv_size(len));
|
||||||
if (!str)
|
if (!str)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
vendorstr_set_vendor_id(str,vendor_id);
|
bstrv_set_vendor_id(str,vendor_id);
|
||||||
vendorstr_set_len(str,len);
|
bstrv_set_len(str,len);
|
||||||
memcpy(vendorstr_data(str),data,len);
|
memcpy(bstrv_data(str),data,len);
|
||||||
*(vendorstr_data(str)+vendorstr_len(str))=0;
|
*(bstrv_data(str)+bstrv_len(str))=0;
|
||||||
return str;
|
return str;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t * vendorstr_create_from_str(uint32_t vendor_id,const char *s);
|
uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s);
|
||||||
|
|
||||||
|
|
||||||
uint8_t * bstr16cfgstr(const char * s);
|
uint8_t * bstr16cfgstr(const char * s);
|
||||||
|
@ -1084,9 +1084,9 @@ static inline int cw_put_ac_status(uint8_t * dst, struct cw_ac_status *s)
|
|||||||
static inline int cw_put_version(uint8_t * dst, uint16_t subelem_id, uint8_t * v)
|
static inline int cw_put_version(uint8_t * dst, uint16_t subelem_id, uint8_t * v)
|
||||||
{
|
{
|
||||||
uint8_t *d = dst;
|
uint8_t *d = dst;
|
||||||
d += cw_put_dword(d, vendorstr_get_vendor_id(v));
|
d += cw_put_dword(d, bstrv_get_vendor_id(v));
|
||||||
d += cw_put_dword(d, (subelem_id << 16) | vendorstr_len(v));
|
d += cw_put_dword(d, (subelem_id << 16) | bstrv_len(v));
|
||||||
d += cw_put_data(d, vendorstr_data(v), vendorstr_len(v));
|
d += cw_put_data(d, bstrv_data(v), bstrv_len(v));
|
||||||
return d - dst;
|
return d - dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,18 +66,18 @@ static int read_subeelms(struct conn *conn,struct cw_action_in * a,uint8_t *data
|
|||||||
int subtype = cw_get_word(data+sub+4);
|
int subtype = cw_get_word(data+sub+4);
|
||||||
printf("substart : %d\n",sub);
|
printf("substart : %d\n",sub);
|
||||||
|
|
||||||
vendorstr_t vstr=NULL;
|
bstrv_t vstr=NULL;
|
||||||
switch (subtype){
|
switch (subtype){
|
||||||
case 0:
|
case 0:
|
||||||
case 4:
|
case 4:
|
||||||
/* hardware version */
|
/* hardware version */
|
||||||
vstr = mbag_set_vendorstr(conn->incomming,CW_ITEM_AC_HARDWARE_VERSION,
|
vstr = mbag_set_bstrv(conn->incomming,CW_ITEM_AC_HARDWARE_VERSION,
|
||||||
vendor_id,data+sub+8,sublen);
|
vendor_id,data+sub+8,sublen);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
case 5:
|
case 5:
|
||||||
/* software version */
|
/* software version */
|
||||||
vstr = mbag_set_vendorstr(conn->incomming,CW_ITEM_AC_SOFTWARE_VERSION,
|
vstr = mbag_set_bstrv(conn->incomming,CW_ITEM_AC_SOFTWARE_VERSION,
|
||||||
vendor_id,data+sub+8,sublen);
|
vendor_id,data+sub+8,sublen);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ int cw_detect_capwap(struct conn *conn)
|
|||||||
|
|
||||||
mbag_item_t * item = mbag_get(is,CW_ITEM_WTP_SOFTWARE_VERSION);
|
mbag_item_t * item = mbag_get(is,CW_ITEM_WTP_SOFTWARE_VERSION);
|
||||||
if (item) {
|
if (item) {
|
||||||
vendorstr_t s = item->data;
|
bstrv_t s = item->data;
|
||||||
uint32_t v = vendorstr_get_vendor_id(s);
|
uint32_t v = bstrv_get_vendor_id(s);
|
||||||
|
|
||||||
switch(v) {
|
switch(v) {
|
||||||
case CW_VENDOR_ID_CISCO:
|
case CW_VENDOR_ID_CISCO:
|
||||||
|
@ -22,16 +22,16 @@ int cw_in_check_img_data_req_ac(struct conn *conn, struct cw_action_in *a, uint8
|
|||||||
|
|
||||||
struct mbag_item *i = mbag_get(conn->incomming,CW_ITEM_IMAGE_IDENTIFIER);
|
struct mbag_item *i = mbag_get(conn->incomming,CW_ITEM_IMAGE_IDENTIFIER);
|
||||||
if (i) {
|
if (i) {
|
||||||
uint32_t vendor_id = vendorstr_get_vendor_id(i->data);
|
uint32_t vendor_id = bstrv_get_vendor_id(i->data);
|
||||||
|
|
||||||
const char * image_dir;
|
const char * image_dir;
|
||||||
image_dir = mbag_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR,"./img");
|
image_dir = mbag_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR,"./img");
|
||||||
|
|
||||||
char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir));
|
char * image_filename = malloc(6+bstrv_len(i->data)+1+strlen(image_dir));
|
||||||
if (!image_filename)
|
if (!image_filename)
|
||||||
return CW_RESULT_IMAGE_DATA_ERROR;
|
return CW_RESULT_IMAGE_DATA_ERROR;
|
||||||
|
|
||||||
sprintf(image_filename,"%s%04X/%s",image_dir,vendor_id,vendorstr_data(i->data));
|
sprintf(image_filename,"%s%04X/%s",image_dir,vendor_id,bstrv_data(i->data));
|
||||||
|
|
||||||
|
|
||||||
FILE *infile = fopen(image_filename,"rb");
|
FILE *infile = fopen(image_filename,"rb");
|
||||||
|
@ -33,16 +33,16 @@ int cw_in_check_img_data_req_wtp(struct conn *conn, struct cw_action_in *a, uint
|
|||||||
|
|
||||||
struct mbag_item *i = mbag_get(conn->incomming,CW_ITEM_IMAGE_IDENTIFIER);
|
struct mbag_item *i = mbag_get(conn->incomming,CW_ITEM_IMAGE_IDENTIFIER);
|
||||||
if (i) {
|
if (i) {
|
||||||
uint32_t vendor_id = vendorstr_get_vendor_id(i->data);
|
uint32_t vendor_id = bstrv_get_vendor_id(i->data);
|
||||||
|
|
||||||
const char * image_dir;
|
const char * image_dir;
|
||||||
image_dir = mbag_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR,"./img");
|
image_dir = mbag_get_str(conn->local,CW_ITEM_AC_IMAGE_DIR,"./img");
|
||||||
|
|
||||||
char * image_filename = malloc(6+vendorstr_len(i->data)+1+strlen(image_dir));
|
char * image_filename = malloc(6+bstrv_len(i->data)+1+strlen(image_dir));
|
||||||
if (!image_filename)
|
if (!image_filename)
|
||||||
return CW_RESULT_IMAGE_DATA_ERROR;
|
return CW_RESULT_IMAGE_DATA_ERROR;
|
||||||
|
|
||||||
sprintf(image_filename,"%s%04X/%s",image_dir,vendor_id,vendorstr_data(i->data));
|
sprintf(image_filename,"%s%04X/%s",image_dir,vendor_id,bstrv_data(i->data));
|
||||||
|
|
||||||
|
|
||||||
FILE *infile = fopen(image_filename,"rb");
|
FILE *infile = fopen(image_filename,"rb");
|
||||||
|
@ -31,7 +31,7 @@ int cw_in_cisco_image_identifier(struct conn *conn,struct cw_action_in * a,uint8
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mbag_set(conn->remote,a->item_id,a->itemtype,data+dstart,len);
|
// mbag_set(conn->remote,a->item_id,a->itemtype,data+dstart,len);
|
||||||
mbag_set_vendorstr(conn->incomming,a->item_id,vendor_id,data+dstart,len);
|
mbag_set_bstrv(conn->incomming,a->item_id,vendor_id,data+dstart,len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ int static do_save(mbag_t itemstore, struct conn *conn, struct cw_action_in *a,
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (a->itemtype == MBAG_VENDORSTR) {
|
if (a->itemtype == MBAG_VENDORSTR) {
|
||||||
mbag_set_vendorstr(itemstore, a->item_id,
|
mbag_set_bstrv(itemstore, a->item_id,
|
||||||
cw_get_dword(data), data + 4, len - 4);
|
cw_get_dword(data), data + 4, len - 4);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ int static do_save(mbag_t itemstore, struct conn *conn, struct cw_action_in *a,
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if (idef->type == MBAG_VENDORSTR) {
|
if (idef->type == MBAG_VENDORSTR) {
|
||||||
mbag_set_vendorstr(itemstore, a->item_id,
|
mbag_set_bstrv(itemstore, a->item_id,
|
||||||
cw_get_dword(data), data + 4, len - 4);
|
cw_get_dword(data), data + 4, len - 4);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,14 @@ static int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
|||||||
data + i, sublen);
|
data + i, sublen);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mbag_set_vendorstr(mbag,
|
mbag_set_bstrv(mbag,
|
||||||
CW_ITEM_WTP_HARDWARE_VERSION,
|
CW_ITEM_WTP_HARDWARE_VERSION,
|
||||||
vendor_id, data + i, sublen);
|
vendor_id, data + i, sublen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
|
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
|
||||||
|
|
||||||
mbag_set_vendorstr(mbag,
|
mbag_set_bstrv(mbag,
|
||||||
CW_ITEM_WTP_SOFTWARE_VERSION,
|
CW_ITEM_WTP_SOFTWARE_VERSION,
|
||||||
vendor_id, data + i, sublen);
|
vendor_id, data + i, sublen);
|
||||||
/*
|
/*
|
||||||
@ -104,7 +104,7 @@ static int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data,
|
|||||||
break;
|
break;
|
||||||
case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
|
case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
|
||||||
|
|
||||||
mbag_set_vendorstr(mbag,
|
mbag_set_bstrv(mbag,
|
||||||
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||||
vendor_id, data + i, sublen);
|
vendor_id, data + i, sublen);
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ int cw_put_item(uint8_t * dst, struct mbag_item *item)
|
|||||||
if (MBAG_VENDORSTR == item->type)
|
if (MBAG_VENDORSTR == item->type)
|
||||||
{
|
{
|
||||||
int l=0;
|
int l=0;
|
||||||
l+=cw_put_dword(dst, vendorstr_get_vendor_id(item->data));
|
l+=cw_put_dword(dst, bstrv_get_vendor_id(item->data));
|
||||||
l+=cw_put_data(dst+4, vendorstr_data(item->data),vendorstr_len(item->data));
|
l+=cw_put_data(dst+4, bstrv_data(item->data),bstrv_len(item->data));
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
cw_log(LOG_ERR,"No method to put items of type %d",item->type);
|
cw_log(LOG_ERR,"No method to put items of type %d",item->type);
|
||||||
|
@ -45,20 +45,20 @@ int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len)
|
|||||||
|
|
||||||
switch (subtype) {
|
switch (subtype) {
|
||||||
case CW_SUBELEM_WTP_HARDWARE_VERSION:
|
case CW_SUBELEM_WTP_HARDWARE_VERSION:
|
||||||
mbag_set_vendorstr(mbag,
|
mbag_set_bstrv(mbag,
|
||||||
CW_ITEM_WTP_HARDWARE_VERSION,
|
CW_ITEM_WTP_HARDWARE_VERSION,
|
||||||
vendor_id, data + i, sublen);
|
vendor_id, data + i, sublen);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
|
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
|
||||||
|
|
||||||
mbag_set_vendorstr(mbag,
|
mbag_set_bstrv(mbag,
|
||||||
CW_ITEM_WTP_SOFTWARE_VERSION,
|
CW_ITEM_WTP_SOFTWARE_VERSION,
|
||||||
vendor_id, data + i, sublen);
|
vendor_id, data + i, sublen);
|
||||||
break;
|
break;
|
||||||
case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
|
case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
|
||||||
|
|
||||||
mbag_set_vendorstr(mbag,
|
mbag_set_bstrv(mbag,
|
||||||
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
CW_ITEM_WTP_BOOTLOADER_VERSION,
|
||||||
vendor_id, data + i, sublen);
|
vendor_id, data + i, sublen);
|
||||||
|
|
||||||
|
10
src/cw/dbg.c
10
src/cw/dbg.c
@ -529,14 +529,14 @@ int cw_format_item(char *dst,mbag_item_t * item)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cw_format_version(char *s, vendorstr_t ver, char * def)
|
static int cw_format_version(char *s, bstrv_t ver, char * def)
|
||||||
{
|
{
|
||||||
if (!ver)
|
if (!ver)
|
||||||
return sprintf(s,"%s",def);
|
return sprintf(s,"%s",def);
|
||||||
|
|
||||||
|
|
||||||
uint8_t * version = vendorstr_data(ver);
|
uint8_t * version = bstrv_data(ver);
|
||||||
int len = vendorstr_len(ver);
|
int len = bstrv_len(ver);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -567,14 +567,14 @@ static int cw_format_version(char *s, vendorstr_t ver, char * def)
|
|||||||
rs+=sprintf(s+rs,")");
|
rs+=sprintf(s+rs,")");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t vendor = vendorstr_get_vendor_id(ver);
|
uint32_t vendor = bstrv_get_vendor_id(ver);
|
||||||
rs+=sprintf(s+rs,", Vendor Id: %d, %s",vendor, cw_strvendor(vendor));
|
rs+=sprintf(s+rs,", Vendor Id: %d, %s",vendor, cw_strvendor(vendor));
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void cw_dbg_version_subelem(int level,const char*context,int subtype,vendorstr_t vstr)
|
void cw_dbg_version_subelem(int level,const char*context,int subtype,bstrv_t vstr)
|
||||||
{
|
{
|
||||||
if ( !cw_dbg_is_level(level))
|
if ( !cw_dbg_is_level(level))
|
||||||
return;
|
return;
|
||||||
|
@ -180,7 +180,7 @@ extern void cw_dbg_elem_colored(int level, struct conn *conn, int msg, int msgel
|
|||||||
void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
void cw_dbg_pkt(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||||
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
void cw_dbg_msg(int level,struct conn *conn, uint8_t * packet, int len,struct sockaddr *from);
|
||||||
char * cw_dbg_mkdmp(const uint8_t * data, int len);
|
char * cw_dbg_mkdmp(const uint8_t * data, int len);
|
||||||
void cw_dbg_version_subelem(int level,const char*context,int subtype,vendorstr_t vstr);
|
void cw_dbg_version_subelem(int level,const char*context,int subtype,bstrv_t vstr);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ extern const struct mbag_typedef mbag_type_dword;
|
|||||||
extern const struct mbag_typedef mbag_type_mbag;
|
extern const struct mbag_typedef mbag_type_mbag;
|
||||||
extern const struct mbag_typedef mbag_type_bstr;
|
extern const struct mbag_typedef mbag_type_bstr;
|
||||||
extern const struct mbag_typedef mbag_type_bstr16;
|
extern const struct mbag_typedef mbag_type_bstr16;
|
||||||
extern const struct mbag_typedef mbag_type_vendorstr;
|
extern const struct mbag_typedef mbag_type_bstrv;
|
||||||
extern const struct mbag_typedef mbag_type_str;
|
extern const struct mbag_typedef mbag_type_str;
|
||||||
extern const struct mbag_typedef mbag_type_avltree;
|
extern const struct mbag_typedef mbag_type_avltree;
|
||||||
extern const struct mbag_typedef mbag_type_const_data;
|
extern const struct mbag_typedef mbag_type_const_data;
|
||||||
@ -121,7 +121,7 @@ extern const struct mbag_typedef mbag_type_mbag_dyn;
|
|||||||
#define MBAG_MBAG_DYN (&mbag_type_mbag_dyn)
|
#define MBAG_MBAG_DYN (&mbag_type_mbag_dyn)
|
||||||
#define MBAG_BSTR (&mbag_type_bstr)
|
#define MBAG_BSTR (&mbag_type_bstr)
|
||||||
#define MBAG_BSTR16 (&mbag_type_bstr16)
|
#define MBAG_BSTR16 (&mbag_type_bstr16)
|
||||||
#define MBAG_VENDORSTR (&mbag_type_vendorstr)
|
#define MBAG_VENDORSTR (&mbag_type_bstrv)
|
||||||
#define MBAG_STR (&mbag_type_str)
|
#define MBAG_STR (&mbag_type_str)
|
||||||
#define MBAG_DATA MBAG_STR
|
#define MBAG_DATA MBAG_STR
|
||||||
#define MBAG_AVLTREE (&mbag_type_avltree)
|
#define MBAG_AVLTREE (&mbag_type_avltree)
|
||||||
@ -218,15 +218,15 @@ static inline int mbag_set_data(mbag_t s, const char *id, const struct mbag_type
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline vendorstr_t mbag_set_vendorstr(mbag_t s, const char *id, uint32_t vendor_id,
|
static inline bstrv_t mbag_set_bstrv(mbag_t s, const char *id, uint32_t vendor_id,
|
||||||
uint8_t * vendorstr, int len)
|
uint8_t * bstrv, int len)
|
||||||
{
|
{
|
||||||
mbag_item_t *i = mbag_item_create(s, id);
|
mbag_item_t *i = mbag_item_create(s, id);
|
||||||
if (!i)
|
if (!i)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
i->type = MBAG_VENDORSTR;
|
i->type = MBAG_VENDORSTR;
|
||||||
i->data = vendorstr_create(vendor_id,vendorstr,len);
|
i->data = bstrv_create(vendor_id,bstrv,len);
|
||||||
return i->data;
|
return i->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*@file
|
*@file
|
||||||
*@brief Implementation of mbag_type vendorstr
|
*@brief Implementation of mbag_type bstrv
|
||||||
*@addtogroup MbagFunctions
|
*@addtogroup MbagFunctions
|
||||||
*@{
|
*@{
|
||||||
*/
|
*/
|
||||||
@ -33,14 +33,14 @@ static int to_str(void *item,char *dst)
|
|||||||
mbag_item_t *i= item;
|
mbag_item_t *i= item;
|
||||||
|
|
||||||
char *d=dst;
|
char *d=dst;
|
||||||
d+=sprintf(d,"%d,",vendorstr_get_vendor_id(i->data));
|
d+=sprintf(d,"%d,",bstrv_get_vendor_id(i->data));
|
||||||
|
|
||||||
if (cw_is_utf8(vendorstr_data(i->data), vendorstr_len(i->data))) {
|
if (cw_is_utf8(bstrv_data(i->data), bstrv_len(i->data))) {
|
||||||
d += sprintf(d, "%.*s", vendorstr_len(i->data),
|
d += sprintf(d, "%.*s", bstrv_len(i->data),
|
||||||
vendorstr_data(i->data));
|
bstrv_data(i->data));
|
||||||
} else {
|
} else {
|
||||||
d += sprintf(d, ".x");
|
d += sprintf(d, ".x");
|
||||||
d += cw_format_hex(d, vendorstr_data(i->data), vendorstr_len(i->data));
|
d += cw_format_hex(d, bstrv_data(i->data), bstrv_len(i->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
return d-dst;
|
return d-dst;
|
||||||
@ -58,10 +58,10 @@ static struct mbag_item * from_str(const char *src)
|
|||||||
|
|
||||||
|
|
||||||
if (s){
|
if (s){
|
||||||
i->data=vendorstr_create_from_str(vendor_id,s+1);
|
i->data=bstrv_create_from_str(vendor_id,s+1);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
i->data=vendorstr_create_from_str(vendor_id,"");
|
i->data=bstrv_create_from_str(vendor_id,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
@ -70,9 +70,9 @@ static struct mbag_item * from_str(const char *src)
|
|||||||
/**
|
/**
|
||||||
* Defines the VendorStr type.
|
* Defines the VendorStr type.
|
||||||
*
|
*
|
||||||
* MBAG items of this type containing a variable of type #vendorstr_t.
|
* MBAG items of this type containing a variable of type #bstrv_t.
|
||||||
*/
|
*/
|
||||||
const struct mbag_typedef mbag_type_vendorstr = {
|
const struct mbag_typedef mbag_type_bstrv = {
|
||||||
"VendorStr",free,to_str,from_str
|
"VendorStr",free,to_str,from_str
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,20 +2,20 @@
|
|||||||
#include "format.h"
|
#include "format.h"
|
||||||
|
|
||||||
|
|
||||||
uint8_t * vendorstr_create_from_str(uint32_t vendor_id,const char *s)
|
uint8_t * bstrv_create_from_str(uint32_t vendor_id,const char *s)
|
||||||
{
|
{
|
||||||
int l = strlen(s);
|
int l = strlen(s);
|
||||||
if (s[0]!='.')
|
if (s[0]!='.')
|
||||||
return vendorstr_create(vendor_id,(uint8_t*)s,l);
|
return bstrv_create(vendor_id,(uint8_t*)s,l);
|
||||||
|
|
||||||
if (l<=2)
|
if (l<=2)
|
||||||
return vendorstr_create(vendor_id,(uint8_t*)s,l);
|
return bstrv_create(vendor_id,(uint8_t*)s,l);
|
||||||
|
|
||||||
if (s[1]=='.')
|
if (s[1]=='.')
|
||||||
return vendorstr_create(vendor_id,(uint8_t*)s+1,l-1);
|
return bstrv_create(vendor_id,(uint8_t*)s+1,l-1);
|
||||||
|
|
||||||
if (s[1]!='x')
|
if (s[1]!='x')
|
||||||
return vendorstr_create(vendor_id,(uint8_t*)s,l);
|
return bstrv_create(vendor_id,(uint8_t*)s,l);
|
||||||
|
|
||||||
/* the string starts with ".x" - read hexbytes */
|
/* the string starts with ".x" - read hexbytes */
|
||||||
l-=2;
|
l-=2;
|
||||||
@ -24,13 +24,13 @@ uint8_t * vendorstr_create_from_str(uint32_t vendor_id,const char *s)
|
|||||||
msize++;
|
msize++;
|
||||||
|
|
||||||
|
|
||||||
uint8_t * mem = malloc(vendorstr_size(msize));
|
uint8_t * mem = malloc(bstrv_size(msize));
|
||||||
if(!mem)
|
if(!mem)
|
||||||
return NULL;
|
return NULL;
|
||||||
vendorstr_set_vendor_id(mem,vendor_id);
|
bstrv_set_vendor_id(mem,vendor_id);
|
||||||
vendorstr_set_len(mem,msize);
|
bstrv_set_len(mem,msize);
|
||||||
|
|
||||||
cw_format_scan_hex_bytes(vendorstr_data(mem),s+2,l);
|
cw_format_scan_hex_bytes(bstrv_data(mem),s+2,l);
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,11 +7,6 @@
|
|||||||
|
|
||||||
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
||||||
{
|
{
|
||||||
if (capwap_mode==CW_MODE_CISCO){
|
|
||||||
cw_put_word(dst,0x01);
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
int n=2;
|
int n=2;
|
||||||
|
|
||||||
dst+=cw_put_byte(dst,n);
|
dst+=cw_put_byte(dst,n);
|
||||||
@ -28,7 +23,7 @@ static int cw_put_encryption_subelems(uint8_t *dst,int capwap_mode)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cw_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
int capwap_out_wtp_descriptor(struct conn *conn, struct cw_action_out *a, uint8_t * dst)
|
||||||
{
|
{
|
||||||
|
|
||||||
mbag_t mbag = conn->config;
|
mbag_t mbag = conn->config;
|
||||||
|
@ -172,6 +172,10 @@ conn->config=mbag_create();
|
|||||||
|
|
||||||
mbag_set_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, board_data);
|
mbag_set_mbag(conn->config, CW_ITEM_WTP_BOARD_DATA, board_data);
|
||||||
|
|
||||||
|
// hw = vendorstr_create(conf_vendor_id,conf_hardware_version
|
||||||
|
//mbag_set_bstr16(conn->config, CW_ITEM_WTP_HARDWARE_VERSION,conf_hardware_version);
|
||||||
|
//mbag_set_bstr16(conn->config, CW_ITEM_WTP_SOFTWARE_VERSION,conf_software_version);
|
||||||
|
|
||||||
printf("Board_data %p\n",board_data);
|
printf("Board_data %p\n",board_data);
|
||||||
|
|
||||||
mbag_t mb = mbag_get_mbag(conn->config,CW_ITEM_WTP_BOARD_DATA,NULL);
|
mbag_t mb = mbag_get_mbag(conn->config,CW_ITEM_WTP_BOARD_DATA,NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user