rework error exits path to simplify if statement

This commit is contained in:
Andreas Schultz 2016-03-26 20:22:25 +01:00
parent e92c257ac4
commit f85928e0b0
4 changed files with 34 additions and 23 deletions

View File

@ -119,16 +119,19 @@ void wtp_send_configure(void)
capwap_packet_txmng_free(txmngpacket);
/* Send Configuration Status request to AC */
if (capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
g_wtp.retransmitcount = 0;
wtp_dfa_change_state(CAPWAP_CONFIGURE_STATE);
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL, wtp_dfa_retransmition_timeout, NULL, NULL);
} else {
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
/* Error to send packets */
capwap_logging_debug("Warning: error to send configuration status request packet");
wtp_free_reference_last_request();
wtp_teardown_connection();
return;
}
g_wtp.retransmitcount = 0;
wtp_dfa_change_state(CAPWAP_CONFIGURE_STATE);
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL,
wtp_dfa_retransmition_timeout, NULL, NULL);
}
/* */

View File

@ -34,16 +34,19 @@ void wtp_send_datacheck(void)
capwap_packet_txmng_free(txmngpacket);
/* Send Change State Event request to AC */
if (capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
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 {
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
/* Error to send packets */
capwap_logging_debug("Warning: error to send change state event request packet");
wtp_free_reference_last_request();
wtp_teardown_connection();
return;
}
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);
}
/* */

View File

@ -77,16 +77,19 @@ void wtp_send_join(void)
capwap_packet_txmng_free(txmngpacket);
/* Send join request to AC */
if (capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
g_wtp.retransmitcount = 0;
wtp_dfa_change_state(CAPWAP_JOIN_STATE);
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL, wtp_dfa_retransmition_timeout, NULL, NULL);
} else {
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
/* Error to send packets */
capwap_logging_debug("Warning: error to send join request packet");
wtp_free_reference_last_request();
wtp_teardown_connection();
return;
}
g_wtp.retransmitcount = 0;
wtp_dfa_change_state(CAPWAP_JOIN_STATE);
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL,
wtp_dfa_retransmition_timeout, NULL, NULL);
}
/* */

View File

@ -30,15 +30,15 @@ static int send_echo_request(void)
capwap_packet_txmng_free(txmngpacket);
/* Send echo request to AC */
if (capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
result = 0;
} else {
if (!capwap_crypt_sendto_fragmentpacket(&g_wtp.dtls, g_wtp.requestfragmentpacket)) {
/* Error to send packets */
capwap_logging_debug("Warning: error to send echo request packet");
wtp_free_reference_last_request();
return result;
}
return result;
return 0;
}
/* */
@ -218,13 +218,15 @@ void wtp_dfa_state_run_echo_timeout(struct capwap_timeout* timeout, unsigned lon
void* context, void* param)
{
capwap_logging_debug("Send Echo Request");
if (!send_echo_request()) {
g_wtp.retransmitcount = 0;
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL, wtp_dfa_retransmition_timeout, NULL, NULL);
} else {
if (send_echo_request()) {
capwap_logging_error("Unable to send Echo Request");
wtp_teardown_connection();
return;
}
g_wtp.retransmitcount = 0;
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimercontrol, WTP_RETRANSMIT_INTERVAL,
wtp_dfa_retransmition_timeout, NULL, NULL);
}
/* */