Reengineering the timeout manager. Allows to create an arbitrary number of timer
with the possibility to invoke a callback function on timeout.
This commit is contained in:
@ -33,9 +33,9 @@ void wtp_send_datacheck(void) {
|
||||
|
||||
/* Send Change State Event request to AC */
|
||||
if (capwap_crypt_sendto_fragmentpacket(&g_wtp.ctrldtls, g_wtp.acctrlsock.socket[g_wtp.acctrlsock.type], g_wtp.requestfragmentpacket, &g_wtp.wtpctrladdress, &g_wtp.acctrladdress)) {
|
||||
g_wtp.dfa.rfcRetransmitCount = 0;
|
||||
capwap_timeout_set(g_wtp.dfa.rfcRetransmitInterval, g_wtp.timeout, CAPWAP_TIMER_CONTROL_CONNECTION);
|
||||
g_wtp.retransmitcount = 0;
|
||||
wtp_dfa_change_state(CAPWAP_DATA_CHECK_STATE);
|
||||
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL, wtp_dfa_retransmition_timeout, NULL, NULL);
|
||||
} else {
|
||||
/* Error to send packets */
|
||||
capwap_logging_debug("Warning: error to send change state event request packet");
|
||||
@ -49,37 +49,19 @@ void wtp_dfa_state_datacheck(struct capwap_parsed_packet* packet) {
|
||||
unsigned short binding;
|
||||
struct capwap_resultcode_element* resultcode;
|
||||
|
||||
if (packet) {
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (packet->rxmngpacket->isctrlpacket && (binding == g_wtp.binding) && (packet->rxmngpacket->ctrlmsg.type == CAPWAP_CHANGE_STATE_EVENT_RESPONSE) && ((g_wtp.localseqnumber - 1) == packet->rxmngpacket->ctrlmsg.seq)) {
|
||||
/* Valid packet, free request packet */
|
||||
wtp_free_reference_last_request();
|
||||
/* */
|
||||
binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
if (packet->rxmngpacket->isctrlpacket && (binding == g_wtp.binding) && (packet->rxmngpacket->ctrlmsg.type == CAPWAP_CHANGE_STATE_EVENT_RESPONSE) && ((g_wtp.localseqnumber - 1) == packet->rxmngpacket->ctrlmsg.seq)) {
|
||||
/* Valid packet, free request packet */
|
||||
wtp_free_reference_last_request();
|
||||
|
||||
/* Check the success of the Request */
|
||||
resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_RESULTCODE);
|
||||
if (resultcode && !CAPWAP_RESULTCODE_OK(resultcode->code)) {
|
||||
capwap_logging_warning("Receive Data Check Response with error: %d", (int)resultcode->code);
|
||||
wtp_teardown_connection();
|
||||
} else {
|
||||
/* TODO: gestione richiesta */
|
||||
wtp_start_datachannel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* No change state response received */
|
||||
g_wtp.dfa.rfcRetransmitCount++;
|
||||
if (g_wtp.dfa.rfcRetransmitCount >= g_wtp.dfa.rfcMaxRetransmit) {
|
||||
/* Timeout join state */
|
||||
wtp_free_reference_last_request();
|
||||
/* Check the success of the Request */
|
||||
resultcode = (struct capwap_resultcode_element*)capwap_get_message_element_data(packet, CAPWAP_ELEMENT_RESULTCODE);
|
||||
if (resultcode && !CAPWAP_RESULTCODE_OK(resultcode->code)) {
|
||||
capwap_logging_warning("Receive Data Check Response with error: %d", (int)resultcode->code);
|
||||
wtp_teardown_connection();
|
||||
} else {
|
||||
/* Retransmit change state request */
|
||||
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.ctrldtls, g_wtp.acctrlsock.socket[g_wtp.acctrlsock.type], g_wtp.requestfragmentpacket, &g_wtp.wtpctrladdress, &g_wtp.acctrladdress)) {
|
||||
capwap_logging_debug("Warning: error to send change state request packet");
|
||||
}
|
||||
|
||||
/* Update timeout */
|
||||
capwap_timeout_set(g_wtp.dfa.rfcRetransmitInterval, g_wtp.timeout, CAPWAP_TIMER_CONTROL_CONNECTION);
|
||||
wtp_start_datachannel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user