WTP Reboot Statistics

FossilOrigin-Name: 9317f838e1c76e55e5a1dfc684c014d10455b5006f152987ea2197b7d62c385b
This commit is contained in:
7u83@mail.ru 2016-03-11 22:45:35 +00:00
parent dca1ec6b2a
commit d87cd8741a
8 changed files with 102 additions and 61 deletions

View File

@ -148,6 +148,7 @@ CAPWAPOBJS= \
cw_out_generic.o \
cw_out_wtp_descriptor.o \
cw_out_wtp_reboot_statistics.o \
cw_in_wtp_reboot_statistics.o\
cw_in_cisco_image_identifier.o\
cw_out_radio_operational_state.o\
cw_in_ac_descriptor.o\

View File

@ -205,23 +205,23 @@ static inline int cw_get_hdr_msg_total_len(uint8_t * rawmsg)
static inline int cw_set_hdr_rmac(uint8_t * th,bstr_t rmac)
static inline int cw_set_hdr_rmac(uint8_t * th, bstr_t rmac)
{
if (!rmac){
cw_set_hdr_flags(th,CW_FLAG_HDR_M,0);
if (!rmac) {
cw_set_hdr_flags(th, CW_FLAG_HDR_M, 0);
cw_set_hdr_hlen(th, 2);
return 0;
}
int rmac_len = bstr_len(rmac);
memcpy(cw_get_hdr_rmac(th),rmac,rmac_len+1);
cw_set_hdr_flags(th,CW_FLAG_HDR_M,1);
memcpy(cw_get_hdr_rmac(th), rmac, rmac_len + 1);
cw_set_hdr_flags(th, CW_FLAG_HDR_M, 1);
int hlen = 4+rmac_len/4;
if (rmac_len %4 != 0) {
int hlen = 4 + rmac_len / 4;
if (rmac_len % 4 != 0) {
hlen++;
}
cw_set_hdr_hlen(th,hlen);
cw_set_hdr_hlen(th, hlen);
return 1;
}
@ -307,7 +307,7 @@ static inline int cw_put_elem_vendor_hdr(uint8_t * dst, uint32_t vendorid,
#define cw_put_sockaddr lw_put_sockaddr
int cw_put_image_data(uint8_t *dst,FILE *infile);
int cw_put_image_data(uint8_t * dst, FILE * infile);
/**
* Add a message element to a buffer
@ -387,10 +387,10 @@ extern int cw_in_check_generic_resp(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len, struct sockaddr *from);
extern int cw_in_check_generic_req(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len, struct sockaddr *from);
uint8_t * data, int len, struct sockaddr *from);
extern int cw_in_mtu_discovery_padding(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len,struct sockaddr *from);
uint8_t * data, int len, struct sockaddr *from);
@ -398,6 +398,13 @@ extern int cw_in_mtu_discovery_padding(struct conn *conn, struct cw_action_in *a
* @defgroup CWELEMIN Input Handlers for Message Elements
* @{
*/
extern int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from);
extern int cw_in_wtp_board_data(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from);
extern int cw_in_vendor_specific_payload(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len, struct sockaddr *from);
@ -406,13 +413,15 @@ extern int cw_in_capwap_control_ip_address(struct conn *conn, struct cw_action_i
struct sockaddr *from);
extern int cw_in_capwap_local_ipv4_address(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len,struct sockaddr *from);
uint8_t * data, int len,
struct sockaddr *from);
extern int cw_in_capwap_local_ipv6_address(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len,struct sockaddr *from);
uint8_t * data, int len,
struct sockaddr *from);
extern int cw_in_radio_operational_state(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from);
extern int cw_in_radio_operational_state(struct conn *conn, struct cw_action_in *a,
uint8_t * data, int len, struct sockaddr *from);
/**
@ -426,6 +435,9 @@ extern int cw_in_radio_operational_state(struct conn *conn, struct cw_action_in
*/
extern int cw_out_capwap_local_ip_address(struct conn *conn, struct cw_action_out *action,
uint8_t * dst);
extern int cw_out_wtp_reboot_statistics(struct conn *conn, struct cw_action_out *a,
uint8_t * dst);
/**
* @}
*/

View File

@ -64,7 +64,7 @@ static int read_subeelms(struct conn *conn,struct cw_action_in * a,uint8_t *data
uint32_t vendor_id = cw_get_dword(data+sub);
int sublen = cw_get_word(data+sub+6);
int subtype = cw_get_word(data+sub+4);
printf("substart : %d\n",sub);
//printf("substart : %d\n",sub);
bstrv_t vstr=NULL;
switch (subtype){

View File

@ -0,0 +1,46 @@
/*
This file is part of libcapwap.
libcapwap 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/>.
*/
#include "cw.h"
#include "log.h"
#include "capwap_items.h"
int cw_in_wtp_reboot_statistics(struct conn *conn, struct cw_action_in *a, uint8_t * data,
int len, struct sockaddr *from)
{
mbag_t rs = mbag_create();
if (!rs) {
cw_log(LOG_ERR,"Can't create REBOOT_STATISITCS");
return 0;
}
mbag_set_word( rs, CW_ITEM_REBOOT_COUNT,cw_get_word(data+0) );
mbag_set_word( rs, CW_ITEM_REBOOT_AC_INITIATED_COUNT,cw_get_word(data+2) );
mbag_set_word( rs, CW_ITEM_REBOOT_LINK_FAILURE_COUNT,cw_get_word(data+2) );
mbag_set_word( rs, CW_ITEM_REBOOT_SW_FAILURE_COUNT,cw_get_word(data+4) );
mbag_set_word( rs, CW_ITEM_REBOOT_HW_FAILURE_COUNT,cw_get_word(data+6) );
mbag_set_word( rs, CW_ITEM_REBOOT_OTHER_FAILURE_COUNT,cw_get_word(data+8) );
mbag_set_word( rs, CW_ITEM_REBOOT_UNKNOWN_FAILURE_COUNT,cw_get_word(data+10) );
mbag_set_byte( rs, CW_ITEM_REBOOT_LAST_FAILURE_TYPE,cw_get_byte(data+12) );
return 1;
}

View File

@ -73,7 +73,7 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
cw_action_out_t *ae=(cw_action_out_t*)e->data;
DBGX("Put %d %i %p\n",ae->msg_id,ae->elem_id,ae->item_id);
printf("Put %d %i %s\n",ae->msg_id,ae->elem_id,ae->item_id);
//printf("Put %d %i %s\n",ae->msg_id,ae->elem_id,ae->item_id);
DBGX("Elem ID %s",ae->item_id);
if ( ae->item_id ) {
DBGX("Item ID: %s %p",ae->item_id,CW_ITEM_NONE);
@ -86,11 +86,11 @@ int cw_put_msg(struct conn *conn, uint8_t * rawout)
if (ae->out) {
int l=0;
printf("Out Call with len =%d\n",len);
// printf("Out Call with len =%d\n",len);
l= ae->out(conn, ae, dst+len);
printf("Returned len = %d\n",l);
// printf("Returned len = %d\n",l);
len +=l;

View File

@ -1,40 +0,0 @@
/*
This file is part of libcapwap.
libcapwap 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/>.
*/
#include "capwap.h"
#include "wtpinfo.h"
int cw_readelem_wtp_reboot_statistics(struct wtp_reboot_statistics *s, int type,uint8_t *msgelem, int len)
{
if (type != CW_ELEM_WTP_REBOOT_STATISTICS)
return 0;
s->reboot_count=ntohs(*((uint16_t*)(msgelem+0)));
s->ac_initiated_count=ntohs(*((uint16_t*)(msgelem+2)));
s->link_failure_count=ntohs(*((uint16_t*)(msgelem+4)));
s->sw_failure_count=ntohs(*((uint16_t*)(msgelem+6)));
s->hw_failure_count=ntohs(*((uint16_t*)(msgelem+8)));
s->other_failure_count=ntohs(*((uint16_t*)(msgelem+10)));
s->unknown_failure_count=ntohs(*((uint16_t*)(msgelem+12)));
s->last_failure_type=*(msgelem+14);
return 1;
}

View File

@ -281,6 +281,18 @@ static cw_action_in_t actions_in[] = {
}
,
/* WTP Reboot Statistics - Join Request */
{
.capwap_state = CW_STATE_JOIN,
.msg_id = CW_MSG_JOIN_REQUEST,
.elem_id = CW_ELEM_WTP_REBOOT_STATISTICS,
.start = cw_in_wtp_reboot_statistics,
.item_id = CW_ITEM_WTP_REBOOT_STATISTICS,
.min_len = 15,
.max_len = 15
}
,
/* --------------------------------------------------------------------------

View File

@ -329,11 +329,21 @@ static cw_action_out_t actions_out[] = {
.msg_id = CW_MSG_JOIN_REQUEST,
.item_id = CW_ITEM_CAPWAP_LOCAL_IP_ADDRESS,
.out = cw_out_capwap_local_ip_address,
// .get = cw_out_get_config,
.mand = 1
}
,
/* WTP Reboot Statistics - Join Request */
{
.msg_id = CW_MSG_JOIN_REQUEST,
.elem_id = CW_ELEM_WTP_REBOOT_STATISTICS,
.item_id = CW_ITEM_WTP_REBOOT_STATISTICS,
.out = cw_out_wtp_reboot_statistics,
.get = cw_out_get_config,
.mand = 0
}
,