Debian Codegraph @

src/testlib/sctputil.c

raw symbols SCIP
1 /* SCTP kernel Implementation
2 * (C) Copyright IBM Corp. 2001, 2003
3 * Copyright (C) 1999 Cisco
4 * Copyright (C) 1999-2000 Motorola
5 # Copyright (C) 2001 Nokia
6 * Copyright (C) 2001 La Monte H.P. Yarroll
7 *
8 * The SCTP implementation is free software;
9 * you can redistribute it and/or modify it under the terms of
10 * the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 *
14 * The SCTP implementation is distributed in the hope that it
15 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
16 * ************************
17 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 * See the GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with GNU CC; see the file COPYING. If not, write to
22 * the Free Software Foundation, 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
24 *
25 * Please send any bug reports or fixes you make to the
26 * email address(es):
27 * lksctp developers <[email protected]>
28 *
29 * Or submit a bug report through the following website:
30 * https://github.com/sctp/lksctp-tools/
31 *
32 * Any bugs reported to us we will try to fix... any fixes shared will
33 * be incorporated into the next SCTP release.
34 *
35 * Written or modified by:
36 * La Monte H.P. Yarroll <[email protected]>
37 * Narasimha Budihal <[email protected]>
38 * Karl Knutson <[email protected]>
39 * Jon Grimm <[email protected]>
40 * Daisy Chang <[email protected]>
41 * Sridhar Samudrala <[email protected]>
42 */
43
44 #include <stdio.h>
45 #include <ctype.h>
46 #include <string.h>
47 #include <sys/types.h>
48 #include <sys/socket.h>
49 #include <sys/uio.h>
50 #include <netinet/in.h>
51 #include <errno.h>
52 #include <malloc.h>
53 #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/
54 #include <sctputil.h>cxx . . $ `<file>/src/testlib/sctputil.h`/
55
56 /* This function prints the cmsg data. */
57 void
58 test_print_cmsgcxx . . $ test_print_cmsg(b4e74ad669979bc0).(sctp_cmsg_tcxx . . $ sctp_cmsg_t# type, sctp_cmsg_data_tcxx . . $ sctp_cmsg_data_t# *data)
59 {
60 switch(type) {
61 case SCTP_INITcxx . . $ `<external>/17169092326581286071/sctp.h:331:9`!:
62 printfcxx . . $ printf(581fddd72a8db8fc).("INIT\n");
63 printfcxx . . $ printf(581fddd72a8db8fc).(" sinit_num_ostreams %d\n",
64 data->initcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#init..sinit_num_ostreamscxx . . $ sctp_initmsg#sinit_num_ostreams.);
65 printfcxx . . $ printf(581fddd72a8db8fc).(" sinit_max_instreams %d\n",
66 data->initcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#init..sinit_max_instreamscxx . . $ sctp_initmsg#sinit_max_instreams.);
67 printfcxx . . $ printf(581fddd72a8db8fc).(" sinit_max_attempts %d\n",
68 data->initcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#init..sinit_max_attemptscxx . . $ sctp_initmsg#sinit_max_attempts.);
69 printfcxx . . $ printf(581fddd72a8db8fc).(" sinit_max_init_timeo %d\n",
70 data->initcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#init..sinit_max_init_timeocxx . . $ sctp_initmsg#sinit_max_init_timeo.);
71
72 break;
73 case SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!:
74 printfcxx . . $ printf(581fddd72a8db8fc).("SNDRCV\n");
75 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_stream %u\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_streamcxx . . $ sctp_sndrcvinfo#sinfo_stream.);
76 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_ssn %u\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_ssncxx . . $ sctp_sndrcvinfo#sinfo_ssn.);
77 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_flags 0x%x\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags.);
78 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_ppid %u\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_ppidcxx . . $ sctp_sndrcvinfo#sinfo_ppid.);
79 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_context %x\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_contextcxx . . $ sctp_sndrcvinfo#sinfo_context.);
80 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_tsn %u\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_tsncxx . . $ sctp_sndrcvinfo#sinfo_tsn.);
81 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_cumtsn %u\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_cumtsncxx . . $ sctp_sndrcvinfo#sinfo_cumtsn.);
82 printfcxx . . $ printf(581fddd72a8db8fc).(" sinfo_assoc_id %u\n", data->sndrcvcxx . . $ $anonymous_type_69a1fd1e4114ead1_0#sndrcv..sinfo_assoc_idcxx . . $ sctp_sndrcvinfo#sinfo_assoc_id.);
83
84 break;
85
86 default:
87 printfcxx . . $ printf(581fddd72a8db8fc).("UNKNOWN CMSG: %d\n", type);
88 break;
89 }
90 }
91
92 /* This function prints the message. */
93 void
94 test_print_messagecxx . . $ test_print_message(86d1599861512f92).(int sk, struct msghdrcxx . . $ msghdr# *msg, size_t msg_len)
95 {
96 sctp_cmsg_data_tcxx . . $ sctp_cmsg_data_t# *data;
97 struct cmsghdrcxx . . $ cmsghdr# *cmsg;
98 int i;
99 int done = 0;
100 char save;
101 union sctp_notificationcxx . . $ sctp_notification# *sn;
102
103 for (cmsg = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(msg);
104 cmsg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
105 cmsg = CMSG_NXTHDRcxx . . $ `<external>/8962547315054503424/socket.h:303:9`!(msg, cmsg)) {
106 data = (sctp_cmsg_data_tcxx . . $ sctp_cmsg_data_t# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(cmsg);
107 test_print_cmsgcxx . . $ test_print_cmsg(b4e74ad669979bc0).(cmsg->cmsg_typecxx . . $ cmsghdr#cmsg_type., data);
108 }
109
110 if (!(MSG_NOTIFICATIONcxx . . $ `<external>/17169092326581286071/sctp.h:181:9`! & msg->msg_flagscxx . . $ msghdr#msg_flags.)) {
111 int index = 0;
112 /* Make sure that everything is printable and that we
113 * are NUL terminated...
114 */
115 printfcxx . . $ printf(581fddd72a8db8fc).("DATA(%lu): ", msg_len);
116 while ( msg_len > 0 ) {
117 char *text;
118 int len;
119
120 text = msg->msg_iovcxx . . $ msghdr#msg_iov.[index].iov_basecxx . . $ iovec#iov_base.;
121 len = msg->msg_iovcxx . . $ msghdr#msg_iov.[index].iov_lencxx . . $ iovec#iov_len.;
122
123 save = text[msg_len-1];
124 if ( len > msg_len ) {
125 text[(len = msg_len) - 1] = '\0';
126 }
127
128 if ( (msg_len -= len) > 0 ) { index++; }
129
130 for (i = 0; i < len - 1; ++i) {
131 if (!isprintcxx . . $ `<external>/17904084882347303253/ctype.h:195:10`!(text[i])) text[i] = '.';
132 }
133
134 printfcxx . . $ printf(581fddd72a8db8fc).("%s", text);
135 text[msg_len-1] = save;
136
137 if ( (done = !strcmpcxx . . $ strcmp(5ae29d726ae57f88).(text, "exit")) ) { break; }
138 }
139 } else {
140 printfcxx . . $ printf(581fddd72a8db8fc).("NOTIFICATION: ");
141 sn = (union sctp_notificationcxx . . $ sctp_notification# *)msg->msg_iovcxx . . $ msghdr#msg_iov.[0].iov_basecxx . . $ iovec#iov_base.;
142 switch (sn->sn_headercxx . . $ sctp_notification#sn_header..sn_typecxx . . $ sctp_notification#$anonymous_type_3#sn_type.) {
143 case SCTP_ASSOC_CHANGEcxx . . $ `<external>/17169092326581286071/sctp.h:666:9`!:
144 switch (sn->sn_assoc_changecxx . . $ sctp_notification#sn_assoc_change..sac_statecxx . . $ sctp_assoc_change#sac_state.) {
145 case SCTP_COMM_UPcxx . . $ SCTP_COMM_UP.:
146 printfcxx . . $ printf(581fddd72a8db8fc).("ASSOC_CHANGE - COMM_UP");
147 break;
148 case SCTP_COMM_LOSTcxx . . $ SCTP_COMM_LOST.:
149 printfcxx . . $ printf(581fddd72a8db8fc).("ASSOC_CHANGE - COMM_LOST");
150 break;
151 case SCTP_RESTARTcxx . . $ SCTP_RESTART.:
152 printfcxx . . $ printf(581fddd72a8db8fc).("ASSOC_CHANGE - RESTART");
153 break;
154 case SCTP_SHUTDOWN_COMPcxx . . $ SCTP_SHUTDOWN_COMP.:
155 printfcxx . . $ printf(581fddd72a8db8fc).("ASSOC_CHANGE - SHUTDOWN_COMP");
156 break;
157 case SCTP_CANT_STR_ASSOCcxx . . $ SCTP_CANT_STR_ASSOC.:
158 printfcxx . . $ printf(581fddd72a8db8fc).("ASSOC_CHANGE - CANT_STR_ASSOC");
159 break;
160 default:
161 printfcxx . . $ printf(581fddd72a8db8fc).("ASSOC_CHANGE - UNEXPECTED(%d)",
162 sn->sn_assoc_changecxx . . $ sctp_notification#sn_assoc_change..sac_statecxx . . $ sctp_assoc_change#sac_state.);
163 break;
164 }
165 break;
166 default:
167 printfcxx . . $ printf(581fddd72a8db8fc).("%d", sn->sn_headercxx . . $ sctp_notification#sn_header..sn_typecxx . . $ sctp_notification#$anonymous_type_3#sn_type.);
168 break;
169 }
170 }
171
172 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
173 }
174
175 /* Check if a buf/msg_flags matches a notification, its type, and possibly an
176 * additional field in the corresponding notification structure.
177 */
178 void
179 test_check_buf_notificationcxx . . $ test_check_buf_notification(a530689182f1c6cd).(void *buf, int datalen, int msg_flags,
180 int expected_datalen, uint16_tcxx . . $ uint16_t# expected_sn_type,
181 uint32_tcxx . . $ uint32_t# expected_additional)
182 {
183 union sctp_notificationcxx . . $ sctp_notification# *sn;
184
185 if (!(msg_flags & MSG_NOTIFICATIONcxx . . $ `<external>/17169092326581286071/sctp.h:181:9`!))
186 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Got a datamsg, expecting "
187 "notification");
188
189 if (expected_datalen <= 0)
190 return;
191
192 if (datalen != expected_datalen)
193 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Got a notification of unexpected "
194 "length:%d, expected length:%d", datalen,
195 expected_datalen);
196
197 sn = (union sctp_notificationcxx . . $ sctp_notification# *)buf;
198 if (sn->sn_headercxx . . $ sctp_notification#sn_header..sn_typecxx . . $ sctp_notification#$anonymous_type_3#sn_type. != expected_sn_type)
199 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Unexpected notification:%d"
200 "expected:%d", sn->sn_header.sn_type,
201 expected_sn_type);
202
203 switch(sn->sn_headercxx . . $ sctp_notification#sn_header..sn_typecxx . . $ sctp_notification#$anonymous_type_3#sn_type.){
204 case SCTP_ASSOC_CHANGEcxx . . $ `<external>/17169092326581286071/sctp.h:666:9`!:
205 if (sn->sn_assoc_changecxx . . $ sctp_notification#sn_assoc_change..sac_statecxx . . $ sctp_assoc_change#sac_state. != expected_additional)
206 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Unexpected sac_state:%d "
207 "expected:%d", sn->sn_assoc_change.sac_state,
208 expected_additional);
209 break;
210 default:
211 break;
212 }
213 }
214
215 /* Check if a message matches a notification, its type, and possibly an
216 * additional field in the corresponding notification structure.
217 */
218 void
219 test_check_msg_notificationcxx . . $ test_check_msg_notification(bda0d4705bf9b0d0).(struct msghdrcxx . . $ msghdr# *msg, int datalen,
220 int expected_datalen, uint16_tcxx . . $ uint16_t# expected_sn_type,
221 uint32_tcxx . . $ uint32_t# expected_additional)
222 {
223 test_check_buf_notificationcxx . . $ test_check_buf_notification(a530689182f1c6cd).(msg->msg_iovcxx . . $ msghdr#msg_iov.[0].iov_basecxx . . $ iovec#iov_base., datalen,
224 msg->msg_flagscxx . . $ msghdr#msg_flags., expected_datalen,
225 expected_sn_type, expected_additional);
226 }
227
228 /* Check if a buf/msg_flags/sinfo corresponds to data, its length, msg_flags,
229 * stream and ppid.
230 */
231 void
232 test_check_buf_datacxx . . $ test_check_buf_data(96488715d48893be).(void *buf, int datalen, int msg_flags,
233 struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sinfo, int expected_datalen,
234 int expected_msg_flags, uint16_tcxx . . $ uint16_t# expected_stream,
235 uint32_tcxx . . $ uint32_t# expected_ppid)
236 {
237 if (msg_flags & MSG_NOTIFICATIONcxx . . $ `<external>/17169092326581286071/sctp.h:181:9`!)
238 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Got a notification, expecting a"
239 "datamsg");
240
241 if (expected_datalen <= 0)
242 return;
243
244 if (datalen != expected_datalen)
245 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Got a datamsg of unexpected "
246 "length:%d, expected length:%d", datalen,
247 expected_datalen);
248
249 if ((msg_flags & ~0x80000000) != expected_msg_flags)
250 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Unexpected msg_flags:0x%x "
251 "expecting:0x%x", msg_flags, expected_msg_flags);
252
253 if ((0 == expected_stream) && (0 == expected_ppid))
254 return;
255
256 if (!sinfo)
257 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Null sinfo, but expected "
258 "stream:%d expected ppid:%d", expected_stream,
259 expected_ppid);
260
261 if (sinfo->sinfo_streamcxx . . $ sctp_sndrcvinfo#sinfo_stream. != expected_stream)
262 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "stream mismatch: expected:%x "
263 "got:%x", expected_stream, sinfo->sinfo_stream);
264 if (sinfo->sinfo_ppidcxx . . $ sctp_sndrcvinfo#sinfo_ppid. != expected_ppid)
265 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "ppid mismatch: expected:%x "
266 "got:%x\n", expected_ppid, sinfo->sinfo_ppid);
267 }
268
269 /* Check if a message corresponds to data, its length, msg_flags, stream and
270 * ppid.
271 */
272 void
273 test_check_msg_datacxx . . $ test_check_msg_data(87a4c472fd2f0d28).(struct msghdrcxx . . $ msghdr# *msg, int datalen, int expected_datalen,
274 int expected_msg_flags, uint16_tcxx . . $ uint16_t# expected_stream,
275 uint32_tcxx . . $ uint32_t# expected_ppid)
276 {
277 struct cmsghdrcxx . . $ cmsghdr# *cmsg = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
278 struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sinfo = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
279
280 /* Receive auxiliary data in msgh. */
281 for (cmsg = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(msg); cmsg != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
282 cmsg = CMSG_NXTHDRcxx . . $ `<external>/8962547315054503424/socket.h:303:9`!(msg, cmsg)){
283 if (IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`! == cmsg->cmsg_levelcxx . . $ cmsghdr#cmsg_level. &&
284 SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`! == cmsg->cmsg_typecxx . . $ cmsghdr#cmsg_type.)
285 break;
286 } /* for( all cmsgs) */
287
288 if ((!cmsg) ||
289 (cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len. < CMSG_LENcxx . . $ `<external>/8962547315054503424/socket.h:311:9`!(sizeof(struct sctp_sndrcvinfo))))
290 sinfo = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
291 else
292 sinfo = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(cmsg);
293
294 test_check_buf_datacxx . . $ test_check_buf_data(96488715d48893be).(msg->msg_iovcxx . . $ msghdr#msg_iov.[0].iov_basecxx . . $ iovec#iov_base., datalen, msg->msg_flagscxx . . $ msghdr#msg_flags.,
295 sinfo, expected_datalen, expected_msg_flags,
296 expected_stream, expected_ppid);
297
298 }
299
300
301 /* Allocate a buffer of requested len and fill in with data. */
302 void *
303 test_build_msgcxx . . $ test_build_msg(d1680a912d714170).(int len)
304 {
305 int i = len - 1;
306 int n;
307 unsigned char msg[] =
308 "012345678901234567890123456789012345678901234567890";
309 char *msg_buf, *p;
310
311 msg_buf = (char *)test_malloccxx . . $ test_malloc(bfcfa4d6b7f7ef64).(len);
312 p = msg_buf;
313
314 do {
315 n = ((i > 50)?50:i);
316 memcpycxx . . $ memcpy(cc817cb175f282d).(p, msg, ((i > 50)?50:i));
317 p += n;
318 i -= n;
319 } while (i > 0);
320
321 msg_buf[len-1] = '\0';
322
323 return(msg_buf);
324 }
325
326 /* Enable ASSOC_CHANGE and SNDRCVINFO notifications. */
327 void test_enable_assoc_changecxx . . $ test_enable_assoc_change(d4f767463ce0a6b3).(int fd)
328 {
329 struct sctp_event_subscribecxx . . $ sctp_event_subscribe# subscribe;
330
331 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&subscribe, 0, sizeof(subscribe));
332 subscribe.sctp_data_io_eventcxx . . $ sctp_event_subscribe#sctp_data_io_event. = 1;
333 subscribe.sctp_association_eventcxx . . $ sctp_event_subscribe#sctp_association_event. = 1;
334 test_setsockoptcxx . . $ test_setsockopt(57908ac6eaa2fecc).(fd, SCTP_EVENTScxx . . $ `<external>/17169092326581286071/sctp.h:80:9`!, (char *)&subscribe,
335 sizeof(subscribe));
336 }
337
338 static int cmp_addrcxx . . $ cmp_addr(8b08d931fe5800dc).(sockaddr_storage_tcxx . . $ sockaddr_storage_t# *addr1, sockaddr_storage_tcxx . . $ sockaddr_storage_t# *addr2)
339 {
340 if (addr1->sacxx . . $ $anonymous_type_f8e963888af85862_0#sa..sa_familycxx . . $ sockaddr#sa_family. != addr2->sacxx . . $ $anonymous_type_f8e963888af85862_0#sa..sa_familycxx . . $ sockaddr#sa_family.)
341 return 0;
342 switch (addr1->sacxx . . $ $anonymous_type_f8e963888af85862_0#sa..sa_familycxx . . $ sockaddr#sa_family.) {
343 case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!:
344 if (addr1->v6cxx . . $ $anonymous_type_f8e963888af85862_0#v6..sin6_portcxx . . $ sockaddr_in6#sin6_port. != addr2->v6cxx . . $ $anonymous_type_f8e963888af85862_0#v6..sin6_portcxx . . $ sockaddr_in6#sin6_port.)
345 return -1;
346 return memcmpcxx . . $ memcmp(36f949851efa3055).(&addr1->v6cxx . . $ $anonymous_type_f8e963888af85862_0#v6..sin6_addrcxx . . $ sockaddr_in6#sin6_addr., &addr2->v6cxx . . $ $anonymous_type_f8e963888af85862_0#v6..sin6_addrcxx . . $ sockaddr_in6#sin6_addr.,
347 sizeof(addr1->v6cxx . . $ $anonymous_type_f8e963888af85862_0#v6..sin6_addrcxx . . $ sockaddr_in6#sin6_addr.));
348 case AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!:
349 if (addr1->v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_portcxx . . $ sockaddr_in#sin_port. != addr2->v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_portcxx . . $ sockaddr_in#sin_port.)
350 return 0;
351 return memcmpcxx . . $ memcmp(36f949851efa3055).(&addr1->v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_addrcxx . . $ sockaddr_in#sin_addr., &addr2->v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_addrcxx . . $ sockaddr_in#sin_addr.,
352 sizeof(addr1->v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_addrcxx . . $ sockaddr_in#sin_addr.));
353 default:
354 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "invalid address type %d",
355 addr1->sa.sa_family);
356 return -1;
357 }
358 }
359
360 /* Test peer addresses for association. */
361 int test_peer_addrcxx . . $ test_peer_addr(8adf02859e3182c0).(int sk, sctp_assoc_tcxx . . $ sctp_assoc_t# asoc, sockaddr_storage_tcxx . . $ sockaddr_storage_t# *peers, int count)
362 {
363 struct sockaddrcxx . . $ sockaddr# *addrs;
364 int error, i, j;
365 struct sockaddrcxx . . $ sockaddr# *sa_addr;
366 socklen_tcxx . . $ socklen_t# addrs_size = 0;
367 void *addrbuf;
368 char *found;
369
370 found = (char *)test_malloccxx . . $ test_malloc(bfcfa4d6b7f7ef64).(count);
371 memsetcxx . . $ memset(d1de1e4fb215f1c6).(found, 0, count);
372
373 error = sctp_getpaddrscxx . . $ sctp_getpaddrs(481df579f251e854).(sk, asoc, &addrs);
374 if (-1 == error) {
375 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sctp_getpaddrs: %s", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
376 return error;
377 }
378 if (error != count) {
379 sctp_freepaddrscxx . . $ sctp_freepaddrs(10d3a1a0427e771a).(addrs);
380 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "peer count %d mismatch, expected %d",
381 error, count);
382 }
383 addrbuf = addrs;
384 for (i = 0; i < count; i++) {
385 sa_addr = (struct sockaddrcxx . . $ sockaddr# *)addrbuf;
386 switch (sa_addr->sa_familycxx . . $ sockaddr#sa_family.) {
387 case AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!:
388 addrs_size += sizeof(struct sockaddr_incxx . . $ sockaddr_in#);
389 addrbuf += sizeof(struct sockaddr_incxx . . $ sockaddr_in#);
390 break;
391 case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!:
392 addrs_size += sizeof(struct sockaddr_in6cxx . . $ sockaddr_in6#);
393 addrbuf += sizeof(struct sockaddr_in6cxx . . $ sockaddr_in6#);
394 break;
395 default:
396 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
397 sctp_freepaddrscxx . . $ sctp_freepaddrs(10d3a1a0427e771a).(addrs);
398 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sctp_getpaddrs: %s", strerror(errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
399 return -1;
400 }
401 for (j = 0; j < count; j++) {
402 if (cmp_addrcxx . . $ cmp_addr(8b08d931fe5800dc).((sockaddr_storage_tcxx . . $ sockaddr_storage_t# *)sa_addr,
403 &peers[j]) == 0) {
404 found[j] = 1;
405 }
406 }
407 }
408 for (j = 0; j < count; j++) {
409 if (found[j] == 0) {
410 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "peer address %d not found", j);
411 }
412 }
413 sctp_freepaddrscxx . . $ sctp_freepaddrs(10d3a1a0427e771a).(addrs);
414 freecxx . . $ free(5d22bdacc48458e8).(found);
415 return 0;
416 }