### Eclipse Workspace Patch 1.0 #P ecos Index: net/common/current/cdl/net.cdl =================================================================== RCS file: /cvs/ecos/ecos-opt/net/net/common/current/cdl/net.cdl,v retrieving revision 1.17 diff -u -r1.17 net.cdl --- net/common/current/cdl/net.cdl 7 Jan 2007 14:46:55 -0000 1.17 +++ net/common/current/cdl/net.cdl 19 Dec 2007 09:04:00 -0000 @@ -167,6 +167,16 @@ threads can have precedence over TFTP server processing." } + cdl_option CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE { + display "Pervert TFTP protocol to allow bigger packets." + flavor data + default_value 512 + legal_values 512 to 65464 + description " + Some TFTP servers pragmatically allow increasing the + packet size, contrary to the TFTP standard. Use with caution!" + } + cdl_option CYGPKG_NET_TFTPD_THREAD_STACK_SIZE { display "Stack size for TFTP threads." flavor data Index: net/common/current/src/tftp_client.c =================================================================== RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/tftp_client.c,v retrieving revision 1.10 diff -u -r1.10 tftp_client.c --- net/common/current/src/tftp_client.c 16 Sep 2005 14:56:26 -0000 1.10 +++ net/common/current/src/tftp_client.c 19 Dec 2007 09:04:01 -0000 @@ -57,6 +57,7 @@ #include #include #include +#include #define min(x,y) (xth_opcode = htons(ACK); @@ -256,7 +257,7 @@ goto out; } // A short packet marks the end of the file. - if ((actual_len >= 0) && (actual_len < SEGSIZE)) { + if ((actual_len >= 0) && (actual_len < CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE)) { // End of data close(s); freeaddrinfo(res); @@ -290,6 +291,35 @@ freeaddrinfo(res); return -1; } + + +int tftp_client_get(const char * const filename, + const char * const server, + const int port, + char *buf, + int len, + const int mode, + int * const err) { + int result; +#if CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE>512 + char *data = malloc(CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE+sizeof(struct tftphdr)); + if (data==NULL) + { + *err=TFTP_ENOSPACE; + return -1; + } +#else + char data[SEGSIZE+sizeof(struct tftphdr)]; +#endif + result=tftp_client_get_inner(data, filename, server, port, buf, len, mode, err); + +#if CYGPKG_NET_TFTPD_CLIENT_GET_PACKETSIZE>512 + free(data); +#endif + + return result; +} + // // Read a file from a host into a local buffer. Returns the // number of bytes actually read, or (-1) if an error occurs.