FreeCalypso > hg > themwi-interim
annotate mncc/extsock.c @ 14:44c1d4d787e9 default tip
themwi-test-mtc: add option to set bearer cap
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Nov 2024 20:37:23 +0000 |
parents | 053f04687106 |
children |
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 gather functions that deal with external |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * socket connections, both externally-originating MT calls |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * and outbound MO calls. |
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 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/types.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <sys/socket.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include "../include/mncc.h" |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include "../include/gsm48_const.h" |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "struct.h" |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "gsm_call.h" |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern char *mncc_msg_name(); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 extsock_dec_refcount(conn) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 struct socket_conn *conn; |
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 if (!conn->ncalls) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 syslog(LOG_CRIT, "FATAL BUG: ncalls=0 on socket call clearing"); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 exit(1); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 conn->ncalls--; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 static void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 send_rel_on_broken_socket(call) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 struct gsm_call *call; |
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 struct gsm_mncc msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 bzero(&msg, sizeof(struct gsm_mncc)); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 msg.msg_type = MNCC_REL_REQ; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 msg.callref = call->callref; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 mncc_set_cause(&msg, GSM48_CAUSE_LOC_PRN_S_LU, GSM48_CC_CAUSE_DEST_OOO); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 send_mncc_to_gsm(&msg, sizeof(struct gsm_mncc)); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 static void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 broken_socket_clear_calls(conn) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 struct socket_conn *conn; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 extern struct gsm_call *call_list_head; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 struct gsm_call *call; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 for (call = call_list_head; call; call = call->next) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (call->gc_flag) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 continue; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 if (call->socket == conn) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 syslog(LOG_WARNING, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 "clearing broken socket call: GSM callref 0x%x, socket ref 0x%x", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 call->callref, call->socket_ref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 send_rel_on_broken_socket(call); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 extsock_dec_refcount(conn); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 call->gc_flag = 1; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 if (conn->ncalls) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 syslog(LOG_CRIT, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 "FATAL BUG: ncalls!=0 after broken socket call clearing"); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 exit(1); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 } |
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 report_runt(msg) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 union mncc_msg *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 syslog(LOG_CRIT, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 "MNCC message type 0x%x from ThemWi call socket is too short!", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 msg->msg_type); |
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 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 static void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 handle_setup_req(conn, msg, msglen) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 struct socket_conn *conn; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 struct gsm_mncc *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 unsigned msglen; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 struct gsm_call *call; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 if (msglen < sizeof(struct gsm_mncc)) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 report_runt(msg); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 return; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 syslog(LOG_DEBUG, "Rx MNCC_SETUP_REQ from socket, callref=0x%x", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 call = find_socket_call(conn, msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 if (call) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 syslog(LOG_ERR, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 "duplicate MNCC_SETUP_REQ from socket for callref 0x%x", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 /* drop it like OsmoMSC's mncc_builtin does */ |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 return; |
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 /* further processing */ |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 process_ext_mtcall_setup(conn, msg); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 static void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 handle_signaling_msg(conn, msg, msglen) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 struct socket_conn *conn; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 struct gsm_mncc *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 unsigned msglen; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 struct gsm_call *call; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 if (msglen < sizeof(struct gsm_mncc)) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 report_runt(msg); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 return; |
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 syslog(LOG_DEBUG, "Rx %s from socket, callref=0x%x", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 mncc_msg_name(msg->msg_type), msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 call = find_socket_call(conn, msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 if (!call) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 syslog(LOG_ERR, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 "MNCC message from ThemWi call socket: callref 0x%x not found", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 /* drop it like OsmoMSC's mncc_builtin does */ |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 return; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 /* forward to GSM MNCC interface */ |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 msg->callref = call->callref; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc)); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (msg->msg_type == MNCC_REJ_REQ) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 extsock_dec_refcount(conn); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 call->gc_flag = 1; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 static void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 handle_rtp_msg(conn, msg, msglen) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 struct socket_conn *conn; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 struct gsm_mncc_rtp *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 unsigned msglen; |
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 struct gsm_call *call; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 if (msglen < sizeof(struct gsm_mncc_rtp)) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 report_runt(msg); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 return; |
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 syslog(LOG_DEBUG, "Rx %s from socket, callref=0x%x", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 mncc_msg_name(msg->msg_type), msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 call = find_socket_call(conn, msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 if (!call) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 syslog(LOG_ERR, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 "MNCC message from ThemWi call socket: callref 0x%x not found", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 msg->callref); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 /* drop it like OsmoMSC's mncc_builtin does */ |
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 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 /* forward to GSM MNCC interface */ |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 msg->callref = call->callref; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 send_mncc_to_gsm(msg, sizeof(struct gsm_mncc_rtp)); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 void |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 extsock_read_select(conn) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 struct socket_conn *conn; |
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 union mncc_msg msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 int rc; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 rc = recv(conn->fd, &msg, sizeof msg, 0); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 if (rc < 4) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 if (conn->ncalls) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 syslog(LOG_ERR, "ext socket broken with calls present"); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 broken_socket_clear_calls(conn); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 } else |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 syslog(LOG_INFO, "normal closing of ext socket"); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 close(conn->fd); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 conn->fd = -1; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 return; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 switch (msg.msg_type) { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 case MNCC_SETUP_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 handle_setup_req(conn, &msg, rc); |
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_SETUP_RSP: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 case MNCC_SETUP_COMPL_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 case MNCC_CALL_PROC_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 case MNCC_PROGRESS_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 case MNCC_ALERT_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 case MNCC_NOTIFY_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 case MNCC_DISC_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 case MNCC_REL_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 case MNCC_FACILITY_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 case MNCC_START_DTMF_RSP: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 case MNCC_START_DTMF_REJ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 case MNCC_STOP_DTMF_RSP: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 case MNCC_MODIFY_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 case MNCC_MODIFY_RSP: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 case MNCC_MODIFY_REJ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 case MNCC_HOLD_CNF: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 case MNCC_HOLD_REJ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 case MNCC_RETRIEVE_CNF: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 case MNCC_RETRIEVE_REJ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 case MNCC_USERINFO_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 case MNCC_REJ_REQ: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 handle_signaling_msg(conn, &msg, rc); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 return; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 case MNCC_RTP_CREATE: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 case MNCC_RTP_CONNECT: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 case MNCC_RTP_FREE: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 handle_rtp_msg(conn, &msg, rc); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 return; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 default: |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 syslog(LOG_CRIT, |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 "unknown MNCC message type 0x%x from ThemWi call socket", |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 msg.msg_type); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 mncc_signal_to_socket(call, msg) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 struct gsm_call *call; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 struct gsm_mncc *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 msg->callref = call->socket_ref; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 return send(call->socket->fd, msg, sizeof(struct gsm_mncc), 0); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 mncc_signal_to_socket_nocall(conn, msg) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 struct socket_conn *conn; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 struct gsm_mncc *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 return send(conn->fd, msg, sizeof(struct gsm_mncc), 0); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 } |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 mncc_rtp_to_socket(call, msg) |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 struct gsm_call *call; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 struct gsm_mncc_rtp *msg; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 { |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 msg->callref = call->socket_ref; |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 return send(call->socket->fd, msg, sizeof(struct gsm_mncc_rtp), 0); |
053f04687106
mncc: initial import from old ThemWi
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 } |