FreeCalypso > hg > themwi-system-sw
annotate sip-out/mncc_sig_in.c @ 184:f8c40090a0a8
librtpalloc: new library for talking to themwi-rtp-mgr
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 11 Mar 2023 23:48:14 -0800 |
parents | e54b0a9e322f |
children |
rev | line source |
---|---|
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement our handling of call control messages |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * from OsmoMSC relayed to us via themwi-mncc. |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
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> |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <netinet/in.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdio.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdint.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdlib.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <string.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <strings.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <syslog.h> |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../include/mncc.h" |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "../include/gsm48_const.h" |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
18 #include "../include/out_routes.h" |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 #include "call.h" |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 extern struct call *find_call_by_mncc_callref(); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 static void |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 handle_disconnect_ind(call, msg) |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 struct call *call; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 struct gsm_mncc *msg; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 { |
83
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
28 /* release back to MNCC */ |
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
29 msg->msg_type = MNCC_REL_REQ; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
30 send_mncc_to_sock(call->mncc, msg, sizeof(struct gsm_mncc)); |
83
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
31 call->mncc_state = MNCC_STATE_RELEASE; |
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
32 /* signal disconnect to SIP */ |
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
33 call->overall_state = OVERALL_STATE_TEARDOWN; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
34 disconnect_sip(call); |
83
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
35 disconnect_tmgw(call); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 static void |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 handle_final_release(call, msg) |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 struct call *call; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 struct gsm_mncc *msg; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
83
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
43 /* MNCC call leg is gone */ |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
44 call->mncc = 0; |
83
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
45 /* signal disconnect to SIP */ |
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
46 call->overall_state = OVERALL_STATE_TEARDOWN; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
47 disconnect_sip(call); |
83
3e3fbf44f9d7
sip-in: disconnect and call clearing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
66
diff
changeset
|
48 disconnect_tmgw(call); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
49 check_dead_call(call); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 static void |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
53 handle_dtmf_start(call, msg) |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
54 struct call *call; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
55 struct gsm_mncc *msg; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
56 { |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
57 if (!(msg->fields & MNCC_F_KEYPAD) || |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
58 !is_valid_dtmf_digit(msg->keypad)) { |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
59 msg->msg_type = MNCC_START_DTMF_REJ; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
60 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU, |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
61 GSM48_CC_CAUSE_INVAL_MAND_INF); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
62 send_mncc_to_sock(call->mncc, msg, sizeof(struct gsm_mncc)); |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
63 return; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
64 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
65 if (call->mncc_state != MNCC_STATE_CONNECTED || |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
66 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
|
67 msg->msg_type = MNCC_START_DTMF_REJ; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
68 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU, |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
69 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
70 send_mncc_to_sock(call->mncc, msg, sizeof(struct gsm_mncc)); |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
71 return; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
72 } |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
73 call->dtmf_digit = msg->keypad; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
74 tmgw_send_dtmf_start(call); |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
75 } |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
76 |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
77 static void |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
78 handle_dtmf_stop(call, msg) |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
79 struct call *call; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
80 struct gsm_mncc *msg; |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
81 { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
82 if (call->mncc_state != MNCC_STATE_CONNECTED) |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
83 return; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
84 if (call->mgw_state == MGW_STATE_COMPLETE) |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
85 tmgw_send_dtmf_stop(call); |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
86 else if (call->mgw_state == MGW_STATE_DTMF_OP) |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
87 call->dtmf_pending_stop = 1; |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
88 else { |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
89 /* dummy OK response */ |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
90 msg->msg_type = MNCC_STOP_DTMF_RSP; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
91 send_mncc_to_sock(call->mncc, msg, sizeof(struct gsm_mncc)); |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
92 } |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
93 } |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
94 |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
95 static void |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
96 handle_call_hold(call, msg) |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
97 struct call *call; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
98 struct gsm_mncc *msg; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
99 { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
100 if (call->mncc_state != MNCC_STATE_CONNECTED || |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
101 call->mgw_state != MGW_STATE_COMPLETE) { |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
102 msg->msg_type = MNCC_HOLD_REJ; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
103 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU, |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
104 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
105 send_mncc_to_sock(call->mncc, msg, sizeof(struct gsm_mncc)); |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
106 return; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
107 } |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
108 tmgw_send_mdcx_hold(call); |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
109 } |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
110 |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
111 static void |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
112 handle_call_retrieve(call, msg) |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
113 struct call *call; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
114 struct gsm_mncc *msg; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
115 { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
116 if (call->mncc_state != MNCC_STATE_CONNECTED || |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
117 call->mgw_state != MGW_STATE_HELD) { |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
118 msg->msg_type = MNCC_RETRIEVE_REJ; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
119 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU, |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
120 GSM48_CC_CAUSE_MSGTYPE_INCOMPAT); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
121 send_mncc_to_sock(call->mncc, msg, sizeof(struct gsm_mncc)); |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
122 return; |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
123 } |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
124 send_rtp_connect(call); |
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
125 tmgw_send_mdcx_retrieve(call); |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
126 } |
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
127 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
128 void |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
129 handle_mncc_signal(mncc, msg, msglen) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
130 struct mncc_conn *mncc; |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 struct gsm_mncc *msg; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 unsigned msglen; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 struct call *call; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (msglen != sizeof(struct gsm_mncc)) { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 syslog(LOG_CRIT, |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 "FATAL: Rx MNCC message type 0x%x has wrong length", |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 msg->msg_type); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 exit(1); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
142 call = find_call_by_mncc_callref(mncc, msg->callref); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 if (!call) { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 syslog(LOG_CRIT, |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 "error: Rx MNCC message type 0x%x has invalid callref 0x%x", |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 msg->msg_type, msg->callref); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 exit(1); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 switch (msg->msg_type) { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 case MNCC_DISC_IND: |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 handle_disconnect_ind(call, msg); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 case MNCC_REL_IND: |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 case MNCC_REL_CNF: |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 handle_final_release(call, msg); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 case MNCC_START_DTMF_IND: |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
158 handle_dtmf_start(call, msg); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 case MNCC_STOP_DTMF_IND: |
128
5685412bd6aa
sip-in: pass DTMF start & stop to themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
110
diff
changeset
|
161 handle_dtmf_stop(call, msg); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 case MNCC_MODIFY_IND: |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 msg->msg_type = MNCC_MODIFY_REJ; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU, |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 GSM48_CC_CAUSE_SERV_OPT_UNIMPL); |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
167 send_mncc_to_sock(mncc, msg, sizeof(struct gsm_mncc)); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 case MNCC_HOLD_IND: |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
170 handle_call_hold(call, msg); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 case MNCC_RETRIEVE_IND: |
141
e499e8db8b82
sip-in: handle call hold and retrieve
Mychaela Falconia <falcon@freecalypso.org>
parents:
140
diff
changeset
|
173 handle_call_retrieve(call, msg); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 return; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 } |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
178 void |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
179 handle_rtp_create(mncc, msg, msglen) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
180 struct mncc_conn *mncc; |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 struct gsm_mncc_rtp *msg; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 unsigned msglen; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 struct call *call; |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 if (msglen != sizeof(struct gsm_mncc_rtp)) { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 syslog(LOG_CRIT, |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 "FATAL: Rx MNCC message type 0x%x has wrong length", |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 msg->msg_type); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 exit(1); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
192 call = find_call_by_mncc_callref(mncc, msg->callref); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 if (!call) { |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 syslog(LOG_CRIT, |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 "error: Rx MNCC message type 0x%x has invalid callref 0x%x", |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 msg->msg_type, msg->callref); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 exit(1); |
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
199 /* we need to be in the right state */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
200 if (call->mncc_state != MNCC_STATE_MO_PROC) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
201 syslog(LOG_ERR, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
202 "duplicate MNCC_RTP_CREATE for MO callref 0x%x, ignoring", |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
203 msg->callref); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
204 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
205 } |
84
f82157ac7303
sip-in: handle MNCC_RTP_CREATE
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
206 /* save Osmocom network RTP information */ |
f82157ac7303
sip-in: handle MNCC_RTP_CREATE
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
207 bcopy(&msg->addr, &call->gsm_rtp_osmo, sizeof(struct sockaddr_storage)); |
f82157ac7303
sip-in: handle MNCC_RTP_CREATE
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
208 call->gsm_payload_type = msg->payload_type; |
f82157ac7303
sip-in: handle MNCC_RTP_CREATE
Mychaela Falconia <falcon@freecalypso.org>
parents:
83
diff
changeset
|
209 call->gsm_payload_msg_type = msg->payload_msg_type; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
210 /* move forward */ |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
211 call->mncc_state = MNCC_STATE_GOT_RTP; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
212 call->overall_state = OVERALL_STATE_CRCX; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
213 tmgw_send_crcx(call); |
63
e5aee661e3b2
sip-in: beginning to handle incoming MNCC messages from themwi-mncc
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 } |