comparison sip-out/disconnect.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/disconnect.c@e499e8db8b82
children
comparison
equal deleted inserted replaced
153:99fd4ae573ae 154:e54b0a9e322f
1 /*
2 * In this module we implement call disconnection and clearing procedures.
3 */
4
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <sys/time.h>
8 #include <netinet/in.h>
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <string.h>
13 #include <strings.h>
14 #include <syslog.h>
15 #include "../include/mncc.h"
16 #include "../include/gsm48_const.h"
17 #include "../include/out_routes.h"
18 #include "call.h"
19
20 extern unsigned sip_linger_timeout;
21
22 void
23 disconnect_mncc(call, cause_loc, cause_val)
24 struct call *call;
25 {
26 struct gsm_mncc msg;
27
28 if (!call->mncc)
29 return;
30 switch (call->mncc_state) {
31 case MNCC_STATE_DISCONNECT:
32 case MNCC_STATE_RELEASE:
33 return;
34 }
35 bzero(&msg, sizeof(struct gsm_mncc));
36 msg.msg_type = MNCC_DISC_REQ;
37 msg.callref = call->mncc_callref;
38 mncc_set_cause(&msg, cause_loc, cause_val);
39 send_mncc_to_sock(call->mncc, &msg, sizeof(struct gsm_mncc));
40 call->mncc_state = MNCC_STATE_DISCONNECT;
41 }
42
43 void
44 disconnect_tmgw(call)
45 struct call *call;
46 {
47 switch (call->mgw_state) {
48 case MGW_STATE_NO_EXIST:
49 case MGW_STATE_DELETING:
50 case MGW_STATE_MDCX_IBT:
51 case MGW_STATE_MDCX_CONN:
52 case MGW_STATE_MDCX_HOLD:
53 case MGW_STATE_MDCX_RETR:
54 case MGW_STATE_DTMF_OP:
55 return;
56 case MGW_STATE_ALLOCATED:
57 case MGW_STATE_IBT_CONN:
58 case MGW_STATE_COMPLETE:
59 case MGW_STATE_HELD:
60 tmgw_send_dlcx(call);
61 return;
62 default:
63 syslog(LOG_CRIT,
64 "FATAL: invalid MGW state 0x%x in disconnect_tmgw()",
65 call->mgw_state);
66 exit(1);
67 }
68 }
69
70 void
71 disconnect_sip(call)
72 struct call *call;
73 {
74 if (!call->sip_call_exists)
75 return;
76 switch (call->sip_state) {
77 case SIP_STATE_INV_SENT:
78 call->sip_state = SIP_STATE_ACCEPT_100;
79 sip_mark_end_time(call, sip_linger_timeout);
80 break;
81 case SIP_STATE_100_RCVD:
82 initiate_sip_cancel(call);
83 break;
84 case SIP_STATE_CONNECTED:
85 initiate_bye(call);
86 break;
87 }
88 }