WTP can join and send cfg request

This commit is contained in:
2022-08-17 18:41:17 +02:00
parent 9307b05b46
commit c2cb96e5dc
43 changed files with 429 additions and 718 deletions

View File

@ -338,7 +338,7 @@ static struct cw_ElemHandler handlers[] = {
CW_TYPE_STRUCT, /* type */
"wtp-reboot-statistics", /* Key */
cw_in_generic, /* handler */
cw_out_generic_struct, /* put */
cw_out_generic, /* put */
NULL,
NULL,
wtp_reboot_statistics

View File

@ -37,7 +37,7 @@ int capwap_in_vendor_specific_payload(struct cw_ElemHandler *handler,
// cw_dbg_elem(DBG_ELEM_IN,params->conn,0,vhandler, data+6,len-6);
//vhandler->get(vhandler, params, data+6, len-6);
*/
cw_process_element(params,0,vendor_id,elem_id,data+6,len-6);
cw_decode_element(params,0,vendor_id,elem_id,data+6,len-6);
return 1;

View File

@ -26,8 +26,6 @@
int capwap_in_wtp_descriptor(struct cw_ElemHandler *eh, struct cw_ElemHandlerParams *params, uint8_t * data,
int len)
{
stop();
int rc;
/*rc =cw_read_wtp_descriptor(params->remote_cfg, params->conn, eh, data, len, NULL);*/
rc =cw_read_wtp_descriptor(params->cfg, NULL, eh, data, len, NULL);

View File

@ -11,7 +11,7 @@ int capwap_out_capwap_local_ip_address(struct cw_ElemHandler * eh,
memset(&ip,0,sizeof(cw_Val_t));
ip.type=CW_TYPE_IPADDRESS;
ipstr = cw_cfg_get(params->cfg,eh->key,NULL);
ipstr = cw_cfg_get_l(params->cfg_list,eh->key,NULL);
if (ipstr==NULL){
return 0;
}

View File

@ -45,7 +45,8 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
val = cw_cfg_get_byte_l(params->cfg_list,key, 0);
d+=cw_put_byte(d,val); /*radios in use*/
cw_dbg("WTP-DESCRIPTOR: radios in use: %d",val);
d+=cw_put_byte(d,val); /*radios in use*/
/* d+=cw_put_encryption_capabilities_7(d,1); */
/* d+=cw_put_encryption_subelems(d,params->conn->capwap_mode);*/
@ -56,17 +57,17 @@ int capwap_out_wtp_descriptor(struct cw_ElemHandler * eh,
/* hardware version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_HARDWARE_VERSION, key);
/* software version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
d+=cw_write_descriptor_subelem (d, params->cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_SOFTWARE_VERSION, key);
/* bootloader version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER);
d+=cw_write_descriptor_subelem (d, params->cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_BOOTLOADER_VERSION, key);
len = d-dst-4;

View File

@ -110,8 +110,8 @@ static cw_ValStruct_t cisco_ap_led_state_config73[] = {
};
static cw_ValEnum_t cisco_ap_telnet_ssh_enum[] ={
{0, "telnet", CW_TYPE_BOOL, cw_in_generic, NULL },
{1, "ssh", CW_TYPE_BOOL, cw_in_generic, NULL },
{0, "telnet", CW_TYPE_BOOL, cw_in_generic, cw_out_generic },
{1, "ssh", CW_TYPE_BOOL, cw_in_generic, cw_out_generic },
{0,0,0,0}
};
@ -119,8 +119,7 @@ static cw_ValIndexed_t cisco_ap_telnet_ssh = {
1,cisco_ap_telnet_ssh_enum
};
static cw_ValStruct_t cisco_multi_domain_cabability[]={
{CW_TYPE_BYTE, "radio-id", 1, -1},
static cw_ValStruct_t cisco_multi_domain_capability[]={
{CW_TYPE_BYTE, "reserved", 1, -1},
{CW_TYPE_WORD, "first-channel", 2, -1},
{CW_TYPE_WORD, "number-of-channels", 2, -1},
@ -192,7 +191,6 @@ static cw_ValStruct_t cisco_ap_regulatory_domain5[]={
static cw_ValStruct_t cisco_mac_operation70[]={
{CW_TYPE_BYTE,"radio-id",1,-1},
{CW_TYPE_BYTE,"reserved",1,-1},
{CW_TYPE_WORD,"rts-threshold",2,-1},
{CW_TYPE_BYTE,"short-retry",1,-1},
@ -254,24 +252,23 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
char testkey[CW_CFG_MAX_KEY_LEN];
int idx;
void * type;
cw_Val_t * result, search;
cw_Val_t * result;
int len,start;
uint8_t * ob;
stop();
idx = 0;
ob = dst;
stop();
type = NULL;
result = cw_ktv_get(params->cfg,"ac-descriptor/software/version",CW_TYPE_BSTR16);
result = cw_cfg_get_val_l(params->cfg_list,"wtp-descriptor/software/version",CW_TYPE_BSTR16);
if (result!=NULL){
if(result->type->len(result)==4){
uint32_t rv;
rv = cw_get_dword(result->type->data(result));
cw_dbg(DBG_X,"Version is %08X",rv);
if (rv >= 0x07056600){
type = cisco_ap_regulatory_domain5;
}
@ -281,32 +278,33 @@ int cisco_out_ap_regulatory_domain(struct cw_ElemHandler * eh,
}
}
else {
stop();
}
cw_val_destroy(result);
do {
sprintf(key,"%s.%d",eh->key,idx);
search.key=key;
result = mavl_get_first(params->cfg,&search);
if (result==NULL)
if (!cw_cfg_base_exists_l(params->cfg_list,key))
break;
if (strncmp(result->key,key,strlen(key))!=0)
break;
if(type == NULL){
sprintf(testkey,"%s/%s",key,"band-id");
stop();
result = cw_ktv_get(params->cfg,key,CW_TYPE_BYTE);
result = cw_ktv_get_val_l(params->cfg_list,key,CW_TYPE_BYTE);
if (result==NULL){
type = cisco_ap_regulatory_domain4;
}
else{
type = cisco_ap_regulatory_domain5;
cw_val_destroy(result);
}
}
start = params->msgset->header_len(eh);
stop();
len = cw_ktv_write_struct(params->cfg,NULL,type,key,ob+start);
len = CW_TYPE_STRUCT->write(params->cfg_list,key,ob+start,type);
// len = cw_ktv_write_struct(params->cfg,NULL,type,key,ob+start);
ob += params->msgset->write_header(eh,ob,len);
idx++;
@ -349,7 +347,6 @@ static cw_ValStruct_t cisco_antenna_payload70[]={
static cw_ValStruct_t cisco_wtp_radio_config70[]={
{CW_TYPE_BYTE,"radio-id",1,-1},
{CW_TYPE_BYTE,"cfg-type",1,-1},
{CW_TYPE_WORD,"occupancy-limit",2,-1},
{CW_TYPE_BYTE,"cfg-period",1,-1},
@ -401,7 +398,6 @@ static cw_ValStruct_t cisco_wtp_radio_config75[]={
static cw_ValStruct_t cisco_tx_power[]={
{CW_TYPE_BYTE,"radio-id",1,-1},
{CW_TYPE_BYTE,"reserved",1,-1},
{CW_TYPE_WORD,"current-tx-power",2,-1},
{NULL,NULL,0,0}
@ -578,6 +574,7 @@ static int cw_mkradiokey(const char *pkey, uint8_t*data, int len, char *dst)
return 1;
}
/*
static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *dst)
{
int wlan_id,radio_id;
@ -587,7 +584,7 @@ static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *d
sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id);
return 1;
}
*/
static int cisoc_add_wlan_mkkey70(const char *pkey, uint8_t*data, int len, char *dst)
{
@ -831,7 +828,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_DWORD, /* type */
"wtp-radio-information", /* Key */
cw_in_radio_generic, /* get */
cisco_out_radio_generic /* put */
cw_out_radio_generic /* put */
}
,
{
@ -958,7 +955,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */
"cisco/loghost-config", /* Key */
cw_in_generic, /* get */
cw_out_generic_struct, /* put */
cw_out_generic, /* put */
NULL,
NULL,
cisco_loghost_config, /* type */
@ -1009,11 +1006,11 @@ static struct cw_ElemHandler handlers70[] = {
8,8, /* min/max length */
CW_TYPE_STRUCT, /* type */
"cisco/multi-domain-capability", /* Key */
cw_in_generic, /* get */
NULL, /* put */
cw_mkradiokey,
cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */
NULL,
cisco_multi_domain_cabability,
NULL,
cisco_multi_domain_capability,
}
,
@ -1080,7 +1077,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */
"cisco/ap-mode-and-type", /* Key */
cw_in_generic, /* get */
cw_out_generic_struct, /* put */
cw_out_generic, /* put */
NULL,
NULL,
cisco_ap_mode_and_type,
@ -1166,7 +1163,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */
"cisco/ap-model", /* Key */
cw_in_generic, /* get */
cw_out_generic_struct, /* put */
cw_out_generic, /* put */
NULL,
NULL,
cisco_ap_model,
@ -1191,9 +1188,9 @@ static struct cw_ElemHandler handlers70[] = {
25,25, /* min/max length */
CW_TYPE_STRUCT, /* type */
"cisco/wtp-radio-config", /* Key */
cw_in_generic, /* get */
cw_out_generic, /* put */
cw_mkradiokey,
cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */
NULL,
NULL,
cisco_wtp_radio_config70,
@ -1253,9 +1250,9 @@ static struct cw_ElemHandler handlers70[] = {
16,16, /* min/max length */
CW_TYPE_STRUCT, /* type */
"cisco/mac-operation", /* Key */
cw_in_generic, /* get */
cw_out_radio_generic_struct, /* put */
cw_mkradiokey,
cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */
NULL,
NULL,
cisco_mac_operation70,
@ -1269,9 +1266,9 @@ static struct cw_ElemHandler handlers70[] = {
4,4, /* min/max length */
CW_TYPE_STRUCT, /* type */
"cisco/tx-power", /* Key */
cw_in_generic, /* get */
cw_out_radio_generic_struct, /* put */
cw_mkradiokey,
cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */
NULL,
NULL,
cisco_tx_power,
@ -1284,9 +1281,9 @@ static struct cw_ElemHandler handlers70[] = {
5,150, /* min/max length */
CW_TYPE_BSTR16, /* type */
"cisco/tx-power-levels", /* Key */
cw_in_generic, /* get */
cw_in_radio_generic, /* get */
cw_out_radio_generic, /* put */
cw_mkradiokey,
NULL,
NULL,
@ -1656,7 +1653,7 @@ static struct cw_ElemHandler handlers70[] = {
CW_TYPE_STRUCT, /* type */
"cisco/cisco-discovery-protocol", /* Key */
cw_in_generic, /* get */
cw_out_generic_struct, /* put */
cw_out_generic, /* put */
NULL,
NULL,
cisco_discovery_protocol,
@ -2362,11 +2359,15 @@ static int preprocess_join_request(struct cw_Conn *conn)
use_ac_version = cw_cfg_get_bool(conn->global_cfg,"cisco/wtp-use-ac-version",0);
if (use_ac_version){
ver = cw_cfg_get_bstr16(conn->remote_cfg,"ac-descriptor/software/version",NULL );
cw_cfg_set_bstr16(conn->local_cfg,"wtp-descriptor/software/version",ver);
cw_format_version(verstr,bstr16_data(ver),bstr16_len(ver));
cw_dbg(DBG_INFO, "Cisco WTP - Using AC's software version: %s", verstr);
free(ver);
if (ver != NULL){
cw_cfg_set_bstr16(conn->local_cfg,"wtp-descriptor/software/version",ver);
cw_format_version(verstr,bstr16_data(ver),bstr16_len(ver));
cw_dbg(DBG_INFO, "Cisco WTP - Using AC's software version: %s", verstr);
free(ver);
}
else{
cw_dbg(DBG_X,"No version defined");
}
}

View File

@ -1,47 +0,0 @@
/*
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.
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/>.
*/
/**
* @file
* @brief Implements cw_in_capwap_control_ip_address
*/
#include "mod_capwap.h"
int cisco_in_ap_regulatory_domain(struct cw_ElemHandler *eh,
struct cw_ElemHandlerParams *params,
uint8_t * data, int len)
{
char key[CW_KTV_MAX_KEY_LEN];
int idx;
sprintf(key,"%s/address",eh->key);
idx = cw_ktv_idx_get(params->conn->remote_cfg,key);
/* printf("SKEY is %s , idx: %d\n",key,idx);*/
sprintf(key,"%s/address.%d",eh->key,idx+1);
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_IPADDRESS,data,len-2);
sprintf(key,"%s/wtps.%d",eh->key,idx+1);
cw_ktv_add(params->conn->remote_cfg,key,CW_TYPE_WORD,data+len-2,2);
return 1;
}

View File

@ -25,5 +25,5 @@ int cisco_in_spam_vendor_specific(struct cw_ElemHandler *eh,
}
return cw_process_element(params,CW_PROTO_LWAPP,vendor_id,elem_id,data+6,len-6);
return cw_decode_element(params,CW_PROTO_LWAPP,vendor_id,elem_id,data+6,len-6);
}

View File

@ -66,11 +66,11 @@ int cisco_out_ac_descriptor(struct cw_ElemHandler * eh,
/* 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,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
1, key);
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->conn->local_cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
0, key);

View File

@ -15,7 +15,7 @@ int cisco_out_radio_generic(struct cw_ElemHandler * handler, struct cw_ElemHandl
int radios;
len =0;
radios = cw_cfg_get_byte(params->cfg,"wtp-descriptor/max-radios",0);
radios = cw_cfg_get_byte_l(params->cfg_list,"wtp-descriptor/max-radios",0);
cw_dbg(DBG_X,"NUM RADIOS: %d",radios);
for(i=0;i<radios+0;i++){
l = cw_write_radio_element(handler,params,i,dst+len);

View File

@ -20,23 +20,33 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
rc = cw_generic_write_l(params->cfg_list, CW_TYPE_BYTE,key,
d, eh->param);
const char *
xxx = cw_cfg_get_l(params->cfg_list, key, NULL);
cw_dbg(DBG_X,"What??? %s: %s",key,xxx);
// val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
if (rc==-1){
cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", key);
d+=cw_put_byte(d,0);
}
else {
int yyy = cw_get_byte(d);
cw_dbg(DBG_X,"Verify: %d",yyy);
d+=rc;
}
sprintf(key,"%s/%s",eh->key,CW_SKEY_RADIOS_IN_USE);
xxx = cw_cfg_get_l(params->cfg_list, key, NULL);
cw_dbg(DBG_X,"What??? %s: %s",key,xxx);
rc = cw_generic_write_l(params->cfg_list, CW_TYPE_BYTE,key,
d, eh->param);
// val = cw_ktv_get(params->cfg,key, CW_TYPE_BYTE);
if (rc != -1){
if (rc == -1){
cw_dbg(DBG_WARN,"Cannot get value for %s, setting to 0", key);
d+=cw_put_byte(d,0);
}
@ -46,20 +56,20 @@ int cisco_out_wtp_descriptor(struct cw_ElemHandler * eh,
d+=cw_put_encryption_capabilities_7(d,1);
cw_dbg(DBG_X,"befor subelem ^p",params->cfg_list);
/* hardware version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_HARDWARE);
d+=cw_write_descriptor_subelem (d, params->cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_HARDWARE_VERSION, key);
/* software version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_SOFTWARE);
d+=cw_write_descriptor_subelem (d, params->cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_SOFTWARE_VERSION, key);
/* bootloader version sub element */
sprintf(key,"%s/%s",eh->key,CW_SKEY_BOOTLOADER);
d+=cw_write_descriptor_subelem (d, params->cfg,
d+=cw_write_descriptor_subelem (d, params->cfg_list,
CW_SUBELEM_WTP_BOOTLOADER_VERSION, key);
len = d-dst-4;