Lines Matching +full:recv +full:- +full:not +full:- +full:empty

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
43 #include <atf-c.h>
49 static int s = -1; /* tftp client socket */
51 static bool s_flag = false; /* Pass -s to tftpd */
52 static bool w_flag = false; /* Pass -w to tftpd */
64 #define RECV(hdr, contents, contents_len) do { \ macro
74 &buffer[sizeof(hdr)], r - sizeof(hdr)); \
76 ((struct sockaddr_in *)&addr)->sin_port = \
77 ((struct sockaddr_in *)&from)->sin_port; \
79 ((struct sockaddr_in6 *)&addr)->sin6_port = \
80 ((struct sockaddr_in6 *)&from)->sin6_port; \
88 RECV(hdr, NULL, 0); in recv_ack()
95 RECV(hdr, options, options_len); in recv_oack()
108 RECV(hdr, contents, contents_len); in recv_data()
113 RECV(hdr, msg, sizeof(msg)); \
149 ATF_REQUIRE_EQ(sizeof(cmd) - 1, \
150 sendto(s, (cmd), sizeof(cmd) - 1, 0, \
326 char b_flag_str[] = "-b"; in setup()
327 char s_flag_str[] = "-s"; in setup()
328 char w_flag_str[] = "-w"; in setup()
359 /* Must bind(2) pre-fork so it happens before the client's send(2) */ in setup()
372 case -1: in setup()
407 to4->sin_len = sizeof(*to4); in setup()
408 to4->sin_family = PF_INET; in setup()
409 to4->sin_port = htons(port); in setup()
410 to4->sin_addr.s_addr = htonl(INADDR_LOOPBACK); in setup()
414 to6->sin6_len = sizeof(*to6); in setup()
415 to6->sin6_family = PF_INET6; in setup()
416 to6->sin6_port = htons(port); in setup()
417 to6->sin6_addr = loopback; in setup()
440 nbytes -= (size_t)r; in write_all()
462 ATF_REQUIRE(getcwd(&command[2], sizeof(command) - 2) != NULL);
463 pathlen = strlcat(&command[2], "/abspath.txt", sizeof(command) - 2);
464 ATF_REQUIRE(pathlen + sizeof(suffix) < sizeof(command) - 2);
493 * With "-s", tftpd should chroot to the specified directory
600 fd = open("empty.txt", O_CREAT | O_RDONLY, 0000);
604 SEND_RRQ("empty.txt", "octet");
609 * Read an empty file
615 fd = open("empty.txt", O_CREAT | O_RDONLY, 0644);
619 SEND_RRQ("empty.txt", "octet");
667 recv_oack(options, sizeof(options) - 1);
682 * Weirdly, RFC-764 says that CR must be followed by NUL if a line feed
683 * is not intended
703 RECV_ERROR(1, "File not found");
761 alignas(uint32_t) char contents[13 * 512 - 4];
774 recv_oack(options, sizeof(options) - 1);
786 /* ACK 5 as if 6-8 were dropped. */
798 /* Drop ACK and after timeout receive 10-13. */
817 SEND_RRQ("foo.txt", "en_US.UTF-8");
820 SEND_RRQ("foo.txt", "mail"); /* Obsolete in RFC-1350 */
835 * Invoke tftpd with "-w" and write to a nonexistent file.
973 fd = open("empty.txt", O_CREAT | O_RDONLY, 0440);
977 SEND_WRQ("empty.txt", "octet");
989 fd = open("empty.txt", O_CREAT | O_RDONLY, 0444);
993 SEND_WRQ("empty.txt", "octet");
1051 recv_oack(options, sizeof(options) - 1);
1072 * Weirdly, RFC-764 says that CR must be followed by NUL if a line feed
1073 * is not intended
1105 RECV_ERROR(1, "File not found");
1138 * Write an empty file over a non-empty one
1169 alignas(uint32_t) char contents[13 * 512 - 4];
1182 recv_oack(options, sizeof(options) - 1);
1190 /* Drop 6-8. */
1209 /* Ignore ACK for 10 and resend 10-13. */