FreeCalypso > hg > themwi-system-sw
annotate sip-out/mncc_sock.c @ 191:6ac96217c442
sip-manual-out: add SDP response parsing
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 17 Mar 2023 12:07:17 -0800 |
parents | e54b0a9e322f |
children |
rev | line source |
---|---|
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
2 * In this module we implement the MNCC socket interface to themwi-sip-out. |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
3 * We have an outcall socket on which we accept connections, and each |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
4 * accepted connection becomes a struct mncc_conn for us. |
15
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> |
35
db7ed6a55ba4
themwi-{mgw,mncc}: chmod connection-accepting sockets to 775
Mychaela Falconia <falcon@freecalypso.org>
parents:
28
diff
changeset
|
8 #include <sys/stat.h> |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <sys/socket.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <sys/un.h> |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
11 #include <sys/time.h> |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
12 #include <netinet/in.h> |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <stdio.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <stdint.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <stdlib.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <string.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include <strings.h> |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include <syslog.h> |
35
db7ed6a55ba4
themwi-{mgw,mncc}: chmod connection-accepting sockets to 775
Mychaela Falconia <falcon@freecalypso.org>
parents:
28
diff
changeset
|
19 #include <unistd.h> |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 #include "../include/mncc.h" |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
21 #include "../include/out_routes.h" |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
22 #include "call.h" |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
24 static char outcall_socket_pathname[] = "/var/gsm/outcall_socket"; |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
26 int mncc_listener; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
27 struct mncc_conn *mncc_conn_list; |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
29 create_outcall_socket() |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 struct sockaddr_un sa; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 unsigned sa_len; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 int rc; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
35 mncc_listener = socket(AF_UNIX, SOCK_SEQPACKET, 0); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
36 if (mncc_listener < 0) { |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 syslog(LOG_CRIT, "socket(AF_UNIX, SOCK_SEQPACKET, 0): %m"); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return(-1); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
40 unlink(outcall_socket_pathname); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
41 fill_sockaddr_un(outcall_socket_pathname, &sa, &sa_len); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
42 rc = bind(mncc_listener, (struct sockaddr *) &sa, sa_len); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (rc < 0) { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
44 syslog(LOG_ERR, "bind to %s: %m", outcall_socket_pathname); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 return(-1); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
47 rc = listen(mncc_listener, 3); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (rc < 0) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 syslog(LOG_CRIT, "listen on UNIX socket: %m"); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 return(-1); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
52 chmod(outcall_socket_pathname, 0775); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
53 update_max_fd(mncc_listener); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 return(0); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 void |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
58 mncc_listener_select() |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 struct sockaddr_un sa; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 socklen_t sa_len; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 int fd; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
63 struct mncc_conn *conn; |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
25
fd43f179ff1d
themwi-mncc: need to initialize sa_len before accept call
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
65 sa_len = sizeof sa; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
66 fd = accept(mncc_listener, (struct sockaddr *) &sa, &sa_len); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (fd < 0) { |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 syslog(LOG_CRIT, "accept on UNIX socket: %m"); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 exit(1); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
71 conn = malloc(sizeof(struct mncc_conn)); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if (!conn) { |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
73 syslog(LOG_CRIT, "malloc for outcall socket conn: %m"); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 close(fd); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 return; |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
77 syslog(LOG_INFO, "new outcall socket connection"); |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 conn->fd = fd; |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
79 conn->next = mncc_conn_list; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
80 mncc_conn_list = conn; |
15
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 update_max_fd(fd); |
ccc5ab6d8388
first version of themwi-mncc for ThemWi2
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 } |
154
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
83 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
84 static void |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
85 dispatch_mncc_msg(mncc, msg, msglen) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
86 struct mncc_conn *mncc; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
87 union mncc_msg *msg; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
88 unsigned msglen; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
89 { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
90 switch (msg->msg_type) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
91 case MNCC_SETUP_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
92 handle_setup_ind(mncc, msg, msglen); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
93 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
94 case MNCC_SETUP_COMPL_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
95 case MNCC_NOTIFY_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
96 case MNCC_DISC_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
97 case MNCC_FACILITY_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
98 case MNCC_START_DTMF_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
99 case MNCC_STOP_DTMF_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
100 case MNCC_MODIFY_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
101 case MNCC_HOLD_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
102 case MNCC_RETRIEVE_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
103 case MNCC_USERINFO_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
104 case MNCC_REL_IND: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
105 case MNCC_REL_CNF: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
106 handle_mncc_signal(mncc, msg, msglen); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
107 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
108 case MNCC_RTP_CREATE: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
109 handle_rtp_create(mncc, msg, msglen); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
110 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
111 case MNCC_RTP_CONNECT: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
112 syslog(LOG_ERR, "MNCC_RTP_CONNECT error from OsmoMSC"); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
113 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
114 case MNCC_RTP_FREE: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
115 syslog(LOG_ERR, "MNCC_RTP_FREE bogon from OsmoMSC"); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
116 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
117 default: |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
118 syslog(LOG_CRIT, |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
119 "FATAL: received unexpected MNCC message type 0x%x", |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
120 msg->msg_type); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
121 exit(1); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
122 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
123 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
124 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
125 void |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
126 mncc_socket_select(conn) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
127 struct mncc_conn *conn; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
128 { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
129 union mncc_msg msg; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
130 int rc; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
131 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
132 rc = recv(conn->fd, &msg, sizeof msg, 0); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
133 if (rc <= 0) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
134 syslog(LOG_ERR, "outcall socket disconnected"); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
135 close(conn->fd); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
136 conn->fd = -1; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
137 shutdown_mncc_socket(conn); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
138 return; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
139 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
140 if (rc < 4) { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
141 syslog(LOG_CRIT, "short read from MNCC socket: %d bytes", rc); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
142 exit(1); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
143 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
144 dispatch_mncc_msg(conn, &msg, rc); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
145 } |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
146 |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
147 send_mncc_to_sock(mncc, msg, msglen) |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
148 struct mncc_conn *mncc; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
149 union mncc_msg *msg; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
150 unsigned msglen; |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
151 { |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
152 return send(mncc->fd, msg, msglen, 0); |
e54b0a9e322f
beginning of themwi-sip-out
Mychaela Falconia <falcon@freecalypso.org>
parents:
35
diff
changeset
|
153 } |