Debian Codegraph @

src/func_tests/test_tcp_style.c

raw symbols SCIP
1 /* SCTP kernel Implementation
2 * (C) Copyright IBM Corp. 2003
3 * Copyright (c) 1999-2001 Motorola, Inc.
4 *
5 * This file is part of the SCTP kernel Implementation
6 *
7 * The SCTP implementation is free software;
8 * you can redistribute it and/or modify it under the terms of
9 * the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * The SCTP implementation is distributed in the hope that it
14 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
15 * ************************
16 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 * See the GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with GNU CC; see the file COPYING. If not, write to
21 * the Free Software Foundation, 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
23 *
24 * Please send any bug reports or fixes you make to the
25 * email address(es):
26 * lksctp developers <[email protected]>
27 *
28 * Or submit a bug report through the following website:
29 * https://github.com/sctp/lksctp-tools/
30 *
31 * Any bugs reported to us we will try to fix... any fixes shared will
32 * be incorporated into the next SCTP release.
33 *
34 * Written or modified by:
35 * Sridhar Samudrala <[email protected]>
36 */
37
38 /* This is a kernel test to verify the TCP-style socket interfaces. */
39
40 #include <stdio.h>
41 #include <unistd.h>
42 #include <stdlib.h>
43 #include <string.h>
44 #include <fcntl.h>
45 #include <sys/types.h>
46 #include <sys/socket.h>
47 #include <sys/uio.h>
48 #include <sys/poll.h>
49 #include <netinet/in.h>
50 #include <errno.h>
51 #include <netinet/sctp.h>cxx . . $ `<file>/src/include/netinet/sctp.h`/
52 #include <sctputil.h>cxx . . $ `<file>/src/testlib/sctputil.h`/
53
54 char *TCIDcxx . . $ TCID. = __FILE__;
55 int TST_TOTALcxx . . $ TST_TOTAL. = 22;
56 int TST_CNTcxx . . $ TST_CNT. = 0;
57
58 #define MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`! 10
59
60 int
61 maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[])
62 {
63 int clt_sk[MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!], accept_sk[MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!];
64 int listen_sk, clt2_sk, accept2_sk;
65 sockaddr_storage_tcxx . . $ sockaddr_storage_t# clt_loop[MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!];
66 sockaddr_storage_tcxx . . $ sockaddr_storage_t# svr_loop, accept_loop, clt2_loop;
67 socklen_tcxx . . $ socklen_t# addrlen;
68 int error, i;
69 char *message = "hello, world!\n";
70 char msgbuf[100];
71 int pf_class;
72 struct pollfdcxx . . $ pollfd# poll_fd;
73 fd_setcxx . . $ fd_set# set;
74 struct msghdrcxx . . $ msghdr# outmessage;
75 char outcmsg[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(struct sctp_sndrcvinfo))];
76 struct ioveccxx . . $ iovec# out_iov;
77 struct cmsghdrcxx . . $ cmsghdr# *cmsg;
78 struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *sinfo;
79 struct msghdrcxx . . $ msghdr# inmessage;
80 char incmsg[CMSG_SPACEcxx . . $ `<external>/8962547315054503424/socket.h:309:9`!(sizeof(sctp_cmsg_data_t))];
81 char *big_buffer;
82 struct ioveccxx . . $ iovec# iov;
83
84 /* Rather than fflush() throughout the code, set stdout to
85 * be unbuffered.
86 */
87 setvbufcxx . . $ setvbuf(4da3ba8c983f31bc).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, _IONBFcxx . . $ `<external>/232824719582829767/stdio.h:100:9`!, 0);
88
89 /* Initialize the server and client addresses. */
90 #if TEST_V6
91 pf_class = PF_INET6;
92 svr_loop.v6.sin6_family = AF_INET6;
93 svr_loop.v6.sin6_addr = in6addr_loopbackcxx . . $ in6addr_loopback.;
94 svr_loop.v6.sin6_port = htons(SCTP_TESTPORT_1);
95 for (i = 0; i < MAX_CLIENTS; i++) {
96 clt_loop[i].v6.sin6_family = AF_INET6;
97 clt_loop[i].v6.sin6_addr = in6addr_loopbackcxx . . $ in6addr_loopback.;
98 clt_loop[i].v6.sin6_port = htons(SCTP_TESTPORT_2 + i);
99 }
100 clt2_loop.v6.sin6_family = AF_INET6;
101 clt2_loop.v6.sin6_addr = in6addr_loopbackcxx . . $ in6addr_loopback.;
102 clt2_loop.v6.sin6_port = htons(SCTP_TESTPORT_2 + i);
103 #else
104 pf_class = PF_INETcxx . . $ `<external>/8962547315054503424/socket.h:45:9`!;
105 svr_loop.v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
106 svr_loop.v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!;
107 svr_loop.v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_1cxx . . $ `src/testlib/sctputil.h:71:9`!);
108 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++) {
109 clt_loop[i].v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
110 clt_loop[i].v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!;
111 clt_loop[i].v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_2cxx . . $ `src/testlib/sctputil.h:73:9`! + i);
112 }
113 clt2_loop.v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_familycxx . . $ sockaddr_in#sin_family. = AF_INETcxx . . $ `<external>/8962547315054503424/socket.h:97:9`!;
114 clt2_loop.v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_addrcxx . . $ sockaddr_in#sin_addr..s_addrcxx . . $ in_addr#s_addr. = SCTP_IP_LOOPBACKcxx . . $ `src/testlib/sctputil.h:76:9`!;
115 clt2_loop.v4cxx . . $ $anonymous_type_f8e963888af85862_0#v4..sin_portcxx . . $ sockaddr_in#sin_port. = htonscxx . . $ `<external>/9581057695539925927/in.h:431:12`!(SCTP_TESTPORT_2cxx . . $ `src/testlib/sctputil.h:73:9`! + i);
116 #endif
117
118 /* Create and bind the listening server socket. */
119 listen_sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!);
120 test_bindcxx . . $ test_bind(18e507052d945257).(listen_sk, &svr_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(svr_loop));
121
122 /* Mark listen_sk as being able to accept new associations. */
123 test_listencxx . . $ test_listen(9b79fb6aee4c0440).(listen_sk, MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!-1);
124
125 /* Create and bind the client sockets. */
126 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++) {
127 clt_sk[i] = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!);
128 test_bindcxx . . $ test_bind(18e507052d945257).(clt_sk[i], &clt_loop[i].sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(clt_loop[i]));
129 }
130 clt2_sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!);
131 test_bindcxx . . $ test_bind(18e507052d945257).(clt2_sk, &clt2_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(clt2_loop));
132
133 addrlen = sizeof(accept_loop);
134 /* Try to do accept on a non-listening socket. It should fail. */
135 error = acceptcxx . . $ accept(46fcd054f4a4d98b).(clt_sk[0], &accept_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., &addrlen);
136 if ((-1 != error) && (EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
137 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "accept on non-listening socket "
138 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
139
140 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "accept on non-listening socket");
141
142 /* Try to do a connect from a listening socket. It should fail. */
143 error = connectcxx . . $ connect(1ce9971e209c3c95).(listen_sk, (struct sockaddrcxx . . $ sockaddr# *)&clt_loop[0],
144 sizeof(clt_loop[0]));
145 if ((-1 != error) && (EISCONNcxx . . $ `<external>/17922322188510340118/errno.h:90:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
146 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "connect to non-listening socket "
147 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
148
149 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "connect to non-listening socket");
150
151 /* Do a blocking connect from clt_sk's to listen_sk */
152 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++)
153 test_connectcxx . . $ test_connect(18e507052d945257).(clt_sk[i], &svr_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(svr_loop));
154
155 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "connect to listening socket");
156
157 /* Verify that no more connect's can be done after the acceptq
158 * backlog has reached the max value.
159 */
160 error = connectcxx . . $ connect(1ce9971e209c3c95).(clt2_sk, &svr_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(svr_loop));
161 if ((-1 != error) && (ECONNREFUSEDcxx . . $ `<external>/17922322188510340118/errno.h:95:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
162 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "connect after max backlog "
163 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
164
165 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "connect after max backlog");
166
167 /* Extract the associations on the listening socket as new sockets. */
168 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++) {
169 poll_fd.fdcxx . . $ pollfd#fd. = listen_sk;
170 poll_fd.eventscxx . . $ pollfd#events. = POLLINcxx . . $ `<external>/17223861378049612178/poll.h:25:9`!;
171 poll_fd.reventscxx . . $ pollfd#revents. = 0;
172 error = pollcxx . . $ poll(bc0744c797f613bd).(&poll_fd, 1, -1);
173 if ((1 != error) && (1 != poll_fd.reventscxx . . $ pollfd#revents.))
174 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Unexpected return value "
175 "with poll, error:%d errno:%d, revents:%d",
176 error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!, poll_fd.revents);
177
178 addrlen = sizeof(accept_loop);
179 accept_sk[i] = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(listen_sk, &accept_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa.,
180 &addrlen);
181 }
182
183 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "accept from listening socket");
184
185 /* Try to do a connect on an established socket. It should fail. */
186 error = connectcxx . . $ connect(1ce9971e209c3c95).(accept_sk[0], &clt_loop[0].sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(clt_loop[0]));
187 if ((-1 != error) || (EISCONNcxx . . $ `<external>/17922322188510340118/errno.h:90:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
188 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "connect on an established socket "
189 "error:%d errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
190
191 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "connect on an established socket");
192
193 /* Try to do accept on an established socket. It should fail. */
194 error = acceptcxx . . $ accept(46fcd054f4a4d98b).(accept_sk[0], &accept_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., &addrlen);
195 if ((-1 != error) && (EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
196 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "accept on an established socket "
197 "error:%d errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
198
199 error = acceptcxx . . $ accept(46fcd054f4a4d98b).(clt_sk[0], &accept_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., &addrlen);
200 if ((-1 != error) && (EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
201 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "accept on an established socket "
202 "failure: error:%d errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
203
204 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "accept on an established socket");
205
206 /* Send and receive a message from the client sockets to the accepted
207 * sockets.
208 */
209 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++) {
210 test_sendcxx . . $ test_send(9d1ebb2cd9604347).(clt_sk[i], message, strlencxx . . $ strlen(751346f8406fd082).(message), 0);
211 test_recvcxx . . $ test_recv(6076e73854a1e617).(accept_sk[i], msgbuf, 100, 0);
212 }
213
214 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "client sockets -> accepted sockets");
215
216 /* Send and receive a message from the accepted sockets to the client
217 * sockets.
218 */
219 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++) {
220 test_sendcxx . . $ test_send(9d1ebb2cd9604347).(accept_sk[i], message, strlencxx . . $ strlen(751346f8406fd082).(message), 0);
221 test_recvcxx . . $ test_recv(6076e73854a1e617).(clt_sk[i], msgbuf, 100, 0);
222 }
223
224 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "accepted sockets -> client sockets");
225
226 /* Sending a message on a listening socket should fail. */
227 error = sendcxx . . $ send(4e364047dcdcb5ca).(listen_sk, message, strlencxx . . $ strlen(751346f8406fd082).(message), MSG_NOSIGNALcxx . . $ `<external>/8962547315054503424/socket.h:242:9`!);
228 if ((-1 != error) || (EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
229 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "send on a listening socket "
230 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
231
232 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "send on a listening socket");
233
234 /* Trying to receive a message on a listening socket should fail. */
235 error = recvcxx . . $ recv(4136b1fcb15a75da).(listen_sk, msgbuf, 100, 0);
236 if ((-1 != error) || (ENOTCONNcxx . . $ `<external>/17922322188510340118/errno.h:91:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
237 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a listening socket "
238 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
239
240 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "recv on a listening socket");
241
242 /* TESTCASES for shutdown() */
243 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
244 test_sendcxx . . $ test_send(9d1ebb2cd9604347).(accept_sk[0], message, strlencxx . . $ strlen(751346f8406fd082).(message), 0);
245
246 /* Enable ASSOC_CHANGE and SNDRCVINFO notifications. */
247 test_enable_assoc_changecxx . . $ test_enable_assoc_change(d4f767463ce0a6b3).(clt_sk[0]);
248
249 /* Do a SHUT_WR on clt_sk[0] to disable any new sends. */
250 test_shutdowncxx . . $ test_shutdown(9b79fb6aee4c0440).(clt_sk[0], SHUT_WRcxx . . $ `<external>/14344695994193663403/socket.h:46:9`!);
251
252 /* Reading on a socket that has received SHUTDOWN should return 0
253 * indicating EOF.
254 */
255 error = recvcxx . . $ recv(4136b1fcb15a75da).(accept_sk[0], msgbuf, 100, 0);
256 if ((0 != error) || (0 != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
257 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a SHUTDOWN received socket "
258 "error:%d errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
259
260 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "recv on a SHUTDOWN received socket");
261
262 /* Read the pending message on clt_sk[0] that was received before
263 * SHUTDOWN call.
264 */
265 test_recvcxx . . $ test_recv(6076e73854a1e617).(clt_sk[0], msgbuf, 100, 0);
266
267 /* Initialize inmessage for all receives. */
268 big_buffer = test_malloccxx . . $ test_malloc(bfcfa4d6b7f7ef64).(REALLY_BIGcxx . . $ `src/testlib/sctputil.h:65:9`!);
269 memsetcxx . . $ memset(d1de1e4fb215f1c6).(&inmessage, 0, sizeof(inmessage));
270 iov.iov_basecxx . . $ iovec#iov_base. = big_buffer;
271 iov.iov_lencxx . . $ iovec#iov_len. = REALLY_BIGcxx . . $ `src/testlib/sctputil.h:65:9`!;
272 inmessage.msg_iovcxx . . $ msghdr#msg_iov. = &iov;
273 inmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1;
274 inmessage.msg_controlcxx . . $ msghdr#msg_control. = incmsg;
275 inmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(incmsg);
276
277 /* Receive the SHUTDOWN_COMP notification as they are enabled. */
278 error = test_recvmsgcxx . . $ test_recvmsg(2284ea468be03a33).(clt_sk[0], &inmessage, MSG_WAITALLcxx . . $ `<external>/8962547315054503424/socket.h:230:9`!);
279 test_check_msg_notificationcxx . . $ test_check_msg_notification(bda0d4705bf9b0d0).(&inmessage, error,
280 sizeof(struct sctp_assoc_changecxx . . $ sctp_assoc_change#),
281 SCTP_ASSOC_CHANGEcxx . . $ `<external>/17169092326581286071/sctp.h:666:9`!, SCTP_SHUTDOWN_COMPcxx . . $ SCTP_SHUTDOWN_COMP.);
282
283 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "recv SHUTDOWN_COMP notification on a SHUT_WR socket");
284
285 /* No more messages and the association is SHUTDOWN, should fail. */
286 error = recvcxx . . $ recv(4136b1fcb15a75da).(clt_sk[0], msgbuf, 100, 0);
287 if ((-1 != error) || (ENOTCONNcxx . . $ `<external>/17922322188510340118/errno.h:91:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
288 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a SHUTDOWN sent socket "
289 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
290
291 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "recv on a SHUTDOWN sent socket");
292
293 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
294
295 /* Do a SHUT_RD on clt_sk[1] to disable any new receives. */
296 test_shutdowncxx . . $ test_shutdown(9b79fb6aee4c0440).(clt_sk[1], SHUT_RDcxx . . $ `<external>/14344695994193663403/socket.h:44:9`!);
297
298 error = recvcxx . . $ recv(4136b1fcb15a75da).(clt_sk[1], msgbuf, 100, 0);
299 if ((0 != error) || (0 != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
300 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a SHUT_RD socket "
301 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
302
303 /* Sending a message on SHUT_RD socket. */
304 test_sendcxx . . $ test_send(9d1ebb2cd9604347).(clt_sk[1], message, strlencxx . . $ strlen(751346f8406fd082).(message), 0);
305
306 /* Receive the message sent on SHUT_RD socket. */
307 test_recvcxx . . $ test_recv(6076e73854a1e617).(accept_sk[1], msgbuf, 100, 0);
308
309 /* Send a message to the SHUT_RD socket. */
310 test_sendcxx . . $ test_send(9d1ebb2cd9604347).(accept_sk[1], message, strlencxx . . $ strlen(751346f8406fd082).(message), 0);
311
312 /* We should not receive the message as the socket is SHUT_RD */
313 error = recvcxx . . $ recv(4136b1fcb15a75da).(clt_sk[1], msgbuf, 100, 0);
314 if ((0 != error) || (0 != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
315 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a SHUT_RD socket "
316 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
317
318 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "recv on a SHUT_RD socket");
319
320 /* Do a SHUT_RDWR on clt_sk[2] to disable any new sends/receives. */
321 test_shutdowncxx . . $ test_shutdown(9b79fb6aee4c0440).(clt_sk[2], SHUT_RDWRcxx . . $ `<external>/14344695994193663403/socket.h:48:9`!);
322
323 error = recvcxx . . $ recv(4136b1fcb15a75da).(accept_sk[2], msgbuf, 100, 0);
324 if ((0 != error) || (0 != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
325 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a SHUT_RDWR socket "
326 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
327
328 error = recvcxx . . $ recv(4136b1fcb15a75da).(clt_sk[2], msgbuf, 100, 0);
329 if ((0 != error) || (0 != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
330 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "recv on a SHUT_RDWR socket "
331 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
332
333 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "recv on a SHUT_RDWR socket");
334
335 error = 0;
336
337 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++)
338 closecxx . . $ close(7864480464b09eea).(clt_sk[i]);
339 for (i = 0; i < MAX_CLIENTScxx . . $ `src/func_tests/test_tcp_style.c:58:9`!; i++)
340 closecxx . . $ close(7864480464b09eea).(accept_sk[i]);
341
342 /* Test case to verify accept of a CLOSED association. */
343 /* Do a connect, send and a close to ESTABLISH and CLOSE an
344 * association on the listening socket.
345 */
346 test_connectcxx . . $ test_connect(18e507052d945257).(clt2_sk, &svr_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(svr_loop));
347
348 test_sendcxx . . $ test_send(9d1ebb2cd9604347).(clt2_sk, message, strlencxx . . $ strlen(751346f8406fd082).(message), 0);
349
350 closecxx . . $ close(7864480464b09eea).(clt2_sk);
351
352 FD_ZEROcxx . . $ `<external>/946878812840035423/select.h:88:9`!(&set);
353 FD_SETcxx . . $ `<external>/946878812840035423/select.h:85:9`!(listen_sk, &set);
354
355 error = selectcxx . . $ select(6d24c7514c8a5b88).(listen_sk + 1, &set, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
356 if (1 != error)
357 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "select error:%d, "
358 "errno: %d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
359
360 /* Now accept the CLOSED association waiting on the listening
361 * socket.
362 */
363 accept2_sk = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(listen_sk, &accept_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., &addrlen);
364
365 /* Receive the message sent before doing a close. */
366 test_recvcxx . . $ test_recv(6076e73854a1e617).(accept2_sk, msgbuf, 100, 0);
367
368 /* Receive EOF indication as there are no more messages and the
369 * socket is SHUTDOWN.
370 */
371 error = recvcxx . . $ recv(4136b1fcb15a75da).(accept2_sk, msgbuf, 100, 0);
372 if ((0 != error) || (0 != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
373 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "Unexpected error return on "
374 "recv(error:%d, errno:%d)", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
375
376 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "accept of a CLOSED association");
377
378 /* Trying to send a message over the CLOSED association should
379 * generate EPIPE.
380 */
381 error = sendcxx . . $ send(4e364047dcdcb5ca).(accept2_sk, message, strlencxx . . $ strlen(751346f8406fd082).(message), MSG_NOSIGNALcxx . . $ `<external>/8962547315054503424/socket.h:242:9`!);
382 if ((-1 != error) || (EPIPEcxx . . $ `<external>/8987895939074593727/errno-base.h:36:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
383 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "send to a CLOSED association "
384 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
385
386 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "send to a CLOSED association");
387
388 error = 0;
389 closecxx . . $ close(7864480464b09eea).(accept2_sk);
390
391 /* Verify that auto-connect can be done on a TCP-style socket using
392 * sendto/sendmsg.
393 */
394 clt2_sk = test_socketcxx . . $ test_socket(2326284602b0bb2d).(pf_class, SOCK_STREAMcxx . . $ `<external>/5956532346368192945/socket_type.h:28:9`!, IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!);
395 test_bindcxx . . $ test_bind(18e507052d945257).(clt2_sk, &clt2_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., sizeof(clt2_loop));
396
397 /* Do a sendto() without a connect() */
398 test_sendtocxx . . $ test_sendto(727eb71adbe2edd3).(clt2_sk, message, strlencxx . . $ strlen(751346f8406fd082).(message), 0, &svr_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa.,
399 sizeof(svr_loop));
400
401 accept2_sk = test_acceptcxx . . $ test_accept(46fcd054f4a4d98b).(listen_sk, &accept_loop.sacxx . . $ $anonymous_type_f8e963888af85862_0#sa., &addrlen);
402
403 test_recvcxx . . $ test_recv(6076e73854a1e617).(accept2_sk, msgbuf, 100, 0);
404
405 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "auto-connect using sendto");
406
407 outmessage.msg_namecxx . . $ msghdr#msg_name. = &svr_loop;
408 outmessage.msg_namelencxx . . $ msghdr#msg_namelen. = sizeof(svr_loop);
409 outmessage.msg_iovcxx . . $ msghdr#msg_iov. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
410 outmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 0;
411 outmessage.msg_controlcxx . . $ msghdr#msg_control. = outcmsg;
412 outmessage.msg_controllencxx . . $ msghdr#msg_controllen. = sizeof(outcmsg);
413 outmessage.msg_flagscxx . . $ msghdr#msg_flags. = 0;
414
415 cmsg = CMSG_FIRSTHDRcxx . . $ `<external>/8962547315054503424/socket.h:304:9`!(&outmessage);
416 cmsg->cmsg_levelcxx . . $ cmsghdr#cmsg_level. = IPPROTO_SCTPcxx . . $ `<external>/9581057695539925927/in.h:87:9`!;
417 cmsg->cmsg_typecxx . . $ cmsghdr#cmsg_type. = SCTP_SNDRCVcxx . . $ `<external>/17169092326581286071/sctp.h:333:9`!;
418 cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len. = CMSG_LENcxx . . $ `<external>/8962547315054503424/socket.h:311:9`!(sizeof(struct sctp_sndrcvinfo));
419 outmessage.msg_controllencxx . . $ msghdr#msg_controllen. = cmsg->cmsg_lencxx . . $ cmsghdr#cmsg_len.;
420 sinfo = (struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo# *)CMSG_DATAcxx . . $ `<external>/8962547315054503424/socket.h:299:10`!(cmsg);
421 memsetcxx . . $ memset(d1de1e4fb215f1c6).(sinfo, 0x00, sizeof(struct sctp_sndrcvinfocxx . . $ sctp_sndrcvinfo#));
422
423 /* Verify that SCTP_EOF cannot be used to shutdown an association
424 * on a TCP-style socket.
425 */
426 sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. |= SCTP_EOFcxx . . $ SCTP_EOF.;
427 error = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(clt2_sk, &outmessage, 0);
428 if ((-1 != error) || (EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
429 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with SCTP_EOF flag "
430 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
431
432 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg with SCTP_EOF flag");
433
434 /* Verify that SCTP_ABORT cannot be used to abort an association
435 * on a TCP-style socket.
436 */
437 sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. |= SCTP_ABORTcxx . . $ SCTP_ABORT.;
438 error = sendmsgcxx . . $ sendmsg(bc65c149164ceef5).(clt2_sk, &outmessage, 0);
439 if ((-1 != error) || (EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`! != errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!))
440 tst_brkmcxx . . $ `src/testlib/sctputil.h:116:9`!(TBROK, tst_exit, "sendmsg with SCTP_ABORT flag "
441 "error:%d, errno:%d", error, errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!);
442
443 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg with SCTP_ABORT flag");
444
445 /* Verify that a normal message can be sent using sendmsg. */
446 outmessage.msg_iovcxx . . $ msghdr#msg_iov. = &out_iov;
447 outmessage.msg_iovlencxx . . $ msghdr#msg_iovlen. = 1;
448 out_iov.iov_basecxx . . $ iovec#iov_base. = message;
449 out_iov.iov_lencxx . . $ iovec#iov_len. = strlencxx . . $ strlen(751346f8406fd082).(message) + 1;
450 sinfo->sinfo_flagscxx . . $ sctp_sndrcvinfo#sinfo_flags. = 0;
451 test_sendmsgcxx . . $ test_sendmsg(c45a39c477f473e).(clt2_sk, &outmessage, 0, strlencxx . . $ strlen(751346f8406fd082).(message)+1);
452
453 test_recvcxx . . $ test_recv(6076e73854a1e617).(accept2_sk, msgbuf, 100, 0);
454
455 tst_resmcxx . . $ `src/testlib/sctputil.h:123:9`!(TPASS, "sendmsg with no flags");
456
457 closecxx . . $ close(7864480464b09eea).(clt2_sk);
458 closecxx . . $ close(7864480464b09eea).(accept2_sk);
459 closecxx . . $ close(7864480464b09eea).(listen_sk);
460
461 freecxx . . $ free(5d22bdacc48458e8).(big_buffer);
462 /* Indicate successful completion. */
463 return 0;
464 }