aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhpa <hpa>2003-08-23 00:31:20 +0000
committerhpa <hpa>2003-08-23 00:31:20 +0000
commit530706aebef96e25dd4bf27416df9d78c83f3bed (patch)
tree3e603d73e38d0b59e633686df51f63f8f4451ede
parentb3941f251adc0d31d307839fd3b97d0d595cf16e (diff)
downloadtftp-hpa-530706aebef96e25dd4bf27416df9d78c83f3bed.tar.gz
#include <sys/socket.h> if it exists;
Add option to control the max blksize negotiated.
-rw-r--r--CHANGES5
-rw-r--r--config.h10
-rw-r--r--configure.in5
-rw-r--r--tftpd/tftpd.8.in9
-rw-r--r--tftpd/tftpd.c27
-rw-r--r--version2
6 files changed, 49 insertions, 9 deletions
diff --git a/CHANGES b/CHANGES
index 4c2df40..e2379e0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,10 @@
$Id$
+Changes in 0.35:
+ Add an option to control the maximum value of blksize
+ negotiated.
+
+
Changes in 0.34:
Additional Solaris gcc compiler bug workarounds; these
actually make the code somewhat cleaner.
diff --git a/config.h b/config.h
index ef0d408..67dc7ae 100644
--- a/config.h
+++ b/config.h
@@ -96,7 +96,17 @@
#include <errno.h>
#include <signal.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#else
+#ifdef HAVE_WINSOCK2_H
+#include <winsock2.h>
+#else
+#ifdef HAVE_WINSOCK_H
+#include <winsock.h>
+#endif
+#endif
+#endif
/* Test for EAGAIN/EWOULDBLOCK */
#ifdef EAGAIN
diff --git a/configure.in b/configure.in
index eee5071..e9bee9f 100644
--- a/configure.in
+++ b/configure.in
@@ -77,6 +77,9 @@ AC_CHECK_HEADERS(arpa/inet.h)
AC_HEADER_TIME
dnl This is needed on some versions of FreeBSD...
AC_CHECK_HEADERS(machine/param.h)
+AC_CHECK_HEADERS(sys/socket.h)
+AC_CHECK_HEADERS(winsock2.h)
+AC_CHECK_HEADERS(winsock.h)
AC_CHECK_TYPES(intmax_t)
AC_CHECK_TYPES(long long)
@@ -89,7 +92,7 @@ AC_TYPE_PID_T
AC_TYPE_MODE_T
AC_TYPE_SIZE_T
-AC_SEARCH_LIBS(socket, socket, , [AC_MSG_ERROR(socket library not found)])
+AC_SEARCH_LIBS(socket, [socket ws2_32 wsock32], , [AC_MSG_ERROR(socket library not found)])
AC_SEARCH_LIBS(gethostbyname, [nsl resolv], , [AC_MSG_ERROR(gethostbyname not found)])
AC_SEARCH_LIBS(inet_aton, [nsl resolv], , [AC_MSG_ERROR(inet_aton not found)])
AC_SEARCH_LIBS(herror, [nsl resolv], , [AC_MSG_ERROR(herror not found)])
diff --git a/tftpd/tftpd.8.in b/tftpd/tftpd.8.in
index aab8bf6..6462ea0 100644
--- a/tftpd/tftpd.8.in
+++ b/tftpd/tftpd.8.in
@@ -150,6 +150,15 @@ This flag can be specified multiple times for even higher verbosity.
Indicate that a specific RFC 2347 TFTP option should never be
accepted.
.TP
+\fB\-B\fP \fImax-block-size\fP
+Specifies the maximum permitted block size. The permitted range for
+this parameter is from 512 to 65464. Some embedded clients request
+large block sizes and yet do not handle fragmented packets correctly;
+for these clients, it is recommended to set this value to the smallest
+MTU on your network minus 32 bytes (20 bytes for IP, 8 for UDP, and 4
+for TFTP; less if you use IP options on your network.) For example,
+on a standard Ethernet (MTU 1500) a value of 1468 is reasonable.
+.TP
.B \-V
Print the version number and configuration to standard output, then
exit gracefully.
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index fc9a843..6b5b0db 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -92,8 +92,10 @@ int timeout_quit = 0;
sigjmp_buf timeoutbuf;
#define PKTSIZE MAX_SEGSIZE+4
-char buf[PKTSIZE];
-char ackbuf[PKTSIZE];
+char buf[PKTSIZE];
+char ackbuf[PKTSIZE];
+unsigned int max_blksize = MAX_SEGSIZE;
+
struct sockaddr_in from;
int fromlen;
off_t tsize;
@@ -279,7 +281,7 @@ main(int argc, char **argv)
openlog(__progname, LOG_PID|LOG_NDELAY, LOG_DAEMON);
- while ((c = getopt(argc, argv, "cspvVla:u:U:r:t:T:m:")) != -1)
+ while ((c = getopt(argc, argv, "cspvVla:B:u:U:r:t:T:m:")) != -1)
switch (c) {
case 'c':
cancreate = 1;
@@ -299,6 +301,17 @@ main(int argc, char **argv)
case 't':
waittime = atoi(optarg);
break;
+ case 'B':
+ {
+ char *vp;
+ max_blksize = (unsigned int)strtoul(optarg, &vp, 10);
+ if ( max_blksize < 512 || max_blksize > MAX_SEGSIZE || *vp ) {
+ syslog(LOG_ERR, "Bad maximum blocksize value (range 512-%d): %s",
+ MAX_SEGSIZE, optarg);
+ exit(EX_USAGE);
+ }
+ }
+ break;
case 'T':
{
char *vp;
@@ -817,8 +830,8 @@ set_blksize(char *val, char **ret)
if (sz < 8)
return(0);
- else if (sz > MAX_SEGSIZE)
- sz = MAX_SEGSIZE;
+ else if (sz > max_blksize)
+ sz = max_blksize;
segsize = sz;
sprintf(*ret = b_ret, "%u", sz);
@@ -845,8 +858,8 @@ set_blksize2(char *val, char **ret)
if (sz < 8)
return(0);
- else if (sz > MAX_SEGSIZE)
- sz = MAX_SEGSIZE;
+ else if (sz > max_blksize)
+ sz = max_blksize;
/* Convert to a power of two */
if ( sz & (sz-1) ) {
diff --git a/version b/version
index 61d2f35..c74e8a0 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-0.34
+0.35