Inserted zeroed param into create array function
This commit is contained in:
parent
49bf2dc5c9
commit
4f119771c0
@ -19,7 +19,7 @@ static int ac_init(void) {
|
||||
/* Network */
|
||||
capwap_network_init(&g_ac.net);
|
||||
g_ac.mtu = CAPWAP_MTU_DEFAULT;
|
||||
g_ac.binding = capwap_array_create(sizeof(unsigned short), 0);
|
||||
g_ac.binding = capwap_array_create(sizeof(uint16_t), 0, 0);
|
||||
g_ac.net.bind_sock_ctrl_port = CAPWAP_CONTROL_PORT;
|
||||
|
||||
/* Standard name */
|
||||
@ -31,7 +31,7 @@ static int ac_init(void) {
|
||||
g_ac.descriptor.security = 0;
|
||||
g_ac.descriptor.rmacfield = CAPWAP_ACDESC_RMACFIELD_NOTSUPPORTED;
|
||||
g_ac.descriptor.dtlspolicy = CAPWAP_ACDESC_CLEAR_DATA_CHANNEL_ENABLED;
|
||||
g_ac.descriptor.descsubelement = capwap_array_create(sizeof(struct capwap_acdescriptor_desc_subelement), 0);
|
||||
g_ac.descriptor.descsubelement = capwap_array_create(sizeof(struct capwap_acdescriptor_desc_subelement), 0, 1);
|
||||
|
||||
/* */
|
||||
g_ac.dfa.ecn.flag = CAPWAP_LIMITED_ECN_SUPPORT;
|
||||
@ -45,8 +45,8 @@ static int ac_init(void) {
|
||||
g_ac.dfa.wtpfallback.mode = AC_DEFAULT_WTP_FALLBACK_MODE;
|
||||
|
||||
/* */
|
||||
g_ac.dfa.acipv4list.addresses = capwap_array_create(sizeof(struct in_addr), 0);
|
||||
g_ac.dfa.acipv6list.addresses = capwap_array_create(sizeof(struct in6_addr), 0);
|
||||
g_ac.dfa.acipv4list.addresses = capwap_array_create(sizeof(struct in_addr), 0, 0);
|
||||
g_ac.dfa.acipv6list.addresses = capwap_array_create(sizeof(struct in6_addr), 0, 0);
|
||||
|
||||
/* */
|
||||
g_ac.dfa.rfcWaitJoin = AC_DEFAULT_WAITJOIN_INTERVAL;
|
||||
|
@ -30,8 +30,7 @@ int wifi_init_driver(void) {
|
||||
}
|
||||
|
||||
/* Device handler */
|
||||
wifi_device = capwap_array_create(sizeof(struct wifi_device), 0);
|
||||
wifi_device->zeroed = 1;
|
||||
wifi_device = capwap_array_create(sizeof(struct wifi_device), 0, 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include "capwap_array.h"
|
||||
|
||||
/* */
|
||||
struct capwap_array* capwap_array_create(unsigned short itemsize, unsigned long initcount) {
|
||||
struct capwap_array* capwap_array_create(unsigned short itemsize, unsigned long initcount, int zeroed) {
|
||||
struct capwap_array* array;
|
||||
|
||||
ASSERT(itemsize > 0);
|
||||
@ -14,6 +14,7 @@ struct capwap_array* capwap_array_create(unsigned short itemsize, unsigned long
|
||||
|
||||
memset(array, 0, sizeof(struct capwap_array));
|
||||
array->itemsize = itemsize;
|
||||
array->zeroed = zeroed;
|
||||
if (initcount > 0) {
|
||||
capwap_array_resize(array, initcount);
|
||||
}
|
||||
@ -28,9 +29,8 @@ struct capwap_array* capwap_array_clone(struct capwap_array* array) {
|
||||
ASSERT (array != NULL);
|
||||
|
||||
/* Clone array e items */
|
||||
clone = capwap_array_create(array->itemsize, array->count);
|
||||
clone = capwap_array_create(array->itemsize, array->count, array->zeroed);
|
||||
memcpy(clone->buffer, array->buffer, array->itemsize * array->count);
|
||||
clone->zeroed = array->zeroed;
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ struct capwap_array {
|
||||
int zeroed;
|
||||
};
|
||||
|
||||
struct capwap_array* capwap_array_create(unsigned short itemsize, unsigned long initcount);
|
||||
struct capwap_array* capwap_array_create(unsigned short itemsize, unsigned long initcount, int zeroed);
|
||||
struct capwap_array* capwap_array_clone(struct capwap_array* array);
|
||||
void capwap_array_free(struct capwap_array* array);
|
||||
void* capwap_array_get_item_pointer(struct capwap_array* array, unsigned long pos);
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#define ARRAY_PARSING_MESSAGE_ELEMENT(data, type) \
|
||||
type msgelement; \
|
||||
if (!data) { data = capwap_array_create(sizeof(type), 0); } \
|
||||
if (!data) { data = capwap_array_create(sizeof(type), 0, 0); } \
|
||||
msgelement = read_ops->parsing_message_element((capwap_message_elements_handle)rxmngpacket, &rxmngpacket->read_ops); \
|
||||
if (!msgelement) { return 1; } \
|
||||
memcpy(capwap_array_get_item_pointer(data, data->count), &msgelement, sizeof(type));
|
||||
|
@ -89,8 +89,7 @@ static void* capwap_acdescriptor_element_parsing(capwap_message_elements_handle
|
||||
}
|
||||
|
||||
memset(data, 0, sizeof(struct capwap_acdescriptor_element));
|
||||
data->descsubelement = capwap_array_create(sizeof(struct capwap_acdescriptor_desc_subelement), 0);
|
||||
data->descsubelement->zeroed = 1;
|
||||
data->descsubelement = capwap_array_create(sizeof(struct capwap_acdescriptor_desc_subelement), 0, 1);
|
||||
|
||||
/* Retrieve data */
|
||||
func->read_u16(handle, &data->stations);
|
||||
|
@ -49,7 +49,7 @@ static void* capwap_acipv4list_element_parsing(capwap_message_elements_handle ha
|
||||
}
|
||||
|
||||
/* Retrieve data */
|
||||
data->addresses = capwap_array_create(sizeof(struct in_addr), 0);
|
||||
data->addresses = capwap_array_create(sizeof(struct in_addr), 0, 0);
|
||||
while (length > 0) {
|
||||
struct in_addr* address = (struct in_addr*)capwap_array_get_item_pointer(data->addresses, data->addresses->count);
|
||||
func->read_block(handle, (uint8_t*)address, sizeof(struct in_addr));
|
||||
|
@ -55,7 +55,7 @@ static void* capwap_acipv6list_element_parsing(capwap_message_elements_handle ha
|
||||
}
|
||||
|
||||
/* Retrieve data */
|
||||
data->addresses = capwap_array_create(sizeof(struct in6_addr), 0);
|
||||
data->addresses = capwap_array_create(sizeof(struct in6_addr), 0, 0);
|
||||
while (length > 0) {
|
||||
struct in6_addr* address = (struct in6_addr*)capwap_array_get_item_pointer(data->addresses, data->addresses->count);
|
||||
func->read_block(handle, (uint8_t*)address, sizeof(struct in6_addr));
|
||||
|
@ -75,9 +75,7 @@ static void* capwap_wtpboarddata_element_parsing(capwap_message_elements_handle
|
||||
capwap_outofmemory();
|
||||
}
|
||||
|
||||
memset(data, 0, sizeof(struct capwap_wtpboarddata_element));
|
||||
data->boardsubelement = capwap_array_create(sizeof(struct capwap_wtpboarddata_board_subelement), 0);
|
||||
data->boardsubelement->zeroed = 1;
|
||||
data->boardsubelement = capwap_array_create(sizeof(struct capwap_wtpboarddata_board_subelement), 0, 1);
|
||||
|
||||
/* Retrieve data */
|
||||
func->read_u32(handle, &data->vendor);
|
||||
|
@ -98,11 +98,8 @@ static void* capwap_wtpdescriptor_element_parsing(capwap_message_elements_handle
|
||||
capwap_outofmemory();
|
||||
}
|
||||
|
||||
memset(data, 0, sizeof(struct capwap_wtpdescriptor_element));
|
||||
data->encryptsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_encrypt_subelement), 0);
|
||||
data->encryptsubelement->zeroed = 1;
|
||||
data->descsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_desc_subelement), 0);
|
||||
data->descsubelement->zeroed = 1;
|
||||
data->encryptsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_encrypt_subelement), 0, 0);
|
||||
data->descsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_desc_subelement), 0, 1);
|
||||
|
||||
/* Retrieve data */
|
||||
func->read_u8(handle, &data->maxradios);
|
||||
|
@ -46,9 +46,9 @@ static int wtp_init(void) {
|
||||
capwap_network_init(&g_wtp.net);
|
||||
|
||||
/* Standard configuration */
|
||||
g_wtp.boarddata.boardsubelement = capwap_array_create(sizeof(struct capwap_wtpboarddata_board_subelement), 0);
|
||||
g_wtp.descriptor.encryptsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_encrypt_subelement), 0);
|
||||
g_wtp.descriptor.descsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_desc_subelement), 0);
|
||||
g_wtp.boarddata.boardsubelement = capwap_array_create(sizeof(struct capwap_wtpboarddata_board_subelement), 0, 1);
|
||||
g_wtp.descriptor.encryptsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_encrypt_subelement), 0, 0);
|
||||
g_wtp.descriptor.descsubelement = capwap_array_create(sizeof(struct capwap_wtpdescriptor_desc_subelement), 0, 1);
|
||||
|
||||
g_wtp.binding = CAPWAP_WIRELESS_BINDING_NONE;
|
||||
|
||||
@ -70,12 +70,12 @@ static int wtp_init(void) {
|
||||
/* AC information */
|
||||
g_wtp.discoverytype.type = CAPWAP_ELEMENT_DISCOVERYTYPE_TYPE_UNKNOWN;
|
||||
g_wtp.acdiscoveryrequest = 1;
|
||||
g_wtp.acdiscoveryarray = capwap_array_create(sizeof(struct sockaddr_storage), 0);
|
||||
g_wtp.acpreferedarray = capwap_array_create(sizeof(struct sockaddr_storage), 0);
|
||||
g_wtp.acdiscoveryresponse = capwap_array_create(sizeof(struct wtp_discovery_response), 0);
|
||||
|
||||
g_wtp.acdiscoveryarray = capwap_array_create(sizeof(struct sockaddr_storage), 0, 0);
|
||||
g_wtp.acpreferedarray = capwap_array_create(sizeof(struct sockaddr_storage), 0, 0);
|
||||
g_wtp.acdiscoveryresponse = capwap_array_create(sizeof(struct wtp_discovery_response), 0, 1);
|
||||
|
||||
/* Radios */
|
||||
g_wtp.radios = capwap_array_create(sizeof(struct wtp_radio), 0);
|
||||
g_wtp.radios = capwap_array_create(sizeof(struct wtp_radio), 0, 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ int wtp_dfa_state_discovery(struct capwap_parsed_packet* packet, struct timeout_
|
||||
struct wtp_discovery_response* response = (struct wtp_discovery_response*)capwap_array_get_item_pointer(g_wtp.acdiscoveryresponse, g_wtp.acdiscoveryresponse->count);
|
||||
|
||||
/* Create controlipv4 */
|
||||
response->controlipv4 = capwap_array_create(sizeof(struct capwap_controlipv4_element), 0);
|
||||
response->controlipv4 = capwap_array_create(sizeof(struct capwap_controlipv4_element), 0, 0);
|
||||
for (i = 0; i < packet->messageelements.controlipv4->count; i++) {
|
||||
struct capwap_controlipv4_element* src = *(struct capwap_controlipv4_element**)capwap_array_get_item_pointer(packet->messageelements.controlipv4, i);
|
||||
struct capwap_controlipv4_element* dst = (struct capwap_controlipv4_element*)capwap_array_get_item_pointer(response->controlipv4, i);
|
||||
@ -45,7 +45,7 @@ int wtp_dfa_state_discovery(struct capwap_parsed_packet* packet, struct timeout_
|
||||
}
|
||||
|
||||
/* Create controlipv4 */
|
||||
response->controlipv6 = capwap_array_create(sizeof(struct capwap_controlipv6_element), 0);
|
||||
response->controlipv6 = capwap_array_create(sizeof(struct capwap_controlipv6_element), 0, 0);
|
||||
for (i = 0; i < packet->messageelements.controlipv6->count; i++) {
|
||||
struct capwap_controlipv6_element* src = *(struct capwap_controlipv6_element**)capwap_array_get_item_pointer(packet->messageelements.controlipv6, i);
|
||||
struct capwap_controlipv6_element* dst = (struct capwap_controlipv6_element*)capwap_array_get_item_pointer(response->controlipv6, i);
|
||||
|
Loading…
Reference in New Issue
Block a user