freewtp/lib/element_wtpradiostat.c

104 lines
3.7 KiB
C
Raw Normal View History

2013-06-02 22:21:49 +02:00
#include "capwap.h"
2016-08-22 16:59:55 +02:00
#include "element.h"
2013-06-02 22:21:49 +02:00
/********************************************************************
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Radio ID | Last Fail Type| Reset Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| SW Failure Count | HW Failure Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Other Failure Count | Unknown Failure Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Config Update Count | Channel Change Count |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Band Change Count | Current Noise Floor |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Type: 47 for WTP Radio Statistics
Length: 20
********************************************************************/
/* */
static void capwap_wtpradiostat_element_create(void* data, capwap_message_elements_handle handle, struct capwap_write_message_elements_ops* func) {
struct capwap_wtpradiostat_element* element = (struct capwap_wtpradiostat_element*)data;
ASSERT(data != NULL);
ASSERT(IS_VALID_RADIOID(element->radioid));
2013-06-02 22:21:49 +02:00
/* */
func->write_u8(handle, element->radioid);
func->write_u8(handle, element->lastfailtype);
func->write_u16(handle, element->resetcount);
func->write_u16(handle, element->swfailercount);
func->write_u16(handle, element->hwfailercount);
func->write_u16(handle, element->otherfailercount);
func->write_u16(handle, element->unknownfailercount);
func->write_u16(handle, element->configupdatecount);
func->write_u16(handle, element->channelchangecount);
func->write_u16(handle, element->bandchangecount);
func->write_u16(handle, element->currentnoisefloor);
}
2013-10-01 16:39:27 +02:00
/* */
static void* capwap_wtpradiostat_element_clone(void* data) {
ASSERT(data != NULL);
return capwap_clone(data, sizeof(struct capwap_wtpradiostat_element));
}
/* */
static void capwap_wtpradiostat_element_free(void* data) {
ASSERT(data != NULL);
capwap_free(data);
}
2013-06-02 22:21:49 +02:00
/* */
static void* capwap_wtpradiostat_element_parsing(capwap_message_elements_handle handle, struct capwap_read_message_elements_ops* func) {
struct capwap_wtpradiostat_element* data;
ASSERT(handle != NULL);
ASSERT(func != NULL);
if (func->read_ready(handle) != 20) {
log_printf(LOG_DEBUG, "Invalid WTP Radio Statistics element: underbuffer");
2013-06-02 22:21:49 +02:00
return NULL;
}
/* Retrieve data */
data = (struct capwap_wtpradiostat_element*)capwap_alloc(sizeof(struct capwap_wtpradiostat_element));
2013-06-02 22:21:49 +02:00
func->read_u8(handle, &data->radioid);
if (!IS_VALID_RADIOID(data->radioid)) {
capwap_wtpradiostat_element_free((void*)data);
log_printf(LOG_DEBUG, "Invalid WTP Radio Statistics element: invalid radioid");
return NULL;
}
2013-06-02 22:21:49 +02:00
func->read_u8(handle, &data->lastfailtype);
func->read_u16(handle, &data->resetcount);
func->read_u16(handle, &data->swfailercount);
func->read_u16(handle, &data->hwfailercount);
func->read_u16(handle, &data->otherfailercount);
func->read_u16(handle, &data->unknownfailercount);
func->read_u16(handle, &data->configupdatecount);
func->read_u16(handle, &data->channelchangecount);
func->read_u16(handle, &data->bandchangecount);
func->read_u16(handle, &data->currentnoisefloor);
return data;
}
/* */
2016-03-07 18:07:46 +01:00
const struct capwap_message_elements_ops capwap_element_wtpradiostat_ops = {
.category = CAPWAP_MESSAGE_ELEMENT_SINGLE,
.create = capwap_wtpradiostat_element_create,
.parse = capwap_wtpradiostat_element_parsing,
.clone = capwap_wtpradiostat_element_clone,
.free = capwap_wtpradiostat_element_free
2013-06-02 22:21:49 +02:00
};