More cisco-compatibility.

FossilOrigin-Name: 04ec8be34c8f04e70ce803fb8f47f72f426bdc7cf85edced8f09d3a9f1f0c50d
This commit is contained in:
7u83@mail.ru 2015-03-14 20:41:50 +00:00
parent b0191ba570
commit 4a20f80250
26 changed files with 439 additions and 64 deletions

View File

@ -379,8 +379,8 @@ static void wtpman_run_discovery(void *arg)
struct radioinfo radioinfo;
radioinfo.rid = cwrmsg->rid;
memcpy(radioinfo.rmac, cwrmsg->rmac,8);
radioinfo.rmac[0]=0;
// memcpy(radioinfo.rmac, cwrmsg->rmac,8);
// radioinfo.rmac[0]=0;
struct ac_info * acinfo = get_acinfo();

View File

@ -94,7 +94,6 @@ CAPWAPOBJS= \
cwread_discovery_request.o\
cwread_change_state_event_request.o\
cwread_wtp_event_request.o \
process_msgelems_discovery_request.o \
process_conf_status_request.o \
process_join_request.o \
wtpinfo_readelem_wtp_board_data.o \
@ -132,6 +131,7 @@ CAPWAPOBJS= \
cwmsg_addelem_vendor_cisco_mwar_addr.o \
lw_checksum.o \
#cwmsg_addelem_session_id.o
# process_msgelems_discovery_request.o \
# cwsend_image_data_request.o
# cwmsg_set_control_header.o
@ -185,7 +185,8 @@ CONNOBJS= conn.o \
BSTROBJS= bstr_create.o \
bstr_create_from_cfgstr.o \
bstr_replace.o
bstr_replace.o \
bstr_to_str.o
FRAGOBJS=fragman.o

View File

@ -53,8 +53,12 @@ struct ac_info{
struct sockaddr_storage local_ip;
/* wireless bindings */
struct radioinfo radioinfos[32];
uint32_t result_code;
};
typedef struct ac_info ACINFO;

View File

@ -1,3 +1,21 @@
/*
This file is part of libcapwap.
libcapwap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __BSTR_H
#define __BSTR_H
@ -10,9 +28,14 @@ extern uint8_t * bstr_create(uint8_t *data, uint8_t len);
extern uint8_t * bstr_create_from_cfgstr(const char * s);
extern uint8_t * bstr_replace( uint8_t ** dst, uint8_t * bstr);
extern int bstr_to_str(char *dst, bstr_t str,char * def);
#define bstr_len(s) (*(s))
#define bstr_data(s) (s+1)
#define bstr_size(len) (len+1)
#define BSTR_MAX_LEN 254
#endif

View File

@ -31,13 +31,13 @@ uint8_t * bstr_create_from_cfgstr(const char * s)
if (s[0]!='.')
return bstr_create((uint8_t*)s,l+1);
return bstr_create((uint8_t*)s,l);
if (l<=2)
return bstr_create((uint8_t*)s,l+1);
return bstr_create((uint8_t*)s,l);
if (s[1]=='.')
return bstr_create((uint8_t*)s+1,l);
return bstr_create((uint8_t*)s+1,l-1);
if (s[1]=='x'){
uint8_t * ns=0;

View File

@ -27,9 +27,11 @@
#define CWVENDOR_CISCO_RAD_NAME 5
#define CWVENDOR_CISCO_MWAR 6
#define CWVENDOR_CISCO_AP_GROUP_NAME 124
#define CWVENDOR_CISCO_AP_GROUP_NAME 123
#define CWVENDOR_CISCO_AP_TIMESYNC 151
#define CWVENDOR_CISCO_PL207 207
extern void cwmsg_addelem_vendor_cisco_ap_timesync(struct cwmsg * cwmsg);
@ -38,6 +40,12 @@ extern void cwmsg_addelem_vendor_cisco_ap_timesync(struct cwmsg * cwmsg);
#define cwmsg_addelem_vendor_cisco_rad_name(cwmsg,str) \
cwmsg_addelem_vendor_specific_payload(cwmsg,CW_VENDOR_ID_CISCO, \
CWVENDOR_CISCO_RAD_NAME,str,strlen((char*)str))
/* group name payload */
#define cwmsg_addelem_vendor_cisco_group_name(cwmsg,str) \
cwmsg_addelem_vendor_secific_payload(cwmsg,CW_VENDOR_ID_CISCO, \
CWVENDOR_CISCO_GROUP_NAME,str,strlen((char*)str));
/* payload 207 */
#endif

View File

@ -0,0 +1,79 @@
/*
This file is part of libcapwap.
libcapwap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string.h>
#include "capwap.h"
#include "cwmsg.h"
#include "conn.h"
uint8_t * cw_addelem(uint8_t * buf,int type, uint8_t *elem, int len)
{
uint32_t val = type<<16|len;
*((uint32_t*)(buf))=htonl(val);
buf+=4;
memcpy(buf,elem,len);
return buf+len;
}
void cw_addelem_capwap_local_ip_addr(struct cwmsg *msg, int sock, int cw_mode)
{
struct sockaddr_storage a;
socklen_t alen = sizeof(struct sockaddr_storage);
getsockname (sock,(struct sockaddr *)&a,&alen);
int cw_mode = cwmsg->capwap_mode;
switch (((struct sockaddr*)&a)->sa_family){
case AF_INET:
{
struct sockaddr_in * sain = (struct sockaddr_in*)&a;
int id;
if (cw_mode == CWMODE_CISCO)
id = CWMSGELEM_WTP_IPV4_IP_ADDR;
else
id = CWMSGELEM_CAPWAP_LOCAL_IPV4_ADDRESS;
cwmsg_addelem(msg,id,(uint8_t*)&sain->sin_addr,4);
break;
}
case AF_INET6:
{
int id;
if (cw_mode == CWMODE_CISCO)
id = CWMSGELEM_WTP_IPV6_IP_ADDR;
else
id = CWMSGELEM_CAPWAP_LOCAL_IPV6_ADDRESS;
struct sockaddr_in6 * sain = (struct sockaddr_in6*)&a;
return cwmsg_addelem(msg,id,(uint8_t*)&sain->sin6_addr,16);
}
break;
}
}

View File

@ -0,0 +1,112 @@
/*
This file is part of libcapwap.
libcapwap is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
libcapwap is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Foobar. If not, see <http://www.gnu.org/licenses/>.
*/
#include "capwap.h"
#include "wtpinfo.h"
#include "cw_util.h"
#include "cw_log.h"
static int wtpinfo_readelem_wtp_descriptor_(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len, int cq)
{
if (type != CWMSGELEM_WTP_DESCRIPTOR)
return 0;
if (len<6)
return -1;
wtpinfo->max_radios=*msgelem;
wtpinfo->radios_in_use=*(msgelem+1);
int ncrypt = *(msgelem+2);
int i;
if (ncrypt == 0 ){
/* non-conform */
cw_dbg(DBG_CW_RFC,"Non-standard-conform WTP descriptor detected (See RFC 5415)");
if (!cq)
i=3;
else
i=4;
}
else{
i=ncrypt*3+3;
}
do {
if (i+8>len)
{
cw_dbg(DBG_CW_MSG_ERR,"WTP descriptor subelement to long, length=%d>%d",i+8,len);
return -1;
}
uint32_t vendor_id=ntohl(*((uint32_t*)(msgelem+i)));
uint32_t val = ntohl(*((uint32_t*)(msgelem+i+4)));
int subtype= (val>>16)&0xffff;
int sublen = val&0xffff;
i+=8;
if (sublen+i>len){
cw_dbg(DBG_CW_MSG_ERR,"WTP descriptor subelement too long, length = %d",sublen);
return -1;
}
cw_dbg(DBG_CW_MSG,"Reading WTP descriptor subelement, type=%d,len=%d",subtype,sublen);
switch(subtype){
case CWMSGSUBELEM_WTP_DESCRIPTOR_HARDWARE_VERSION:
wtpinfo->hardware_vendor_id=vendor_id;
cw_setstr(&wtpinfo->hardware_version,msgelem+i,sublen);
wtpinfo->hardware_version_len=sublen;
break;
case CWMSGSUBELEM_WTP_DESCRIPTOR_SOFTWARE_VERSION:
wtpinfo->software_vendor_id=vendor_id;
cw_setstr(&wtpinfo->software_version,msgelem+i,sublen);
wtpinfo->software_version_len=sublen;
break;
case CWMSGSUBELEM_WTP_DESCRIPTOR_BOOTLOADER_VERSION:
wtpinfo->bootloader_vendor_id=vendor_id;
cw_setstr(&wtpinfo->bootloader_version,msgelem+i,sublen);
wtpinfo->bootloader_version_len=sublen;
break;
default:
cw_dbg(DBG_CW_MSG_ERR,"Unknown WTP descriptor subelement, type = %d",subtype);
break;
}
i+=sublen;
}while(i<len);
return 1;
}
int wtpinfo_readelem_wtp_descriptor(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len)
{
int rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,0);
if (rc==-1){
cw_dbg(DBG_CW_RFC,"Bad wtp descriptor, trying cisco hack");
rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,1);
}
return rc;
}

View File

@ -6,32 +6,44 @@
#include "bstr.h"
static int add_board_data_subelem(uint8_t *msg,int type, bstr_t data)
{
if (!data)
return 0;
int l = bstr_len(data);
*((uint32_t *) (msg)) = htonl(type << 16 | l);
memcpy(msg + 4, bstr_data(data), l);
return l+4;
}
void cwmsg_addelem_wtp_board_data(struct cwmsg *cwmsg, struct wtpinfo *wtpinfo)
{
uint8_t msg[512];
uint8_t msg[1024];
/* vendor identifier */
*((uint32_t *) msg) = htonl(wtpinfo->vendor_id);
int l;
int len = 4;
/* mandatory sub-elements */
if (wtpinfo->model_no) {
l = bstr_len(wtpinfo->model_no);
*((uint32_t *) (msg + len)) = htonl(CWBOARDDATA_MODELNO << 16 | l);
memcpy(msg + len + 4, bstr_data(wtpinfo->model_no), l);
len += l + 4;
}
if (wtpinfo->serial_no) {
l = bstr_len( wtpinfo->serial_no);
*((uint32_t *) (msg + len)) = htonl(CWBOARDDATA_SERIALNO << 16 | l);
memcpy(msg + len + 4, bstr_data(wtpinfo->serial_no), l);
len += l + 4;
}
len += add_board_data_subelem(msg+len,CWBOARDDATA_MODELNO,wtpinfo->model_no);
len += add_board_data_subelem(msg+len,CWBOARDDATA_SERIALNO,wtpinfo->serial_no);
/* other sub-elements */
len += add_board_data_subelem(msg+len,CWBOARDDATA_BOARDID,wtpinfo->board_id);
len += add_board_data_subelem(msg+len,CWBOARDDATA_REVISION,wtpinfo->board_revision);
if (wtpinfo->macaddress) {
*((uint32_t *) (msg + len)) =
htonl(CWBOARDDATA_MACADDRESS << 16 | wtpinfo->macaddress_len);

View File

@ -27,7 +27,8 @@ void cwmsg_addelem_wtp_descriptor(struct cwmsg * cwmsg, struct wtpinfo * wtpinfo
switch (cwmsg->capwap_mode){
case CWMODE_CISCO:
*((uint16_t*)(d+len))=0;
/* encryption capabilities */
*((uint16_t*)(d+len))=htons(wtpinfo->encryption_cap);
len+=2;
break;
default:

View File

@ -33,15 +33,16 @@ void cwmsg_init(struct cwmsg * cwmsg, uint8_t *buffer, int type, int seqnum, str
cwmsg->flags=0;
if (radioinfo){
if (radioinfo->rmac[0]){
if (radioinfo->rmac){
/* we assume the radio mac is already aligned */
rmaclen=(*radioinfo->rmac);
memcpy(buffer+8,radioinfo->rmac,rmaclen/8+8);
rmaclen=bstr_len(radioinfo->rmac);
*(buffer+8)=rmaclen;
memcpy(buffer+9,bstr_data(radioinfo->rmac),rmaclen);
cwmsg->flags=CWTH_FLAGS_M;
}
}
hlen+=rmaclen;
hlen+=rmaclen+1;
if (hlen%4)
hlen = (hlen>>2)*4+4;

View File

@ -25,14 +25,21 @@
static int acinfo_readelem_join_resp(void * a,int type,uint8_t* msgelem,int len)
{
printf("Here we are reading\n");
cw_dbg_msgelem(CWMSG_JOIN_RESPONSE, type, msgelem, len);
struct ac_info * acinfo = (struct ac_info *)a;
// cw_log_debug1("Process join resp msgelem, type=%d, len=%d\n",type,len);
if (cw_readelem_result_code(&acinfo->result_code,type,msgelem,len))
goto foundX;
if (acinfo_readelem_ecn_support(acinfo,type,msgelem,len))
return 1;
goto foundX;
if (acinfo_readelem_ac_descriptor(acinfo,type,msgelem,len))
return 1;
goto foundX;
if (acinfo_readelem_ac_name(acinfo,type,msgelem,len))
return 1;
@ -43,7 +50,10 @@ static int acinfo_readelem_join_resp(void * a,int type,uint8_t* msgelem,int len)
/* if (acinfo_readelem_cw_local_ip_addr(acinfo,type,msgelem,len))
return 1;
*/
return 0;
foundX:
return 1;
}

View File

@ -19,6 +19,8 @@
#include <string.h>
#include "capwap.h"
#include "capwap_cisco.h"
#include "conn.h"
#include "cwmsg.h"
@ -61,6 +63,16 @@ int cwsend_join_request(struct conn *conn, struct radioinfo *radioinfo, struct w
switch (conn->capwap_mode) {
case CWMODE_CISCO:
cwmsg_addelem_vendor_cisco_mwar_addr(&cwmsg,conn);
uint8_t data207[4] = {1,1,0,1};
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,
CWVENDOR_CISCO_PL207,data207,4);
cwmsg_addelem_vendor_specific_payload(&cwmsg,CW_VENDOR_ID_CISCO,
CWVENDOR_CISCO_AP_GROUP_NAME,(uint8_t*)"Tobias",strlen("Tobias"));
break;
default:
/* ECN support */

View File

@ -70,7 +70,7 @@ static int process_elem(void *eparm,int type,uint8_t* msgelem,int len)
if (wtpinfo_readelem_ecn_support(wtpinfo,type,msgelem,len))
goto foundX;
if (cw_readelem_capwap_local_ip_addr(wtpinfo,type,msgelem,len)){
if (cw_readelem_capwap_local_ip_addr(&wtpinfo->local_ip,type,msgelem,len)){
cw_mand_elem_found(e->mand, XCWMSGELEM_CAPWAP_LOCAL_IP_ADDRESS);
return 1;
}

View File

@ -20,6 +20,9 @@
#ifndef __RADIOINFO_H
#define __RADIOINFO_H
#include "bstr.h"
struct radioinfo{
char set;
int rid;
@ -27,7 +30,7 @@ struct radioinfo{
int admin_state;
int state;
int cause;
uint8_t rmac[8];
bstr_t rmac;
};
#endif

View File

@ -50,8 +50,9 @@ struct wtpinfo{
uint32_t vendor_id;
uint8_t* model_no;
uint8_t* serial_no;
uint8_t* board_id;
uint8_t* board_revision;
bstr_t board_id;
bstr_t board_revision;
uint16_t statistics_timer;
@ -78,6 +79,9 @@ struct wtpinfo{
int bootloader_version_len;
uint32_t bootloader_vendor_id;
uint16_t encryption_cap;
uint8_t * macaddress;

View File

@ -168,14 +168,40 @@ int wtpinfo_print(char *str, struct wtpinfo * wtpinfo)
sock_addrtostr((struct sockaddr*)&wtpinfo->local_ip,hstr,64);
s+=sprintf (s,"\tLocal IP: %s\n",hstr);
// sock_addrtostr((struct sockaddr*)&wtpinfo->local_ip,hstr,64);
int i0;
for (i0=0; i0<10; i0++){
printf("%d\n", ((char*)(&wtpinfo->local_ip))[i0] );
}
s+=sprintf (s,"\tLocal IP: %s\n",sock_addr2str(&(wtpinfo->local_ip)));
s+=sprintf (s,"\tVendor ID: %d, %s\n", wtpinfo->vendor_id,cw_ianavendoridtostr(wtpinfo->vendor_id) );
s+=sprintf (s,"\tModel No.: %s\n", (!wtpinfo->model_no ? (uint8_t*)"Not set" : wtpinfo->model_no) );
s+=sprintf (s,"\tSerial No.: %s\n", (!wtpinfo->serial_no ? (uint8_t*)"Not set" : wtpinfo->serial_no) );
s+=sprintf (s,"\tModel No.: "); //, (!wtpinfo->model_no ? (uint8_t*)"Not set" : wtpinfo->model_no) );
s+=bstr_to_str(s,wtpinfo->model_no,0);
s+=sprintf(s,"\n");
// s+=sprintf (s,"\tSerial No.: %s\n", (!wtpinfo->serial_no ? (uint8_t*)"Not set" : wtpinfo->serial_no) );
s+=sprintf (s,"\tSerial No.: ");
s+=bstr_to_str(s,wtpinfo->serial_no,0);
s+=sprintf(s,"\n");
s+=sprintf (s,"\tBoard ID: ");
s+=bstr_to_str(s,wtpinfo->board_id,0);
s+=sprintf(s,"\n");
s+=sprintf (s,"\tBoard Revision: ");
s+=bstr_to_str(s,wtpinfo->board_revision,0);
s+=sprintf(s,"\n");
// s+=sprintf (s,"\tBoard Id: %s\n", (!wtpinfo->board_id ? (uint8_t*)"Not set" : wtpinfo->board_id) );
@ -257,6 +283,9 @@ int wtpinfo_print(char *str, struct wtpinfo * wtpinfo)
s+=sprintf(s,"%s",ristr);
s+=sprintf(s,"Encryption: %08x\n",wtpinfo->encryption_cap);
s+=wtp_reboot_statistics_print(s,&wtpinfo->reboot_statistics);
return s-str;

View File

@ -30,10 +30,10 @@ static void wtpinfo_readsubelems_wtp_board_data(struct wtpinfo * wtpinfo,uint8_t
switch(subtype){
case CWBOARDDATA_MODELNO:
cw_setstr(&wtpinfo->model_no,msgelem+i,sublen);
bstr_replace(&wtpinfo->model_no,bstr_create(msgelem+i,sublen));
break;
case CWBOARDDATA_SERIALNO:
cw_setstr(&wtpinfo->serial_no,msgelem+i,sublen);
bstr_replace(&wtpinfo->serial_no,bstr_create(msgelem+i,sublen));
break;
case CWBOARDDATA_MACADDRESS:
wtpinfo->macaddress=realloc(wtpinfo->macaddress,sublen);
@ -41,10 +41,10 @@ static void wtpinfo_readsubelems_wtp_board_data(struct wtpinfo * wtpinfo,uint8_t
wtpinfo->macaddress_len=sublen;
break;
case CWBOARDDATA_BOARDID:
cw_setstr(&wtpinfo->board_id,msgelem+i,sublen);
bstr_replace(&wtpinfo->board_id,bstr_create(msgelem+i,sublen));
break;
case CWBOARDDATA_REVISION:
cw_setstr(&wtpinfo->board_revision,msgelem+i,sublen);
bstr_replace(&wtpinfo->board_revision,bstr_create(msgelem+i,sublen));
default:
break;
}

View File

@ -26,7 +26,7 @@
static int wtpinfo_readelem_wtp_descriptor_(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len, int cq)
static int wtpinfo_readelem_wtp_descriptor_(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len, int capwap_mode)
{
if (type != CWMSGELEM_WTP_DESCRIPTOR)
return 0;
@ -37,19 +37,31 @@ static int wtpinfo_readelem_wtp_descriptor_(struct wtpinfo * wtpinfo, int type,
wtpinfo->max_radios=*msgelem;
wtpinfo->radios_in_use=*(msgelem+1);
int ncrypt = *(msgelem+2);
int i;
if (ncrypt == 0 ){
/* non-conform */
cw_dbg(DBG_CW_RFC,"Non-standard-conform WTP descriptor detected (See RFC 5415)");
if (!cq)
i=3;
else
int ncrypt;
int i=2;
switch (capwap_mode){
case CWMODE_CISCO:
wtpinfo->encryption_cap = ntohs( *((uint16_t*)(msgelem+2)) );
i=4;
break;
default:
{
ncrypt= *(msgelem+2);
if (ncrypt == 0 ){
/* non-conform */
cw_dbg(DBG_CW_RFC,"Non-standard-conform WTP descriptor detected (See RFC 5415)");
i=3;
}
else
i=ncrypt*3+3;
}
}
else{
i=ncrypt*3+3;
}
do {
if (i+8>len)
@ -101,10 +113,11 @@ static int wtpinfo_readelem_wtp_descriptor_(struct wtpinfo * wtpinfo, int type,
int wtpinfo_readelem_wtp_descriptor(struct wtpinfo * wtpinfo, int type, uint8_t *msgelem, int len)
{
int rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,0);
int rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,CWMODE_STD);
if (rc==-1){
cw_dbg(DBG_CW_RFC,"Bad wtp descriptor, trying cisco hack");
rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,1);
cw_dbg(DBG_CW_RFC,"Bad wtp descriptor, trying cisco");
rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,CWMODE_CISCO);
}
return rc;

View File

@ -182,6 +182,18 @@ int read_config(const char * filename){
}
str = uci_lookup_option_string(ctx,section,"board_id");
if (str){
uint8_t * s = bstr_create_from_cfgstr(str);
bstr_replace(&conf_board_id,s);
}
str = uci_lookup_option_string(ctx,section,"board_revision");
if (str){
uint8_t * s = bstr_create_from_cfgstr(str);
bstr_replace(&conf_board_revision,s);
}
str = uci_lookup_option_string(ctx,section,"serial_no");
if (str){

View File

@ -134,6 +134,9 @@ static int do_discover_conn(struct conn * conn,struct discovery_info * di)
struct radioinfo ri;
memset(&ri,0,sizeof(ri));
struct radioinfo * rip = &wtpinfo->radioinfo[0];
/*
ri.rmac[0]=6;
ri.rmac[2]=14;
ri.rmac[3]=14;
@ -141,7 +144,7 @@ static int do_discover_conn(struct conn * conn,struct discovery_info * di)
ri.rmac[5]=14;
ri.rmac[6]=14;
ri.rmac[7]=14;
*/
#ifdef WITH_CW_LOG_DEBUG
char str[100];
@ -153,7 +156,7 @@ static int do_discover_conn(struct conn * conn,struct discovery_info * di)
do {
conn->capwap_mode=CWMODE_CISCO;
rc = cwsend_discovery_request(conn,&ri,wtpinfo);
rc = cwsend_discovery_request(conn,rip,wtpinfo);
if (rc<0){
if (errno == EINTR)
continue;

View File

@ -20,6 +20,7 @@ void acinfo_log_(int level,const struct ac_info *acinfo,const char * xstr)
{
char str[8192];
acinfo_print(str,acinfo);
cw_dbg(DBG_CW_INFO,"%s",str);
// cw_log_debug(level,"%s\n%s",xstr,str);
return;
}
@ -35,37 +36,54 @@ int join_state(struct conn * conn)
memset(&ri,0,sizeof(ri));
int rc;
struct radioinfo *rip = &(wtpinfo->radioinfo[0]);
#ifdef WITH_CW_LOG_DEBUG
char str[64];
sock_addrtostr(&conn->addr,str,64);
// cw_log_debug0("Sending join request to %s",str);
#endif
printf("Seqnum before = %i\n",conn->seqnum);
rc = cwsend_join_request(conn,&ri,wtpinfo);
rc = cwsend_join_request(conn,rip,wtpinfo);
printf("Seqnum after = %i\n",conn->seqnum);
struct cwrmsg * cwrmsg;
// do {
int i;
for(int i=0; i<10; i++){
cwrmsg = conn_get_message(conn);
if ( cwrmsg)
break;
}
printf("Received %08p\n",cwrmsg);
// }while(cwrmsg==0);
exit(0);
printf("SEQQQQS %d %d\n",cwrmsg->seqnum,conn->seqnum);
// cw_log_debug0("Received message %i",cwrmsg->seqnum);
if (cwrmsg->type != CWMSG_JOIN_RESPONSE || cwrmsg->seqnum != conn->seqnum){
printf("Wrong message\n");
printf("Wrong messagei %d %d\n",cwrmsg->seqnum,conn->seqnum);
}
struct ac_info acinfo;
memset(&acinfo,0,sizeof(acinfo));
printf("cwrad\n");
cwread_join_response(&acinfo,cwrmsg->msgelems,cwrmsg->msgelems_len);
printf("Done reading\n");
acinfo_log(0,&acinfo,"Connectet to the following AC");
printf("Result_code: %d\n",acinfo.result_code);
}

View File

@ -74,6 +74,13 @@ uint8_t * conf_model_no;
uint8_t * conf_serial_no;
bstr_t conf_board_id;
bstr_t conf_board_revision;
LONGSTRS conf_timer_cfgstrs[] = {
"max_discovery_interval",&conf_max_discovery_interval,
"discovery_interval",&conf_discovery_interval,
@ -204,7 +211,8 @@ int wtpconf_preinit()
conf_software_version = bstr_create_from_cfgstr(CONF_DEFAULT_SOFTWARE_VERSION);
conf_serial_no = bstr_create_from_cfgstr(CONF_DEFAULT_SERIAL_NO);
conf_board_id = bstr_create_from_cfgstr(CONF_DEFAULT_BOARD_ID);
conf_board_revision = bstr_create_from_cfgstr(CONF_DEFAULT_BOARD_REVISION);
}
int wtpconf_init()

View File

@ -4,6 +4,10 @@
#include <sys/socket.h>
#include "capwap/capwap.h"
#include "capwap/bstr.h"
extern int read_config(const char * filename);
extern char * conf_wtpname;
@ -25,6 +29,9 @@ extern uint8_t * conf_model_no;
extern uint8_t * conf_serial_no;
extern bstr_t conf_board_id;
extern bstr_t conf_board_revision;
extern struct sockaddr_storage * conf_preffered_ac_sa;
extern char * conf_primary_if;
@ -71,8 +78,13 @@ extern uint8_t conf_macaddress_len;
#endif
#ifndef CONF_DEFAULT_BOARD_ID
#define CONF_DEFAULT_BOARD_ID "00"
#endif
#ifndef CONF_DEFAULT_BOARD_REVISION
#define CONF_DEFAULT_BOARD_REVISION "00"
#endif
#ifndef CONF_DEFAULT_MAX_DISCOVERY_INTERVAL

View File

@ -19,7 +19,8 @@ struct wtpinfo * get_wtpinfo()
wtpinfo=malloc(sizeof(struct wtpinfo));
memset(wtpinfo,0,sizeof(struct wtpinfo));
wtpinfo->name = (uint8_t*)"wtpXY";
wtpinfo->name = conf_wtpname;
wtpinfo->location = (uint8_t*)"default location";
wtpinfo->max_radios=wtpdrv_get_num_radios();
@ -29,6 +30,8 @@ struct wtpinfo * get_wtpinfo()
}
wtpinfo->encryption_cap=1;
wtpinfo->serial_no=conf_serial_no;
wtpinfo->vendor_id=conf_vendor_id;
@ -45,6 +48,8 @@ struct wtpinfo * get_wtpinfo()
wtpinfo->bootloader_version=conf_bootloader_version;
wtpinfo->board_id = conf_board_id;
wtpinfo->board_revision = conf_board_revision;
wtpinfo->software_vendor_id=CW_VENDOR_ID_CISCO;

View File

@ -1217,6 +1217,11 @@ int wtpdrv_get_radioinfo(int rid,struct radioinfo * radioinfo)
{
radioinfo->rid=rid;
//uint8_t rm[8]="12345600";
uint8_t rm[8]={0x00,0x19,0xdb,0xe0,0x93,0x27};
radioinfo->rmac = bstr_create(rm,6);
radioinfo->type|=CW_IEEE80211_RADIO_TYPE_B; //CWRADIO_TYPE_N;
/*