2014-07-11 22:12:11 +02:00
|
|
|
/*
|
|
|
|
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/>.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2015-03-15 16:02:48 +01:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* @brief Implementation of cwmsg_addelem_ac_descriptor.
|
|
|
|
*/
|
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
#include <string.h>
|
|
|
|
#include "capwap.h"
|
|
|
|
|
2015-03-15 16:02:48 +01:00
|
|
|
|
|
|
|
static int add_subelem(uint8_t * buffer,int type, uint32_t vendor,bstr_t version)
|
|
|
|
{
|
|
|
|
|
|
|
|
*((uint32_t*)buffer) = htonl(vendor);
|
|
|
|
*((uint32_t*)(buffer+4)) = htonl( (type<<16) | bstr_len(version));
|
|
|
|
|
|
|
|
memcpy(buffer+8,bstr_data(version),bstr_len(version));
|
|
|
|
|
|
|
|
return 8+bstr_len(version);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Add an ac descriptor message element.
|
|
|
|
* @param msg pointer to the message
|
|
|
|
* @param acinfo acinfo structure where data is taken from
|
|
|
|
*/
|
2014-07-11 22:12:11 +02:00
|
|
|
void cwmsg_addelem_ac_descriptor(struct cwmsg *msg,struct ac_info * acinfo)
|
|
|
|
{
|
2015-03-15 16:02:48 +01:00
|
|
|
uint8_t buffer[600];
|
2014-07-11 22:12:11 +02:00
|
|
|
uint8_t * acd = buffer;
|
|
|
|
|
|
|
|
*((uint32_t*)(acd))=htonl((acinfo->stations<<16) | (acinfo->limit));
|
|
|
|
*((uint32_t*)(acd+4))=htonl((acinfo->active_wtps<<16) | acinfo->max_wtps);
|
|
|
|
*((uint32_t*)(acd+8))=htonl((acinfo->security<<24) | (acinfo->rmac<<16) | acinfo->dtls_policy );
|
|
|
|
|
2014-08-25 07:56:14 +02:00
|
|
|
|
2014-07-11 22:12:11 +02:00
|
|
|
int len = 12;
|
|
|
|
|
2015-03-15 16:02:48 +01:00
|
|
|
switch (msg->capwap_mode){
|
|
|
|
case CWMODE_CISCO:
|
|
|
|
len+=add_subelem(buffer+len,0,CW_VENDOR_ID_CISCO,acinfo->cisco_hardware_version);
|
|
|
|
len+=add_subelem(buffer+len,1,CW_VENDOR_ID_CISCO,acinfo->cisco_software_version);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
len+=add_subelem(buffer+len,0,0,acinfo->hardware_version);
|
|
|
|
len+=add_subelem(buffer+len,1,0,acinfo->software_version);
|
2014-07-11 22:12:11 +02:00
|
|
|
|
2015-03-15 16:02:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cwmsg_addelem(msg,CWMSGELEM_AC_DESCRIPTOR,acd,len);
|
|
|
|
}
|
2014-07-11 22:12:11 +02:00
|
|
|
|