annotate rtp-mgr/ctrl_prot.c @ 189:1266e024de6c

sip-manual-out: implement hunt for IS_Header in Rx RTP
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 17 Mar 2023 09:54:22 -0800
parents 3962d9345a09
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * In this module we implement our control socket protocol.
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/socket.h>
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
7 #include <sys/uio.h>
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <netinet/in.h>
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
38
020ba624bdd8 mgw source: #include <stdlib.h> in files using tmgw_ctrl.h
Mychaela Falconia <falcon@freecalypso.org>
parents: 34
diff changeset
10 #include <stdint.h>
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <string.h>
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <strings.h>
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 #include <syslog.h>
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 #include <unistd.h>
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
16 #include "../include/tmgw_const.h"
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
17 #include "../include/rtp_alloc.h"
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 #include "struct.h"
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 #include "select.h"
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
21 extern struct bind_range_cfg bind_range_gsm, bind_range_pstn;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
22
180
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
23 static void
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
24 free_rtp_end(roe)
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
25 struct rtp_one_end *roe;
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 {
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
27 close(roe->rtp_fd);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
28 close(roe->rtcp_fd);
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
180
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
31 static void
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
32 close_fds(fd_list, num_fd)
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
33 int *fd_list, num_fd;
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
34 {
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
35 int i;
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
36
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
37 for (i = 0; i < num_fd; i++)
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
38 close(fd_list[i]);
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
39 }
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
40
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 void
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
42 ctrl_message_handler(fd)
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 {
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
44 struct rtp_alloc_req req;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
45 struct rtp_alloc_resp resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
46 struct rtp_one_end rtp_gsm, rtp_pstn;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
47 struct iovec iov;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
48 struct msghdr msg;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
49 int fd_out[4], num_fd, *fd_bufptr;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
50 union {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
51 char buf[CMSG_SPACE(sizeof fd_out)];
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
52 struct cmsghdr align;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
53 } cmsgu;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
54 struct cmsghdr *cmsg;
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 int rc;
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
57 /* receive request */
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 rc = recv(fd, &req, sizeof req, 0);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 if (rc < sizeof req) {
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
60 syslog(LOG_DEBUG, "ctrl connection closing");
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 close(fd);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 FD_CLR(fd, &select_for_read);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 return;
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 }
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
65 /* start preparing response */
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 bzero(&resp, sizeof resp);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 resp.transact_ref = req.transact_ref;
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
68 switch (req.ep_type) {
183
3962d9345a09 rtp-mgr: use new EP type constant names
Mychaela Falconia <falcon@freecalypso.org>
parents: 180
diff changeset
69 case TMGW_EP_TYPE_GSM_ONLY:
3962d9345a09 rtp-mgr: use new EP type constant names
Mychaela Falconia <falcon@freecalypso.org>
parents: 180
diff changeset
70 case TMGW_EP_TYPE_PSTN_ONLY:
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
71 case TMGW_EP_TYPE_GATEWAY:
127
f062c32a5116 mgw: implement DTMF
Mychaela Falconia <falcon@freecalypso.org>
parents: 38
diff changeset
72 break;
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 default:
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
74 resp.res = RTP_ALLOC_ERR_PARAM;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
75 error_resp: send(fd, &resp, sizeof resp, 0);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
76 return;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
77 }
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
78 /* allocate resources */
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
79 if (req.ep_type & TMGW_EP_HAS_GSM_SOCK) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
80 rc = get_rtp_port_pair(&rtp_gsm, &bind_range_gsm);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
81 if (rc < 0) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
82 syslog(LOG_ERR,
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
83 "unable to get local port pair on GSM side");
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
84 resp.res = RTP_ALLOC_ERR_RSRC;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
85 goto error_resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
86 }
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
87 }
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
88 if (req.ep_type & TMGW_EP_HAS_PSTN_SOCK) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
89 rc = get_rtp_port_pair(&rtp_pstn, &bind_range_pstn);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
90 if (rc < 0) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
91 syslog(LOG_ERR,
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
92 "unable to get local port pair on PSTN side");
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
93 if (req.ep_type & TMGW_EP_HAS_GSM_SOCK)
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
94 free_rtp_end(&rtp_gsm);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
95 resp.res = RTP_ALLOC_ERR_RSRC;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
96 goto error_resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
97 }
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 }
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
99 /* finish ordinary body of response */
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
100 resp.res = RTP_ALLOC_OK;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
101 if (req.ep_type & TMGW_EP_HAS_GSM_SOCK)
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
102 bcopy(&rtp_gsm.bound_addr, &resp.gsm_addr,
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
103 sizeof(struct sockaddr_in));
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
104 if (req.ep_type & TMGW_EP_HAS_PSTN_SOCK)
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
105 bcopy(&rtp_pstn.bound_addr, &resp.pstn_addr,
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
106 sizeof(struct sockaddr_in));
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
107 iov.iov_base = &resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
108 iov.iov_len = sizeof resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
109 /* file descriptor passing voodoo */
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
110 switch (req.ep_type) {
183
3962d9345a09 rtp-mgr: use new EP type constant names
Mychaela Falconia <falcon@freecalypso.org>
parents: 180
diff changeset
111 case TMGW_EP_TYPE_GSM_ONLY:
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
112 num_fd = 2;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
113 fd_out[0] = rtp_gsm.rtp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
114 fd_out[1] = rtp_gsm.rtcp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
115 break;
183
3962d9345a09 rtp-mgr: use new EP type constant names
Mychaela Falconia <falcon@freecalypso.org>
parents: 180
diff changeset
116 case TMGW_EP_TYPE_PSTN_ONLY:
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
117 num_fd = 2;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
118 fd_out[0] = rtp_pstn.rtp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
119 fd_out[1] = rtp_pstn.rtcp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
120 break;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
121 case TMGW_EP_TYPE_GATEWAY:
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
122 num_fd = 4;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
123 fd_out[0] = rtp_gsm.rtp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
124 fd_out[1] = rtp_gsm.rtcp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
125 fd_out[2] = rtp_pstn.rtp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
126 fd_out[3] = rtp_pstn.rtcp_fd;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
127 }
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
128 bzero(&msg, sizeof msg);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
129 msg.msg_iov = &iov;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
130 msg.msg_iovlen = 1;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
131 msg.msg_control = cmsgu.buf;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
132 msg.msg_controllen = CMSG_SPACE(sizeof(int) * num_fd);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
133 cmsg = CMSG_FIRSTHDR(&msg);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
134 cmsg->cmsg_level = SOL_SOCKET;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
135 cmsg->cmsg_type = SCM_RIGHTS;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
136 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fd);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
137 fd_bufptr = (int *) CMSG_DATA(cmsg);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
138 bcopy(fd_out, fd_bufptr, sizeof(int) * num_fd);
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
139 sendmsg(fd, &msg, 0);
180
565477d07418 themwi-rtp-mgr: close file descriptors after sending them across
Mychaela Falconia <falcon@freecalypso.org>
parents: 179
diff changeset
140 close_fds(fd_out, num_fd);
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 }