annotate rtp-mgr/ctrl_prot.c @ 179:b79d6334f543

themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 Mar 2023 20:19:14 -0800
parents mgw/ctrl_prot.c@f062c32a5116
children 565477d07418
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
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
23 void
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
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 void
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
32 ctrl_message_handler(fd)
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
34 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
35 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
36 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
37 struct iovec iov;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
38 struct msghdr msg;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
39 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
40 union {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
41 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
42 struct cmsghdr align;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
43 } cmsgu;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
44 struct cmsghdr *cmsg;
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 int rc;
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
47 /* receive request */
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 rc = recv(fd, &req, sizeof req, 0);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 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
50 syslog(LOG_DEBUG, "ctrl connection closing");
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 close(fd);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 FD_CLR(fd, &select_for_read);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 return;
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
55 /* start preparing response */
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 bzero(&resp, sizeof resp);
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 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
58 switch (req.ep_type) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
59 case TMGW_EP_TYPE_DUMMY_GSM:
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
60 case TMGW_EP_TYPE_DUMMY_PSTN:
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
61 case TMGW_EP_TYPE_GATEWAY:
127
f062c32a5116 mgw: implement DTMF
Mychaela Falconia <falcon@freecalypso.org>
parents: 38
diff changeset
62 break;
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 default:
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
64 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
65 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
66 return;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
67 }
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
68 /* allocate resources */
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
69 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
70 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
71 if (rc < 0) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
72 syslog(LOG_ERR,
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
73 "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
74 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
75 goto error_resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
76 }
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 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
79 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
80 if (rc < 0) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
81 syslog(LOG_ERR,
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
82 "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
83 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
84 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
85 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
86 goto error_resp;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
87 }
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 }
179
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
89 /* 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 /* 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
100 switch (req.ep_type) {
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
101 case TMGW_EP_TYPE_DUMMY_GSM:
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
102 num_fd = 2;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
103 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
104 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
105 break;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
106 case TMGW_EP_TYPE_DUMMY_PSTN:
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
107 num_fd = 2;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
108 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
109 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
110 break;
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
111 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
112 num_fd = 4;
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 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
116 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
117 }
b79d6334f543 themwi-rtp-mgr: RTP port allocation split out of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents: 127
diff changeset
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 sendmsg(fd, &msg, 0);
32
b3f74df7b808 beginning of themwi-mgw
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 }