Counter function

FossilOrigin-Name: 7f88de81e3340b664d21ef5b091aebec1115813b6751d824930ea2734ddb50ae
This commit is contained in:
7u83@mail.ru 2018-05-20 18:29:40 +00:00
parent 74631d08df
commit 59b08b31c0
7 changed files with 123 additions and 30 deletions

View File

@ -4,8 +4,8 @@
<Project Name="wtp" Path="wtp.project" Active="No"/>
<Project Name="mod_cipwap" Path="mod_cipwap.project" Active="No"/>
<Project Name="mod_capwap" Path="mod_capwap.project" Active="No"/>
<Project Name="mod_cisco" Path="mod_cisco.project" Active="Yes"/>
<Project Name="libcw" Path="libcw.project" Active="No"/>
<Project Name="mod_cisco" Path="mod_cisco.project" Active="No"/>
<Project Name="libcw" Path="libcw.project" Active="Yes"/>
<Project Name="mod_capwap80211" Path="mod_capwap80211.project" Active="No"/>
<Project Name="mod_fortinet" Path="mod_fortinet.project" Active="No"/>
<BuildMatrix>

View File

@ -83,6 +83,10 @@ radio.255/admin-state :Str: enabled
radio.255/operational-state/cause :Str: Normal
radio.255/operational-state/state :Str: enabled
radio.0/wlan.0/add-lw-wlan/misc :Bstr16: .x3e9904fac0000100
radio.0/wlan.0/add-lw-wlan/misc2 :Word: 4
radio.0/wlan.0/add-lw-wlan/ssid :Str: TubeSSID
radio.1/admin-state :Byte: reserved
radio.1/cisco-multi-domain-capability/first-channel :Word: 36
radio.1/cisco-multi-domain-capability/max-tx-power-level :Word: 65535

View File

@ -447,7 +447,7 @@ static void * wtpman_main(void *arg)
mavl_t tmp;
tmp = conn->local_cfg;
conn->local_cfg=conn->update_cfg;
/*conn->local_cfg=conn->update_cfg;*/
conn->default_cfg = conn->remote_cfg;
cw_dbg(DBG_INFO, "Updating WTP %s",sock_addr2str(&conn->addr,sock_buf));

View File

@ -78,6 +78,7 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
char ikey[CW_KTV_MAX_KEY_LEN];
cw_KTV_t search, * result;
char *d;
int i;
sprintf(ikey,"%s.%d",key,n);
@ -90,13 +91,35 @@ int cw_ktv_idx_get_next(mavl_t ktv, const char *key, int n)
return -1;
}
d = strchr(result->key,'.');
/*d = strchr(result->key,'.');*/
d=NULL;
/* for (i = strlen(result->key); i>=0; i--){
if (result->key[i]=='/')
break;
}
*/ for (i = strlen(ikey); i>=0; i--){
if (ikey[i]=='.'){
d = result->key+i;
break;
}
}
if (d==NULL){
return -1;
}
if (strncmp(result->key,ikey,d-result->key)!=0)
if(result->key[i]!='.'){
return -1;
}
/* if (strncmp(result->key,ikey,d-result->key)!=0)
return -1;
*/
if (strncmp(result->key,ikey,i)!=0)
return -1;
return atoi(d+1);
return atoi(result->key+i+1);
}

View File

@ -8,23 +8,14 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
, uint8_t * dst)
{
int i,l, offset;
/* int radios;*/
uint8_t * cdst;
cdst = dst;
/* radios = cw_ktv_get_byte(params->conn->local_cfg,"wtp-descriptor/max-radios",0);*/
/* int idx=0;
while(1){
idx = cw_ktv_idx_get_next(params->conn->local_cfg,"radio",idx);
idx++;
}
*/
offset = params->conn->header_len(handler);
/* for(i=0;i<radios;i++){*/
i=-1;
while(1){
char basekey[CW_KTV_MAX_KEY_LEN];
@ -47,11 +38,78 @@ int cw_out_radio_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemH
cdst+=params->conn->write_header(handler,cdst,l);
/* l = cw_write_radio_element(handler,params,i,dst+len);
cw_dbg_elem(DBG_ELEM_OUT,params->conn,params->msgdata->type,handler,dst,l);
len+=l;*/
}
return cdst-dst;
}
int cw_out_traverse0(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst, int i, const char *current, const char * next)
{
char *sl;
int l;
char key[CW_KTV_MAX_KEY_LEN];
char tcurrent[CW_KTV_MAX_KEY_LEN];
sl = strchr(next,'/');
if (sl==NULL){
cw_KTV_t * result;
sprintf(key,"%s/%s",current,next);
result = cw_ktv_base_exists(params->conn->local_cfg,key);
if (result != NULL){
printf("Yea! We can do it: %s\n",result->key);
}
return 0;
}
strcpy(key,current);
if (key[0!=0])
strcat(key,"/");
l = sl - next;
strncat(key,next,l);
printf("Here we are %s\n",key);
cw_dbg_ktv_dump(params->conn->local_cfg,DBG_INFO,"start"," ", "end" );
i=-1;
while(1){
char basekey[CW_KTV_MAX_KEY_LEN];
cw_KTV_t * result;
i = cw_ktv_idx_get_next(params->conn->local_cfg,key,i+1);
if (i==-1)
break;
sprintf(basekey,"%s.%d",key,i);
printf("Our basekey is %s\n",basekey);
result = cw_ktv_base_exists(params->conn->local_cfg,basekey);
if (result == NULL){
continue;
}
cw_out_traverse0(handler,params,dst,-1,basekey,next+l+1);
}
}
int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst)
{
int i;
char current[CW_KTV_MAX_KEY_LEN];
i=-1;
current[0]=0;
cw_out_traverse0(handler,params,dst,-1,current,handler->key);
printf("Hello world\n");
exit(0);
}

View File

@ -1,12 +1,12 @@
/*
This file is part of libcapwap.
This file is part of actube.
libcapwap is free software: you can redistribute it and/or modify
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,
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.
@ -476,10 +476,12 @@ static int cisoc_add_wlan_mkkey(const char *pkey, uint8_t*data, int len, char *d
radio_id = cw_get_byte(data);
wlan_id = cw_get_byte(data+3);
sprintf(dst,"radio.%d/wlan.%d",radio_id,wlan_id);
sprintf(dst,"radio.%d/wlan.%d/add-wlan",radio_id,wlan_id);
return 1;
}
static cw_KTVStruct_t cisco_add_lwwlan[]={
{CW_TYPE_BSTR16, "misc", 8, 2},
{CW_TYPE_STR, "ssid",-1,10},
@ -522,7 +524,7 @@ static int cisoc_add_lwwlan_mkkey(const char *pkey, uint8_t*data, int len, char
radio_id = cw_get_byte(data);
wlan_id = cw_get_byte(data+1);
sprintf(dst,"radio.%d/wlan.%d",radio_id,wlan_id);
sprintf(dst,"radio.%d/wlan.%d/add-lw-wlan",radio_id,wlan_id);
return 1;
}
@ -561,6 +563,9 @@ static cw_KTVStruct_t cisco_rad_extended_config[]={
};
int cw_out_traverse(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst);
static cw_KTVStruct_t cisco_80211_assoc_limit[]={
{CW_TYPE_BOOL, "enable",1,-1},
{CW_TYPE_BYTE, "limit",1,-1},
@ -1197,9 +1202,9 @@ static struct cw_ElemHandler handlers73[] = {
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
7,1117, /* min/max length */
cisco_add_lwwlan, /* type */
"radio/wlan", /* Key */
"radio/wlan/add-lw-wlan", /* Key */
cw_in_generic_struct, /* get */
cw_out_generic_struct, /* put */
cw_out_traverse, /* put */
cisoc_add_lwwlan_mkkey
}
,

View File

@ -61,7 +61,7 @@ cisco/ap-regulatory-domain.1/slot :Byte: 1
cisco/ap-sub-mode :Byte: 0
cisco/ap-telnet-ssh/ssh :Bool: false
cisco/ap-telnet-ssh/telnet :Bool: false
cisco/ap-timesync/timestamp :Dword: 1526543483
cisco/ap-timesync/timestamp :Dword: 1526767373
cisco/ap-timesync/type :Byte: 0
cisco/ap-username-and-password/802.1x-credentials/option :Word: 2
cisco/ap-username-and-password/802.1x-credentials/password :Str:
@ -211,6 +211,9 @@ radio.1/decryption-error-report-period :Word: 120
radio.1/operational-state/cause :Byte: Normal
radio.1/operational-state/state :Byte: enabled
radio.1/rate_set :Bstr16: .x8c129824b048606c
radio.1/wlan.0/add-lw-wlan/misc :Bstr16: .x3e9904fac0000100
radio.1/wlan.0/add-lw-wlan/misc2 :Word: 4
radio.1/wlan.0/add-lw-wlan/ssid :Str: TubeSSID
radio.1/wlan.0/allow-aaa-override :Byte: 0
radio.1/wlan.0/broadcast-ssid :Bool: true
radio.1/wlan.0/dtim-period :Byte: 1