Lines Matching +full:one +full:- +full:to +full:- +full:many

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44 #include <atf-c.h>
48 .it_value = { 1, 0 }, /* one second */
69 * Fill socket to a state when next send(len) would fail.
100 * - fd[0] to send, fd[1] to receive in ATF_TC_BODY()
101 * - buf[maxdgram] for data in ATF_TC_BODY()
105 ATF_REQUIRE(socketpair(PF_UNIX, SOCK_DGRAM, 0, fd) != -1); in ATF_TC_BODY()
116 /* Fail to send > maxdgram. */ in ATF_TC_BODY()
117 ATF_REQUIRE(send(fd[0], buf, maxdgram + 1, 0) == -1); in ATF_TC_BODY()
144 ATF_REQUIRE(recv(fd[1], buf, maxdgram, 0) == -1); in ATF_TC_BODY()
149 ATF_REQUIRE(recv(fd[1], buf, maxdgram, MSG_DONTWAIT) == -1); in ATF_TC_BODY()
153 ATF_REQUIRE(fcntl(fd[1], F_SETFL, O_NONBLOCK) != -1); in ATF_TC_BODY()
154 ATF_REQUIRE(recv(fd[1], buf, maxdgram, 0) == -1); in ATF_TC_BODY()
159 ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1); in ATF_TC_BODY()
164 * for explanation why this behavior needs to be preserved. in ATF_TC_BODY()
166 ATF_REQUIRE(fcntl(fd[0], F_SETFL, O_NONBLOCK) != -1); in ATF_TC_BODY()
167 ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1); in ATF_TC_BODY()
170 /* Remote side closed -> ECONNRESET. */ in ATF_TC_BODY()
172 ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1); in ATF_TC_BODY()
179 int one, many[3], two; in ATF_TC_BODY() local
183 /* Establish one to many connection. */ in ATF_TC_BODY()
184 ATF_REQUIRE((one = socket(PF_UNIX, SOCK_DGRAM, 0)) > 0); in ATF_TC_BODY()
185 ATF_REQUIRE(bind(one, (struct sockaddr *)&sun, sizeof(sun)) == 0); in ATF_TC_BODY()
187 ATF_REQUIRE(listen(one, -1) != 0); in ATF_TC_BODY()
189 ATF_REQUIRE((many[i] = socket(PF_UNIX, SOCK_DGRAM, 0)) > 0); in ATF_TC_BODY()
190 ATF_REQUIRE(connect(many[i], (struct sockaddr *)&sun, in ATF_TC_BODY()
195 ATF_REQUIRE(accept(one, NULL, NULL) == -1); in ATF_TC_BODY()
199 * Connecting a bound socket to self: a strange, useless, but in ATF_TC_BODY()
203 ATF_REQUIRE(connect(one, (struct sockaddr *)&sun, sizeof(sun)) == 0); in ATF_TC_BODY()
204 ATF_REQUIRE(send(one, buf, 42, 0) == 42); in ATF_TC_BODY()
205 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == 42); in ATF_TC_BODY()
210 * One sender can not fill the receive side. Other senders can in ATF_TC_BODY()
216 * the data. Allow the data to migrate to peers buffer only if the in ATF_TC_BODY()
217 * latter is empty. Otherwise discard it, to prevent against in ATF_TC_BODY()
218 * connect-fill-close attack. in ATF_TC_BODY()
220 #define FLOODER 13 /* for connected flooder on many[0] */ in ATF_TC_BODY()
221 #define GOODBOY 42 /* for a good boy on many[1] */ in ATF_TC_BODY()
231 ATF_REQUIRE(send(many[1], goodboy, BUFSIZE, 0) == BUFSIZE); in ATF_TC_BODY()
232 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
234 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
238 fill(many[0], flooder, sizeof(flooder)); in ATF_TC_BODY()
239 ATF_REQUIRE(send(many[0], flooder, BUFSIZE, 0) == -1); in ATF_TC_BODY()
241 ATF_REQUIRE(send(many[1], goodboy, BUFSIZE, 0) == BUFSIZE); in ATF_TC_BODY()
242 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
244 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
248 ATF_REQUIRE(recv(one, buf, sizeof(buf), MSG_PEEK) == sizeof(buf)); in ATF_TC_BODY()
250 ATF_REQUIRE(send(many[1], goodboy, BUFSIZE, 0) == BUFSIZE); in ATF_TC_BODY()
251 ATF_REQUIRE(recv(one, buf, sizeof(buf), MSG_PEEK) == sizeof(buf)); in ATF_TC_BODY()
253 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
255 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
256 ATF_REQUIRE(buf[0] == GOODBOY); /* ... and next one is the good boy */ in ATF_TC_BODY()
261 close(many[0]); in ATF_TC_BODY()
262 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
264 ATF_REQUIRE(recv(one, buf, sizeof(buf), MSG_DONTWAIT) == -1); in ATF_TC_BODY()
265 ATF_REQUIRE(errno == EAGAIN); /* data from many[0] discarded */ in ATF_TC_BODY()
268 ATF_REQUIRE(send(many[1], goodboy, BUFSIZE, 0) == BUFSIZE); in ATF_TC_BODY()
269 close(many[1]); in ATF_TC_BODY()
270 ATF_REQUIRE(recv(one, buf, sizeof(buf), 0) == sizeof(buf)); in ATF_TC_BODY()
271 ATF_REQUIRE(buf[0] == GOODBOY); /* message from many[1] preserved */ in ATF_TC_BODY()
274 ATF_REQUIRE(send(many[2], buf, 42, 0) == 42); in ATF_TC_BODY()
275 ATF_REQUIRE(send(many[2], buf, 42, 0) == 42); in ATF_TC_BODY()
276 ATF_REQUIRE(recv(one, buf, sizeof(buf), MSG_PEEK) == 42); in ATF_TC_BODY()
279 close(one); in ATF_TC_BODY()
293 ATF_REQUIRE(ioctl(fd, FIONREAD, &data) != -1); in test42()
308 ATF_REQUIRE((kq = kqueue()) != -1); in test42()
354 ATF_REQUIRE(socketpair(PF_UNIX, SOCK_DGRAM, 0, fd) != -1); in ATF_TC_BODY()
360 /* Not-connected send */ in ATF_TC_BODY()
380 ATF_REQUIRE(sd != -1); in ATF_TC_BODY()
409 ATF_REQUIRE(sd != -1); in ATF_TC_BODY()
412 ATF_REQUIRE_ERRNO(EINVAL, error == -1); in ATF_TC_BODY()
427 ATF_REQUIRE_ERRNO(EINVAL, error == -1); in ATF_TC_BODY()