2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "wtpinfo.h"
|
|
|
|
|
|
|
|
#include "capwap.h"
|
|
|
|
|
|
|
|
#include "cw_util.h"
|
|
|
|
#include "cw_log.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void wtpinfo_readsubelems_wtp_board_data(struct wtpinfo * wtpinfo,uint8_t * msgelem,int len)
|
|
|
|
{
|
|
|
|
int i=0;
|
|
|
|
uint32_t val;
|
|
|
|
do {
|
|
|
|
val = ntohl(*((uint32_t*)(msgelem+i)));
|
|
|
|
int subtype= (val>>16)&0xffff;
|
|
|
|
int sublen = val&0xffff;
|
|
|
|
i+=4;
|
2014-07-28 07:05:13 +02:00
|
|
|
if (sublen+i>len){
|
2015-03-28 12:51:34 +01:00
|
|
|
cw_dbg(DBG_ELEM,"WTP Board data sub-element too long, type=%d,len=%d",subtype,sublen);
|
2014-07-11 22:12:11 +02:00
|
|
|
return;
|
2014-07-28 07:05:13 +02:00
|
|
|
}
|
|
|
|
|
2015-03-28 12:51:34 +01:00
|
|
|
cw_dbg(DBG_ELEM,"Reading WTP board data sub-element, type=%d, len=%d",subtype,sublen);
|
2014-07-28 07:05:13 +02:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
switch(subtype){
|
|
|
|
case CWBOARDDATA_MODELNO:
|
2015-03-14 21:41:50 +01:00
|
|
|
bstr_replace(&wtpinfo->model_no,bstr_create(msgelem+i,sublen));
|
2014-07-11 22:12:11 +02:00
|
|
|
break;
|
|
|
|
case CWBOARDDATA_SERIALNO:
|
2015-03-14 21:41:50 +01:00
|
|
|
bstr_replace(&wtpinfo->serial_no,bstr_create(msgelem+i,sublen));
|
2014-07-11 22:12:11 +02:00
|
|
|
break;
|
|
|
|
case CWBOARDDATA_MACADDRESS:
|
|
|
|
wtpinfo->macaddress=realloc(wtpinfo->macaddress,sublen);
|
|
|
|
memcpy(wtpinfo->macaddress,msgelem+i,sublen);
|
|
|
|
wtpinfo->macaddress_len=sublen;
|
|
|
|
break;
|
2014-07-28 07:05:13 +02:00
|
|
|
case CWBOARDDATA_BOARDID:
|
2015-03-14 21:41:50 +01:00
|
|
|
bstr_replace(&wtpinfo->board_id,bstr_create(msgelem+i,sublen));
|
2014-07-28 07:05:13 +02:00
|
|
|
break;
|
|
|
|
case CWBOARDDATA_REVISION:
|
2015-03-14 21:41:50 +01:00
|
|
|
bstr_replace(&wtpinfo->board_revision,bstr_create(msgelem+i,sublen));
|
2014-07-11 22:12:11 +02:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i+=sublen;
|
|
|
|
|
|
|
|
}while(i<len);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int wtpinfo_readelem_wtp_board_data(struct wtpinfo *wtpinfo, int type, uint8_t *msgelem, int len)
|
|
|
|
{
|
|
|
|
|
2015-03-30 07:56:42 +02:00
|
|
|
if (type!=CW_ELEM_WTP_BOARD_DATA)
|
2014-07-11 22:12:11 +02:00
|
|
|
return 0;
|
|
|
|
if (len<4){
|
2015-03-28 12:51:34 +01:00
|
|
|
cw_dbg(DBG_ELEM,"Discarding WTP_BOARD_DATA msgelem, wrong size, type=%d, len=%d\n",type,len);
|
2014-07-11 22:12:11 +02:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wtpinfo->vendor_id = ntohl(*((uint32_t*)msgelem));
|
|
|
|
wtpinfo_readsubelems_wtp_board_data(wtpinfo,msgelem+4,len-4);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|