Lines Matching +full:send +full:- +full:empty

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
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 */
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; \
117 * send a command to tftpd.
118 * @param cmd Command to send, as a char array
144 * send a command to tftpd.
145 * @param cmd Command to send, as a const string
149 ATF_REQUIRE_EQ(sizeof(cmd) - 1, \
150 sendto(s, (cmd), sizeof(cmd) - 1, 0, \
174 * send a read request to tftpd.
182 * send a read request with options
188 * send a write request to tftpd.
196 * send a write request with options
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
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 */
825 * Send an unknown opcode. tftpd should respond with the appropriate error
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
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. */
1203 * We can't send 13 here as tftpd has probably already seen 12
1209 /* Ignore ACK for 10 and resend 10-13. */
1226 * Send less than four bytes