Work in progrsss.

FossilOrigin-Name: efb7fb1dc204a4d673f899994eb72005a6cdead3dff43ecab63f1ed4ca8e61ba
This commit is contained in:
7u83@mail.ru
2014-09-14 20:46:14 +00:00
parent 8677fe1a1e
commit 4f7def25f2
16 changed files with 214 additions and 61 deletions

View File

@ -1,4 +1,3 @@
CC=clang
ifndef CC
CC=gcc
endif
@ -139,8 +138,8 @@ DTLSOBJS= dtls_openssl.o \
dtls_openssl_connect.o \
dtls_openssl_get_cipher.o \
dtls_openssl_bio.o \
dtls_gnutls.o \
dtls_gnutls_accept.o \
# dtls_gnutls.o \
# dtls_gnutls_accept.o \
CONNOBJS= conn.o \

View File

@ -28,7 +28,8 @@ int conn_send_cwmsg(struct conn * conn, struct cwmsg * cwmsg)
uint32_t val;
/* second dword of message control header */
val = (cwmsg->seqnum<<24)|((cwmsg->pos+3)<<8);
//orig val = (cwmsg->seqnum<<24)|((cwmsg->pos+3)<<8);
val = (cwmsg->seqnum<<24)|((cwmsg->pos)<<8);
*((uint32_t*)(cwmsg->ctrlhdr+4))=htonl(val);

View File

@ -18,29 +18,35 @@
#include "capwap.h"
#include <stdio.h>
/*
* for each capwap message element in msgelems call the callback function
*/
int cw_foreach_msgelem(uint8_t * msgelems, int len,
int (*callback)(void*,int,uint8_t*,int),void *arg )
int cw_foreach_msgelem(uint8_t * msgelems, int len,
int (*callback) (void *, int, uint8_t *, int),
void *arg)
{
uint32_t val;
int type;
int elen;
int i=0;
int i = 0;
do {
val = ntohl(*(uint32_t*)(msgelems+i));
type=(val>>16) & 0xFFFF;
val = ntohl(*(uint32_t *) (msgelems + i));
type = (val >> 16) & 0xFFFF;
elen = val & 0xffff;
if (i+elen+4>len) {
if (i + elen + 4 > len) {
printf("***************************************************************************\n");
printf("Type: %d\n",type);
printf("Bumm %d %d\n",i+elen+4,len);
return 0;
}
callback(arg,type,msgelems+i+4,elen);
i+=elen+4;
} while (i<len);
callback(arg, type, msgelems + i + 4, elen);
i += elen + 4;
} while (i < len);
return 1;
}

View File

@ -24,7 +24,7 @@
void cwmsg_addelem_ac_timestamp(struct cwmsg *msg)
{
time_t t = time(NULL);
uint32_t ntpt = t+2398291200;
uint32_t ntpt = t+(uint32_t)2398291200LL;
uint8_t c[4];
*((uint32_t*)c)= htonl(ntpt);
cwmsg_addelem(msg,CWMSGELEM_AC_TIMESTAMP,c,4);

View File

@ -4,13 +4,16 @@
#include "capwap.h"
static inline int wtpdesc_addsubelem(uint8_t * dst,uint8_t type,uint32_t vendorid,uint8_t * str)
static inline int wtpdesc_addsubelem(uint8_t * dst,uint8_t type,uint32_t vendorid,uint8_t * str,int len)
{
// printf("add subelem\n");
int l;
*((uint32_t*)(dst))=htonl(vendorid);
// printf("htonl done\n");
l=strlen((char*)str);
if (len==-1)
l=strlen((char*)str);
else
l=len;
// printf("strlne got %d\n",l);
*((uint32_t*)(dst+4))=htonl((type<<16)|l);
// printf("memcopy str %d\n",l);
@ -29,28 +32,38 @@ void cwmsg_addelem_wtp_descriptor(struct cwmsg * cwmsg, struct wtpinfo * wtpinfo
len=2;
/* number of encryption elemnts */
*(d+len)=1;
// *(d+len)=1;
// len+=1;
*(d+len)=0;
len+=1;
/* encryption elements */
*(d+len)=CWTH_WBID_IEEE80211;
/* *(d+len)=CWTH_WBID_IEEE80211;
uint16_t val = 0;
*((uint16_t*)(d+len+1))=htons(val);
len+=3;
*/
uint8_t hww[2];
hww[0]=0x1c;
hww[1]=0;
/* 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,
wtpinfo->hardware_vendor_id,wtpinfo->hardware_version);
wtpinfo->hardware_vendor_id,hww,2);
/* software subelem*/
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_SOFTWARE_VERSION,
wtpinfo->software_vendor_id,wtpinfo->software_version);
wtpinfo->software_vendor_id,wtpinfo->software_version,-1);
/* bootloader subelem*/
len+=wtpdesc_addsubelem(d+len,CWMSGSUBELEM_WTP_DESCRIPTOR_BOOTLOADER_VERSION,
wtpinfo->bootloader_vendor_id,wtpinfo->bootloader_version);
wtpinfo->bootloader_vendor_id,wtpinfo->bootloader_version,-1);
cwmsg_addelem(cwmsg,CWMSGELEM_WTP_DESCRIPTOR,d,len);

View File

@ -28,7 +28,9 @@ int __old_cwmsg_send(struct cwmsg * cwmsg, int seqnum, int rid, struct conn * co
uint32_t val;
/* second dword of message control header */
val = (seqnum<<24)|((cwmsg->pos+3)<<8);
//orig val = (seqnum<<24)|((cwmsg->pos+3)<<8);
val = (seqnum<<24)|((cwmsg->pos)<<8);
*((uint32_t*)(cwmsg->ctrlhdr+4))=htonl(val);

View File

@ -25,15 +25,38 @@ int cwsend_discovery_request(struct conn * conn,struct radioinfo * radioinfo,str
uint8_t buffer[CWMSG_MAX_SIZE];
struct cwmsg cwmsg;
cwmsg_init(&cwmsg,buffer,CWMSG_DISCOVERY_REQUEST,conn_get_next_seqnum(conn),radioinfo);
cwmsg_init(&cwmsg,buffer,CWMSG_DISCOVERY_REQUEST,conn_get_next_seqnum(conn),NULL /*radioinfo*/);
cwmsg_addelem(&cwmsg,CWMSGELEM_DISCOVERY_TYPE,&wtpinfo->discovery_type,sizeof(uint8_t));
cwmsg_addelem_wtp_board_data(&cwmsg,wtpinfo);
// cwmsg_addelem_wtp_board_data(&cwmsg,wtpinfo);
cwmsg_addelem_wtp_descriptor(&cwmsg,wtpinfo);
cwmsg_addelem(&cwmsg,CWMSGELEM_WTP_FRAME_TUNNEL_MODE,&wtpinfo->frame_tunnel_mode,sizeof(uint8_t));
cwmsg_addelem(&cwmsg,CWMSGELEM_WTP_MAC_TYPE,&wtpinfo->mac_type,sizeof(uint8_t));
cwmsg_addelem_wtp_radio_infos(&cwmsg,wtpinfo->radioinfo);
cwmsg_addelem_mtu_discovery_padding(&cwmsg,conn);
//cwmsg_addelem(&cwmsg,CWMSGELEM_CAPWAP_LOCAL_IPV4_ADDRESS);
cwmsg_addelem_cw_local_ip_addr(&cwmsg,conn);
// cwmsg_addelem_wtp_radio_infos(&cwmsg,wtpinfo->radioinfo);
// cwmsg_addelem_mtu_discovery_padding(&cwmsg,conn);
//uint8_t zven[] = {0xBF, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,0x66,0x69,0x73,0x68,0x00,0x02,0xFC,0xF5,0x28,0xCA,0xAE,0xE4,0x00,0x03,0x10,0x10,
//0x04, 0x10, 0x00,0x00,0x10,0x00,0x00,0x06,0xFC,0xF5,0x28,0xCA,0xAE,0xE5,0xC4,0x2E,0xC4,0x2E,0xC4,0x2E,0xC4,0x2E,0xC4,0x2E,
//0xC4,0x2E,0xC4,0x2E,0xC4,0x2E,0xC4,0x2E };
uint8_t zven [] = {
// 0x00, 00 03 7A 00 02
0x22, 0xE0, 00, 00, 00, 00, 00, 00, 00, 0x01, 0x66, 0x69, 0x73,0x68,0x00,0x02,0xFC,0xF5,0x28,0xCA,0xAE,0xE4,0x00,0x03,0x10,0x10 ,
0x04,0x10,0x00, 00, 0x10, 00, 00,0x06,0xFC,0xF5,0x28,0xCA,0xAE,0xE5,0xAB,0x37,0xAB,0x37,0xAB,0x37,0xAB,0x37,0xAB,0x37,0xAB,0x37,0xAB,0x37,0xAB,0x37,0xAB,0x37,
00, 0x07, 00, 00, 0x27,0x11,0x00,0x08,0x00,0x00 };
cwmsg_addelem_vendor_specific_payload(&cwmsg,890,2,zven,sizeof(zven));
return conn_send_cwmsg(conn,&cwmsg);
}

View File

@ -46,7 +46,7 @@ void cwsend_discovery_response(struct conn * conn,int seqnum, struct radioinfo *
cwmsg_addelem_ctrl_ip_addrs(cwmsg,acinfo);
cwmsg_addelem_vendor_cisco_ap_timesync(cwmsg);
//cwmsg_addelem_vendor_cisco_ap_timesync(cwmsg);
// uint8_t buffer[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";