More cisco-compatibility.
FossilOrigin-Name: 04ec8be34c8f04e70ce803fb8f47f72f426bdc7cf85edced8f09d3a9f1f0c50d
This commit is contained in:
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
79
src/capwap/cw_addelem_capwap_local_ip_addr.c
Normal file
79
src/capwap/cw_addelem_capwap_local_ip_addr.c
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
112
src/capwap/cw_readelem_wtp_descriptor.c
Normal file
112
src/capwap/cw_readelem_wtp_descriptor.c
Normal 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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user