summaryrefslogtreecommitdiff
path: root/usr.bin/tftp
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-03-02 22:19:30 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2020-03-02 22:19:30 +0000
commitfdf929ff91d432d17c4d7d0aa0f9995fffe6fa8e (patch)
treec6b6ae4416bf0bd83c995fe237bc2598f24be4d9 /usr.bin/tftp
parenta969e975c9557614ae944ff43daa6581d943b1d0 (diff)
downloadsrc-test2-fdf929ff91d432d17c4d7d0aa0f9995fffe6fa8e.tar.gz
src-test2-fdf929ff91d432d17c4d7d0aa0f9995fffe6fa8e.zip
Notes
Diffstat (limited to 'usr.bin/tftp')
-rw-r--r--usr.bin/tftp/main.c26
-rw-r--r--usr.bin/tftp/tftp.113
2 files changed, 38 insertions, 1 deletions
diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
index 5644132fe920..33546dc4ee23 100644
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -114,6 +114,7 @@ static void setblocksize2(int, char **);
static void setoptions(int, char **);
static void setrollover(int, char **);
static void setpacketdrop(int, char **);
+static void setwindowsize(int, char **);
static void command(bool, EditLine *, History *, HistEvent *) __dead2;
static const char *command_prompt(void);
@@ -158,6 +159,7 @@ static struct cmd cmdtab[] = {
"enable or disable RFC2347 style options" },
{ "help", help, "print help information" },
{ "packetdrop", setpacketdrop, "artificial packetloss feature" },
+ { "windowsize", setwindowsize, "set windowsize[*]" },
{ "?", help, "print help information" },
{ NULL, NULL, NULL }
};
@@ -1069,3 +1071,27 @@ setpacketdrop(int argc, char *argv[])
printf("Randomly %d in 100 packets will be dropped\n",
packetdroppercentage);
}
+
+static void
+setwindowsize(int argc, char *argv[])
+{
+
+ if (!options_rfc_enabled)
+ printf("RFC2347 style options are not enabled "
+ "(but proceeding anyway)\n");
+
+ if (argc != 1) {
+ int size = atoi(argv[1]);
+
+ if (size < WINDOWSIZE_MIN || size > WINDOWSIZE_MAX) {
+ printf("Windowsize should be between %d and %d "
+ "blocks.\n", WINDOWSIZE_MIN, WINDOWSIZE_MAX);
+ return;
+ } else {
+ asprintf(&options[OPT_WINDOWSIZE].o_request, "%d",
+ size);
+ }
+ }
+ printf("Windowsize is now %s blocks.\n",
+ options[OPT_WINDOWSIZE].o_request);
+}
diff --git a/usr.bin/tftp/tftp.1 b/usr.bin/tftp/tftp.1
index 7ee892bc4c52..7f413e2b1035 100644
--- a/usr.bin/tftp/tftp.1
+++ b/usr.bin/tftp/tftp.1
@@ -28,7 +28,7 @@
.\" @(#)tftp.1 8.2 (Berkeley) 4/18/94
.\" $FreeBSD$
.\"
-.Dd Aug 22, 2018
+.Dd March 2, 2020
.Dt TFTP 1
.Os
.Sh NAME
@@ -216,6 +216,14 @@ Toggle packet tracing.
.Pp
.It Cm verbose
Toggle verbose mode.
+.Pp
+.It Cm windowsize Op Ar size
+Sets the TFTP windowsize option in TFTP Read Request or Write Request packets to
+.Op Ar size
+blocks as specified in RFC 7440.
+Valid values are between 1 and 65535.
+If no windowsize is specified,
+then the default windowsize of 1 block will be used.
.El
.Sh SEE ALSO
.Xr tftpd 8
@@ -236,6 +244,9 @@ The following RFC's are supported:
.Rs
.%T RFC 3617: Uniform Resource Identifier (URI) Scheme and Applicability Statement for the Trivial File Transfer Protocol (TFTP)
.Re
+.Rs
+.%T RFC 7440: TFTP Windowsize Option
+.Re
.Pp
The non-standard
.Cm rollover