2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "capwap.h"
|
2015-03-12 23:21:57 +01:00
|
|
|
#include "bstr.h"
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
static inline int wtpdesc_addsubelem(uint8_t * dst,uint8_t type,uint32_t vendorid,bstr_t str)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
|
|
|
int l;
|
|
|
|
*((uint32_t*)(dst))=htonl(vendorid);
|
2015-03-12 23:21:57 +01:00
|
|
|
l = bstr_len(str);
|
2014-07-11 22:12:11 +02:00
|
|
|
*((uint32_t*)(dst+4))=htonl((type<<16)|l);
|
2015-03-12 23:21:57 +01:00
|
|
|
memcpy(dst+8,bstr_data(str),l);
|
2014-07-11 22:12:11 +02:00
|
|
|
return l+8;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cwmsg_addelem_wtp_descriptor(struct cwmsg * cwmsg, struct wtpinfo * wtpinfo)
|
|
|
|
{
|
|
|
|
uint8_t d[1024];
|
|
|
|
int len=0;
|
|
|
|
|
|
|
|
/* radios info */
|
|
|
|
*(d)= wtpinfo->max_radios;
|
|
|
|
*(d+1)=wtpinfo->radios_in_use;
|
|
|
|
len=2;
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
switch (cwmsg->capwap_mode){
|
2015-03-12 23:21:57 +01:00
|
|
|
case CWMODE_CISCO:
|
2015-03-14 21:41:50 +01:00
|
|
|
/* encryption capabilities */
|
|
|
|
*((uint16_t*)(d+len))=htons(wtpinfo->encryption_cap);
|
2015-03-12 23:21:57 +01:00
|
|
|
len+=2;
|
|
|
|
break;
|
|
|
|
default:
|
2015-03-14 10:15:12 +01:00
|
|
|
/* number of encryption elemnts */
|
|
|
|
*(d+len)=0;
|
|
|
|
len += 1;
|
|
|
|
/* encryption elements */
|
2015-03-12 23:21:57 +01:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* *(d+len)=CWTH_WBID_IEEE80211;
|
|
|
|
uint16_t val = 0;
|
|
|
|
*((uint16_t*)(d+len+1))=htons(val);
|
|
|
|
len+=3;
|
|
|
|
*/
|
2014-09-14 22:46:14 +02:00
|
|
|
|
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
break;
|
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* hardware version subelem*/
|
2015-04-05 02:07:59 +02:00
|
|
|
len+=wtpdesc_addsubelem(d+len,CW_SUBELEM_WTP_HARDWARE_VERSION,
|
2015-03-12 23:21:57 +01:00
|
|
|
wtpinfo->hardware_vendor_id,wtpinfo->hardware_version);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-14 10:15:12 +01:00
|
|
|
/* software version subelem*/
|
2015-04-05 02:07:59 +02:00
|
|
|
len+=wtpdesc_addsubelem(d+len,CW_SUBELEM_WTP_SOFTWARE_VERSION,
|
2015-03-14 10:15:12 +01:00
|
|
|
wtpinfo->software_vendor_id,wtpinfo->software_version);
|
|
|
|
|
|
|
|
/* bootloader version subelem*/
|
2015-04-05 02:07:59 +02:00
|
|
|
len+=wtpdesc_addsubelem(d+len,CW_SUBELEM_WTP_BOOTLOADER_VERSION,
|
2015-03-12 23:21:57 +01:00
|
|
|
wtpinfo->bootloader_vendor_id,wtpinfo->bootloader_version);
|
|
|
|
|
2015-03-30 07:56:42 +02:00
|
|
|
cwmsg_addelem(cwmsg,CW_ELEM_WTP_DESCRIPTOR,d,len);
|
2014-07-11 22:12:11 +02:00
|
|
|
}
|