From ad2f724daf9c7a63d9f2454e9a638c9d792d9274 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Jul 2017 13:19:16 -0600 Subject: [PATCH 1/2] apps/netutils/tftpc: Missing header file causes errors in some configurations. --- netutils/tftpc/tftpc_internal.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netutils/tftpc/tftpc_internal.h b/netutils/tftpc/tftpc_internal.h index 47a7bd0cd..4fbfb4459 100644 --- a/netutils/tftpc/tftpc_internal.h +++ b/netutils/tftpc/tftpc_internal.h @@ -50,6 +50,7 @@ #include #include #include +#include /**************************************************************************** * Pre-processor Definitions @@ -101,7 +102,7 @@ #if MIN_UDP_MSS < TFTP_MAXPACKETSIZE # define TFTP_PACKETSIZE MIN_UDP_MSS # ifdef CONFIG_CPP_HAVE_WARNING -# warning "uIP MSS is too small for TFTP" +# warning "MSS is too small for TFTP" # endif #else # define TFTP_PACKETSIZE TFTP_MAXPACKETSIZE From ae1eeada8a64c45f3ed9b5e49ed51e4d937be802 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 10 Jul 2017 14:36:56 -0600 Subject: [PATCH 2/2] Eliminate a warning --- netutils/tftpc/tftpc_internal.h | 43 +++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/netutils/tftpc/tftpc_internal.h b/netutils/tftpc/tftpc_internal.h index 4fbfb4459..9d02bca04 100644 --- a/netutils/tftpc/tftpc_internal.h +++ b/netutils/tftpc/tftpc_internal.h @@ -47,10 +47,10 @@ #include #include -#include -#include -#include #include +#include +#include +#include /**************************************************************************** * Pre-processor Definitions @@ -83,33 +83,44 @@ /* Sizes of TFTP messsage headers */ -#define TFTP_ACKHEADERSIZE 4 -#define TFTP_ERRHEADERSIZE 4 -#define TFTP_DATAHEADERSIZE 4 +#define TFTP_ACKHEADERSIZE 4 +#define TFTP_ERRHEADERSIZE 4 +#define TFTP_DATAHEADERSIZE 4 /* The maximum size for TFTP data is determined by the configured UDP packet * payload size (UDP_MSS), but cannot exceed 512 + sizeof(TFTP_DATA header). * * In the case where there are multiple network devices with different * link layer protocols (CONFIG_NET_MULTILINK), each network device - * may support a different UDP MSS value. Here we arbitrarily select - * the minimum MSS for that case. + * may support a different UDP MSS value. Here, if Ethernet is enabled, + * we (arbitrarily) assume that the Ethernet is link that will be used. + * if Ethernet is not one of the enabled interfaces, we (arbitrarily) select + * the minimum MSS. */ -#define TFTP_DATAHEADERSIZE 4 -#define TFTP_MAXPACKETSIZE (TFTP_DATAHEADERSIZE+512) +#define TFTP_DATAHEADERSIZE 4 +#define TFTP_MAXPACKETSIZE (TFTP_DATAHEADERSIZE+512) -#if MIN_UDP_MSS < TFTP_MAXPACKETSIZE -# define TFTP_PACKETSIZE MIN_UDP_MSS +#if defined(CONFIG_NET_ETHERNET) +# if ETH_UDP_MSS(IPv4_HDRLEN) < TFTP_MAXPACKETSIZE +# define TFTP_PACKETSIZE ETH_UDP_MSS(IPv4_HDRLEN) +# ifdef CONFIG_CPP_HAVE_WARNING +# warning "Ethernet MSS is too small for TFTP" +# endif +# else +# define TFTP_PACKETSIZE TFTP_MAXPACKETSIZE +# endif +#elif MIN_UDP_MSS < TFTP_MAXPACKETSIZE +# define TFTP_PACKETSIZE MIN_UDP_MSS # ifdef CONFIG_CPP_HAVE_WARNING -# warning "MSS is too small for TFTP" +# warning "Minimum MSS is too small for TFTP" # endif #else -# define TFTP_PACKETSIZE TFTP_MAXPACKETSIZE +# define TFTP_PACKETSIZE TFTP_MAXPACKETSIZE #endif -#define TFTP_DATASIZE (TFTP_PACKETSIZE-TFTP_DATAHEADERSIZE) -#define TFTP_IOBUFSIZE (TFTP_PACKETSIZE+8) +#define TFTP_DATASIZE (TFTP_PACKETSIZE-TFTP_DATAHEADERSIZE) +#define TFTP_IOBUFSIZE (TFTP_PACKETSIZE+8) /* TFTP Opcodes *************************************************************/