actube/src/mod/cisco/cisco_out_ac_descriptor.c

89 lines
2.2 KiB
C
Raw Normal View History

#include "cw/log.h"
#include "cw/dbg.h"
#include "cw/conn.h"
#include "cw/capwap.h"
#include "cw/cw.h"
2022-07-31 17:15:32 +02:00
#include "cw/val.h"
#include "cw/keys.h"
2022-08-11 00:21:01 +02:00
#include "cw/cfg.h"
2022-08-11 00:21:01 +02:00
static int put_ac_status(cw_Cfg_t * cfg, cw_Cfg_t * default_cfg, uint8_t *dst, const char * parent_key){
uint8_t *d = dst;
uint8_t security;
2022-08-11 00:21:01 +02:00
char key[CW_CFG_MAX_KEY_LEN];
2022-08-11 00:21:01 +02:00
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/stations","0"));
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/station-limit","0"));
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/active-wtps","0"));
d += cw_put_word(d,cw_cfg_get_word(cfg,"ac-descriptor/max-wtps","0"));
2022-08-11 00:21:01 +02:00
d += cw_put_byte(d,cw_cfg_get_byte(cfg,"ac-descriptor/security",0));
/*
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;
if (security == 0){
cw_log(LOG_WARNING,"No AC security selected");
}
d += cw_put_byte(dst,security);
*/
sprintf(key,"%s/%s",parent_key,"ac-descriptor/r-mac-field");
2022-08-11 00:21:01 +02:00
d += cw_put_byte(d,cw_cfg_get_byte(cfg,"ac-descriptor/r-mac-field",0));
/*d += cw_put_byte(d,3);*/
d += cw_put_byte(d,0);
sprintf(key,"%s/%s",parent_key,CW_SKEY_DTLS_POLICY);
2022-08-11 00:21:01 +02:00
d += cw_put_byte(d,cw_cfg_get_byte(cfg,"ac-descriptor/dtls-policy",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;
2022-08-11 00:21:01 +02:00
char key[CW_CFG_MAX_KEY_LEN];
cw_dbg(DBG_X,"Putting AC TATUS WIITH KEY: %s",eh->key);
2022-08-11 00:21:01 +02:00
d+=put_ac_status(params->cfg,
params->default_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->local_cfg,
1, key);
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->local_cfg,
0, key);
len = d-dst-4;
l = len + cw_put_elem_hdr(dst,eh->id,len);
cw_dbg_elem(DBG_ELEM_OUT,NULL,params->msgdata->type,eh,dst,l);
return l;
}