cw_in_wtp_board_data completed.
FossilOrigin-Name: 6475dd3ea1609b3c41571e7d3ae360dbb3e6e6ecd9af7bdb7a8a2ba2f96401f5
This commit is contained in:
parent
b63692f46e
commit
ec6602f5ec
@ -168,6 +168,7 @@ CAPWAPOBJS= \
|
|||||||
itemstore.o \
|
itemstore.o \
|
||||||
cw_in_vendor_specific_payload.o \
|
cw_in_vendor_specific_payload.o \
|
||||||
cw_in_wtp_name.o \
|
cw_in_wtp_name.o \
|
||||||
|
cw_in_wtp_board_data.o
|
||||||
|
|
||||||
|
|
||||||
#cw_ianavendoridtostr.o \
|
#cw_ianavendoridtostr.o \
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
enum capwap_items {
|
enum capwap_items {
|
||||||
CW_ITEM_NONE=0,
|
CW_ITEM_NONE=0,
|
||||||
CW_ITEM_DISCOVERY_TYPE,
|
CW_ITEM_DISCOVERY_TYPE,
|
||||||
CW_ITEM_WTP_NAME
|
CW_ITEM_WTP_NAME,
|
||||||
CW_ITEM_WTP_BOARD_VENDOR,
|
CW_ITEM_WTP_BOARD_VENDOR,
|
||||||
CW_ITEM_WTP_BOARD_MODELNO,
|
CW_ITEM_WTP_BOARD_MODELNO,
|
||||||
CW_ITEM_WTP_BOARD_MACADDRESS,
|
CW_ITEM_WTP_BOARD_MACADDRESS,
|
||||||
CW_ITEM_WTP_BOARD_ID,
|
CW_ITEM_WTP_BOARD_ID,
|
||||||
CW_ITEM_WTP_BOARD_REVISISON,
|
CW_ITEM_WTP_BOARD_REVISION,
|
||||||
CW_ITEM_WTP_BOARD_SERIALNO
|
CW_ITEM_WTP_BOARD_SERIALNO
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -6,66 +6,92 @@
|
|||||||
#include "wtpinfo.h"
|
#include "wtpinfo.h"
|
||||||
|
|
||||||
#include "capwap.h"
|
#include "capwap.h"
|
||||||
|
#include "capwap_items.h"
|
||||||
|
|
||||||
|
#include "itemstore.h"
|
||||||
|
|
||||||
#include "cw_util.h"
|
#include "cw_util.h"
|
||||||
#include "cw_log.h"
|
#include "cw_log.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void wtpinfo_readsubelems_wtp_board_data(struct wtpinfo * wtpinfo,uint8_t * msgelem,int len)
|
static void readsubelems_wtp_board_data(cw_itemstore_t itemstore, uint8_t * msgelem,
|
||||||
|
int len)
|
||||||
{
|
{
|
||||||
int i=0;
|
|
||||||
|
int i = 0;
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
do {
|
do {
|
||||||
val = ntohl(*((uint32_t*)(msgelem+i)));
|
val = ntohl(*((uint32_t *) (msgelem + i)));
|
||||||
int subtype= (val>>16)&0xffff;
|
int subtype = (val >> 16) & 0xffff;
|
||||||
int sublen = val&0xffff;
|
int sublen = val & 0xffff;
|
||||||
i+=4;
|
i += 4;
|
||||||
if (sublen+i>len){
|
if (sublen + i > len) {
|
||||||
cw_dbg(DBG_ELEM,"WTP Board data sub-element too long, type=%d,len=%d",subtype,sublen);
|
cw_dbg(DBG_ELEM, "WTP Board data sub-element too long, type=%d,len=%d",
|
||||||
|
subtype, sublen);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cw_dbg(DBG_ELEM,"Reading WTP board data sub-element, type=%d, len=%d",subtype,sublen);
|
|
||||||
|
|
||||||
switch(subtype){
|
cw_dbg(DBG_ELEM, "Reading WTP board data sub-element, type=%d, len=%d", subtype,
|
||||||
|
sublen);
|
||||||
|
|
||||||
|
switch (subtype) {
|
||||||
case CWBOARDDATA_MODELNO:
|
case CWBOARDDATA_MODELNO:
|
||||||
bstr_replace(&wtpinfo->model_no,bstr_create(msgelem+i,sublen));
|
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_MODELNO,
|
||||||
|
msgelem + i, sublen);
|
||||||
break;
|
break;
|
||||||
case CWBOARDDATA_SERIALNO:
|
case CWBOARDDATA_SERIALNO:
|
||||||
bstr_replace(&wtpinfo->serial_no,bstr_create(msgelem+i,sublen));
|
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_SERIALNO,
|
||||||
|
msgelem + i, sublen);
|
||||||
|
|
||||||
|
// bstr_replace(&wtpinfo->serial_no, bstr_create(msgelem + i, sublen));
|
||||||
break;
|
break;
|
||||||
case CWBOARDDATA_MACADDRESS:
|
case CWBOARDDATA_MACADDRESS:
|
||||||
wtpinfo->macaddress=realloc(wtpinfo->macaddress,sublen);
|
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_MACADDRESS,
|
||||||
memcpy(wtpinfo->macaddress,msgelem+i,sublen);
|
msgelem + i, sublen);
|
||||||
wtpinfo->macaddress_len=sublen;
|
|
||||||
|
/*
|
||||||
|
wtpinfo->macaddress = realloc(wtpinfo->macaddress, sublen);
|
||||||
|
memcpy(wtpinfo->macaddress, msgelem + i, sublen);
|
||||||
|
wtpinfo->macaddress_len = sublen;
|
||||||
|
*/
|
||||||
break;
|
break;
|
||||||
case CWBOARDDATA_BOARDID:
|
case CWBOARDDATA_BOARDID:
|
||||||
bstr_replace(&wtpinfo->board_id,bstr_create(msgelem+i,sublen));
|
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_ID,
|
||||||
|
msgelem + i, sublen);
|
||||||
|
// bstr_replace(&wtpinfo->board_id, bstr_create(msgelem + i, sublen));
|
||||||
break;
|
break;
|
||||||
case CWBOARDDATA_REVISION:
|
case CWBOARDDATA_REVISION:
|
||||||
bstr_replace(&wtpinfo->board_revision,bstr_create(msgelem+i,sublen));
|
cw_itemstore_set_bstrn(itemstore, CW_ITEM_WTP_BOARD_REVISION,
|
||||||
|
msgelem + i, sublen);
|
||||||
|
// bstr_replace(&wtpinfo->board_revision,
|
||||||
|
// bstr_create(msgelem + i, sublen));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
i+=sublen;
|
i += sublen;
|
||||||
|
|
||||||
}while(i<len);
|
} while (i < len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int cw_in_wtp_board_data(struct conn *conn,struct cw_action * a,uint8_t *data,int len)
|
int cw_in_wtp_board_data(struct conn *conn, struct cw_action *a, uint8_t * data, int len)
|
||||||
{
|
{
|
||||||
if (len<4){
|
if (len < 4) {
|
||||||
cw_dbg(DBG_ELEM_ERR,"Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d\n",type,len);
|
cw_dbg(DBG_ELEM_ERR,
|
||||||
|
"Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d", a->elem_id,
|
||||||
|
len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cw_itemstore_t itemstore = conn->itemstore;
|
||||||
|
cw_itemstore_set_dword(itemstore, CW_ITEM_WTP_BOARD_VENDOR,get_dword(data));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
wtpinfo->vendor_id = ntohl(*((uint32_t*)msgelem));
|
wtpinfo->vendor_id = ntohl(*((uint32_t*)msgelem));
|
||||||
wtpinfo_readsubelems_wtp_board_data(wtpinfo,msgelem+4,len-4);
|
|
||||||
*/
|
*/
|
||||||
|
readsubelems_wtp_board_data(itemstore,data+4,len-4);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,38 @@ int cw_itemstore_set_strn(cw_itemstore_t s,uint32_t id,const char *str,int n)
|
|||||||
i->data=strndup(str,n);
|
i->data=strndup(str,n);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int cw_itemstore_set_ptr(cw_itemstore_t s, uint32_t id, void*ptr)
|
||||||
|
{
|
||||||
|
struct cw_item *i = cw_item_create(s,id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->type=CW_ITEMTYPE_DATA;
|
||||||
|
i->data=ptr;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int cw_itemstore_set_bstrn(cw_itemstore_t s, uint32_t id, uint8_t *data,int len)
|
||||||
|
{
|
||||||
|
struct cw_item *i = cw_item_create(s,id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->type=CW_ITEMTYPE_DATA;
|
||||||
|
i->data=bstr_create(data,len);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int cw_itemstore_set_const_ptr(cw_itemstore_t s, uint32_t id, void*ptr)
|
||||||
|
{
|
||||||
|
struct cw_item *i = cw_item_create(s,id);
|
||||||
|
if (!i)
|
||||||
|
return 0;
|
||||||
|
i->type=CW_ITEMTYPE_CONST_DATA;
|
||||||
|
i->data=ptr;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
struct cw_item * i = malloc(sizeof(struct cw_item));
|
struct cw_item * i = malloc(sizeof(struct cw_item));
|
||||||
if ( !i)
|
if ( !i)
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "avltree.h"
|
#include "avltree.h"
|
||||||
|
#include "bstr.h"
|
||||||
|
|
||||||
enum cw_cfgtem_types{
|
enum cw_cfgtem_types{
|
||||||
CW_ITEMTYPE_NONE=0,
|
CW_ITEMTYPE_NONE=0,
|
||||||
@ -58,6 +59,9 @@ static inline struct cw_item * cw_itemstore_get(cw_itemstore_t s, uint32_t id)
|
|||||||
|
|
||||||
extern cw_itemstore_t cw_itemstore_create();
|
extern cw_itemstore_t cw_itemstore_create();
|
||||||
extern int cw_itemstore_set_strn(cw_itemstore_t s,uint32_t id,const char *str,int n);
|
extern int cw_itemstore_set_strn(cw_itemstore_t s,uint32_t id,const char *str,int n);
|
||||||
|
extern int cw_itemstore_set_ptr(cw_itemstore_t s, uint32_t id, void*ptr);
|
||||||
|
extern int cw_itemstore_set_bstrn(cw_itemstore_t s, uint32_t id, uint8_t *data,int len);
|
||||||
|
extern int cw_itemstore_set_dword(cw_itemstore_t s,uint32_t id,uint32_t dword);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user