annotate sip-in/mgw_ops.c @ 141:e499e8db8b82

sip-in: handle call hold and retrieve
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 08 Oct 2022 13:28:30 -0800
parents 5685412bd6aa
children 0ecbc3dc8f93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement all transactions from themwi-sip-in
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * toward themwi-mgw.
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/socket.h>
109
9b87894704eb sip-in: first step toward final call clearing
Mychaela Falconia <falcon@freecalypso.org>
parents: 98
diff changeset
8 #include <sys/time.h>
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <netinet/in.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdio.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdint.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdlib.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <string.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <strings.h>
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <syslog.h>
98
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
16 #include "../include/gsm48_const.h"
141
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
17 #include "../include/mncc.h"
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include "../include/tmgw_ctrl.h"
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include "../include/tmgw_const.h"
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 #include "call.h"
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 extern struct call *call_list;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct call *
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 find_call_with_mgw_xact(xact_id)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 uint32_t xact_id;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 for (call = call_list; call; call = call->next)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 if (call->mgw_xact && call->mgw_xact_id == xact_id)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 return call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 return 0;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 uint32_t
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 get_new_tmgw_xact_id()
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 static uint32_t next_xact_id;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 for (;;) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 next_xact_id++;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (!find_call_with_mgw_xact(next_xact_id))
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 return next_xact_id;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 void
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 tmgw_send_crcx(call)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 struct tmgw_ctrl_req req;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 bzero(&req, sizeof req);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 req.opcode = TMGW_CTRL_OP_CRCX;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 req.transact_ref = get_new_tmgw_xact_id();
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 req.ep_id = TMGW_EP_TYPE_GATEWAY;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 req.setup_mask = TMGW_CTRL_MASK_PSTN_CONN;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 bcopy(&call->pstn_rtp_remote, &req.pstn_addr,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 sizeof(struct sockaddr_in));
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 req.pstn_payload_type =
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 call->use_pcma ? PSTN_CODEC_PCMA : PSTN_CODEC_PCMU;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 send_req_to_tmgw(&req);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 call->mgw_xact = TMGW_CTRL_OP_CRCX;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 call->mgw_xact_id = req.transact_ref;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 void
86
f332ccc240f1 sip-in: preparations toward TMGW connect-through
Mychaela Falconia <falcon@freecalypso.org>
parents: 62
diff changeset
69 tmgw_send_mdcx_connect(call)
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 struct tmgw_ctrl_req req;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 bzero(&req, sizeof req);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 req.opcode = TMGW_CTRL_OP_MDCX;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 req.transact_ref = get_new_tmgw_xact_id();
61
e12036337412 sip-in/mgw_ops.c: fix double semicolon
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
77 req.ep_id = call->mgw_ep_id;
86
f332ccc240f1 sip-in: preparations toward TMGW connect-through
Mychaela Falconia <falcon@freecalypso.org>
parents: 62
diff changeset
78 req.setup_mask = TMGW_CTRL_MASK_GSM_CONN | TMGW_CTRL_MASK_FWD_MODE;
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 bcopy(&call->gsm_rtp_osmo, &req.gsm_addr,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 sizeof(struct sockaddr_storage));
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 req.gsm_payload_type = call->gsm_payload_type;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 req.gsm_payload_msg_type = call->gsm_payload_msg_type;
86
f332ccc240f1 sip-in: preparations toward TMGW connect-through
Mychaela Falconia <falcon@freecalypso.org>
parents: 62
diff changeset
83 req.fwd_mode = TMGW_FWD_MODE_SENDRECV;
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 send_req_to_tmgw(&req);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 call->mgw_state = MGW_STATE_CONNECTING;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 call->mgw_xact = TMGW_CTRL_OP_MDCX;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 call->mgw_xact_id = req.transact_ref;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 void
141
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
91 tmgw_send_mdcx_hold(call)
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
92 struct call *call;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
93 {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
94 struct tmgw_ctrl_req req;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
95
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
96 bzero(&req, sizeof req);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
97 req.opcode = TMGW_CTRL_OP_MDCX;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
98 req.transact_ref = get_new_tmgw_xact_id();
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
99 req.ep_id = call->mgw_ep_id;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
100 req.setup_mask = TMGW_CTRL_MASK_FWD_MODE;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
101 req.fwd_mode = TMGW_FWD_MODE_INACTIVE;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
102 send_req_to_tmgw(&req);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
103 call->mgw_state = MGW_STATE_HOLD_OP;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
104 call->mgw_xact = TMGW_CTRL_OP_MDCX;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
105 call->mgw_xact_id = req.transact_ref;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
106 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
107
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
108 void
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
109 tmgw_send_mdcx_retrieve(call)
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
110 struct call *call;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
111 {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
112 struct tmgw_ctrl_req req;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
113
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
114 bzero(&req, sizeof req);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
115 req.opcode = TMGW_CTRL_OP_MDCX;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
116 req.transact_ref = get_new_tmgw_xact_id();
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
117 req.ep_id = call->mgw_ep_id;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
118 req.setup_mask = TMGW_CTRL_MASK_FWD_MODE;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
119 req.fwd_mode = TMGW_FWD_MODE_SENDRECV;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
120 send_req_to_tmgw(&req);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
121 call->mgw_state = MGW_STATE_RETRIEVE_OP;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
122 call->mgw_xact = TMGW_CTRL_OP_MDCX;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
123 call->mgw_xact_id = req.transact_ref;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
124 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
125
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
126 void
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 tmgw_send_dlcx(call)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 struct tmgw_ctrl_req req;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 bzero(&req, sizeof req);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 req.opcode = TMGW_CTRL_OP_DLCX;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 req.transact_ref = get_new_tmgw_xact_id();
61
e12036337412 sip-in/mgw_ops.c: fix double semicolon
Mychaela Falconia <falcon@freecalypso.org>
parents: 60
diff changeset
135 req.ep_id = call->mgw_ep_id;
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 send_req_to_tmgw(&req);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 call->mgw_state = MGW_STATE_DELETING;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 call->mgw_xact = TMGW_CTRL_OP_DLCX;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 call->mgw_xact_id = req.transact_ref;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141
128
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
142 void
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
143 tmgw_send_dtmf_start(call)
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
144 struct call *call;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
145 {
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
146 struct tmgw_ctrl_req req;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
147
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
148 bzero(&req, sizeof req);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
149 req.opcode = TMGW_CTRL_OP_DTMF_START;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
150 req.transact_ref = get_new_tmgw_xact_id();
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
151 req.ep_id = call->mgw_ep_id;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
152 req.fwd_mode = call->dtmf_digit;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
153 send_req_to_tmgw(&req);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
154 call->mgw_state = MGW_STATE_DTMF_OP;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
155 call->mgw_xact = TMGW_CTRL_OP_DTMF_START;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
156 call->mgw_xact_id = req.transact_ref;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
157 }
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
158
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
159 void
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
160 tmgw_send_dtmf_stop(call)
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
161 struct call *call;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
162 {
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
163 struct tmgw_ctrl_req req;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
164
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
165 bzero(&req, sizeof req);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
166 req.opcode = TMGW_CTRL_OP_DTMF_STOP;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
167 req.transact_ref = get_new_tmgw_xact_id();
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
168 req.ep_id = call->mgw_ep_id;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
169 send_req_to_tmgw(&req);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
170 call->mgw_state = MGW_STATE_DTMF_OP;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
171 call->mgw_xact = TMGW_CTRL_OP_DTMF_STOP;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
172 call->mgw_xact_id = req.transact_ref;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
173 }
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
174
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 static void
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 handle_crcx_fail(call, msg)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 struct tmgw_ctrl_resp *msg;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 call->overall_state = OVERALL_STATE_TEARDOWN;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 strcpy(call->invite_fail, "503 Gateway resource allocation failure");
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 signal_invite_error(call);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 static void
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 crcx_response(call, msg)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 struct tmgw_ctrl_resp *msg;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 if (msg->res == TMGW_RESP_OK) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 call->mgw_state = MGW_STATE_ALLOCATED;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 call->mgw_ep_id = msg->ep_id;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 bcopy(&msg->gsm_addr, &call->gsm_rtp_tmgw,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 sizeof(struct sockaddr_storage));
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 bcopy(&msg->pstn_addr, &call->pstn_rtp_local,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 sizeof(struct sockaddr_in));
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 switch (call->overall_state) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 case OVERALL_STATE_CRCX:
62
75b7a7b61824 sip-in: got as far as sending MNCC_SETUP_REQ to themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents: 61
diff changeset
199 proceed_with_call_setup(call);
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 return;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 case OVERALL_STATE_TEARDOWN:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 tmgw_send_dlcx(call);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 return;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 default:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 bad_state:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 syslog(LOG_CRIT,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 "FATAL: invalid overall state 0x%x on CRCX response",
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 call->overall_state);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 exit(1);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 } else {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 switch (call->overall_state) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 case OVERALL_STATE_CRCX:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 handle_crcx_fail(call, msg);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 return;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216 case OVERALL_STATE_TEARDOWN:
110
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
217 transition_dead_sip(call);
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 return;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 default:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 goto bad_state;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225 static void
141
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
226 handle_mdcx_connect_fail(call, msg)
98
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
227 struct call *call;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
228 struct tmgw_ctrl_resp *msg;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
229 {
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
230 call->overall_state = OVERALL_STATE_TEARDOWN;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
231 switch (msg->res) {
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
232 case TMGW_RESP_ERR_RSRC:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
233 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
234 GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
235 strcpy(call->invite_fail,
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
236 "503 Gateway resource allocation failure");
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
237 break;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
238 case TMGW_RESP_ERR_NOTSUP:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
239 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
240 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
241 strcpy(call->invite_fail, "502 Gateway internal error");
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
242 break;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
243 default:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
244 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
245 GSM48_CC_CAUSE_PROTO_ERR);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
246 strcpy(call->invite_fail, "502 Gateway internal error");
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
247 }
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
248 signal_invite_error(call);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
249 }
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
250
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
251 static void
141
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
252 mdcx_connect_response(call, msg)
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
253 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
254 struct tmgw_ctrl_resp *msg;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
255 {
98
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
256 if (msg->res == TMGW_RESP_OK) {
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
257 call->mgw_state = MGW_STATE_COMPLETE;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
258 switch (call->overall_state) {
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
259 case OVERALL_STATE_ANSWERED:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
260 signal_invite_200(call);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
261 return;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
262 case OVERALL_STATE_TEARDOWN:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
263 tmgw_send_dlcx(call);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
264 return;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
265 default:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
266 bad_state:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
267 syslog(LOG_CRIT,
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
268 "FATAL: invalid overall state 0x%x on MDCX response",
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
269 call->overall_state);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
270 exit(1);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
271 }
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
272 } else {
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
273 tmgw_send_dlcx(call);
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
274 switch (call->overall_state) {
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
275 case OVERALL_STATE_ANSWERED:
141
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
276 handle_mdcx_connect_fail(call, msg);
98
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
277 return;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
278 case OVERALL_STATE_TEARDOWN:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
279 return;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
280 default:
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
281 goto bad_state;
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
282 }
423610bb2c9e sip-in: send MDCX to TMGW to connect the call through
Mychaela Falconia <falcon@freecalypso.org>
parents: 86
diff changeset
283 }
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
284 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
285
141
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
286 static struct gsm_mncc_cause mgw_hold_retrieve_error = {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
287 .coding = GSM48_CAUSE_CODING_GSM,
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
288 .location = GSM48_CAUSE_LOC_PRN_S_LU,
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
289 .value = GSM48_CC_CAUSE_NETWORK_OOO,
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
290 };
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
291
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
292 static void
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
293 mdcx_hold_response(call, msg)
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
294 struct call *call;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
295 struct tmgw_ctrl_resp *msg;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
296 {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
297 if (call->overall_state == OVERALL_STATE_TEARDOWN) {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
298 tmgw_send_dlcx(call);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
299 return;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
300 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
301 if (msg->res == TMGW_RESP_OK) {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
302 call->mgw_state = MGW_STATE_HELD;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
303 mncc_send_hold_ack(call);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
304 } else {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
305 call->overall_state = OVERALL_STATE_TEARDOWN;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
306 tmgw_send_dlcx(call);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
307 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
308 GSM48_CC_CAUSE_NETWORK_OOO);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
309 disconnect_sip(call, &mgw_hold_retrieve_error);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
310 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
311 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
312
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
313 static void
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
314 mdcx_retrieve_response(call, msg)
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
315 struct call *call;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
316 struct tmgw_ctrl_resp *msg;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
317 {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
318 if (call->overall_state == OVERALL_STATE_TEARDOWN) {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
319 tmgw_send_dlcx(call);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
320 return;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
321 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
322 if (msg->res == TMGW_RESP_OK) {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
323 call->mgw_state = MGW_STATE_COMPLETE;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
324 mncc_send_retrieve_ack(call);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
325 } else {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
326 call->overall_state = OVERALL_STATE_TEARDOWN;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
327 tmgw_send_dlcx(call);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
328 disconnect_mncc(call, GSM48_CAUSE_LOC_PRN_S_LU,
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
329 GSM48_CC_CAUSE_NETWORK_OOO);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
330 disconnect_sip(call, &mgw_hold_retrieve_error);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
331 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
332 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
333
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
334 static void
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
335 mdcx_response(call, msg)
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
336 struct call *call;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
337 struct tmgw_ctrl_resp *msg;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
338 {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
339 switch (call->mgw_state) {
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
340 case MGW_STATE_CONNECTING:
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
341 mdcx_connect_response(call, msg);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
342 return;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
343 case MGW_STATE_HOLD_OP:
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
344 mdcx_hold_response(call, msg);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
345 return;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
346 case MGW_STATE_RETRIEVE_OP:
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
347 mdcx_retrieve_response(call, msg);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
348 return;
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
349 default:
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
350 syslog(LOG_CRIT,
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
351 "FATAL: invalid MGW state 0x%x on MDCX response",
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
352 call->mgw_state);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
353 exit(1);
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
354 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
355 }
e499e8db8b82 sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
356
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
357 static void
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
358 dlcx_response(call, msg)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
359 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
360 struct tmgw_ctrl_resp *msg;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
361 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
362 if (msg->res != TMGW_RESP_OK) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
363 syslog(LOG_CRIT, "FATAL: TMGW DLCX failed with code 0x%x",
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
364 msg->res);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
365 exit(1);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
366 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
367 call->mgw_state = MGW_STATE_NO_EXIST;
110
c1c94b7fc2e2 sip-in call clearing: DEAD_SIP transition implemented
Mychaela Falconia <falcon@freecalypso.org>
parents: 109
diff changeset
368 transition_dead_sip(call);
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
369 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
370
128
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
371 static void
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
372 dtmf_start_response(call, msg)
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
373 struct call *call;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
374 struct tmgw_ctrl_resp *msg;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
375 {
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
376 if (call->overall_state == OVERALL_STATE_TEARDOWN) {
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
377 tmgw_send_dlcx(call);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
378 return;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
379 }
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
380 if (msg->res == TMGW_RESP_OK)
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
381 mncc_dtmf_start_ok(call);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
382 else
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
383 mncc_dtmf_start_err(call);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
384 if (call->dtmf_pending_stop)
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
385 tmgw_send_dtmf_stop(call);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
386 else
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
387 call->mgw_state = MGW_STATE_COMPLETE;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
388 }
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
389
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
390 static void
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
391 dtmf_stop_response(call, msg)
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
392 struct call *call;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
393 struct tmgw_ctrl_resp *msg;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
394 {
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
395 if (call->overall_state == OVERALL_STATE_TEARDOWN) {
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
396 tmgw_send_dlcx(call);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
397 return;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
398 }
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
399 mncc_dtmf_stop_ok(call);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
400 call->mgw_state = MGW_STATE_COMPLETE;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
401 call->dtmf_pending_stop = 0;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
402 }
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
403
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
404 void
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
405 process_tmgw_response(msg)
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
406 struct tmgw_ctrl_resp *msg;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
407 {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
408 struct call *call;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
409 unsigned opc;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
410
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
411 call = find_call_with_mgw_xact(msg->transact_ref);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
412 if (!call) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
413 syslog(LOG_CRIT,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
414 "FATAL: response from TMGW xact 0x%x does not match any call",
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
415 msg->transact_ref);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
416 exit(1);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
417 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
418 opc = call->mgw_xact;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
419 call->mgw_xact = 0;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
420 switch (opc) {
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
421 case TMGW_CTRL_OP_CRCX:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
422 crcx_response(call, msg);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
423 return;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
424 case TMGW_CTRL_OP_MDCX:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
425 mdcx_response(call, msg);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
426 return;
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
427 case TMGW_CTRL_OP_DLCX:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
428 dlcx_response(call, msg);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
429 return;
128
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
430 case TMGW_CTRL_OP_DTMF_START:
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
431 dtmf_start_response(call, msg);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
432 return;
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
433 case TMGW_CTRL_OP_DTMF_STOP:
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
434 dtmf_stop_response(call, msg);
5685412bd6aa sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 110
diff changeset
435 return;
60
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
436 default:
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
437 syslog(LOG_CRIT,
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
438 "FATAL: invalid opcode 0x%x in call->msg_xact", opc);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
439 exit(1);
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
440 }
02761f1ae5e5 sip-in INVITE processing: got as far as CRCX completion
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
441 }