diff sip-in/bye_in.c @ 109:9b87894704eb

sip-in: first step toward final call clearing
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 28 Sep 2022 16:32:13 -0800
parents 0d6435808bcd
children c1c94b7fc2e2
line wrap: on
line diff
--- a/sip-in/bye_in.c	Wed Sep 28 14:29:10 2022 -0800
+++ b/sip-in/bye_in.c	Wed Sep 28 16:32:13 2022 -0800
@@ -4,6 +4,7 @@
 
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/time.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdint.h>
@@ -19,6 +20,9 @@
 
 extern struct call *find_call_by_sip_id();
 
+extern unsigned sip_linger_gotbye;
+extern unsigned sip_linger_error;
+
 void
 handle_sip_bye(req, ess, sin)
 	struct sip_pkt_rx *req;
@@ -58,9 +62,11 @@
 				GSM48_CC_CAUSE_NORM_CALL_CLEAR);
 		disconnect_tmgw(call);
 		call->sip_state = SIP_STATE_ENDED;
+		sip_mark_end_time(call, sip_linger_gotbye);
 		break;
 	case SIP_STATE_BYE_SENT:
 		call->sip_state = SIP_STATE_ENDED;
+		sip_mark_end_time(call, sip_linger_gotbye);
 		break;
 	case SIP_STATE_INVITE_ERR:
 	case SIP_STATE_ENDED:
@@ -74,6 +80,7 @@
 	if (rc < 0) {
 msg_size_err:	syslog(LOG_ERR, "BYE 200 response length exceeded");
 		call->sip_state = SIP_STATE_MSG_SIZE_ERR;
+		sip_mark_end_time(call, sip_linger_error);
 		return;
 	}
 	rc = out_msg_add_header(&resp, "To", call->invite_to);