Improved handling of message elements parsed. Reduces the memory occupied but
it introduces a small overhead in retrieving of message elements parsed.
This commit is contained in:
@ -20,38 +20,14 @@ static void capwap_radioadmstate_element_create(void* data, capwap_message_eleme
|
||||
struct capwap_radioadmstate_element* element = (struct capwap_radioadmstate_element*)data;
|
||||
|
||||
ASSERT(data != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(element->radioid));
|
||||
ASSERT((element->state == CAPWAP_RADIO_ADMIN_STATE_ENABLED) || (element->state == CAPWAP_RADIO_ADMIN_STATE_DISABLED));
|
||||
|
||||
/* */
|
||||
func->write_u8(handle, element->radioid);
|
||||
func->write_u8(handle, element->state);
|
||||
}
|
||||
|
||||
/* */
|
||||
static void* capwap_radioadmstate_element_parsing(capwap_message_elements_handle handle, struct capwap_read_message_elements_ops* func) {
|
||||
struct capwap_radioadmstate_element* data;
|
||||
|
||||
ASSERT(handle != NULL);
|
||||
ASSERT(func != NULL);
|
||||
|
||||
if (func->read_ready(handle) != 2) {
|
||||
capwap_logging_debug("Invalid Radio Administrative State element");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
data = (struct capwap_radioadmstate_element*)capwap_alloc(sizeof(struct capwap_radioadmstate_element));
|
||||
if (!data) {
|
||||
capwap_outofmemory();
|
||||
}
|
||||
|
||||
/* Retrieve data */
|
||||
memset(data, 0, sizeof(struct capwap_radioadmstate_element));
|
||||
func->read_u8(handle, &data->radioid);
|
||||
func->read_u8(handle, &data->state);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* */
|
||||
static void capwap_radioadmstate_element_free(void* data) {
|
||||
ASSERT(data != NULL);
|
||||
@ -59,6 +35,41 @@ static void capwap_radioadmstate_element_free(void* data) {
|
||||
capwap_free(data);
|
||||
}
|
||||
|
||||
/* */
|
||||
static void* capwap_radioadmstate_element_parsing(capwap_message_elements_handle handle, struct capwap_read_message_elements_ops* func) {
|
||||
struct capwap_radioadmstate_element* data;
|
||||
|
||||
ASSERT(handle != NULL);
|
||||
ASSERT(func != NULL);
|
||||
|
||||
if (func->read_ready(handle) != 2) {
|
||||
capwap_logging_debug("Invalid Radio Administrative State element: underbuffer");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
data = (struct capwap_radioadmstate_element*)capwap_alloc(sizeof(struct capwap_radioadmstate_element));
|
||||
if (!data) {
|
||||
capwap_outofmemory();
|
||||
}
|
||||
|
||||
/* Retrieve data */
|
||||
func->read_u8(handle, &data->radioid);
|
||||
func->read_u8(handle, &data->state);
|
||||
|
||||
if (!IS_VALID_RADIOID(data->radioid)) {
|
||||
capwap_radioadmstate_element_free((void*)data);
|
||||
capwap_logging_debug("Invalid Radio Administrative State element: invalid radioid");
|
||||
return NULL;
|
||||
} else if ((data->state != CAPWAP_RADIO_ADMIN_STATE_ENABLED) && (data->state != CAPWAP_RADIO_ADMIN_STATE_DISABLED)) {
|
||||
capwap_radioadmstate_element_free((void*)data);
|
||||
capwap_logging_debug("Invalid Radio Administrative State element: invalid state");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/* */
|
||||
struct capwap_message_elements_ops capwap_element_radioadmstate_ops = {
|
||||
.create_message_element = capwap_radioadmstate_element_create,
|
||||
|
Reference in New Issue
Block a user