Debian Codegraph @

lib/freeDiameter-1.2.1/libfdcore/sctp.c

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 /*********************************************************************************************************
2 * Software License Agreement (BSD License) *
3 * Author: Sebastien Decugis <[email protected]> *
4 * *
5 * Copyright (c) 2015, WIDE Project and NICT *
6 * All rights reserved. *
7 * *
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
9 * permitted provided that the following conditions are met: *
10 * *
11 * * Redistributions of source code must retain the above *
12 * copyright notice, this list of conditions and the *
13 * following disclaimer. *
14 * *
15 * * Redistributions in binary form must reproduce the above *
16 * copyright notice, this list of conditions and the *
17 * following disclaimer in the documentation and/or other *
18 * materials provided with the distribution. *
19 * *
20 * * Neither the name of the WIDE Project or NICT nor the *
21 * names of its contributors may be used to endorse or *
22 * promote products derived from this software without *
23 * specific prior written permission of WIDE Project and *
24 * NICT. *
25 * *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
34 *********************************************************************************************************/
35
36 #include "fdcore-internal.h"cxx . . $ `<file>/lib/freeDiameter-1.2.1/libfdcore/fdcore-internal.h`/
37 #include "cnxctx.h"cxx . . $ `<file>/lib/freeDiameter-1.2.1/libfdcore/cnxctx.h`/
38
39 #include <netinet/sctp.h>
40 #include <sys/uio.h>
41
42 /* Size of buffer to receive ancilliary data. May need to be enlarged if more sockopt are set... */
43 #ifndef CMSG_BUF_LEN
44 #define CMSG_BUF_LENcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:44:9`! 1024
45 #endif /* CMSG_BUF_LEN */
46
47 /* Use old draft-ietf-tsvwg-sctpsocket-17 API ? If not defined, RFC6458 API will be used */
48 /* #define OLD_SCTP_SOCKET_API */
49
50 /* Automatically fallback to old API if some of the new symbols are not defined */
•51 //#if (!defined(SCTP_CONNECTX_4_ARGS) || (!defined(SCTP_RECVRCVINFO)) || (!defined(SCTP_SNDINFO)))
52 # define OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
•53 //#endif
54
55 /* Temper with the retransmission timers to try and improve disconnection detection response? Undef this to keep the defaults of SCTP stack */
56 #ifndef USE_DEFAULT_SCTP_RTX_PARAMS /* make this a configuration option if useful */
57 #define ADJUST_RTX_PARAMScxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:57:9`!
58 #endif /* USE_DEFAULT_SCTP_RTX_PARAMS */
59
60 /* Pre-binding socket options -- # streams read in config */
61 static int fd_setsockopt_prebindcxx . . $ fd_setsockopt_prebind(7864480464b09eea).(int sk)
62 {
63 socklen_tcxx . . $ socklen_t# sz;
64
65 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%d", sk);
66
67 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( sk > 0 );
68
69 {
70 int reuse = 1;
71 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, SOL_SOCKETcxx . . $ `<external>/9030916627833342711/socket.h:9:9`!, SO_REUSEADDRcxx . . $ `<external>/9030916627833342711/socket.h:12:9`!, &reuse, sizeof(reuse)) );
72 }
73
74 #ifdef ADJUST_RTX_PARAMScxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:57:9`!
75 /* Set the retransmit parameters */
76 #ifdef SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!
77 {
78 struct sctp_rtoinfocxx . . $ sctp_rtoinfo# rtoinfo;
79 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&rtoinfo, 0, sizeof(rtoinfo));
80
81 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
82 sz = sizeof(rtoinfo);
83 /* Read socket defaults */
84 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!, &rtoinfo, &sz) );
85 if (sz != sizeof(rtoinfo))
86 {
87 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(rtoinfo));
88 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
89 }
90 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_RTOINFO : srto_initial : %u", rtoinfo.srto_initial);
91 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " srto_min : %u", rtoinfo.srto_min);
92 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " srto_max : %u", rtoinfo.srto_max);
93 }
94
95 /* rtoinfo.srto_initial: Estimate of the RTT before it can be measured; keep the default value */
96 rtoinfo.srto_maxcxx . . $ sctp_rtoinfo#srto_max. = 5000; /* Maximum retransmit timer (in ms), we want fast retransmission time. */
97 rtoinfo.srto_mincxx . . $ sctp_rtoinfo#srto_min. = 1000; /* Value under which the RTO does not descend, we set this value to not conflict with srto_max */
98
99 /* Set the option to the socket */
100 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!, &rtoinfo, sizeof(rtoinfo)) );
101
102 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
103 /* Check new values */
104 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_RTOINFOcxx . . $ `<external>/17169092326581286071/sctp.h:69:9`!, &rtoinfo, &sz) );
105 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_RTOINFO : srto_initial : %u", rtoinfo.srto_initial);
106 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " srto_max : %u", rtoinfo.srto_max);
107 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " srto_min : %u", rtoinfo.srto_min);
108 }
109 }
110 #else /* SCTP_RTOINFO */
111 TRACE_DEBUG(ANNOYING, "Skipping SCTP_RTOINFO");
112 #endif /* SCTP_RTOINFO */
113
114 /* Set the association parameters: max number of retransmits, ... */
115 #ifdef SCTP_ASSOCINFOcxx . . $ `<external>/17169092326581286071/sctp.h:70:9`!
116 {
117 struct sctp_assocparamscxx . . $ sctp_assocparams# assoc;
118 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&assoc, 0, sizeof(assoc));
119
120 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
121 sz = sizeof(assoc);
122 /* Read socket defaults */
123 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_ASSOCINFOcxx . . $ `<external>/17169092326581286071/sctp.h:70:9`!, &assoc, &sz) );
124 if (sz != sizeof(assoc))
125 {
126 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(assoc));
127 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
128 }
129 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_ASSOCINFO : sasoc_asocmaxrxt : %hu", assoc.sasoc_asocmaxrxt);
130 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_number_peer_destinations : %hu", assoc.sasoc_number_peer_destinations);
131 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_peer_rwnd : %u" , assoc.sasoc_peer_rwnd);
132 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_local_rwnd : %u" , assoc.sasoc_local_rwnd);
133 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_cookie_life : %u" , assoc.sasoc_cookie_life);
134 }
135
136 assoc.sasoc_asocmaxrxtcxx . . $ sctp_assocparams#sasoc_asocmaxrxt. = 4; /* Maximum number of retransmission attempts: we want fast detection of errors */
137 /* Note that this must remain less than the sum of retransmission parameters of the different paths. */
138
139 /* Set the option to the socket */
140 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_ASSOCINFOcxx . . $ `<external>/17169092326581286071/sctp.h:70:9`!, &assoc, sizeof(assoc)) );
141
142 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
143 /* Check new values */
144 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_ASSOCINFOcxx . . $ `<external>/17169092326581286071/sctp.h:70:9`!, &assoc, &sz) );
145 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_ASSOCINFO : sasoc_asocmaxrxt : %hu", assoc.sasoc_asocmaxrxt);
146 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_number_peer_destinations : %hu", assoc.sasoc_number_peer_destinations);
147 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_peer_rwnd : %u" , assoc.sasoc_peer_rwnd);
148 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_local_rwnd : %u" , assoc.sasoc_local_rwnd);
149 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sasoc_cookie_life : %u" , assoc.sasoc_cookie_life);
150 }
151 }
152 #else /* SCTP_ASSOCINFO */
153 TRACE_DEBUG(ANNOYING, "Skipping SCTP_ASSOCINFO");
154 #endif /* SCTP_ASSOCINFO */
155 #endif /* ADJUST_RTX_PARAMS */
156
157 /* Set the INIT parameters, such as number of streams */
158 #ifdef SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!
159 {
160 struct sctp_initmsgcxx . . $ sctp_initmsg# init;
161 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&init, 0, sizeof(init));
162
163 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
164 sz = sizeof(init);
165
166 /* Read socket defaults */
167 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!, &init, &sz) );
168 if (sz != sizeof(init))
169 {
170 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(init));
171 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
172 }
173 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_INITMSG : sinit_num_ostreams : %hu", init.sinit_num_ostreams);
174 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinit_max_instreams : %hu", init.sinit_max_instreams);
175 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinit_max_attempts : %hu", init.sinit_max_attempts);
176 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinit_max_init_timeo : %hu", init.sinit_max_init_timeo);
177 }
178
179 /* Set the init options -- need to receive SCTP_COMM_UP to confirm the requested parameters, but we don't care (best effort) */
180 init.sinit_num_ostreamscxx . . $ sctp_initmsg#sinit_num_ostreams. = fd_g_configcxx . . $ fd_g_config.->cnf_sctp_strcxx . . $ fd_config#cnf_sctp_str.; /* desired number of outgoing streams */
181 init.sinit_max_init_timeocxx . . $ sctp_initmsg#sinit_max_init_timeo. = CNX_TIMEOUTcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/fdcore-internal.h:55:10`! * 1000;
182
183 /* Set the option to the socket */
184 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!, &init, sizeof(init)) );
185
186 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
187 /* Check new values */
188 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_INITMSGcxx . . $ `<external>/17169092326581286071/sctp.h:71:9`!, &init, &sz) );
189 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_INITMSG : sinit_num_ostreams : %hu", init.sinit_num_ostreams);
190 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinit_max_instreams : %hu", init.sinit_max_instreams);
191 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinit_max_attempts : %hu", init.sinit_max_attempts);
192 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinit_max_init_timeo : %hu", init.sinit_max_init_timeo);
193 }
194 }
195 #else /* SCTP_INITMSG */
196 TRACE_DEBUG(ANNOYING, "Skipping SCTP_INITMSG");
197 #endif /* SCTP_INITMSG */
198
199 /* The SO_LINGER option will be reset if we want to perform SCTP ABORT */
200 #ifdef SO_LINGERcxx . . $ `<external>/9030916627833342711/socket.h:25:9`!
201 {
202 struct lingercxx . . $ linger# linger;
203 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&linger, 0, sizeof(linger));
204
205 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
206 sz = sizeof(linger);
207 /* Read socket defaults */
208 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, SOL_SOCKETcxx . . $ `<external>/9030916627833342711/socket.h:9:9`!, SO_LINGERcxx . . $ `<external>/9030916627833342711/socket.h:25:9`!, &linger, &sz) );
209 if (sz != sizeof(linger))
210 {
211 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(linger));
212 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
213 }
214 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SO_LINGER : l_onoff : %d", linger.l_onoff);
215 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " l_linger : %d", linger.l_linger);
216 }
217
218 linger.l_onoffcxx . . $ linger#l_onoff. = 0; /* Do not activate the linger */
219 linger.l_lingercxx . . $ linger#l_linger. = 0; /* Ignored, but it would mean : Return immediately when closing (=> abort) (graceful shutdown in background) */
220
221 /* Set the option */
222 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, SOL_SOCKETcxx . . $ `<external>/9030916627833342711/socket.h:9:9`!, SO_LINGERcxx . . $ `<external>/9030916627833342711/socket.h:25:9`!, &linger, sizeof(linger)) );
223
224 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
225 /* Check new values */
226 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, SOL_SOCKETcxx . . $ `<external>/9030916627833342711/socket.h:9:9`!, SO_LINGERcxx . . $ `<external>/9030916627833342711/socket.h:25:9`!, &linger, &sz) );
227 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SO_LINGER : l_onoff : %d", linger.l_onoff);
228 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " l_linger : %d", linger.l_linger);
229 }
230 }
231 #else /* SO_LINGER */
232 TRACE_DEBUG(ANNOYING, "Skipping SO_LINGER");
233 #endif /* SO_LINGER */
234
235 /* Set the NODELAY option (Nagle-like algorithm) */
236 #ifdef SCTP_NODELAYcxx . . $ `<external>/17169092326581286071/sctp.h:72:9`!
237 {
238 int nodelay;
239
240 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
241 sz = sizeof(nodelay);
242 /* Read socket defaults */
243 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_NODELAYcxx . . $ `<external>/17169092326581286071/sctp.h:72:9`!, &nodelay, &sz) );
244 if (sz != sizeof(nodelay))
245 {
246 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(nodelay));
247 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
248 }
249 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_NODELAY value : %s", nodelay ? "true" : "false");
250 }
251
252 nodelay = 1; /* We turn ON to disable the Nagle algorithm, so that packets are sent ASAP. */
253
254 /* Set the option to the socket */
255 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_NODELAYcxx . . $ `<external>/17169092326581286071/sctp.h:72:9`!, &nodelay, sizeof(nodelay)) );
256
257 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
258 /* Check new values */
259 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_NODELAYcxx . . $ `<external>/17169092326581286071/sctp.h:72:9`!, &nodelay, &sz) );
260 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_NODELAY value : %s", nodelay ? "true" : "false");
261 }
262 }
263 #else /* SCTP_NODELAY */
264 TRACE_DEBUG(ANNOYING, "Skipping SCTP_NODELAY");
265 #endif /* SCTP_NODELAY */
266
267 /*
268 SO_RCVBUF size of receiver window
269 SO_SNDBUF size of pending data to send
270 SCTP_AUTOCLOSE for one-to-many only
271 SCTP_PRIMARY_ADDR use this address as primary locally
272 SCTP_ADAPTATION_LAYER set adaptation layer indication, we don't use this
273 */
274
275 /* Set the SCTP_DISABLE_FRAGMENTS option, required for TLS */
276 #ifdef SCTP_DISABLE_FRAGMENTScxx . . $ `<external>/17169092326581286071/sctp.h:77:9`!
277 {
278 int nofrag;
279
280 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
281 sz = sizeof(nofrag);
282 /* Read socket defaults */
283 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_DISABLE_FRAGMENTScxx . . $ `<external>/17169092326581286071/sctp.h:77:9`!, &nofrag, &sz) );
284 if (sz != sizeof(nofrag))
285 {
286 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(nofrag));
287 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
288 }
289 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_DISABLE_FRAGMENTS value : %s", nofrag ? "true" : "false");
290 }
291
292 nofrag = 0; /* We turn ON the fragmentation, since Diameter messages & TLS messages can be quite large. */
293
294 /* Set the option to the socket */
295 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_DISABLE_FRAGMENTScxx . . $ `<external>/17169092326581286071/sctp.h:77:9`!, &nofrag, sizeof(nofrag)) );
296
297 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
298 /* Check new values */
299 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_DISABLE_FRAGMENTScxx . . $ `<external>/17169092326581286071/sctp.h:77:9`!, &nofrag, &sz) );
300 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_DISABLE_FRAGMENTS value : %s", nofrag ? "true" : "false");
301 }
302 }
303 #else /* SCTP_DISABLE_FRAGMENTS */
304 # error "TLS requires support of SCTP_DISABLE_FRAGMENTS"
305 #endif /* SCTP_DISABLE_FRAGMENTS */
306
307 /* SCTP_PEER_ADDR_PARAMS control heartbeat per peer address. We set it as a default for all addresses in the association; not sure if it works ... */
308 #ifdef SCTP_PEER_ADDR_PARAMScxx . . $ `<external>/17169092326581286071/sctp.h:78:9`!
309 {
310 struct sctp_paddrparamscxx . . $ sctp_paddrparams# parms;
311 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&parms, 0, sizeof(parms));
312
313 /* Some kernel versions need this to be set */
314 parms.spp_addresscxx . . $ sctp_paddrparams#spp_address..ss_familycxx . . $ sockaddr_storage#ss_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
315
316 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
317 sz = sizeof(parms);
318
319 /* Read socket defaults */
320 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_PEER_ADDR_PARAMScxx . . $ `<external>/17169092326581286071/sctp.h:78:9`!, &parms, &sz) );
321 if (sz != sizeof(parms))
322 {
323 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(parms));
324 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
325 }
326 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_PEER_ADDR_PARAMS : spp_hbinterval : %u", parms.spp_hbinterval);
327 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " spp_pathmaxrxt : %hu", parms.spp_pathmaxrxt);
328 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " spp_pathmtu : %u", parms.spp_pathmtu);
329 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " spp_flags : %x", parms.spp_flags);
330 // fd_log_debug( " spp_ipv6_flowlabel: %u", parms.spp_ipv6_flowlabel);
331 // fd_log_debug( " spp_ipv4_tos : %hhu",parms.spp_ipv4_tos);
332 }
333
334 parms.spp_flagscxx . . $ sctp_paddrparams#spp_flags. = SPP_HB_ENABLEcxx . . $ SPP_HB_ENABLE.; /* Enable heartbeat for the association */
335 #ifdef SPP_PMTUD_ENABLE
336 parms.spp_flags |= SPP_PMTUD_ENABLE; /* also enable path MTU discovery mechanism */
337 #endif /* SPP_PMTUD_ENABLE */
338
339 #ifdef ADJUST_RTX_PARAMScxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:57:9`!
340 parms.spp_hbintervalcxx . . $ sctp_paddrparams#spp_hbinterval. = 6000; /* Send an heartbeat every 6 seconds to quickly start retransmissions */
341 /* parms.spp_pathmaxrxt : max nbr of restransmissions on this address. There is a relationship with sasoc_asocmaxrxt, so we leave the default here */
342 #endif /* ADJUST_RTX_PARAMS */
343
344 /* Set the option to the socket */
345 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_PEER_ADDR_PARAMScxx . . $ `<external>/17169092326581286071/sctp.h:78:9`!, &parms, sizeof(parms)) );
346
347 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
348 /* Check new values */
349 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_PEER_ADDR_PARAMScxx . . $ `<external>/17169092326581286071/sctp.h:78:9`!, &parms, &sz) );
350 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_PEER_ADDR_PARAMS : spp_hbinterval : %u", parms.spp_hbinterval);
351 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " spp_pathmaxrxt : %hu", parms.spp_pathmaxrxt);
352 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " spp_pathmtu : %u", parms.spp_pathmtu);
353 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " spp_flags : %x", parms.spp_flags);
354 // fd_log_debug( " spp_ipv6_flowlabel: %u", parms.spp_ipv6_flowlabel);
355 // fd_log_debug( " spp_ipv4_tos : %hhu",parms.spp_ipv4_tos);
356 }
357 }
358 #else /* SCTP_PEER_ADDR_PARAMS */
359 TRACE_DEBUG(ANNOYING, "Skipping SCTP_PEER_ADDR_PARAMS");
360 #endif /* SCTP_PEER_ADDR_PARAMS */
361
362 /*
363 SCTP_DEFAULT_SEND_PARAM - DEPRECATED // parameters for the sendto() call, we don't use it.
364 */
365
366 /* Subscribe to some notifications */
367 #ifdef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
368 #ifdef SCTP_EVENTScxx . . $ `<external>/17169092326581286071/sctp.h:80:9`! /* DEPRECATED */
369 {
370 struct sctp_event_subscribecxx . . $ sctp_event_subscribe# event;
371
372 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&event, 0, sizeof(event));
373 event.sctp_data_io_eventcxx . . $ sctp_event_subscribe#sctp_data_io_event. = 1; /* to receive the stream ID in SCTP_SNDRCV ancilliary data on message reception */
374 event.sctp_association_eventcxx . . $ sctp_event_subscribe#sctp_association_event. = 0; /* new or closed associations (mostly for one-to-many style sockets) */
375 event.sctp_address_eventcxx . . $ sctp_event_subscribe#sctp_address_event. = 1; /* address changes */
376 event.sctp_send_failure_eventcxx . . $ sctp_event_subscribe#sctp_send_failure_event. = 1; /* delivery failures */
377 event.sctp_peer_error_eventcxx . . $ sctp_event_subscribe#sctp_peer_error_event. = 1; /* remote peer sends an error */
378 event.sctp_shutdown_eventcxx . . $ sctp_event_subscribe#sctp_shutdown_event. = 1; /* peer has sent a SHUTDOWN */
379 event.sctp_partial_delivery_eventcxx . . $ sctp_event_subscribe#sctp_partial_delivery_event. = 1; /* a partial delivery is aborted, probably indicating the connection is being shutdown */
380 // event.sctp_adaptation_layer_event = 0; /* adaptation layer notifications */
381 // event.sctp_authentication_event = 0; /* when new key is made active */
382
383 /* Set the option to the socket */
384 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_EVENTScxx . . $ `<external>/17169092326581286071/sctp.h:80:9`!, &event, sizeof(event)) );
385
386 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
387 sz = sizeof(event);
388 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_EVENTScxx . . $ `<external>/17169092326581286071/sctp.h:80:9`!, &event, &sz) );
389 if (sz != sizeof(event))
390 {
391 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(event));
392 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
393 }
394
395 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "SCTP_EVENTS : sctp_data_io_event : %hhu", event.sctp_data_io_event);
396 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_association_event : %hhu", event.sctp_association_event);
397 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_address_event : %hhu", event.sctp_address_event);
398 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_send_failure_event : %hhu", event.sctp_send_failure_event);
399 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_peer_error_event : %hhu", event.sctp_peer_error_event);
400 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_shutdown_event : %hhu", event.sctp_shutdown_event);
401 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_partial_delivery_event : %hhu", event.sctp_partial_delivery_event);
402 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sctp_adaptation_layer_event : %hhu", event.sctp_adaptation_layer_event);
403 // fd_log_debug( " sctp_authentication_event : %hhu", event.sctp_authentication_event);
404 }
405 }
406 #else /* SCTP_EVENTS */
407 TRACE_DEBUG(ANNOYING, "Skipping SCTP_EVENTS");
408 #endif /* SCTP_EVENTS */
409 #endif /* OLD_SCTP_SOCKET_API */
410
411 /* Set the v4 mapped addresses option */
412 #ifdef SCTP_I_WANT_MAPPED_V4_ADDRcxx . . $ `<external>/17169092326581286071/sctp.h:81:9`!
413 if (!fd_g_configcxx . . $ fd_g_config.->cnf_flagscxx . . $ fd_config#cnf_flags..no_ip6cxx . . $ fd_config#$anonymous_type_0#no_ip6.) {
414 int v4mapped;
415
416 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
417 sz = sizeof(v4mapped);
418 /* Read socket defaults */
419 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_I_WANT_MAPPED_V4_ADDRcxx . . $ `<external>/17169092326581286071/sctp.h:81:9`!, &v4mapped, &sz) );
420 if (sz != sizeof(v4mapped))
421 {
422 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(v4mapped));
423 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
424 }
425 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_I_WANT_MAPPED_V4_ADDR value : %s", v4mapped ? "true" : "false");
426 }
427
428 #ifndef SCTP_USE_MAPPED_ADDRESSES
429 v4mapped = 0; /* We don't want v4 mapped addresses */
430 #else /* SCTP_USE_MAPPED_ADDRESSES */
431 v4mapped = 1; /* but we may have to, otherwise the bind fails in some environments */
432 #endif /* SCTP_USE_MAPPED_ADDRESSES */
433
434 /* Set the option to the socket */
435 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_I_WANT_MAPPED_V4_ADDRcxx . . $ `<external>/17169092326581286071/sctp.h:81:9`!, &v4mapped, sizeof(v4mapped)) );
436
437 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
438 /* Check new values */
439 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_I_WANT_MAPPED_V4_ADDRcxx . . $ `<external>/17169092326581286071/sctp.h:81:9`!, &v4mapped, &sz) );
440 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_I_WANT_MAPPED_V4_ADDR value : %s", v4mapped ? "true" : "false");
441 }
442 } else {
443 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, "Skipping SCTP_I_WANT_MAPPED_V4_ADDR, since IPv6 disabled.");
444 }
445 #else /* SCTP_I_WANT_MAPPED_V4_ADDR */
446 TRACE_DEBUG(ANNOYING, "Skipping SCTP_I_WANT_MAPPED_V4_ADDR");
447 #endif /* SCTP_I_WANT_MAPPED_V4_ADDR */
448
449 /*
450 SCTP_MAXSEG max size of fragmented segments -- bound to PMTU
451 SCTP_HMAC_IDENT authentication algorithms
452 SCTP_AUTH_ACTIVE_KEY set the active key
453 SCTP_DELAYED_SACK control delayed acks
454 */
455
456
457 /* Set the interleaving option */
458 #ifdef SCTP_FRAGMENT_INTERLEAVEcxx . . $ `<external>/17169092326581286071/sctp.h:89:9`!
459 {
460 int interleave;
461
462 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
463 sz = sizeof(interleave);
464 /* Read socket defaults */
465 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_FRAGMENT_INTERLEAVEcxx . . $ `<external>/17169092326581286071/sctp.h:89:9`!, &interleave, &sz) );
466 if (sz != sizeof(interleave))
467 {
468 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(interleave));
469 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
470 }
471 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_FRAGMENT_INTERLEAVE value : %d", interleave);
472 }
473
474 #if 0
475 interleave = 2; /* Allow partial delivery on several streams at the same time, since we are stream-aware in our security modules */
476 #else /* 0 */
477 interleave = 1; /* hmmm actually, we are not yet capable of handling this, and we don t need it. */
478 #endif /* 0 */
479
480 /* Set the option to the socket */
481 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_FRAGMENT_INTERLEAVEcxx . . $ `<external>/17169092326581286071/sctp.h:89:9`!, &interleave, sizeof(interleave)) );
482
483 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
484 /* Check new values */
485 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_FRAGMENT_INTERLEAVEcxx . . $ `<external>/17169092326581286071/sctp.h:89:9`!, &interleave, &sz) );
486 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_FRAGMENT_INTERLEAVE value : %d", interleave);
487 }
488 }
489 #else /* SCTP_FRAGMENT_INTERLEAVE */
490 TRACE_DEBUG(ANNOYING, "Skipping SCTP_FRAGMENT_INTERLEAVE");
491 #endif /* SCTP_FRAGMENT_INTERLEAVE */
492
493 /*
494 SCTP_PARTIAL_DELIVERY_POINT control partial delivery size
495 SCTP_USE_EXT_RCVINFO - DEPRECATED use extended receive info structure (information about the next message if available)
496 */
497 /* SCTP_AUTO_ASCONF is set by the postbind function */
498 /*
499 SCTP_MAX_BURST number of packets that can be burst emitted
500 SCTP_CONTEXT save a context information along with the association.
501 */
502
503 /* SCTP_EXPLICIT_EOR: we assume implicit EOR in freeDiameter, so let's ensure this is known by the stack */
504 #ifdef SCTP_EXPLICIT_EOR
505 {
506 int bool;
507
508 if (TRACE_BOOL(ANNOYING)) {
509 sz = sizeof(bool);
510 /* Read socket defaults */
511 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_EXPLICIT_EOR, &bool, &sz) );
512 if (sz != sizeof(bool))
513 {
514 TRACE_DEBUG(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(bool));
515 return ENOTSUP;
516 }
517 fd_log_debug( "Def SCTP_EXPLICIT_EOR value : %s", bool ? "true" : "false");
518 }
519
520 bool = 0;
521
522 /* Set the option to the socket */
523 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_EXPLICIT_EOR, &bool, sizeof(bool)) );
524
525 if (TRACE_BOOL(ANNOYING)) {
526 /* Check new values */
527 CHECK_SYS( getsockopt(sk, IPPROTO_SCTP, SCTP_EXPLICIT_EOR, &bool, &sz) );
528 fd_log_debug( "New SCTP_EXPLICIT_EOR value : %s", bool ? "true" : "false");
529 }
530 }
531 #else /* SCTP_EXPLICIT_EOR */
532 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, "Skipping SCTP_EXPLICIT_EOR");
533 #endif /* SCTP_EXPLICIT_EOR */
534
535 /*
536 SCTP_REUSE_PORT share one listening port with several sockets
537 */
538
539 #ifndef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
540 #ifdef SCTP_EVENT
541 {
542 /* Subscribe to the following events */
543 int events_I_want[] = {
544 #ifdef SCTP_ASSOC_CHANGE
545 /* SCTP_ASSOC_CHANGE, */
546 #endif
547 #ifdef SCTP_PEER_ADDR_CHANGE
548 SCTP_PEER_ADDR_CHANGE,
549 #endif
550 #ifdef SCTP_REMOTE_ERROR
551 SCTP_REMOTE_ERROR,
552 #endif
553 #ifdef SCTP_SEND_FAILED_EVENT
554 SCTP_SEND_FAILED_EVENT,
555 #endif
556 #ifdef SCTP_SHUTDOWN_EVENT
557 SCTP_SHUTDOWN_EVENT,
558 #endif
559 #ifdef SCTP_ADAPTATION_INDICATION
560 /* SCTP_ADAPTATION_INDICATION, */
561 #endif
562 #ifdef SCTP_PARTIAL_DELIVERY_EVENT
563 /* SCTP_PARTIAL_DELIVERY_EVENT, */
564 #endif
565 #ifdef SCTP_AUTHENTICATION_EVENT
566 /* SCTP_AUTHENTICATION_EVENT, */
567 #endif
568 #ifdef SCTP_SENDER_DRY_EVENT
569 /* SCTP_SENDER_DRY_EVENT, */
570 #endif
571 0
572 };
573 int i;
574
575 struct sctp_event event;
576
577 for (i = 0; i < (sizeof(events_I_want) / sizeof(events_I_want[0]) - 1); i++) {
578 memset(&event, 0, sizeof(event));
579 event.se_type = events_I_want[i];
580 event.se_on = 1;
581
582 /* Set the option to the socket */
583 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_EVENT, &event, sizeof(event)) );
584 }
585 }
586 #else /* SCTP_EVENT */
587 TRACE_DEBUG(ANNOYING, "Skipping SCTP_EVENT");
588 #endif /* SCTP_EVENT */
589
590
591 #ifdef SCTP_RECVRCVINFO /* Replaces SCTP_SNDRCV */
592 {
593 int bool = 1;
594
595 /* Set the option to the socket */
596 CHECK_SYS( setsockopt(sk, IPPROTO_SCTP, SCTP_RECVRCVINFO, &bool, sizeof(bool)) );
597
598 }
599 #else /* SCTP_RECVRCVINFO */
600 TRACE_DEBUG(ANNOYING, "Skipping SCTP_RECVRCVINFO");
601 #endif /* SCTP_RECVRCVINFO */
602
603
604 #endif /* OLD_SCTP_SOCKET_API */
605
606 /*
607 SCTP_RECVNXTINFO
608
609 SCTP_DEFAULT_SNDINFO : send defaults
610 SCTP_DEFAULT_PRINFO : default PR-SCTP
611 */
612
613
614 /* In case of no_ip4, force the v6only option */
615 #ifdef IPV6_V6ONLYcxx . . $ `<external>/13097018388402718637/in.h:186:9`!
616 if (fd_g_configcxx . . $ fd_g_config.->cnf_flagscxx . . $ fd_config#cnf_flags..no_ip4cxx . . $ fd_config#$anonymous_type_0#no_ip4.) {
617 int opt = 1;
618 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!(setsockopt(sk, IPPROTO_IPV6cxx . . $ `<external>/9581057695539925927/in.h:65:9`!, IPV6_V6ONLYcxx . . $ `<external>/13097018388402718637/in.h:186:9`!, &opt, sizeof(opt)));
619 }
620 #endif /* IPV6_V6ONLY */
621
622 return 0;
623 }
624
625
626 /* Post-binding socket options */
627 static int fd_setsockopt_postbindcxx . . $ fd_setsockopt_postbind(9b79fb6aee4c0440).(int sk, int bound_to_default)
628 {
629 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!( "%d %d", sk, bound_to_default);
630
631 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( (sk > 0) );
632
633 /* Set the ASCONF option */
634 #ifdef SCTP_AUTO_ASCONFcxx . . $ `<external>/17169092326581286071/sctp.h:101:9`!
635 if (bound_to_default) {
636 int asconf;
637
638 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
639 socklen_tcxx . . $ socklen_t# sz;
640
641 sz = sizeof(asconf);
642 /* Read socket defaults */
643 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_AUTO_ASCONFcxx . . $ `<external>/17169092326581286071/sctp.h:101:9`!, &asconf, &sz) );
644 if (sz != sizeof(asconf))
645 {
646 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %d", sz, (socklen_t)sizeof(asconf));
647 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
648 }
649 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Def SCTP_AUTO_ASCONF value : %s", asconf ? "true" : "false");
650 }
651
652 asconf = 1; /* allow automatic use of added or removed addresses in the association (for bound-all sockets) */
653
654 /* Set the option to the socket */
655 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( setsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_AUTO_ASCONFcxx . . $ `<external>/17169092326581286071/sctp.h:101:9`!, &asconf, sizeof(asconf)) );
656
657 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
658 socklen_tcxx . . $ socklen_t# sz = sizeof(asconf);
659 /* Check new values */
660 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sk, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_AUTO_ASCONFcxx . . $ `<external>/17169092326581286071/sctp.h:101:9`!, &asconf, &sz) );
661 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "New SCTP_AUTO_ASCONF value : %s", asconf ? "true" : "false");
662 }
663 }
664 #else /* SCTP_AUTO_ASCONF */
665 TRACE_DEBUG(ANNOYING, "Skipping SCTP_AUTO_ASCONF");
666 #endif /* SCTP_AUTO_ASCONF */
667
668 return 0;
669 }
670
671 /* Add addresses from a list to an array, with filter on the flags */
672 static int add_addresses_from_list_maskcxx . . $ add_addresses_from_list_mask(613c6d81537621fc).(uint8_tcxx . . $ uint8_t# ** array, size_t * size, int * addr_count, int target_family, uint16_tcxx . . $ uint16_t# port, struct fd_listcxx . . $ fd_list# * list, uint32_tcxx . . $ uint32_t# mask, uint32_tcxx . . $ uint32_t# val)
673 {
674 struct fd_listcxx . . $ fd_list# * li;
675 int to_add4 = 0;
676 int to_add6 = 0;
677 unioncxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0# {
678 uint8_tcxx . . $ uint8_t# *bufcxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#buf.;
679 sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`! *sincxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#sin.;
680 sSA6cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:633:9`! *sin6cxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#sin6.;
681 } ptr;
682 size_t sz;
683
684 /* First, count the number of addresses to add */
685 for (li = list->nextcxx . . $ fd_list#next.; li != list; li = li->nextcxx . . $ fd_list#next.) {
686 struct fd_endpointcxx . . $ fd_endpoint# * ep = (struct fd_endpointcxx . . $ fd_endpoint# *) li;
687
688 /* Do the flag match ? */
689 if ((val & mask) != (ep->flagscxx . . $ fd_endpoint#flags. & mask))
690 continue;
691
692 if (ep->sacxx . . $ fd_endpoint#$anonymous_type_6#sa..sa_familycxx . . $ sockaddr#sa_family. == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!) {
693 to_add4 ++;
694 } else {
695 to_add6 ++;
696 }
697 }
698
699 if ((to_add4 + to_add6) == 0)
700 return 0; /* nothing to do */
701
702 /* The size to add */
703 if (target_family == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!) {
704 sz = to_add4 * sizeof(sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`!);
705 } else {
706 #ifndef SCTP_USE_MAPPED_ADDRESSES
707 sz = (to_add4 * sizeof(sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`!)) + (to_add6 * sizeof(sSA6cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:633:9`!));
708 #else /* SCTP_USE_MAPPED_ADDRESSES */
709 sz = (to_add4 + to_add6) * sizeof(sSA6);
710 #endif /* SCTP_USE_MAPPED_ADDRESSES */
711 }
712
713 /* Now, (re)alloc the array to store the new addresses */
714 CHECK_MALLOCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:572:10`!( *array = realloc(*array, *size + sz) );
715
716 /* Finally, add the addresses */
717 for (li = list->nextcxx . . $ fd_list#next.; li != list; li = li->nextcxx . . $ fd_list#next.) {
718 struct fd_endpointcxx . . $ fd_endpoint# * ep = (struct fd_endpointcxx . . $ fd_endpoint# *) li;
719
720 /* Skip v6 addresses for v4 socket */
721 if ((target_family == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!) && (ep->sacxx . . $ fd_endpoint#$anonymous_type_6#sa..sa_familycxx . . $ sockaddr#sa_family. == AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!))
722 continue;
723
724 /* Are the flags matching ? */
725 if ((val & mask) != (ep->flagscxx . . $ fd_endpoint#flags. & mask))
726 continue;
727
728 /* Size of the new SA we are adding (array may contain a mix of sockaddr_in and sockaddr_in6) */
729 #ifndef SCTP_USE_MAPPED_ADDRESSES
730 if (ep->sacxx . . $ fd_endpoint#$anonymous_type_6#sa..sa_familycxx . . $ sockaddr#sa_family. == AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!)
731 #else /* SCTP_USE_MAPPED_ADDRESSES */
732 if (target_family == AF_INET6)
733 #endif /* SCTP_USE_MAPPED_ADDRESSES */
734 sz = sizeof(sSA6cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:633:9`!);
735 else
736 sz = sizeof(sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`!);
737
738 /* Place where we add the new address */
739 ptr.bufcxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#buf. = *array + *size; /* place of the new SA */
740
741 /* Update other information */
742 *size += sz;
743 *addr_count += 1;
744
745 /* And write the addr in the buffer */
746 if (sz == sizeof(sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`!)) {
747 memcpycxx . . $ memcpy(cc817cb175f282d).(ptr.bufcxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#buf., &ep->sincxx . . $ fd_endpoint#$anonymous_type_6#sin., sz);
748 ptr.sincxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#sin.->sin_portcxx . . $ sockaddr_in#sin_port. = port;
749 } else {
750 if (ep->sacxx . . $ fd_endpoint#$anonymous_type_6#sa..sa_familycxx . . $ sockaddr#sa_family. == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!) { /* We must map the address */
751 memsetcxx . . $ memset(d1de1e4fb215f1c6).(ptr.bufcxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#buf., 0, sz);
752 ptr.sin6cxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#sin6.->sin6_familycxx . . $ sockaddr_in6#sin6_family. = AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!;
753 IN6_ADDR_V4MAPcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:684:9`!( &ptr.sin6->sin6_addr.s6_addrcxx . . $ `<external>/9581057695539925927/in.h:231:9`!, ep->sin.sin_addr.s_addr );
754 } else {
755 memcpycxx . . $ memcpy(cc817cb175f282d).(ptr.sin6cxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#sin6., &ep->sin6cxx . . $ fd_endpoint#$anonymous_type_6#sin6., sz);
756 }
757 ptr.sin6cxx . . $ add_addresses_from_list_mask(613c6d81537621fc).$anonymous_type_0#sin6.->sin6_portcxx . . $ sockaddr_in6#sin6_port. = port;
758 }
759 }
760
761 return 0;
762 }
763
764 /* Create a socket server and bind it according to daemon s configuration */
765 int fd_sctp_create_bind_servercxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).( int * sock, int family, struct fd_listcxx . . $ fd_list# * list, uint16_tcxx . . $ uint16_t# port )
766 {
767 int bind_default;
768
769 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %i %p %hu", sock, family, list, port);
770 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!(sock);
771
772 /* Create the socket */
773 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( *sock = socket(family, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!) );
774
775 /* Set pre-binding socket options, including number of streams etc... */
776 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!( fd_setsockopt_prebind(*sock) );
777
778 bind_default = (! list) || (FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(list)) ;
779 redo:
780 if ( bind_default ) {
781 /* Implicit endpoints : bind to default addresses */
782 unioncxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1# {
783 sSScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:630:9`! sscxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#ss.;
784 sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! sacxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#sa.;
785 sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`! sincxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#sin.;
786 sSA6cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:633:9`! sin6cxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#sin6.;
787 } s;
788
789 /* 0.0.0.0 and [::] are all zeros */
790 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&s, 0, sizeof(s));
791
792 s.sacxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#sa..sa_familycxx . . $ sockaddr#sa_family. = family;
793
794 if (family == AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!)
795 s.sincxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#sin..sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(port);
796 else
797 s.sin6cxx . . $ fd_sctp_create_bind_server(b4f8b3401271ed3d).$anonymous_type_1#sin6..sin6_portcxx . . $ sockaddr_in6#sin6_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(port);
798
799 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( bind(*sock, &s.sa, sSAlencxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:636:9`!(&s)) );
800
801 } else {
802 /* Explicit endpoints to bind to from config */
803
804 sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! * sar = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* array of addresses */
805 size_t sz = 0; /* size of the array */
806 int count = 0; /* number of sock addr in the array */
807
808 /* Create the array of configured addresses */
809 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!( add_addresses_from_list_mask((void *)&sar, &sz, &count, family, htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(port), list, EP_FL_CONFcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:862:9`!, EP_FL_CONFcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:862:9`!) );
810
811 if (!count) {
812 /* None of the addresses in the list came from configuration, we bind to default */
813 bind_default = 1;
814 goto redo;
815 }
816
817 #if 0
818 union {
819 sSA *sa;
820 uint8_t *buf;
821 } ptr;
822 int i;
823 ptr.sa = sar;
824 fd_log_debug("Calling sctp_bindx with the following address array:");
825 for (i = 0; i < count; i++) {
826 TRACE_sSA(FD_LOG_DEBUG, FULL, " - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
827 ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6) ;
828 }
829 #endif
830
831 /* Bind to this array */
832 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( sctp_bindx(*sock, sar, count, SCTP_BINDX_ADD_ADDRcxx . . $ `<external>/17169092326581286071/sctp.h:1061:9`!) );
833
834 /* We don't need sar anymore */
835 freecxx . . $ free(5d22bdacc48458e8).(sar);
836 }
837
838 /* Now, the server is bound, set remaining sockopt */
839 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!( fd_setsockopt_postbind(*sock, bind_default) );
840
841 /* Debug: show all local listening addresses */
842 #if 0
843 sSA *sar;
844 union {
845 sSA *sa;
846 uint8_t *buf;
847 } ptr;
848 int sz;
849
850 CHECK_SYS( sz = sctp_getladdrs(*sock, 0, &sar) );
851
852 fd_log_debug("SCTP server bound on :");
853 for (ptr.sa = sar; sz-- > 0; ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6)) {
854 TRACE_sSA(FD_LOG_DEBUG, FULL, " - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
855 }
856 sctp_freeladdrs(sar);
857 #endif
858
859 return 0;
860 }
861
862 /* Allow clients connections on server sockets */
863 int fd_sctp_listencxx . . $ fd_sctp_listen(7864480464b09eea).( int sock )
864 {
865 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%d", sock);
866 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( listen(sock, 5) );
867 return 0;
868 }
869
870 /* Create a client socket and connect to remote server */
871 int fd_sctp_clientcxx . . $ fd_sctp_client(cc7a3af1e9c4413e).( int *sock, int no_ip6, uint16_tcxx . . $ uint16_t# port, struct fd_listcxx . . $ fd_list# * list )
872 {
873 int family;
874 unioncxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2# {
875 uint8_tcxx . . $ uint8_t# *bufcxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#buf.;
876 sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! *sacxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#sa.;
877 } sar;
878 size_t size = 0;
879 int count = 0;
880 int ret;
881
882 sar.bufcxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#buf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
883
884 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %i %hu %p", sock, no_ip6, port, list);
885 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( sock && list && (!FD_IS_LIST_EMPTYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:909:9`!(list)) );
886
887 if (no_ip6) {
888 family = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
889 } else {
890 family = AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!;
891 }
892
893 /* Create the socket */
894 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( *sock = socket(family, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!) );
895
896 /* Cleanup if we are cancelled */
897 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!(fd_cleanup_socket, sock);
898
899 /* Set the socket options */
900 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( ret = fd_setsockopt_prebind(*sock), goto out );
901
902 /* Create the array of addresses, add first the configured addresses, then the discovered, then the other ones */
903 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(port), list, EP_FL_CONFcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:862:9`!, EP_FL_CONFcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:862:9`! ), goto out );
904 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(port), list, EP_FL_CONFcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:862:9`! | EP_FL_DISCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:863:9`!, EP_FL_DISCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:863:9`! ), goto out );
905 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( ret = add_addresses_from_list_mask(&sar.buf, &size, &count, family, htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(port), list, EP_FL_CONFcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:862:9`! | EP_FL_DISCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:863:9`!, 0 ), goto out );
906
907 /* Try connecting */
908 LOG_Acxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:326:10`!("Attempting SCTP connection (%d addresses attempted) ", count);
909
910 #if 0
911 /* Dump the SAs */
912 union {
913 uint8_t *buf;
914 sSA *sa;
915 sSA4 *sin;
916 sSA6 *sin6;
917 } ptr;
918 int i;
919 ptr.buf = sar.buf;
920 for (i=0; i< count; i++) {
921 TRACE_sSA(FD_LOG_DEBUG, FULL, " - ", ptr.sa, NI_NUMERICHOST | NI_NUMERICSERV, "" );
922 ptr.buf += (ptr.sa->sa_family == AF_INET) ? sizeof(sSA4) : sizeof(sSA6);
923 }
924 #endif
925
926 /* Bug in some Linux kernel, the sctp_connectx is not a cancellation point. To avoid blocking freeDiameter, we allow async cancel here */
927 pthread_setcanceltypecxx . . $ pthread_setcanceltype(ac48f4a6ffa9e770).(PTHREAD_CANCEL_ASYNCHRONOUScxx . . $ `<external>/14712363683955484316/pthread.h:180:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
928 #ifdef SCTP_CONNECTX_4_ARGScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/config.h:128:9`!
929 ret = sctp_connectxcxx . . $ sctp_connectx(c1090d8010e18ca3).(*sock, sar.sacxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#sa., count, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
930 #else /* SCTP_CONNECTX_4_ARGS */
931 ret = sctp_connectx(*sock, sar.sa, count);
932 #endif /* SCTP_CONNECTX_4_ARGS */
933 /* back to normal cancelation behabior */
934 pthread_setcanceltypecxx . . $ pthread_setcanceltype(ac48f4a6ffa9e770).(PTHREAD_CANCEL_DEFERREDcxx . . $ `<external>/14712363683955484316/pthread.h:178:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
935
936 if (ret < 0) {
937 ret = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
938 /* Some errors are expected, we log at different level */
939 LOG_Acxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:326:10`!("sctp_connectx returned an error: %s", strerror(ret));
940 goto out;
941 }
942
943 freecxx . . $ free(5d22bdacc48458e8).(sar.bufcxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#buf.); sar.bufcxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#buf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
944
945 /* Set the remaining sockopts */
946 CHECK_FCT_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:587:10`!( ret = fd_setsockopt_postbind(*sock, 1),
947 {
948 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( shutdown(*sock, SHUT_RDWRcxx . . $ `<external>/14344695994193663403/socket.h:48:9`!), /* continue */ );
949 } );
950
951 out:
952 ;
953 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
954
955 if (ret) {
956 if (*sock > 0) {
957 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( close(*sock), /* continue */ );
958 *sock = -1;
959 }
960 freecxx . . $ free(5d22bdacc48458e8).(sar.bufcxx . . $ fd_sctp_client(cc7a3af1e9c4413e).$anonymous_type_2#buf.);
961 }
962 return ret;
963 }
964
965 /* Retrieve streams information from a connected association -- optionally provide the primary address */
966 int fd_sctp_get_str_infocxx . . $ fd_sctp_get_str_info(6e53ee05bfc2b7ad).( int sock, uint16_tcxx . . $ uint16_t# *in, uint16_tcxx . . $ uint16_t# *out, sSScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:630:9`! *primary )
967 {
968 struct sctp_statuscxx . . $ sctp_status# status;
969 socklen_tcxx . . $ socklen_t# sz = sizeof(status);
970
971 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%d %p %p %p", sock, in, out, primary);
972 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( (sock > 0) && in && out );
973
974 /* Read the association parameters */
975 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&status, 0, sizeof(status));
976 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( getsockopt(sock, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_STATUScxx . . $ `<external>/17169092326581286071/sctp.h:83:9`!, &status, &sz) );
977 if (sz != sizeof(status))
978 {
979 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Invalid size of socket option: %d / %zd", sz, sizeof(status));
980 return ENOTSUPcxx . . $ `<external>/1531017962457201737/errno.h:30:11`!;
981 }
982 #if 0
983 char sa_buf[sSA_DUMP_STRLEN];
984 fd_sa_sdump_numeric(sa_buf, &status.sstat_primary.spinfo_address);
985 fd_log_debug( "SCTP_STATUS : sstat_state : %i" , status.sstat_state);
986 fd_log_debug( " sstat_rwnd : %u" , status.sstat_rwnd);
987 fd_log_debug( " sstat_unackdata : %hu", status.sstat_unackdata);
988 fd_log_debug( " sstat_penddata : %hu", status.sstat_penddata);
989 fd_log_debug( " sstat_instrms : %hu", status.sstat_instrms);
990 fd_log_debug( " sstat_outstrms : %hu", status.sstat_outstrms);
991 fd_log_debug( " sstat_fragmentation_point : %u" , status.sstat_fragmentation_point);
992 fd_log_debug( " sstat_primary.spinfo_address : %s" , sa_buf);
993 fd_log_debug( " sstat_primary.spinfo_state : %d" , status.sstat_primary.spinfo_state);
994 fd_log_debug( " sstat_primary.spinfo_cwnd : %u" , status.sstat_primary.spinfo_cwnd);
995 fd_log_debug( " sstat_primary.spinfo_srtt : %u" , status.sstat_primary.spinfo_srtt);
996 fd_log_debug( " sstat_primary.spinfo_rto : %u" , status.sstat_primary.spinfo_rto);
997 fd_log_debug( " sstat_primary.spinfo_mtu : %u" , status.sstat_primary.spinfo_mtu);
998 #endif /* 0 */
999
1000 *in = status.sstat_instrmscxx . . $ sctp_status#sstat_instrms.;
1001 *out = status.sstat_outstrmscxx . . $ sctp_status#sstat_outstrms.;
1002
1003 if (primary)
1004 memcpycxx . . $ memcpy(cc817cb175f282d).(primary, &status.sstat_primarycxx . . $ sctp_status#sstat_primary..spinfo_addresscxx . . $ sctp_paddrinfo#spinfo_address., sizeof(sSScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:630:9`!));
1005
1006 return 0;
1007 }
1008
1009 /* Get the list of remote endpoints of the socket */
1010 int fd_sctp_get_remote_epcxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).(int sock, struct fd_listcxx . . $ fd_list# * list)
1011 {
1012 unioncxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).$anonymous_type_3# {
1013 sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! *sacxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).$anonymous_type_3#sa.;
1014 uint8_tcxx . . $ uint8_t# *bufcxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).$anonymous_type_3#buf.;
1015 } ptr;
1016
1017 sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! * data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1018 int count;
1019
1020 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%d %p", sock, list);
1021 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!(list);
1022
1023 /* Read the list on the socket */
1024 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!( count = sctp_getpaddrs(sock, 0, &data) );
1025 ptr.sacxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).$anonymous_type_3#sa. = data;
1026
1027 while (count) {
1028 socklen_tcxx . . $ socklen_t# sl;
1029 switch (ptr.sacxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).$anonymous_type_3#sa.->sa_familycxx . . $ sockaddr#sa_family.) {
1030 case AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!: sl = sizeof(sSA4cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:632:9`!); break;
1031 case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!: sl = sizeof(sSA6cxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:633:9`!); break;
1032 default:
1033 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(INFO, "Unknown address family returned in sctp_getpaddrs: %d, skip", ptr.sa->sa_family);
1034 /* There is a bug in current Linux kernel: http://www.spinics.net/lists/linux-sctp/msg00760.html */
1035 goto stop;
1036 }
1037
1038 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!( fd_ep_add_merge( list, ptr.sa, sl, EP_FL_LLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:865:9`! ) );
1039 ptr.bufcxx . . $ fd_sctp_get_remote_ep(6e026656f4a8c521).$anonymous_type_3#buf. += sl;
1040 count --;
1041 }
1042 stop:
1043 /* Free the list */
1044 sctp_freepaddrscxx . . $ sctp_freepaddrs(10d3a1a0427e771a).(data);
1045
1046 /* Now get the primary address, the add function will take care of merging with existing entry */
1047 {
1048
1049 struct sctp_statuscxx . . $ sctp_status# status;
1050 socklen_tcxx . . $ socklen_t# sz = sizeof(status);
1051 int ret;
1052
1053 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&status, 0, sizeof(status));
1054 /* Attempt to use SCTP_STATUS message to retrieve the primary address */
1055 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( ret = getsockopt(sock, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!, SCTP_STATUScxx . . $ `<external>/17169092326581286071/sctp.h:83:9`!, &status, &sz), /* continue */);
1056 if (sz != sizeof(status))
1057 ret = -1;
1058 sz = sizeof(sSScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:630:9`!);
1059 if (ret < 0)
1060 {
1061 /* Fallback to getsockname -- not recommended by draft-ietf-tsvwg-sctpsocket-19#section-7.4 */
1062 CHECK_SYScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:539:10`!(getpeername(sock, (sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! *)&status.sstat_primary.spinfo_address, &sz));
1063 }
1064
1065 CHECK_FCTcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:588:10`!( fd_ep_add_merge( list, (sSAcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:631:9`! *)&status.sstat_primary.spinfo_address, sz, EP_FL_PRIMARYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdcore.h:866:9`! ) );
1066 }
1067
1068 /* Done! */
1069 return 0;
1070 }
1071
1072 /* Send a vector over a specified stream */
1073 ssize_tcxx . . $ ssize_t# fd_sctp_sendstrvcxx . . $ fd_sctp_sendstrv(550f1b36cd2778b4).(struct cnxctxcxx . . $ cnxctx# * conn, uint16_tcxx . . $ uint16_t# strid, const struct ioveccxx . . $ iovec# *iov, int iovcnt)
1074 {
1075 struct msghdrcxx . . $ msghdr# mhdr;
1076 struct cmsghdrcxx . . $ cmsghdr# *hdr;
1077 #ifdef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
1078 struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sndrcv;
1079 uint8_tcxx . . $ uint8_t# anci[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(struct sctp_sndrcvinfo))];
1080 #else /* OLD_SCTP_SOCKET_API */
1081 struct sctp_sndinfo *sndinf;
1082 uint8_t anci[CMSG_SPACE(sizeof(struct sctp_sndinfo))];
1083 #endif /* OLD_SCTP_SOCKET_API */
1084 ssize_tcxx . . $ ssize_t# ret;
1085 struct timespeccxx . . $ timespec# ts, now;
1086
1087 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %hu %p %d", conn, strid, iov, iovcnt);
1088 CHECK_PARAMS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:575:10`!(conn && iov && iovcnt, { errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!; return -1; } );
1089 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &ts), return -1 );
1090
1091 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&mhdr, 0, sizeof(mhdr));
1092 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&anci, 0, sizeof(anci));
1093
1094 /* Anciliary data: specify SCTP stream */
1095 hdr = (struct cmsghdrcxx . . $ cmsghdr# *)anci;
1096 hdr->cmsg_lencxx . . $ cmsghdr#cmsg_len. = sizeof(anci);
1097 hdr->cmsg_levelcxx . . $ cmsghdr#cmsg_level. = IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!;
1098 #ifdef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
1099 hdr->cmsg_typecxx . . $ cmsghdr#cmsg_type. = SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!;
1100 sndrcv = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(hdr);
1101 sndrcv->sinfo_streamcxx . . $ sctp_sndrcvinfo#sinfo_stream. = strid;
1102 #else /* OLD_SCTP_SOCKET_API */
1103 hdr->cmsg_type = SCTP_SNDINFO;
1104 sndinf = (struct sctp_sndinfo *)CMSG_DATA(hdr);
1105 sndinf->snd_sid = strid;
1106 #endif /* OLD_SCTP_SOCKET_API */
1107 /* note : we could store other data also, for example in .sinfo_ppid for remote peer or in .sinfo_context for errors. */
1108
1109 /* We don't use mhdr.msg_name here; it could be used to specify an address different from the primary */
1110
1111 mhdr.msg_iovcxx . . $ msghdr#msg_iov. = (struct ioveccxx . . $ iovec# *)iov;
1112 mhdr.msg_iovlencxx . . $ msghdr#msg_iovlen. = iovcnt;
1113
1114 mhdr.msg_controlcxx . . $ msghdr#msg_control. = anci;
1115 mhdr.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(anci);
1116
1117 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Sending %d chunks of data (first:%zdb) on stream %hu of socket %d", iovcnt, iov[0].iov_len, strid, conn->cc_socket);
1118 again:
1119 ret = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(conn->cc_socketcxx . . $ cnxctx#cc_socket., &mhdr, 0);
1120 /* Handle special case of timeout */
1121 if ((ret < 0) && ((errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!) || (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!))) {
1122 pthread_testcancelcxx . . $ pthread_testcancel(49f6e7a06ebc5aa8).();
1123 /* Check how much time we were blocked for this sending. */
1124 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( clock_gettime(CLOCK_REALTIMEcxx . . $ `<external>/89459239771508533/time.h:46:10`!, &now), return -1 );
1125 if ( ((now.tv_seccxx . . $ timespec#tv_sec. - ts.tv_seccxx . . $ timespec#tv_sec.) * 1000 + ((now.tv_nseccxx . . $ timespec#tv_nsec. - ts.tv_nseccxx . . $ timespec#tv_nsec.) / 1000000L)) > MAX_HOTL_BLOCKING_TIMEcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/cnxctx.h:42:9`!) {
1126 LOG_Dcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:330:9`!("Unable to send any data for %dms, closing the connection", MAX_HOTL_BLOCKING_TIMEcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/cnxctx.h:42:9`!);
1127 } else if (! fd_cnx_teststatecxx . . $ fd_cnx_teststate(562fa219d1e2ca4e).(conn, CC_STATUS_CLOSINGcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/cnxctx.h:55:11`! )) {
1128 goto again; /* don't care, just ignore */
1129 }
1130
1131 /* propagate the error */
1132 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = -ret;
1133 ret = -1;
1134 }
1135
1136 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!( ret, ); /* for tracing error only */
1137
1138 return ret;
1139 }
1140
1141 /* Receive the next data from the socket, or next notification */
1142 int fd_sctp_recvmetacxx . . $ fd_sctp_recvmeta(179d6a893b6b710).(struct cnxctxcxx . . $ cnxctx# * conn, uint16_tcxx . . $ uint16_t# * strid, uint8_tcxx . . $ uint8_t# ** buf, size_t * len, int *event)
1143 {
1144 ssize_tcxx . . $ ssize_t# ret = 0;
1145 struct msghdrcxx . . $ msghdr# mhdr;
1146 char ancidata[ CMSG_BUF_LENcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:44:9`! ];
1147 struct ioveccxx . . $ iovec# iov;
1148 uint8_tcxx . . $ uint8_t# *data = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1149 size_t bufsz = 0, datasize = 0;
1150 size_t mempagesz = sysconfcxx . . $ sysconf(dc1f09c09fbff20f).(_SC_PAGESIZEcxx . . $ `<external>/6393649343499073842/confname.h:134:9`!); /* We alloc buffer by memory pages for efficiency */
1151 int timedout = 0;
1152
1153 TRACE_ENTRYcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:374:9`!("%p %p %p %p %p", conn, strid, buf, len, event);
1154 CHECK_PARAMScxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:584:10`!( conn && buf && len && event );
1155
1156 /* Cleanup out parameters */
1157 *buf = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1158 *len = 0;
1159 *event = 0;
1160
1161 /* Prepare header for receiving message */
1162 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&mhdr, 0, sizeof(mhdr));
1163 mhdr.msg_iovcxx . . $ msghdr#msg_iov. = &iov;
1164 mhdr.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1;
1165 mhdr.msg_controlcxx . . $ msghdr#msg_control. = &ancidata;
1166 mhdr.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(ancidata);
1167
1168 next_message:
1169 datasize = 0;
1170
1171 /* We will loop while all data is not received. */
1172 incomplete:
1173 while (datasize >= bufsz ) {
1174 /* The buffer is full, enlarge it */
1175 bufsz += mempagesz;
1176 CHECK_MALLOCcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:572:10`!( data = realloc(data, bufsz ) );
1177 }
1178 /* the new data will be received following the preceding */
1179 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&iov, 0, sizeof(iov));
1180 iov.iov_basecxx . . $ iovec#iov_base. = data + datasize ;
1181 iov.iov_lencxx . . $ iovec#iov_len. = bufsz - datasize;
1182
1183 /* Receive data from the socket */
1184 again:
1185 pthread_cleanup_pushcxx . . $ `<external>/14712363683955484316/pthread.h:681:10`!(free, data);
1186 ret = recvmsgcxx . . $ recvmsg(616999ca12de9af7).(conn->cc_socketcxx . . $ cnxctx#cc_socket., &mhdr, 0);
1187 pthread_testcancelcxx . . $ pthread_testcancel(49f6e7a06ebc5aa8).();
1188 pthread_cleanup_popcxx . . $ `<external>/14712363683955484316/pthread.h:702:10`!(0);
1189
1190 /* First, handle timeouts (same as fd_cnx_s_recv) */
1191 if ((ret < 0) && ((errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EAGAINcxx . . $ `<external>/8987895939074593727/errno-base.h:15:9`!) || (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!))) {
1192 if (! fd_cnx_teststatecxx . . $ fd_cnx_teststate(562fa219d1e2ca4e).(conn, CC_STATUS_CLOSINGcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/cnxctx.h:55:11`! ))
1193 goto again; /* don't care, just ignore */
1194 if (!timedout) {
1195 timedout ++; /* allow for one timeout while closing */
1196 goto again;
1197 }
1198 /* fallback to normal handling */
1199 }
1200
1201 /* Handle errors */
1202 if (ret <= 0) { /* Socket timedout, closed, or an error occurred */
1203 CHECK_SYS_DOcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:530:10`!(ret, /* to log in case of error */);
1204 freecxx . . $ free(5d22bdacc48458e8).(data);
1205 *event = FDEVP_CNX_ERRORcxx . . $ FDEVP_CNX_ERROR.;
1206 return 0;
1207 }
1208
1209 /* Update the size of data we received */
1210 datasize += ret;
1211
1212 /* SCTP provides an indication when we received a full record; loop if it is not the case */
1213 if ( ! (mhdr.msg_flagscxx . . $ msghdr#msg_flags. & MSG_EORcxx . . $ `<external>/8962547315054503424/socket.h:228:9`!) ) {
1214 goto incomplete;
1215 }
1216
1217 /* Handle the case where the data received is a notification */
1218 if (mhdr.msg_flagscxx . . $ msghdr#msg_flags. & MSG_NOTIFICATIONcxx . . $ `<external>/17169092326581286071/sctp.h:181:9`!) {
1219 union sctp_notificationcxx . . $ sctp_notification# * notif = (union sctp_notificationcxx . . $ sctp_notification# *) data;
1220
1221 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received %zdb data of notification on socket %d", datasize, conn->cc_socket);
1222
1223 switch (notif->sn_headercxx . . $ sctp_notification#sn_header..sn_typecxx . . $ sctp_notification#$anonymous_type_3#sn_type.) {
1224
1225 case SCTP_ASSOC_CHANGEcxx . . $ `<external>/17169092326581286071/sctp.h:666:9`!: /* We should not receive these as we did not subscribe for it */
1226 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received SCTP_ASSOC_CHANGE notification");
1227 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " state : %hu", notif->sn_assoc_change.sac_state);
1228 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " error : %hu", notif->sn_assoc_change.sac_error);
1229 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " instr : %hu", notif->sn_assoc_change.sac_inbound_streams);
1230 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " outstr : %hu", notif->sn_assoc_change.sac_outbound_streams);
1231
1232 *event = FDEVP_CNX_EP_CHANGEcxx . . $ FDEVP_CNX_EP_CHANGE.;
1233 break;
1234
1235 case SCTP_PEER_ADDR_CHANGEcxx . . $ `<external>/17169092326581286071/sctp.h:668:9`!:
1236 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received SCTP_PEER_ADDR_CHANGE notification");
1237 /* TRACE_sSA(FD_LOG_DEBUG, ANNOYING, " intf_change : ", &(notif->sn_paddr_change.spc_aaddr), NI_NUMERICHOST | NI_NUMERICSERV, "" ); */
1238 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " state : %d", notif->sn_paddr_change.spc_state);
1239 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " error : %d", notif->sn_paddr_change.spc_error);
1240
1241 *event = FDEVP_CNX_EP_CHANGEcxx . . $ FDEVP_CNX_EP_CHANGE.;
1242 break;
1243
1244 case SCTP_REMOTE_ERRORcxx . . $ `<external>/17169092326581286071/sctp.h:672:9`!:
1245 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received SCTP_REMOTE_ERROR notification");
1246 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " err : %hu", ntohscxx . . $ `<external>/9581057695539925927/in.h:429:12`!(notif->sn_remote_error.sre_error));
1247 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " len : %hu", ntohscxx . . $ `<external>/9581057695539925927/in.h:429:12`!(notif->sn_remote_error.sre_length));
1248
1249 *event = FDEVP_CNX_ERRORcxx . . $ FDEVP_CNX_ERROR.;
1250 break;
1251
1252 #ifdef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
1253 case SCTP_SEND_FAILEDcxx . . $ `<external>/17169092326581286071/sctp.h:670:9`!:
1254 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received SCTP_SEND_FAILED notification");
1255 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " len : %hu", notif->sn_send_failed.ssf_length);
1256 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(ANNOYING, " err : %d", notif->sn_send_failed.ssf_error);
1257
1258 *event = FDEVP_CNX_ERRORcxx . . $ FDEVP_CNX_ERROR.;
1259 break;
1260 #else /* OLD_SCTP_SOCKET_API */
1261 case SCTP_SEND_FAILED_EVENT:
1262 TRACE_DEBUG(FULL, "Received SCTP_SEND_FAILED_EVENT notification");
1263 *event = FDEVP_CNX_ERROR;
1264 break;
1265 #endif /* OLD_SCTP_SOCKET_API */
1266 case SCTP_SHUTDOWN_EVENTcxx . . $ `<external>/17169092326581286071/sctp.h:674:9`!:
1267 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received SCTP_SHUTDOWN_EVENT notification");
1268
1269 *event = FDEVP_CNX_SHUTDOWNcxx . . $ FDEVP_CNX_SHUTDOWN.;
1270 break;
1271
1272 #ifndef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
1273 case SCTP_NOTIFICATIONS_STOPPED_EVENT:
1274 TRACE_DEBUG(INFO, "Received SCTP_NOTIFICATIONS_STOPPED_EVENT notification, marking the association in error state");
1275 *event = FDEVP_CNX_ERROR;
1276 break;
1277 #endif /* OLD_SCTP_SOCKET_API */
1278
1279 default:
1280 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received unknown notification %d, ignored", notif->sn_header.sn_type);
1281 goto next_message;
1282 }
1283
1284 freecxx . . $ free(5d22bdacc48458e8).(data);
1285 return 0;
1286 }
1287
1288 /* From this point, we have received a message */
1289 *event = FDEVP_CNX_MSG_RECVcxx . . $ FDEVP_CNX_MSG_RECV.;
1290 *buf = data;
1291 *len = datasize;
1292
1293 if (strid) {
1294 struct cmsghdrcxx . . $ cmsghdr# *hdr;
1295 #ifdef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
1296 struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sndrcv;
1297 #else /* OLD_SCTP_SOCKET_API */
1298 struct sctp_rcvinfo *rcvinf;
1299 #endif /* OLD_SCTP_SOCKET_API */
1300
1301 /* Handle the anciliary data */
1302 for (hdr = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(&mhdr); hdr; hdr = CMSG_NXTHDRcxx . . $ `<external>/8962547315054503424/socket.h:303:9`!(&mhdr, hdr)) {
1303
1304 /* We deal only with anciliary data at SCTP level */
1305 if (hdr->cmsg_levelcxx . . $ cmsghdr#cmsg_level. != IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!) {
1306 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received some anciliary data at level %d, skipped", hdr->cmsg_level);
1307 continue;
1308 }
1309
1310 #ifdef OLD_SCTP_SOCKET_APIcxx . . $ `lib/freeDiameter-1.2.1/libfdcore/sctp.c:52:10`!
1311 /* Also only interested in SCTP_SNDRCV message for the moment */
1312 if (hdr->cmsg_typecxx . . $ cmsghdr#cmsg_type. != SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!) {
1313 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Anciliary block IPPROTO_SCTP / %d, skipped", hdr->cmsg_type);
1314 continue;
1315 }
1316
1317 sndrcv = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *) CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(hdr);
1318 if (TRACE_BOOLcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:490:9`!(ANNOYING)) {
1319 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( "Anciliary block IPPROTO_SCTP / SCTP_SNDRCV");
1320 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_stream : %hu", sndrcv->sinfo_stream);
1321 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_ssn : %hu", sndrcv->sinfo_ssn);
1322 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_flags : %hu", sndrcv->sinfo_flags);
1323 /* fd_log_debug( " sinfo_pr_policy : %hu", sndrcv->sinfo_pr_policy); */
1324 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_ppid : %u" , sndrcv->sinfo_ppid);
1325 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_context : %u" , sndrcv->sinfo_context);
1326 /* fd_log_debug( " sinfo_pr_value : %u" , sndrcv->sinfo_pr_value); */
1327 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_tsn : %u" , sndrcv->sinfo_tsn);
1328 fd_log_debugcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:510:9`!( " sinfo_cumtsn : %u" , sndrcv->sinfo_cumtsn);
1329 }
1330
1331 *strid = sndrcv->sinfo_streamcxx . . $ sctp_sndrcvinfo#sinfo_stream.;
1332 #else /* OLD_SCTP_SOCKET_API */
1333 /* Also only interested in SCTP_RCVINFO message for the moment */
1334 if (hdr->cmsg_type != SCTP_RCVINFO) {
1335 TRACE_DEBUG(FULL, "Anciliary block IPPROTO_SCTP / %d, skipped", hdr->cmsg_type);
1336 continue;
1337 }
1338
1339 rcvinf = (struct sctp_rcvinfo *) CMSG_DATA(hdr);
1340
1341 *strid = rcvinf->rcv_sid;
1342 #endif /* OLD_SCTP_SOCKET_API */
1343
1344
1345 }
1346 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received %zdb data on socket %d, stream %hu", datasize, conn->cc_socket, *strid);
1347 } else {
1348 TRACE_DEBUGcxx . . $ `lib/freeDiameter-1.2.1/include/freeDiameter/libfdproto.h:515:10`!(FULL, "Received %zdb data on socket %d (stream ignored)", datasize, conn->cc_socket);
1349 }
1350
1351 return 0;
1352 }