FreeCalypso > hg > themwi-system-sw
diff sip-out/call_list.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/call_list.c@6aa63cf4620a |
children | bfa9f0c0f0ac |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sip-out/call_list.c Tue Oct 11 23:04:01 2022 -0800 @@ -0,0 +1,80 @@ +/* + * In this module we implement call list management for themwi-sip-out. + */ + +#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/out_routes.h" +#include "call.h" + +struct call *call_list; + +struct call * +find_call_by_sip_id(sought_id) + char *sought_id; +{ + struct call *call; + + for (call = call_list; call; call = call->next) { + if (!call->sip_call_exists) + continue; + if (!strcmp(call->sip_call_id, sought_id)) + return call; + } + return 0; +} + +struct call * +find_call_by_mncc_callref(mncc, callref) + struct mncc_conn *mncc; + uint32_t callref; +{ + struct call *call; + + for (call = call_list; call; call = call->next) + if (call->mncc == mncc && call->mncc_callref == callref) + return call; + return 0; +} + +void +scan_call_list_for_timeouts(retrans, dead_sip_flag, dead_sip_time) + int *retrans, *dead_sip_flag; + time_t *dead_sip_time; +{ + struct call *call; + int got_dead_sip = 0; + + for (call = call_list; call; call = call->next) { + if (!call->sip_call_exists) + continue; + switch (call->sip_state) { + case SIP_STATE_INV_SENT: + case SIP_STATE_CANCEL_SENT: + case SIP_STATE_BYE_SENT: + *retrans = 1; + break; + case SIP_STATE_ACCEPT_100: + case SIP_STATE_ACCEPT_200: + case SIP_STATE_ENDED: + if (call->overall_state != OVERALL_STATE_SIP_FINISH) + continue; + if (got_dead_sip) { + if (call->sip_clear_time < *dead_sip_time) + *dead_sip_time = call->sip_clear_time; + } else { + got_dead_sip = 1; + *dead_sip_flag = 1; + *dead_sip_time = call->sip_clear_time; + } + } + } +}