annotate mncc/intswitch.c @ 21:cc0e1c6e33c3

themwi-test-mtc utility written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 28 Jun 2022 18:25:28 -0800
parents ccc5ab6d8388
children 52e801b5ebb1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement internally switched calls,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * going from one GSM subscriber to another.
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/socket.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <string.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <strings.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <syslog.h>
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include "../include/mncc.h"
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include "../include/gsm48_const.h"
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 #include "struct.h"
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 #include "gsm_call.h"
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 void
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 internal_switch_mo_setup(call, msg)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 struct gsm_call *call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 struct gsm_mncc *msg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 struct gsm_call *mt;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 struct gsm_mncc callproc;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (!(msg->fields & MNCC_F_BEARER_CAP)) {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 GSM48_CC_CAUSE_INVAL_MAND_INF);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 call->gc_flag = 1;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 /* same speech-only restriction as in OsmoMSC's mncc_builtin */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (msg->bearer_cap.transfer != GSM48_BCAP_ITCAP_SPEECH ||
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 msg->bearer_cap.mode != GSM48_BCAP_TMOD_CIRCUIT) {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 GSM48_CC_CAUSE_BEARER_CA_UNAVAIL);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 call->gc_flag = 1;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 mt = create_new_mt_call();
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 if (!mt) {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 reject_mo_call(msg->callref, GSM48_CAUSE_LOC_PRN_S_LU,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 GSM48_CC_CAUSE_RESOURCE_UNAVAIL);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 call->gc_flag = 1;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 call->other_leg = mt;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 mt->other_leg = call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 /* send call proceeding */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 bzero(&callproc, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 callproc.msg_type = MNCC_CALL_PROC_REQ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 callproc.callref = call->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 send_mncc_to_gsm(&callproc, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 /* turn MNCC_SETUP_IND into MNCC_SETUP_REQ for MT */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 msg->msg_type = MNCC_SETUP_REQ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 msg->callref = mt->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 msg->imsi[0] = '\0';
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 static void
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 handle_setup_cnf(call, msg)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 struct gsm_call *call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 struct gsm_mncc *msg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 struct gsm_mncc ack;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 struct gsm_mncc_bridge bridge;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 /* acknowledge connect */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 bzero(&ack, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 ack.msg_type = MNCC_SETUP_COMPL_REQ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 ack.callref = call->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 send_mncc_to_gsm(&ack, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 /* do we have the far end? */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 if (!call->other_leg)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 msg->msg_type = MNCC_SETUP_RSP;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 msg->callref = call->other_leg->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 /* bridge TCH */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 bzero(&bridge, sizeof(struct gsm_mncc_bridge));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 bridge.msg_type = MNCC_BRIDGE;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 bridge.callref[0] = call->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 bridge.callref[1] = call->other_leg->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 send_mncc_to_gsm(&bridge, sizeof(struct gsm_mncc_bridge));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 static void
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 forward_to_remote(call, msg, new_msg_type)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 struct gsm_call *call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 struct gsm_mncc *msg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 uint32_t new_msg_type;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 if (!call->other_leg) {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 /* drop it like OsmoMSC's mncc_builtin does */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 msg->msg_type = new_msg_type;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 msg->callref = call->other_leg->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 static void
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 handle_disconnect(call, msg)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 struct gsm_call *call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 struct gsm_mncc *msg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 struct gsm_call *remote;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 /* release on near end */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 msg->msg_type = MNCC_REL_REQ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 /* disconnect on far end */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 remote = call->other_leg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 if (!remote)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 msg->msg_type = MNCC_DISC_REQ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 msg->callref = remote->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 /* sever the end-to-end association */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 call->other_leg = 0;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 remote->other_leg = 0;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 static void
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 handle_release(call, msg)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 struct gsm_call *call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 struct gsm_mncc *msg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 struct gsm_call *remote;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 /* do we have a far end? */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 remote = call->other_leg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 /* free the near end */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 call->gc_flag = 1;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 /* if no remote, nothing more to do */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 if (!remote)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 /* send them a release request */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 msg->msg_type = MNCC_REL_REQ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 msg->callref = remote->callref;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 /* sever the end-to-end association */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 remote->other_leg = 0;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 void
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 internal_switch_mncc(call, msg)
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 struct gsm_call *call;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 struct gsm_mncc *msg;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 switch (msg->msg_type) {
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 case MNCC_SETUP_CNF:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 handle_setup_cnf(call, msg);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 case MNCC_ALERT_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 forward_to_remote(call, msg, MNCC_ALERT_REQ);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 case MNCC_NOTIFY_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 forward_to_remote(call, msg, MNCC_NOTIFY_REQ);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 case MNCC_USERINFO_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 forward_to_remote(call, msg, MNCC_USERINFO_REQ);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 case MNCC_DISC_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 handle_disconnect(call, msg);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 case MNCC_START_DTMF_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 msg->msg_type = MNCC_START_DTMF_REJ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 case MNCC_STOP_DTMF_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 msg->msg_type = MNCC_STOP_DTMF_RSP;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 case MNCC_MODIFY_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 msg->msg_type = MNCC_MODIFY_REJ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 case MNCC_HOLD_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184 msg->msg_type = MNCC_HOLD_REJ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 case MNCC_RETRIEVE_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 msg->msg_type = MNCC_RETRIEVE_REJ;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 mncc_set_cause(msg, GSM48_CAUSE_LOC_PRN_S_LU,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 GSM48_CC_CAUSE_SERV_OPT_UNIMPL);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc));
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 case MNCC_SETUP_COMPL_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 case MNCC_CALL_CONF_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 /* no handling needed */
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 case MNCC_REL_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 case MNCC_REJ_IND:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 handle_release(call, msg);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 case MNCC_REL_CNF:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 call->gc_flag = 1;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 return;
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 default:
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 syslog(LOG_ERR,
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 "MNCC message type 0x%x unhandled for internal switch",
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 msg->msg_type);
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210 }
ccc5ab6d8388 first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 }