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