diff sip-in/bye_out.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 2c22b40408fb
children c1c94b7fc2e2
line wrap: on
line diff
--- a/sip-in/bye_out.c	Wed Sep 28 14:29:10 2022 -0800
+++ b/sip-in/bye_out.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 <arpa/inet.h>
 #include <stdio.h>
@@ -22,6 +23,8 @@
 extern struct in_addr sip_bind_ip;
 extern unsigned sip_bind_port;
 extern unsigned max_forwards;
+extern unsigned sip_linger_acked;
+extern unsigned sip_linger_error;
 
 fill_bye_out_msg(msg, call)
 	struct sip_msg_out *msg;
@@ -107,6 +110,11 @@
 	}
 	if (msg->status_code < 200)
 		return;
-	if (call->sip_state == SIP_STATE_BYE_SENT)
+	if (call->sip_state == SIP_STATE_BYE_SENT) {
 		call->sip_state = SIP_STATE_ENDED;
+		if (msg->status_code <= 299)
+			sip_mark_end_time(call, sip_linger_acked);
+		else
+			sip_mark_end_time(call, sip_linger_error);
+	}
 }