Lines Matching +full:1 +full:- +full:512

1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
9 * 1. Redistributions of source code must retain the above copyright
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; \
136 buffer[1] = 3; /* DATA opcode low byte */ in send_data()
149 ATF_REQUIRE_EQ(sizeof(cmd) - 1, \
150 sendto(s, (cmd), sizeof(cmd) - 1, 0, \
271 ATF_REQUIRE_INTEQ(1, fscanf(f, "%d", &pid)); in check_server()
292 if (fscanf(f, "%d", &pid) == 1) { in cleanup()
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()
385 argv_idx = 1; in setup()
400 ATF_REQUIRE_INTEQ(0, close(pd[1])); in setup()
402 ATF_REQUIRE_INTEQ(0, read(pd[0], &pd[1], sizeof(pd[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()
461 command[1] = 1; /* RRQ low byte */
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);
472 recv_data(1, NULL, 0);
473 send_ack(1);
493 * With "-s", tftpd should chroot to the specified directory
504 write_all(fd, contents, strlen(contents) + 1);
508 recv_data(1, contents, strlen(contents) + 1);
509 send_ack(1);
522 write_all(fd, contents, strlen(contents) + 1);
526 recv_data(1, contents, strlen(contents) + 1);
531 recv_data(1, contents, strlen(contents) + 1);
532 send_ack(1);
554 recv_data(1, (const char *)&contents[0], 512);
555 send_ack(1);
561 send_ack(1);
584 recv_data(1, (const char *)&contents[0], 512);
585 send_ack(1);
586 send_ack(1); /* Dupe an ACK packet */
620 recv_data(1, NULL, 0);
621 send_ack(1);
642 recv_data(1, (const char *)&contents[0], 512);
643 send_ack(1);
667 recv_oack(options, sizeof(options) - 1);
669 recv_data(1, (const char *)&contents[0], 512);
682 * Weirdly, RFC-764 says that CR must be followed by NUL if a line feed
689 write_all(fd, contents, strlen(contents) + 1);
693 recv_data(1, expected, sizeof(expected));
694 send_ack(1);
703 RECV_ERROR(1, "File not found");
745 write_all(fd, contents, strlen(contents) + 1);
749 recv_data(1, contents, strlen(contents) + 1);
750 send_ack(1);
761 alignas(uint32_t) char contents[13 * 512 - 4];
774 recv_oack(options, sizeof(options) - 1);
776 recv_data(1, &contents[0 * 512], 512);
777 recv_data(2, &contents[1 * 512], 512);
778 recv_data(3, &contents[2 * 512], 512);
779 recv_data(4, &contents[3 * 512], 512);
781 recv_data(5, &contents[4 * 512], 512);
782 recv_data(6, &contents[5 * 512], 512);
783 recv_data(7, &contents[6 * 512], 512);
784 recv_data(8, &contents[7 * 512], 512);
786 /* ACK 5 as if 6-8 were dropped. */
788 recv_data(6, &contents[5 * 512], 512);
789 recv_data(7, &contents[6 * 512], 512);
790 recv_data(8, &contents[7 * 512], 512);
791 recv_data(9, &contents[8 * 512], 512);
793 recv_data(10, &contents[9 * 512], 512);
794 recv_data(11, &contents[10 * 512], 512);
795 recv_data(12, &contents[11 * 512], 512);
796 recv_data(13, &contents[12 * 512], 508);
798 /* Drop ACK and after timeout receive 10-13. */
799 recv_data(10, &contents[9 * 512], 512);
800 recv_data(11, &contents[10 * 512], 512);
801 recv_data(12, &contents[11 * 512], 512);
802 recv_data(13, &contents[12 * 512], 508);
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.
837 TFTPD_TC_DEFINE(w_flag,, w_flag = 1;)
845 contents_len = strlen(contents) + 1;
848 send_data(1, contents, contents_len);
849 recv_ack(1);
879 send_data(1, (const char *)&contents[0], 512);
885 recv_ack(1);
911 contents_len = strlen(contents) + 1;
920 send_data(1, contents, contents_len);
921 recv_ack(1);
951 send_data(1, (const char *)&contents[0], 512);
952 send_data(1, (const char *)&contents[0], 512);
953 recv_ack(1);
954 recv_ack(1);
1018 send_data(1, (const char *)&contents[0], 512);
1019 recv_ack(1);
1051 recv_oack(options, sizeof(options) - 1);
1052 send_data(1, (const char *)&contents[0], 512);
1072 * Weirdly, RFC-764 says that CR must be followed by NUL if a line feed
1087 send_data(1, contents, contents_len);
1088 recv_ack(1);
1105 RECV_ERROR(1, "File not found");
1122 contents_len = strlen(contents) + 1;
1126 send_data(1, contents, contents_len);
1127 recv_ack(1);
1138 * Write an empty file over a non-empty one
1148 write_all(fd, contents, strlen(contents) + 1);
1153 send_data(1, NULL, 0);
1154 recv_ack(1);
1169 alignas(uint32_t) char contents[13 * 512 - 4];
1182 recv_oack(options, sizeof(options) - 1);
1183 send_data(1, &contents[0 * 512], 512);
1184 send_data(2, &contents[1 * 512], 512);
1185 send_data(3, &contents[2 * 512], 512);
1186 send_data(4, &contents[3 * 512], 512);
1188 send_data(5, &contents[4 * 512], 512);
1190 /* Drop 6-8. */
1192 send_data(6, &contents[5 * 512], 512);
1193 send_data(7, &contents[6 * 512], 512);
1194 send_data(8, &contents[7 * 512], 512);
1195 send_data(9, &contents[8 * 512], 512);
1199 send_data(10, &contents[9 * 512], 512);
1200 send_data(12, &contents[11 * 512], 512);
1209 /* Ignore ACK for 10 and resend 10-13. */
1211 send_data(10, &contents[9 * 512], 512);
1212 send_data(11, &contents[10 * 512], 512);
1213 send_data(12, &contents[11 * 512], 512);
1214 send_data(13, &contents[12 * 512], 508);
1228 TFTPD_TC_DEFINE(short_packet1, /* no head */, exitcode = 1)
1230 SEND_STR("\1");
1232 TFTPD_TC_DEFINE(short_packet2, /* no head */, exitcode = 1)
1234 SEND_STR("\1\2");
1236 TFTPD_TC_DEFINE(short_packet3, /* no head */, exitcode = 1)
1238 SEND_STR("\1\2\3");