als cisco join functions implemented
FossilOrigin-Name: b63ca45f023666ba12e838e0c313536bf2a41dd6170191e150723b4dfbad4ba7
This commit is contained in:
@ -1,73 +1,86 @@
|
||||
/*
|
||||
This file is part of actube.
|
||||
|
||||
actube 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.
|
||||
|
||||
actube 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 "cw/log.h"
|
||||
#include "cw/dbg.h"
|
||||
#include "cw/conn.h"
|
||||
|
||||
|
||||
|
||||
#include "cw/capwap.h"
|
||||
#include "cw/cw.h"
|
||||
#include "cw/ktv.h"
|
||||
#include "cw/keys.h"
|
||||
|
||||
extern mbag_t cisco_config;
|
||||
|
||||
int cisco_out_ac_descriptor(struct conn *conn,struct cw_action_out * a,uint8_t *dst)
|
||||
{
|
||||
|
||||
uint8_t *d = dst+4;
|
||||
struct mbag_item * i;
|
||||
i = mbag_get(conn->local,CW_ITEM_AC_STATUS);
|
||||
static int put_ac_status(mavl_t global, mavl_t local, uint8_t *dst, const char * parent_key){
|
||||
|
||||
uint8_t *d = dst;
|
||||
uint8_t security;
|
||||
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
if (!i) {
|
||||
cw_log(LOG_ERR,"Can't send AC Descriptor, no AC Status Item found");
|
||||
return 0;
|
||||
}
|
||||
|
||||
d+=cw_put_ac_status(d ,(struct cw_ac_status*)(i->u2.data),conn);
|
||||
|
||||
|
||||
i = mbag_get(cisco_config,CW_ITEM_AC_SOFTWARE_VERSION);
|
||||
|
||||
if (!i){
|
||||
/* Send back the same software version as the WTP has,
|
||||
otherwise the AP wants us to send an image */
|
||||
i = mbag_get(conn->incomming,CW_ITEM_WTP_SOFTWARE_VERSION);
|
||||
}
|
||||
d += cw_put_word(d,cw_ktv_get_word(global,"ac-descriptor/stations",0));
|
||||
d += cw_put_word(d,cw_ktv_get_word(global,"ac-descriptor/station-limit",0));
|
||||
d += cw_put_word(d,cw_ktv_get_word(global,"ac-descriptor/active-wtps",0));
|
||||
d += cw_put_word(d,cw_ktv_get_word(global,"ac-descriptor/max-wtps",0));
|
||||
|
||||
d += cw_put_byte(d,cw_ktv_get_byte(global,"ac-descriptor/security",0));
|
||||
/*
|
||||
if ( i ) {
|
||||
d += cw_put_version(d,1,i->u2.data);
|
||||
}
|
||||
else {
|
||||
cw_log(LOG_ERR, "Can't set Cisco Software Version in AC descriptor, No value defined.");
|
||||
}
|
||||
security = 0;
|
||||
if (cw_ktv_get(local,"dtls-cert-file",CW_TYPE_BSTR16))
|
||||
security |= CAPWAP_FLAG_AC_SECURITY_X;
|
||||
|
||||
if (cw_ktv_get(local,"dtls-psk",CW_TYPE_BSTR16))
|
||||
security |= CAPWAP_FLAG_AC_SECURITY_S;
|
||||
|
||||
i = mbag_get(cisco_config, CW_ITEM_AC_HARDWARE_VERSION);
|
||||
if ( i ) {
|
||||
d += cw_put_version(d,0,i->u2.data);
|
||||
if (security == 0){
|
||||
cw_log(LOG_WARNING,"No AC security selected");
|
||||
}
|
||||
else {
|
||||
cw_log(LOG_ERR, "Can't set Cisco Hardware Version in AC descriptor, No value defined.");
|
||||
}
|
||||
*/
|
||||
|
||||
int len = d-dst-4;
|
||||
d += cw_put_byte(dst,security);
|
||||
*/
|
||||
sprintf(key,"%s/%s",parent_key,"ac-descriptor/r-mac-field");
|
||||
d += cw_put_byte(d,cw_ktv_get_byte(global,"ac-descriptor/r-mac-field",0));
|
||||
/*d += cw_put_byte(d,3);*/
|
||||
|
||||
return len + cw_put_elem_hdr(dst,a->elem_id,len);
|
||||
d += cw_put_byte(d,0);
|
||||
|
||||
|
||||
sprintf(key,"%s/%s",parent_key,CW_SKEY_DTLS_POLICY);
|
||||
d += cw_put_byte(d,cw_ktv_get_byte(local,key,0));
|
||||
|
||||
return d - dst;
|
||||
}
|
||||
|
||||
|
||||
int cisco_out_ac_descriptor(struct cw_ElemHandler * eh,
|
||||
struct cw_ElemHandlerParams * params, uint8_t * dst)
|
||||
{
|
||||
int len,l;
|
||||
uint8_t *d = dst+4;
|
||||
char key[CW_KTV_MAX_KEY_LEN];
|
||||
|
||||
d+=put_ac_status(params->conn->local_cfg,
|
||||
params->conn->global_cfg,
|
||||
d, eh->key);
|
||||
|
||||
/* it is important to send software version first,
|
||||
* because APs don't check the type */
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg,
|
||||
1, key);
|
||||
|
||||
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
|
||||
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg,
|
||||
0, key);
|
||||
|
||||
|
||||
|
||||
len = d-dst-4;
|
||||
|
||||
l = len + cw_put_elem_hdr(dst,eh->id,len);
|
||||
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,eh,dst,l);
|
||||
|
||||
return l;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user