FreeCalypso > hg > themwi-rtp-mgr
annotate rtp-mgr/ctrl_prot.c @ 7:b97024a897c3
add top Makefile
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 27 May 2024 21:12:15 +0000 |
parents | 247f4bbde24c |
children |
rev | line source |
---|---|
2
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement our control socket protocol. |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 */ |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <sys/types.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/socket.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/uio.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <netinet/in.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdint.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdlib.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <string.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <strings.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <syslog.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <unistd.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <themwi/rtp/rtp_alloc_if.h> |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 #include "struct.h" |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 #include "select.h" |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 extern struct bind_range_cfg bind_range_gsm, bind_range_pstn; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static void |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 free_rtp_end(roe) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 struct rtp_one_end *roe; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 close(roe->rtp_fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 close(roe->rtcp_fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 static void |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 close_fds(fd_list, num_fd) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 int *fd_list, num_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 int i; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 for (i = 0; i < num_fd; i++) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 close(fd_list[i]); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 void |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 ctrl_message_handler(fd) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 struct rtp_alloc_req req; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 struct rtp_alloc_resp resp; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 struct rtp_one_end rtp_gsm, rtp_pstn; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 struct iovec iov; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 struct msghdr msg; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 int fd_out[4], num_fd, *fd_bufptr; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 union { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 char buf[CMSG_SPACE(sizeof fd_out)]; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 struct cmsghdr align; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } cmsgu; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 struct cmsghdr *cmsg; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 int rc; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 /* receive request */ |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 rc = recv(fd, &req, sizeof req, 0); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 if (rc < sizeof req) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 syslog(LOG_DEBUG, "ctrl connection closing"); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 close(fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 FD_CLR(fd, &select_for_read); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 return; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 /* start preparing response */ |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 bzero(&resp, sizeof resp); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 resp.transact_ref = req.transact_ref; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 switch (req.ep_type) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 case RTP_ALLOC_TYPE_GSM: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 case RTP_ALLOC_TYPE_PSTN: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 case RTP_ALLOC_TYPE_GSM2PSTN: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 case RTP_ALLOC_TYPE_GSM2GSM: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 break; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 default: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 resp.res = RTP_ALLOC_ERR_PARAM; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 error_resp: send(fd, &resp, sizeof resp, 0); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 return; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 /* allocate resources */ |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 if (req.ep_type & RTP_ALLOC_DO_GSM1) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 rc = get_rtp_port_pair(&rtp_gsm, &bind_range_gsm); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 if (rc < 0) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 syslog(LOG_ERR, |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 "unable to get local port pair on GSM side"); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 resp.res = RTP_ALLOC_ERR_RSRC; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 goto error_resp; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 if (req.ep_type & RTP_ALLOC_DO_PSTN) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 rc = get_rtp_port_pair(&rtp_pstn, &bind_range_pstn); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 if (rc < 0) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 syslog(LOG_ERR, |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 "unable to get local port pair on PSTN side"); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 if (req.ep_type & RTP_ALLOC_DO_GSM1) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 free_rtp_end(&rtp_gsm); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 resp.res = RTP_ALLOC_ERR_RSRC; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 goto error_resp; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 if (req.ep_type & RTP_ALLOC_DO_GSM2) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 rc = get_rtp_port_pair(&rtp_pstn, &bind_range_gsm); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 if (rc < 0) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 syslog(LOG_ERR, |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 "unable to get 2nd local port pair on GSM side"); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 free_rtp_end(&rtp_gsm); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 resp.res = RTP_ALLOC_ERR_RSRC; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 goto error_resp; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 /* finish ordinary body of response */ |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 resp.res = RTP_ALLOC_OK; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 if (req.ep_type & RTP_ALLOC_DO_GSM1) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 bcopy(&rtp_gsm.bound_addr, &resp.gsm_addr, |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 sizeof(struct sockaddr_in)); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 if (req.ep_type & (RTP_ALLOC_DO_PSTN | RTP_ALLOC_DO_GSM2)) |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 bcopy(&rtp_pstn.bound_addr, &resp.pstn_addr, |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 sizeof(struct sockaddr_in)); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 iov.iov_base = &resp; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 iov.iov_len = sizeof resp; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 /* file descriptor passing voodoo */ |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 switch (req.ep_type) { |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 case RTP_ALLOC_TYPE_GSM: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 num_fd = 2; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 fd_out[0] = rtp_gsm.rtp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 fd_out[1] = rtp_gsm.rtcp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 break; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 case RTP_ALLOC_TYPE_PSTN: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 num_fd = 2; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 fd_out[0] = rtp_pstn.rtp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 fd_out[1] = rtp_pstn.rtcp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 break; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 case RTP_ALLOC_TYPE_GSM2PSTN: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 case RTP_ALLOC_TYPE_GSM2GSM: |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 num_fd = 4; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 fd_out[0] = rtp_gsm.rtp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 fd_out[1] = rtp_gsm.rtcp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 fd_out[2] = rtp_pstn.rtp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 fd_out[3] = rtp_pstn.rtcp_fd; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 bzero(&msg, sizeof msg); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 msg.msg_iov = &iov; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 msg.msg_iovlen = 1; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 msg.msg_control = cmsgu.buf; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 msg.msg_controllen = CMSG_SPACE(sizeof(int) * num_fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 cmsg = CMSG_FIRSTHDR(&msg); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 cmsg->cmsg_level = SOL_SOCKET; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 cmsg->cmsg_type = SCM_RIGHTS; |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * num_fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 fd_bufptr = (int *) CMSG_DATA(cmsg); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 bcopy(fd_out, fd_bufptr, sizeof(int) * num_fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 sendmsg(fd, &msg, 0); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 close_fds(fd_out, num_fd); |
247f4bbde24c
rtp-mgr: daemon ported over
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 } |