annotate mncc/intswitch.c @ 8:a902ccbf6bbc

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