comparison 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
comparison
equal deleted inserted replaced
108:0d6435808bcd 109:9b87894704eb
2 * Here we implement our handling of incoming SIP BYE requests. 2 * Here we implement our handling of incoming SIP BYE requests.
3 */ 3 */
4 4
5 #include <sys/types.h> 5 #include <sys/types.h>
6 #include <sys/socket.h> 6 #include <sys/socket.h>
7 #include <sys/time.h>
7 #include <netinet/in.h> 8 #include <netinet/in.h>
8 #include <stdio.h> 9 #include <stdio.h>
9 #include <stdint.h> 10 #include <stdint.h>
10 #include <stdlib.h> 11 #include <stdlib.h>
11 #include <string.h> 12 #include <string.h>
16 #include "../libsip/uas_basic.h" 17 #include "../libsip/uas_basic.h"
17 #include "../libsip/out_msg.h" 18 #include "../libsip/out_msg.h"
18 #include "call.h" 19 #include "call.h"
19 20
20 extern struct call *find_call_by_sip_id(); 21 extern struct call *find_call_by_sip_id();
22
23 extern unsigned sip_linger_gotbye;
24 extern unsigned sip_linger_error;
21 25
22 void 26 void
23 handle_sip_bye(req, ess, sin) 27 handle_sip_bye(req, ess, sin)
24 struct sip_pkt_rx *req; 28 struct sip_pkt_rx *req;
25 struct uas_parse_hdrs *ess; 29 struct uas_parse_hdrs *ess;
56 call->overall_state = OVERALL_STATE_TEARDOWN; 60 call->overall_state = OVERALL_STATE_TEARDOWN;
57 disconnect_mncc(call, GSM48_CAUSE_LOC_NET_BEYOND, 61 disconnect_mncc(call, GSM48_CAUSE_LOC_NET_BEYOND,
58 GSM48_CC_CAUSE_NORM_CALL_CLEAR); 62 GSM48_CC_CAUSE_NORM_CALL_CLEAR);
59 disconnect_tmgw(call); 63 disconnect_tmgw(call);
60 call->sip_state = SIP_STATE_ENDED; 64 call->sip_state = SIP_STATE_ENDED;
65 sip_mark_end_time(call, sip_linger_gotbye);
61 break; 66 break;
62 case SIP_STATE_BYE_SENT: 67 case SIP_STATE_BYE_SENT:
63 call->sip_state = SIP_STATE_ENDED; 68 call->sip_state = SIP_STATE_ENDED;
69 sip_mark_end_time(call, sip_linger_gotbye);
64 break; 70 break;
65 case SIP_STATE_INVITE_ERR: 71 case SIP_STATE_INVITE_ERR:
66 case SIP_STATE_ENDED: 72 case SIP_STATE_ENDED:
67 break; 73 break;
68 case SIP_STATE_MSG_SIZE_ERR: 74 case SIP_STATE_MSG_SIZE_ERR:
72 start_response_out_msg(&resp, "200 OK"); 78 start_response_out_msg(&resp, "200 OK");
73 rc = out_msg_add_header(&resp, "From", call->invite_from); 79 rc = out_msg_add_header(&resp, "From", call->invite_from);
74 if (rc < 0) { 80 if (rc < 0) {
75 msg_size_err: syslog(LOG_ERR, "BYE 200 response length exceeded"); 81 msg_size_err: syslog(LOG_ERR, "BYE 200 response length exceeded");
76 call->sip_state = SIP_STATE_MSG_SIZE_ERR; 82 call->sip_state = SIP_STATE_MSG_SIZE_ERR;
83 sip_mark_end_time(call, sip_linger_error);
77 return; 84 return;
78 } 85 }
79 rc = out_msg_add_header(&resp, "To", call->invite_to); 86 rc = out_msg_add_header(&resp, "To", call->invite_to);
80 if (rc < 0) 87 if (rc < 0)
81 goto msg_size_err; 88 goto msg_size_err;