some improvements to support Cisco.

FossilOrigin-Name: 9f0d9e58d55f90bd2020ef622b2501bccbb6038972c04550cb06248139b080c5
This commit is contained in:
7u83@mail.ru
2015-03-12 22:21:57 +00:00
parent 955ab26a81
commit 9f048da56f
21 changed files with 172 additions and 48 deletions

View File

@ -2,22 +2,27 @@
#include <string.h>
#include "capwap.h"
#include "bstr.h"
static inline int wtpdesc_addsubelem(uint8_t * dst,uint8_t type,uint32_t vendorid,uint8_t * str,int len)
static inline int wtpdesc_addsubelem(uint8_t * dst,uint8_t type,uint32_t vendorid,uint8_t * str)
{
// printf("add subelem\n");
int l;
*((uint32_t*)(dst))=htonl(vendorid);
// printf("htonl done\n");
if (len==-1)
l=strlen((char*)str);
else
l=len;
// if (len==-1)
// l=strlen((char*)str);
// else
// l=len;S
l = bstr_len(str);
// 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);
memcpy(dst+8,bstr_data(str),l);
return l+8;
}
@ -31,11 +36,20 @@ void cwmsg_addelem_wtp_descriptor(struct cwmsg * cwmsg, struct wtpinfo * wtpinfo
*(d+1)=wtpinfo->radios_in_use;
len=2;
switch (wtpinfo->capwap_mode){
case CWMODE_CISCO:
*((uint16_t*)(d+len))=0;
len+=2;
break;
default:
break;
}
/* number of encryption elemnts */
// *(d+len)=1;
// len+=1;
*(d+len)=0;
len+=1;
// *(d+len)=0;
// len+=1;
/* encryption elements */
@ -52,20 +66,20 @@ void cwmsg_addelem_wtp_descriptor(struct cwmsg * cwmsg, struct wtpinfo * wtpinfo
*/
/* software subelem*/
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_SOFTWARE_VERSION,
wtpinfo->software_vendor_id,wtpinfo->software_version,-1);
wtpinfo->software_vendor_id,wtpinfo->software_version);
/* hardware subelem*/
// len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION,
// wtpinfo->hardware_vendor_id,wtpinfo->hardware_version,2);
/* len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION,
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION,
wtpinfo->hardware_vendor_id,wtpinfo->hardware_version);
/*
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION,
wtpinfo->hardware_vendor_id,hww,2);
*/
/* bootloader subelem*/
/* len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_BOOTLOADER_VERSION,
wtpinfo->bootloader_vendor_id,wtpinfo->bootloader_version,-1);
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_BOOTLOADER_VERSION,
wtpinfo->bootloader_vendor_id,wtpinfo->bootloader_version);
*/
cwmsg_addelem(cwmsg,CWMSGELEM_WTP_DESCRIPTOR,d,len);
}