Initial commit

FossilOrigin-Name: 05e00fccf3948fc30c7f41a4a8d9d7b90b698c924754367c57dfcfc586a55604
This commit is contained in:
7u83@mail.ru 2016-02-27 09:49:06 +00:00
parent bbe8b6a424
commit 68502c92c4
3 changed files with 101 additions and 0 deletions

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,24 @@
#include "cw.h"
#include "capwap.h"
#include "capwap_items.h"
/**
* Read WTP Descriptor in Cisco-Style (Draft 7)
*/
int cw_read_wtp_descriptor_7(mbag_t mbag, struct conn *conn,
struct cw_action_in *a, uint8_t * data, int len)
{
mbag_set_byte(mbag, CW_ITEM_WTP_MAX_RADIOS, cw_get_byte(data));
mbag_set_byte(mbag, CW_ITEM_WTP_RADIOS_IN_USE, cw_get_byte(data + 1));
int pos = 2;
/* Encryption element, for now dumy XXX */
cw_get_word(data + pos + 2);
pos += 2;
return cw_read_wtp_descriptor_versions(mbag, data + pos, len - pos);
}

View File

@ -0,0 +1,76 @@
#include "cw.h"
#include "capwap.h"
#include "log.h"
#include "dbg.h"
#include "capwap_items.h"
int cw_read_wtp_descriptor_versions(mbag_t mbag, uint8_t * data, int len)
{
int i = 0;
while (i < len) {
if (i + 8 > len) {
cw_dbg(DBG_ELEM_ERR,
"WTP descriptor subelement to long, length=%d>%d",
i + 8, len);
return 0;
}
uint32_t vendor_id = cw_get_dword(data + i);
uint32_t val = cw_get_dword(data + i + 4);
int subtype = (val >> 16) & 0xffff;
int sublen = val & 0xffff;
i += 8;
if (sublen + i > len) {
cw_dbg(DBG_ELEM_ERR,
"WTP Descriptor sub-element too long, length = %d",
sublen);
return 0;
}
char *dmp;
char *dmpmem = NULL;
if (cw_dbg_is_level(DBG_SUBELEM_DMP)) {
dmpmem = cw_dbg_mkdmp(data + i, sublen);
dmp = dmpmem;
} else
dmp = "";
cw_dbg(DBG_SUBELEM, "WTP Descriptor subtype=%d,len=%d%s", subtype,
sublen, dmp);
if (dmpmem)
free(dmpmem);
switch (subtype) {
case CW_SUBELEM_WTP_HARDWARE_VERSION:
mbag_set_vendorstr(mbag,
CW_ITEM_WTP_HARDWARE_VERSION,
vendor_id, data + i, sublen);
break;
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
mbag_set_vendorstr(mbag,
CW_ITEM_WTP_SOFTWARE_VERSION,
vendor_id, data + i, sublen);
break;
case CW_SUBELEM_WTP_BOOTLOADER_VERSION:
mbag_set_vendorstr(mbag,
CW_ITEM_WTP_BOOTLOADER_VERSION,
vendor_id, data + i, sublen);
break;
default:
cw_dbg(DBG_ELEM_ERR,
"Unknown WTP descriptor subelement, type = %d",
subtype);
break;
}
i += sublen;
}
return 1;
}