More Cisco stuff added

FossilOrigin-Name: e68d9b046b5b19112b8c37d63642202ba74c57d927cb4519d0da57e0b0e11698
This commit is contained in:
7u83@mail.ru 2018-04-22 07:00:55 +00:00
parent d316d956f8
commit d1363a2e14
14 changed files with 245 additions and 45 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

@ -292,6 +292,8 @@
<File Name="src/cw/cw_ktv_save.c"/>
<File Name="src/cw/cw_in_generic_with_index.c"/>
<File Name="src/cw/cw_out_generic_with_index.c"/>
<File Name="src/cw/cw_in_generic_indexed_enum.c"/>
<File Name="src/cw/cw_out_generic_indexed_enum.c"/>
</VirtualDirectory>
</VirtualDirectory>
<Description/>

View File

@ -63,6 +63,8 @@ CWSRC=\
cw_in_radio_generic_struct.c\
cw_in_idx_generic.c\
cw_in_idx_generic_struct.c\
cw_in_generic_indexed_enum.c\
cw_out_generic_indexed_enum.c\
cw_in_generic_enum.c\
cw_out_generic_struct.c\
cw_out_idx_generic_struct.c\

View File

@ -411,6 +411,12 @@ int cw_in_generic_struct(struct cw_ElemHandler * handler, struct cw_ElemHandlerP
int cw_in_generic_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
uint8_t * elem_data, int elem_len);
int cw_in_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
uint8_t * elem_data, int elem_len);
int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst);
int cw_out_generic(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst);

View File

@ -31,6 +31,6 @@ int cw_in_generic_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerPar
thandler.type=e->type;
thandler.key=key;
return e->fun(&thandler,params,elem_data,elem_len-1);
return e->fun_in(&thandler,params,elem_data,elem_len-1);
}

View File

@ -0,0 +1,53 @@
#include "cw.h"
static const cw_KTVEnum_t * get_enum(const cw_KTVEnum_t * e, int val){
int i;
for (i=0; e[i].type != NULL; i++ ){
if (e[i].value==val){
return &(e[i]);
}
}
return NULL;
}
int cw_in_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params,
uint8_t * elem_data, int elem_len)
{
int val;
int l,f;
const cw_KTVEnum_t * e;
const cw_KTVIndexed_t * ie;
char key[CW_KTV_MAX_KEY_LEN];
struct cw_ElemHandler thandler;
ie = handler->type;
val = cw_get_byte(elem_data+ie->idxpos);
e = get_enum(ie->type,val);
f=0;
if (ie->idxpos==0){
l=1;
f=1;
}
if (ie->idxpos==elem_len-1){
l=1;
}
if (e!=NULL){
sprintf(key,"%s/%s",handler->key,e->name);
}
else{
sprintf(key,"%s/%u",handler->key,val);
}
thandler.type=e->type;
thandler.key=key;
return e->fun_in(&thandler,params,elem_data+f,elem_len-l);
}

View File

@ -5,7 +5,7 @@ int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
uint8_t * data, int len)
{
char key[CW_KTV_MAX_KEY_LEN];
int pos, i;
int pos, i,l;
cw_KTV_t * result;
@ -16,13 +16,22 @@ int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
pos=stru[i].position;
sprintf(key,"%s/%s",pkey,stru[i].key);
result = cw_ktv_add(ktv,key,stru[i].type,data+pos,stru[i].len);
if (stru[i].len==-1)
l = len-pos;
else
l = stru[i].len;
result = cw_ktv_add(ktv,key,stru[i].type,data+pos,l);
stru[i].type->to_str(result,dbstr,100);
cw_dbg(DBG_ELEM_DETAIL, "Read (%d): %s: %s",pos,key,dbstr);
if (stru[i].len==-1)
l = result->type->len(result);
else
l = stru[i].len;
if(stru[i].position == -1)
pos+=stru[i].len;
pos+=l;
i++;
}

View File

@ -15,7 +15,8 @@ int cw_ktv_write_struct(mavl_t ktv, const cw_KTVStruct_t * stru, const char *pke
if (stru[i].position!=-1){
pos=stru[i].position;
}
memset(dst+pos,0,stru[i].len);
if (stru[i].len!=-1)
memset(dst+pos,0,stru[i].len);
sprintf(key,"%s/%s",pkey,stru[i].key);
result = cw_ktv_get(ktv,key,stru[i].type);
@ -27,8 +28,10 @@ int cw_ktv_write_struct(mavl_t ktv, const cw_KTVStruct_t * stru, const char *pke
else{
result->type->put(result,dst+pos);
}
pos+=stru[i].len;
if (stru[i].len!=-1)
pos+=stru[i].len;
else
pos+=result->type->len(result);
}

View File

@ -0,0 +1,54 @@
#include "cw.h"
int cw_out_generic_indexed_enum(struct cw_ElemHandler * handler, struct cw_ElemHandlerParams * params
, uint8_t * dst)
{
char key[CW_KTV_MAX_KEY_LEN];
int i;
cw_KTV_t * result;
int len,start;
uint8_t * ob;
const cw_KTVIndexed_t *ie;
cw_KTVEnum_t * e;
struct cw_ElemHandler thandler;
ie = handler->type;
i = 0;
ob = dst;
e = ie->type;
for(i=0; e[i].name!=NULL; i++) {
sprintf(key,"%s/%s",handler->key,e[i].name);
result = cw_ktv_base_exists(params->conn->local_cfg,key);
if (result==NULL)
continue;
start = params->conn->header_len(handler);
len = 0;
if (ie->idxpos==0)
len = 1;
if (e[i].fun_out==NULL)
len += result->type->put(result,ob+start+len);
else
len += cw_ktv_write_struct(params->conn->local_cfg,e[i].type,key,ob+start+len);
/* thandler.type=e[i].type;
thandler.key=key;
len += e->fun_out(&thandler,params,ob+start+len);
*/
cw_set_byte(ob+start+ie->idxpos,e[i].value);
if (ie->idxpos==len)
len++;
ob += params->conn->write_header(handler,ob,len);
}
return ob-dst;
}

View File

@ -98,11 +98,19 @@ typedef struct cw_KTVStruct cw_KTVStruct_t;
struct cw_KTVEnum{
int value;
const char * name;
const struct cw_Type * type;
int (*fun)();
const void * type;
int (*fun_in)();
int (*fun_out)();
};
typedef struct cw_KTVEnum cw_KTVEnum_t;
struct cw_KTVIndexed{
int idxpos;
void *type;
};
typedef struct cw_KTVIndexed cw_KTVIndexed_t;
int cw_ktv_read_struct(mavl_t ktv,const cw_KTVStruct_t * stru, const char *pkey,
uint8_t * data, int len);
int cw_ktv_write_struct(mavl_t ktv, const cw_KTVStruct_t * stru, const char *pkey,

View File

@ -109,7 +109,7 @@
#define CW_CISCO_DOT11_CONFIG_CHECKER 242
#define CW_CISCO_AP_VENUE_SETTINGS 249
#define CISCO_ELEM_AP_VENUE_SETTINGS 249
#define CISCO_ELEM_AP_LED_FLASH_CONFIG 254

View File

@ -59,13 +59,36 @@ static cw_KTVStruct_t cisco_ap_uptime[] = {
{NULL,NULL,0,0}
};
static cw_KTVStruct_t cisco_ap_username_and_password[] = {
static cw_KTVStruct_t cisco_login[] = {
{CW_TYPE_STR, "username", 33, -1 },
{CW_TYPE_STR, "password", 121, -1 },
{CW_TYPE_STR, "enable-password", 121, 33+121 },
{CW_TYPE_WORD, "option", 2, 275 },
{NULL,NULL,0,0}
};
static cw_KTVStruct_t cisco_8021xlogin[] = {
{CW_TYPE_STR, "username", 33, -1 },
{CW_TYPE_STR, "password", 121, -1 },
{CW_TYPE_WORD, "option", 2, 275 },
{NULL,NULL,0,0}
};
static cw_KTVEnum_t cisco_ap_username_and_password_enum[] ={
{2, "802.1x-credentials", cisco_8021xlogin, cw_in_generic_struct, cw_ktv_write_struct },
{1, "login-credentials", cisco_login, cw_in_generic_struct, cw_ktv_write_struct },
{0,0,0,0}
};
static cw_KTVIndexed_t cisco_ap_username_and_password = {
276,cisco_ap_username_and_password_enum
};
static cw_KTVStruct_t cisco_loghost_config[] = {
{CW_TYPE_IPADDRESS, "loghost", 4, -1},
{CW_TYPE_STR, "last-joined-ap", 32, -1},
@ -78,12 +101,16 @@ static cw_KTVStruct_t cisco_ap_led_state_config[] = {
{NULL,NULL,0,0}
};
static cw_KTVEnum_t cisco_ap_telnet_ssh[] ={
{0, "telnet", CW_TYPE_BOOL, cw_in_generic },
{1, "ssh", CW_TYPE_BOOL, cw_in_generic },
static cw_KTVEnum_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,0,0,0}
};
static cw_KTVIndexed_t cisco_ap_telnet_ssh = {
1,cisco_ap_telnet_ssh_enum
};
static cw_KTVStruct_t cisco_multi_domain_cabability[]={
{CW_TYPE_BYTE, "reserved", 1, -1},
{CW_TYPE_WORD, "first-channel", 2, -1},
@ -323,7 +350,7 @@ static cw_KTVStruct_t cisco_ap_qos[]={
static cw_KTVStruct_t cisco_ap_core_dump[]={
{CW_TYPE_IPADDRESS,"tftp-server",4,-1},
{CW_TYPE_BOOL,"enable",1,16},
{CW_TYPE_STR,"filename",100,17},
{CW_TYPE_STR,"filename",199,17},
{NULL,NULL,0,0}
};
@ -345,7 +372,14 @@ static cw_KTVStruct_t cisco_rouge_detections[]={
{NULL,NULL,0,0}
};
static cw_KTVStruct_t cisco_ap_venue_settings[]={
{CW_TYPE_WORD,"group",2,-1},
{CW_TYPE_BYTE,"type",1,-1},
{CW_TYPE_STR,"language",3,-1},
{CW_TYPE_STR,"name",-1,7},
{NULL,NULL,0,0}
};
/*
int cisco_in_with_index(struct cw_ElemHandler *eh,
struct cw_ElemHandlerParams *params,
@ -594,10 +628,10 @@ static struct cw_ElemHandler handlers[] = {
CISCO_LWELEM_AP_USERNAME_PASSWORD, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
0,0, /* min/max length */
cisco_ap_username_and_password, /* type */
&cisco_ap_username_and_password, /* type */
"cisco/ap-username-and-password", /* Key */
cw_in_generic_struct, /* get */
cw_out_generic_struct /* put */
cw_in_generic_indexed_enum, /* get */
cw_out_generic_indexed_enum /* put */
}
,
{
@ -627,10 +661,10 @@ static struct cw_ElemHandler handlers[] = {
CISCO_LWELEM_AP_TELNET_SSH, /* Element ID */
CW_VENDOR_ID_CISCO,CW_PROTO_LWAPP, /* Vendor / Proto */
2,2, /* min/max length */
cisco_ap_telnet_ssh, /* type */
&cisco_ap_telnet_ssh, /* type */
"cisco/ap-telnet-ssh", /* Key */
cw_in_generic_enum, /* get */
NULL /* put */
cw_in_generic_indexed_enum, /* get */
cw_out_generic_indexed_enum /* put */
}
,
{
@ -960,6 +994,19 @@ static struct cw_ElemHandler handlers[] = {
}
,
{
"AP Venue Settings", /* name */
CISCO_ELEM_AP_VENUE_SETTINGS, /* Element ID */
CW_VENDOR_ID_CISCO,0, /* Vendor / Proto */
5,1024, /* min/max length */
cisco_ap_venue_settings, /* type */
"cisco/ap-venue-settings", /* Key */
cw_in_generic_struct, /* get */
cw_out_generic_struct /* put */
}
,
{
"Rouge Detection", /* name */
@ -974,6 +1021,7 @@ static struct cw_ElemHandler handlers[] = {
,
{0,0,0,0,0,0,0,0}
};
@ -1054,8 +1102,9 @@ static struct cw_ElemDef configuration_status_request_elements[] ={
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_RESET_BUTTON_STATE, 1, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_WTP_RADIO_CONFIGURATION, 1, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AC_NAME_WITH_INDEX, 0, CW_IGNORE},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_CORE_DUMP, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_VENUE_SETTINGS, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_USERNAME_PASSWORD, 1, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_LOGHOST_CONFIG, 1, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_TELNET_SSH, 1, 0},
@ -1120,7 +1169,7 @@ static struct cw_ElemDef configuration_update_request_elements[] ={
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_CORE_DUMP, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_STATISTICS_TIMER, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AC_NAME_WITH_INDEX, 0, 0},
{0, CW_VENDOR_ID_CISCO, CISCO_ELEM_AP_VENUE_SETTINGS, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_USERNAME_PASSWORD, 0, 0},
{CW_PROTO_LWAPP, CW_VENDOR_ID_CISCO, CISCO_LWELEM_AP_LOGHOST_CONFIG, 0, 0},

View File

@ -9,16 +9,16 @@ ac-descriptor/software/vendor :Dword: 4232704
ac-descriptor/software/version :Bstr16: .x07036500
ac-descriptor/station-limit :Word: 1000
ac-descriptor/stations :Word: 0
ac-name :Bstr16: Cisa173
ac-name-with-index.0 :Bstr16: tabbe
ac-name :Bstr16: CiscoAC73
ac-name-with-index.0 :Bstr16: tabbe88
ac-name-with-index.1 :Bstr16: nudelnudel
ac-name-with-index.2 :Bstr16: nadelnalde
ac-name-with-priority/X1 :Byte: 3
ac-name-with-priority/ac2 :Byte: 5
capwap-control-ip-address/address.0 :IPAddress: 172.16.66.173
capwap-control-ip-address/address.0 :IPAddress: 192.168.0.173
capwap-control-ip-address/address.1 :IPAddress: d96c:4c0a:da6c:4c0a:db6c:4c0a:dc6c:4c0a
capwap-control-ip-address/address.2 :IPAddress: 172.16.66.173
capwap-control-ip-address/wtps.0 :Word: 0
capwap-control-ip-address/address.2 :IPAddress: 192.168.0.173
capwap-control-ip-address/wtps.0 :Word: 1
capwap-control-ip-address/wtps.1 :Word: 10
capwap-control-ip-address/wtps.2 :Word: 1
capwap-local-ip-address :IPAddress: 172.16.66.50
@ -28,15 +28,19 @@ capwap-timers/min-discovery-interval :Byte: 0
cisco/ac-ip-addr-with-index.0 :IPAddress: 1.1.1.1
cisco/ac-ip-addr-with-index.1 :IPAddress: 9.9.9.9
cisco/ac-ip-addr-with-index.2 :IPAddress: 3.3.3.3
cisco/ap-core-dump/enable :Bool: false
cisco/ap-core-dump/filename :Str:
cisco/ap-core-dump/tftp-server :IPAddress: 0.0.0.0
cisco/ap-failover-priority :Byte: 3
cisco/ap-group-name :Bstr16: default-group
cisco/ap-led-state-config/led-state :Byte: 1
cisco/ap-led-state-config/save-flag :Byte: 1
cisco/ap-log-facility :Byte: 0
cisco/ap-mode-and-type :Word: 0
cisco/ap-power-injector-config/selection :Byte: 0
cisco/ap-power-injector-config/sitch-mac-address :Bstr16: .x000000000000
cisco/ap-power-injector-config/state :Byte: 17
cisco/ap-pre-std-switch-config :Byte: 1
cisco/ap-pre-std-switch-config :Byte: 0
cisco/ap-regulatory-domain.0/code0 :Byte: 0
cisco/ap-regulatory-domain.0/code1 :Byte: 1
cisco/ap-regulatory-domain.0/set :Bool: true
@ -45,13 +49,22 @@ cisco/ap-regulatory-domain.1/code0 :Byte: 0
cisco/ap-regulatory-domain.1/code1 :Byte: 1
cisco/ap-regulatory-domain.1/set :Bool: true
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: 1524313188
cisco/ap-timesync/timestamp :Dword: 1524384616
cisco/ap-timesync/type :Byte: 0
cisco/ap-username-and-password/enable-password :Str: $1$F4ey$qyu1z8WDU6KYapJ2Z471q/
cisco/ap-username-and-password/password :Str: $1$pLeF$a4Or8td4SSrWL6WV0KpIj1
cisco/ap-username-and-password/username :Str: giraffe
cisco/ap-username-and-password/802.1x-credentials/option :Word: 2
cisco/ap-username-and-password/802.1x-credentials/password :Str:
cisco/ap-username-and-password/802.1x-credentials/username :Str:
cisco/ap-username-and-password/login-credentials/enable-password :Str: $1$2Iyi$8m7Disb6SL0kuwPU5.6tN.
cisco/ap-username-and-password/login-credentials/option :Word: 513
cisco/ap-username-and-password/login-credentials/password :Str: $1$N03U$Y1wEFRdFpNF/YjQf0e.Vc0
cisco/ap-username-and-password/login-credentials/username :Str: Tobias
cisco/ap-venue-settings/group :Word: 2
cisco/ap-venue-settings/language :Str: en
cisco/ap-venue-settings/name :Str: bumm
cisco/ap-venue-settings/type :Byte: 1
cisco/board-data-options :Dword: 16777217
cisco/loghost-config/last-joined-ap :Str:
cisco/loghost-config/loghost.0 :IPAddress: 7.7.1.3
@ -63,19 +76,19 @@ cisco/lw_path_mtu/max :Word: 1485
cisco/mwar-addr/address :IPAddress: 192.168.0.180
cisco/mwar-addr/mwar-type :Byte: 1
cisco/mwar-addr/unknown :Word: 0
cisco/mwar-hash-value :Bstr16: 0bb44248231d033bf67e1dee5f02fa487af01f32
cisco/mwar-hash-value :Bstr16: 25f312452fcb0a908007304aa201d175d0516d7a
cisco/mwar-type :Byte: 0
cisco/rouge-and-mss/enable :Bool: true
cisco/rouge-and-mss/enable :Bool: false
cisco/rouge-and-mss/mss :Word: 666
cisco/rouge-and-mss/roge-detection :Bool: true
cisco/rouge-and-mss/tcp-adjust-mss :Word: 999
cisco/rouge-detection/rest :Bstr16: .x000000000000
cisco/rouge-detection/rouge-detection :Bool: true
cisco/rouge-and-mss/tcp-adjust-mss :Word: 0
cisco/rouge-detection/rest :Bstr16: .x000aff800000
cisco/rouge-detection/rouge-detection :Bool: false
cisco/ssl-certfile :Str: ../../ssl/certs/wtpc.crt
cisco/ssl-cipher :Str: ALL
cisco/ssl-keyfile :Str: ../../ssl/certs/wtpc.key
cisco/vlan/id :Word: 77
cisco/vlan/tagging :Bool: true
cisco/vlan/id :Word: 0
cisco/vlan/tagging :Bool: false
cisco/wtp-board-data/card-id :Word: 0
cisco/wtp-board-data/card-revision :Word: 0
cisco/wtp-board-data/ethernet-mac-address :Bstr16: .xc47d4f3af8a6
@ -146,7 +159,7 @@ radio.1/cisco/multi-domain-capability/number-of-channels :Word: 4
radio.1/cisco/multi-domain-capability/reserved :Byte: 1
radio.1/cisco/tx-power/current-tx-power :Word: 0
radio.1/cisco/tx-power/reserved :Byte: 1
radio.1/cisco/wtp-radio-config/beacon-period :Word: 100
radio.1/cisco/wtp-radio-config/beacon-period :Word: 999
radio.1/cisco/wtp-radio-config/bss-id :Bstr16: .x04fe7f499b90
radio.1/cisco/wtp-radio-config/cfg-period :Byte: 4
radio.1/cisco/wtp-radio-config/cfg-type :Byte: 1

View File

@ -192,7 +192,8 @@ exit(0);
cw_discovery_init_results(&dis);
cw_run_discovery(conn, "255.255.255.255","172.16.66.100", &dis);
/* cw_run_discovery(conn, "255.255.255.255","172.16.66.100", &dis);*/
cw_run_discovery(conn, "255.255.255.255",NULL, &dis);
cw_dbg_ktv_dump(dis.prio_ip, DBG_INFO, "=== IP list ===", "IP", "=== END IP List ===");
/*