FreeCalypso > hg > themwi-system-sw
diff sip-out/retrans.c @ 154:e54b0a9e322f
beginning of themwi-sip-out
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 11 Oct 2022 23:04:01 -0800 |
parents | sip-in/retrans.c@bf3b19bf57e9 |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sip-out/retrans.c Tue Oct 11 23:04:01 2022 -0800 @@ -0,0 +1,74 @@ +/* + * In this module we handle retransmission of our outgoing SIP UAC packets. + */ + +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/time.h> +#include <netinet/in.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <syslog.h> +#include "../include/gsm48_const.h" +#include "../include/out_routes.h" +#include "../libsip/out_msg.h" +#include "call.h" + +extern unsigned cfg_retrans_count; +extern unsigned sip_linger_timeout; +extern unsigned sip_linger_bye_out_err; +extern struct call *call_list; + +void +run_periodic_retrans() +{ + struct call *call; + struct sip_msg_out msg; + + for (call = call_list; call; call = call->next) { + switch (call->sip_state) { + case SIP_STATE_INV_SENT: + if (call->sip_tx_count < cfg_retrans_count) { + fill_invite_req_msg(&msg, call); + sip_tx_packet(&msg, &call->udp_sin); + call->sip_tx_count++; + } else { + syslog(LOG_ERR, + "outbound INVITE retrans timeout"); + call->overall_state = OVERALL_STATE_TEARDOWN; + disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU, + GSM48_CC_CAUSE_DEST_OOO); + disconnect_tmgw(call); + call->sip_state = SIP_STATE_ACCEPT_100; + sip_mark_end_time(call, sip_linger_timeout); + } + break; + case SIP_STATE_CANCEL_SENT: + if (call->sip_tx_count < cfg_retrans_count) { + fill_cancel_req_msg(&msg, call); + sip_tx_packet(&msg, &call->udp_sin); + call->sip_tx_count++; + } else { + syslog(LOG_ERR, + "outbound CANCEL retrans timeout"); + call->sip_state = SIP_STATE_ACCEPT_200; + sip_mark_end_time(call, sip_linger_timeout); + } + break; + case SIP_STATE_BYE_SENT: + if (call->sip_tx_count < cfg_retrans_count) { + fill_bye_req_msg(&msg, call); + sip_tx_packet(&msg, &call->udp_sin); + call->sip_tx_count++; + } else { + syslog(LOG_ERR, "outbound BYE retrans timeout"); + call->sip_state = SIP_STATE_ENDED; + sip_mark_end_time(call, sip_linger_bye_out_err); + } + break; + } + } +}