Not needed anymore.
FossilOrigin-Name: 91d7440258eb83e19f8ad57a6102ce7c61da2026efa03893c2e419834a888711
This commit is contained in:
parent
6d707d1725
commit
e4753145f6
@ -1,186 +0,0 @@
|
||||
/*
|
||||
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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
#include "capwap.h"
|
||||
#include "log.h"
|
||||
#include "cw_util.h"
|
||||
|
||||
#include "acinfo.h"
|
||||
|
||||
#include "sock.h"
|
||||
|
||||
|
||||
/*
|
||||
int acinfo_readelem_ac_name(struct ac_info * acinfo,int type, uint8_t *msgelem, int len)
|
||||
{
|
||||
if (type != CWMSGELEM_AC_NAME)
|
||||
return 0;
|
||||
cw_setstr(&acinfo->ac_name,msgelem,len);
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
int acinfo_readelem_ac_descriptor(struct ac_info * acinfo,int type, uint8_t *msgelem, int len)
|
||||
{
|
||||
if (type != CW_ELEM_AC_DESCRIPTOR)
|
||||
return 0;
|
||||
|
||||
if (len<12)
|
||||
return -1;
|
||||
|
||||
uint32_t val;
|
||||
|
||||
/* read stations and limit */
|
||||
val = ntohl(*((uint32_t*)msgelem));
|
||||
acinfo->stations = val>>16;
|
||||
acinfo->limit = val&0xffff;
|
||||
|
||||
|
||||
/* read active wtps and max wtps */
|
||||
val = ntohl(*((uint32_t*)(msgelem+4)));
|
||||
acinfo->active_wtps = val>>16;
|
||||
acinfo->max_wtps = val&0xffff;
|
||||
|
||||
/* read active wtps and max wtps */
|
||||
val = ntohl(*((uint32_t*)(msgelem+8)));
|
||||
acinfo->security = val >>24;
|
||||
acinfo->rmac= (val >> 16)&0xff;
|
||||
acinfo->dtls_policy=val&0xf;
|
||||
|
||||
int sub=12;
|
||||
int sublen;
|
||||
|
||||
|
||||
printf("Now trying sublens\n");
|
||||
|
||||
while (sub<len){
|
||||
if (len-sub<8)
|
||||
return -1;
|
||||
|
||||
uint32_t vendor = ntohl(*((uint32_t*)(msgelem+sub)));
|
||||
val = ntohl(*((uint32_t*)(msgelem+sub+4)));
|
||||
sublen = val&0xffff;
|
||||
sub+=8;
|
||||
|
||||
printf("sublen = %d\n",sublen);
|
||||
|
||||
if (vendor != 0){
|
||||
// sub+=sublen;
|
||||
// continue;
|
||||
}
|
||||
int subtype = val>>16;
|
||||
printf("sublen type = %d\n",subtype);
|
||||
|
||||
if (sub+sublen>len)
|
||||
return -1;
|
||||
|
||||
|
||||
switch (subtype){
|
||||
case 4:
|
||||
cw_setstr(&acinfo->hardware_version,msgelem+sub,sublen);
|
||||
break;
|
||||
case 5:
|
||||
cw_setstr(&acinfo->software_version,msgelem+sub,sublen);
|
||||
break;
|
||||
}
|
||||
sub+=sublen;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int acinfo_readelem_ctrl_ip_addr(struct ac_info * acinfo, int type, uint8_t*msgelem,int len)
|
||||
{
|
||||
|
||||
/*
|
||||
switch (type){
|
||||
case CW_ELEM_CONTROL_IPV4_ADDRESS:
|
||||
{
|
||||
if (len!=6)
|
||||
return -1;
|
||||
|
||||
if (!acinfo->aciplist)
|
||||
return 1;
|
||||
|
||||
|
||||
ACIP * acip = malloc(sizeof(ACIP));
|
||||
if (!acip) {
|
||||
cw_log(LOG_ERR,"Can't allocate memory for acv4ip: %s",strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct sockaddr_in addr;
|
||||
memcpy(&addr.sin_addr,msgelem,4);
|
||||
addr.sin_family=AF_INET;
|
||||
memcpy(&acip->ip,&addr,sizeof(addr));
|
||||
|
||||
acip->wtp_count = ntohs( * ((uint16_t*)(msgelem+4)));
|
||||
aciplist_add(acinfo->aciplist,acip);
|
||||
|
||||
// printf ("Read AC IP Elem %s\n",sock_addr2str(&acip->ip));
|
||||
// printf ("WTP COUNT HERE %d\n",acip->wtp_count);
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
case CW_ELEM_CONTROL_IPV6_ADDRESS:
|
||||
{
|
||||
if (len!=18)
|
||||
return -1;
|
||||
|
||||
if (!acinfo->aciplist)
|
||||
return 1;
|
||||
|
||||
|
||||
ACIP * acip = malloc(sizeof(ACIP));
|
||||
if (!acip) {
|
||||
cw_log(LOG_ERR,"Can't allocate memory for acv4ip: %s",strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct sockaddr_in6 addr;
|
||||
memcpy(&addr.sin6_addr,msgelem,16);
|
||||
addr.sin6_family=AF_INET6;
|
||||
memcpy(&acip->ip,&addr,sizeof(addr));
|
||||
acip->wtp_count = ntohs( * ((uint16_t*)(msgelem+16)));
|
||||
|
||||
aciplist_add(acinfo->aciplist,acip);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,126 +0,0 @@
|
||||
/*
|
||||
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 capwap_mode)
|
||||
{
|
||||
if (type != CW_ELEM_WTP_DESCRIPTOR)
|
||||
return 0;
|
||||
|
||||
if (len<6)
|
||||
return -1;
|
||||
|
||||
wtpinfo->max_radios=*msgelem;
|
||||
wtpinfo->radios_in_use=*(msgelem+1);
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
if (i+8>len)
|
||||
{
|
||||
cw_dbg(DBG_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_MSG_ERR,"WTP descriptor subelement too long, length = %d",sublen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
cw_dbg(DBG_MSG,"Reading WTP descriptor subelement, type=%d,len=%d",subtype,sublen);
|
||||
|
||||
switch(subtype){
|
||||
case CW_SUBELEM_WTP_HARDWARE_VERSION:
|
||||
wtpinfo->hardware_vendor_id=vendor_id;
|
||||
cw_setstr(&wtpinfo->hardware_version,msgelem+i,sublen);
|
||||
wtpinfo->hardware_version_len=sublen;
|
||||
break;
|
||||
case CW_SUBELEM_WTP_SOFTWARE_VERSION:
|
||||
wtpinfo->software_vendor_id=vendor_id;
|
||||
|
||||
bstr_replace(&wtpinfo->software_version,bstr_create(msgelem+i,sublen));
|
||||
wtpinfo->software_version_len=sublen;
|
||||
break;
|
||||
case CW_SUBELEM_WTP_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_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,CWMODE_STD);
|
||||
|
||||
if (rc==-1){
|
||||
cw_dbg(DBG_CW_RFC,"Bad wtp descriptor, trying cisco");
|
||||
rc =wtpinfo_readelem_wtp_descriptor_(wtpinfo, type, msgelem, len,CWMODE_CISCO);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user