2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "capwap.h"
|
|
|
|
|
|
|
|
|
2014-09-14 22:46:14 +02:00
|
|
|
static inline int wtpdesc_addsubelem(uint8_t * dst,uint8_t type,uint32_t vendorid,uint8_t * str,int len)
|
2014-07-11 22:12:11 +02:00
|
|
|
{
|
|
|
|
// printf("add subelem\n");
|
|
|
|
int l;
|
|
|
|
*((uint32_t*)(dst))=htonl(vendorid);
|
|
|
|
// printf("htonl done\n");
|
2014-09-14 22:46:14 +02:00
|
|
|
if (len==-1)
|
|
|
|
l=strlen((char*)str);
|
|
|
|
else
|
|
|
|
l=len;
|
2014-07-11 22:12:11 +02:00
|
|
|
// printf("strlne got %d\n",l);
|
|
|
|
*((uint32_t*)(dst+4))=htonl((type<<16)|l);
|
|
|
|
// printf("memcopy str %d\n",l);
|
|
|
|
memcpy(dst+8,str,l);
|
|
|
|
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;
|
|
|
|
|
|
|
|
/* number of encryption elemnts */
|
2014-09-14 22:46:14 +02:00
|
|
|
// *(d+len)=1;
|
|
|
|
// len+=1;
|
|
|
|
*(d+len)=0;
|
2014-07-11 22:12:11 +02:00
|
|
|
len+=1;
|
|
|
|
|
|
|
|
/* encryption elements */
|
2014-09-14 22:46:14 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* *(d+len)=CWTH_WBID_IEEE80211;
|
2014-07-11 22:12:11 +02:00
|
|
|
uint16_t val = 0;
|
|
|
|
*((uint16_t*)(d+len+1))=htons(val);
|
|
|
|
len+=3;
|
2014-09-14 22:46:14 +02:00
|
|
|
*/
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2014-09-14 22:46:14 +02:00
|
|
|
uint8_t hww[2];
|
|
|
|
hww[0]=0x1c;
|
|
|
|
hww[1]=0;
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
/* software subelem*/
|
|
|
|
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_SOFTWARE_VERSION,
|
|
|
|
wtpinfo->software_vendor_id,wtpinfo->software_version,-1);
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
/* hardware subelem*/
|
2014-09-14 22:46:14 +02:00
|
|
|
// len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION,
|
|
|
|
// wtpinfo->hardware_vendor_id,wtpinfo->hardware_version,2);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
/* len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION,
|
|
|
|
wtpinfo->hardware_vendor_id,hww,2);
|
|
|
|
*/
|
2014-07-11 22:12:11 +02:00
|
|
|
|
|
|
|
/* bootloader subelem*/
|
2015-02-01 16:55:45 +01:00
|
|
|
/* len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_BOOTLOADER_VERSION,
|
2014-09-14 22:46:14 +02:00
|
|
|
wtpinfo->bootloader_vendor_id,wtpinfo->bootloader_version,-1);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-02-01 16:55:45 +01:00
|
|
|
*/
|
2014-07-11 22:12:11 +02:00
|
|
|
cwmsg_addelem(cwmsg,CWMSGELEM_WTP_DESCRIPTOR,d,len);
|
|
|
|
}
|