Ejemplo n.º 1
0
static void* capwap_80211_ie_element_clone(void* data) {
	struct capwap_80211_ie_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_80211_ie_element));
	cloneelement->ie = capwap_clone(((struct capwap_80211_ie_element*)data)->ie, cloneelement->ielength);

	return cloneelement;
}
Ejemplo n.º 2
0
static void* capwap_addmacacl_element_clone(void* data) {
	struct capwap_addmacacl_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_addmacacl_element));
	if (cloneelement->entry > 0) {
		cloneelement->address = capwap_clone(((struct capwap_addmacacl_element*)data)->address, cloneelement->entry * cloneelement->length);
	}

	return cloneelement;
}
static void* capwap_duplicateipv6_element_clone(void* data) {
	struct capwap_duplicateipv6_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_duplicateipv6_element));
	if (cloneelement->length > 0) {
		cloneelement->macaddress = capwap_clone(((struct capwap_duplicateipv6_element*)data)->macaddress, cloneelement->length);
	}

	return cloneelement;
}
Ejemplo n.º 4
0
static void* capwap_datatransferdata_element_clone(void* data) {
	struct capwap_datatransferdata_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_datatransferdata_element));
	if (cloneelement->length > 0) {
		cloneelement->data = capwap_clone(((struct capwap_datatransferdata_element*)data)->data, cloneelement->length);
	}

	return cloneelement;
}
static void* capwap_80211_addwlan_element_clone(void* data) {
	struct capwap_80211_addwlan_element* cloneelement;
	struct capwap_80211_addwlan_element* element = (struct capwap_80211_addwlan_element*)data;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_80211_addwlan_element));
	if (cloneelement->keylength > 0) {
		cloneelement->key = capwap_clone(element->key, cloneelement->keylength);
	}
	cloneelement->ssid = (uint8_t*)capwap_duplicate_string((char*)element->ssid);

	return cloneelement;
}
static void* capwap_addstation_element_clone(void* data) {
	struct capwap_addstation_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_addstation_element));
	if (cloneelement->length > 0) {
		cloneelement->address = capwap_clone(((struct capwap_addstation_element*)data)->address, cloneelement->length);
	}

	if (cloneelement->vlan) {
		cloneelement->vlan = (uint8_t*)capwap_duplicate_string((char*)((struct capwap_addstation_element*)data)->vlan);
	}

	return cloneelement;
}
Ejemplo n.º 7
0
int capwap_decrypt_packet(struct capwap_dtls* dtls, void* encrybuffer, int size, void* plainbuffer, int maxsize) {
	int sslerror;
	int result = -1;
	char* clone = NULL;
	
	ASSERT(dtls != NULL);
	ASSERT(dtls->enable != 0);
	ASSERT((dtls->action == CAPWAP_DTLS_ACTION_HANDSHAKE) || (dtls->action == CAPWAP_DTLS_ACTION_DATA));
	ASSERT(dtls->buffer == NULL);
	ASSERT(dtls->length == 0);
	ASSERT(encrybuffer != NULL);
	ASSERT(size > 0);
	ASSERT(maxsize > 0);

	/* */
	if (!plainbuffer) {
		clone = capwap_clone(encrybuffer, size);
	}

	dtls->buffer = (clone ? clone : encrybuffer);
	dtls->length = size;

	/* */	
	if (dtls->action == CAPWAP_DTLS_ACTION_HANDSHAKE) {
		if (capwap_crypt_handshake(dtls) == CAPWAP_HANDSHAKE_ERROR) {
			capwap_logging_debug("Error in DTLS handshake");
			result = CAPWAP_ERROR_CLOSE;			/* Error handshake */
		} else {
			result = CAPWAP_ERROR_AGAIN;			/* Don't parsing DTLS packet */
		}
	} else if (dtls->action == CAPWAP_DTLS_ACTION_DATA) {
		result = CyaSSL_read((CYASSL*)dtls->sslsession, (plainbuffer ? plainbuffer : encrybuffer), maxsize);
		if (!result) {
			dtls->action = CAPWAP_DTLS_ACTION_SHUTDOWN;
			result = CAPWAP_ERROR_SHUTDOWN;
		} else if (result < 0) {
			/* Check error */
			sslerror = CyaSSL_get_error((CYASSL*)dtls->sslsession, 0);
			if ((sslerror == SSL_ERROR_WANT_READ) || (sslerror == SSL_ERROR_WANT_WRITE)) {
				result = CAPWAP_ERROR_AGAIN;			/* DTLS Renegotiation */
			} else {
				result = CAPWAP_ERROR_CLOSE;
			}
		}
	}

	/* Verify BIO read */
	ASSERT(dtls->buffer == NULL);
	ASSERT(dtls->length == 0);

	/* Free clone */
	if (clone) {
		capwap_free(clone);
	}
	
	return result;
}
static void* capwap_location_element_clone(void* data) {
	struct capwap_location_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_location_element));
	cloneelement->value = (uint8_t*)capwap_duplicate_string((char*)((struct capwap_location_element*)data)->value);

	return cloneelement;
}
Ejemplo n.º 9
0
static void* capwap_acname_element_clone(void* data) {
	struct capwap_acname_element* cloneelement;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_acname_element));
	if (cloneelement->name) {
		cloneelement->name = (uint8_t*)capwap_duplicate_string((char*)((struct capwap_acname_element*)data)->name);
	}

	return cloneelement;
}
Ejemplo n.º 10
0
static void* capwap_acdescriptor_element_clone(void* data) {
	int i;
	struct capwap_acdescriptor_element* cloneelement;
	struct capwap_acdescriptor_element* element = (struct capwap_acdescriptor_element*)data;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_acdescriptor_element));
	cloneelement->descsubelement = capwap_array_create(sizeof(struct capwap_acdescriptor_desc_subelement), 0, 1);
	for (i = 0; i < element->descsubelement->count; i++) {
		struct capwap_acdescriptor_desc_subelement* desc = (struct capwap_acdescriptor_desc_subelement*)capwap_array_get_item_pointer(element->descsubelement, i);
		struct capwap_acdescriptor_desc_subelement* clonedesc = (struct capwap_acdescriptor_desc_subelement*)capwap_array_get_item_pointer(cloneelement->descsubelement, i);

		memcpy(clonedesc, desc, sizeof(struct capwap_acdescriptor_desc_subelement));
		if (desc->length) {
			clonedesc->data = capwap_clone(desc->data, desc->length);
		}
	}

	return cloneelement;
}
static void* capwap_80211_antenna_element_clone(void* data) {
	int i;
	struct capwap_80211_antenna_element* cloneelement;
	struct capwap_80211_antenna_element* element = (struct capwap_80211_antenna_element*)data;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_80211_antenna_element));
	cloneelement->selections = capwap_array_create(sizeof(uint8_t), 0, 1);
	for (i = 0; i < element->selections->count; i++) {
		memcpy(capwap_array_get_item_pointer(cloneelement->selections, i), capwap_array_get_item_pointer(element->selections, i), sizeof(uint8_t));
	}

	return cloneelement;
}
Ejemplo n.º 12
0
static void* capwap_acipv6list_element_clone(void* data) {
	int i;
	struct capwap_acipv6list_element* cloneelement;
	struct capwap_acipv6list_element* element = (struct capwap_acipv6list_element*)data;

	ASSERT(data != NULL);

	cloneelement = capwap_clone(data, sizeof(struct capwap_acipv6list_element));
	cloneelement->addresses = capwap_array_create(sizeof(struct in6_addr), 0, 0);
	for (i = 0; i < element->addresses->count; i++) {
		memcpy(capwap_array_get_item_pointer(cloneelement->addresses, i), capwap_array_get_item_pointer(element->addresses, i), sizeof(struct in6_addr));
	}

	return cloneelement;
}
static void* capwap_radioadmstate_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_radioadmstate_element));
}
Ejemplo n.º 14
0
static void* capwap_discoverytype_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_discoverytype_element));
}
Ejemplo n.º 15
0
static void* capwap_idletimeout_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_idletimeout_element));
}
Ejemplo n.º 16
0
static void* capwap_wtpfallback_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_wtpfallback_element));
}
static void* capwap_80211_deletewlan_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_80211_deletewlan_element));
}
static void* capwap_maximumlength_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_maximumlength_element));
}
static void* capwap_wtpstaticipaddress_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_wtpstaticipaddress_element));
}
static void* capwap_80211_updatestationqos_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_80211_updatestationqos_element));
}
static void* capwap_decrypterrorreportperiod_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_decrypterrorreportperiod_element));
}
static void* capwap_80211_multidomaincapability_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_80211_multidomaincapability_element));
}
static void* capwap_imageinfo_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_imageinfo_element));
}
static void* capwap_80211_ofdmcontrol_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_80211_ofdmcontrol_element));
}
Ejemplo n.º 25
0
static void* capwap_localipv4_element_clone(void* data) {
	ASSERT(data != NULL);

	return capwap_clone(data, sizeof(struct capwap_localipv4_element));
}