comparison mncc/main.c @ 167:2ebad02adbe5

themwi-mncc: route outbound calls to themwi-sip-out
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 12 Oct 2022 18:08:34 -0800
parents ccc5ab6d8388
children
comparison
equal deleted inserted replaced
166:8adcd220c6cf 167:2ebad02adbe5
15 #include "struct.h" 15 #include "struct.h"
16 16
17 extern int mncc_socket; 17 extern int mncc_socket;
18 extern int mtcall_listener; 18 extern int mtcall_listener;
19 extern struct socket_conn *mtcall_socket_head; 19 extern struct socket_conn *mtcall_socket_head;
20
21 struct socket_conn outcall_conn;
20 22
21 static int max_fd; 23 static int max_fd;
22 24
23 update_max_fd(newfd) 25 update_max_fd(newfd)
24 { 26 {
45 if (create_mtcall_socket() < 0) { 47 if (create_mtcall_socket() < 0) {
46 fprintf(stderr, "error creating MT call socket\n"); 48 fprintf(stderr, "error creating MT call socket\n");
47 exit(1); 49 exit(1);
48 } 50 }
49 signal(SIGPIPE, SIG_IGN); 51 signal(SIGPIPE, SIG_IGN);
52 outcall_conn.fd = -1;
50 /* main select loop */ 53 /* main select loop */
51 for (;;) { 54 for (;;) {
52 FD_ZERO(&fds); 55 FD_ZERO(&fds);
53 FD_SET(mncc_socket, &fds); 56 FD_SET(mncc_socket, &fds);
54 FD_SET(mtcall_listener, &fds); 57 FD_SET(mtcall_listener, &fds);
59 continue; 62 continue;
60 } 63 }
61 FD_SET(conn->fd, &fds); 64 FD_SET(conn->fd, &fds);
62 connp = &conn->next; 65 connp = &conn->next;
63 } 66 }
67 if (outcall_conn.fd >= 0)
68 FD_SET(outcall_conn.fd, &fds);
64 c = select(max_fd+1, &fds, 0, 0, 0); 69 c = select(max_fd+1, &fds, 0, 0, 0);
65 if (c < 0) { 70 if (c < 0) {
66 if (errno == EINTR) 71 if (errno == EINTR)
67 continue; 72 continue;
68 syslog(LOG_CRIT, "select: %m"); 73 syslog(LOG_CRIT, "select: %m");
73 if (FD_ISSET(mtcall_listener, &fds)) 78 if (FD_ISSET(mtcall_listener, &fds))
74 mtsock_accept_handler(); 79 mtsock_accept_handler();
75 for (conn = mtcall_socket_head; conn; conn = conn->next) 80 for (conn = mtcall_socket_head; conn; conn = conn->next)
76 if (FD_ISSET(conn->fd, &fds)) 81 if (FD_ISSET(conn->fd, &fds))
77 extsock_read_select(conn); 82 extsock_read_select(conn);
83 if (outcall_conn.fd >= 0 && FD_ISSET(outcall_conn.fd, &fds))
84 extsock_read_select(&outcall_conn);
78 gc_call_list(); 85 gc_call_list();
79 } 86 }
80 } 87 }