This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
tftp fix for eCos applications
- From: Barton Meeks <bartonm2002 at yahoo dot com>
- To: ecos-patches at sources dot redhat dot com
- Date: Wed, 12 Mar 2003 17:17:49 -0800 (PST)
- Subject: tftp fix for eCos applications
Looks like I found and fixed something that had
already been fixed for redboot. When I tried to tftp
from my application, it only worked with 2 out of 4
tftp servers that I tried. One of the programs
produced this (winsock?) error: "RecvFrom returns
10040", and described this as a datagram that was
larger than the buffer reserved for it. I traced this
to the initial tftp request message, which was much
larger coming from my application than a similar
request from linux tftp.
I changed the sendto's in tftp_get and tftp_put (file:
tftp_client.c) from:
if (sendto(s, data, sizeof(data), 0,
to
if (sendto(s, data, (int)(cp - data), 0,
In redboot, the change had already been made to:
if (__udp_sendto(tftp_stream.data, cp-(char
*)hdr,
These changes cause the request to only send the
defined packet, instead of sending the full 512 byte
buffer.
I'm not a skilled "patch maker", but I have included
one incase the above doesn't explain things well
enough.
By the way, the two tftp servers that worked with the
large inital request packet were RedHat Linux and
Pumpkin for Windows. The ones that failed were an
internal product and tftpd32. Pumpkin and tftpd32 were
found at http://www.nonags.com, which is a good place
for windows freeware.
__________________________________________________
Do you Yahoo!?
Yahoo! Web Hosting - establish your business online
http://webhosting.yahoo.com
--- bmeeks_Ext_Eth_5_integration/ecos/packages/net/common/current/src/tftp_client.c Thu Feb 13 23:15:23 2003
+++ bmeeks_Ext_Eth_5/ecos/packages/net/common/current/src/tftp_client.c Wed Mar 12 16:14:20 2003
@@ -115,7 +115,7 @@
}
// Send request
- if (sendto(s, data, sizeof(data), 0,
+ if (sendto(s, data, (int)(cp - data), 0,
(struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
// Problem sending request
*err = TFTP_NETERR;
@@ -284,7 +284,7 @@
while (*fp) *cp++ = *fp++;
*cp++ = '\0';
// Send request
- if (sendto(s, data, sizeof(data), 0,
+ if (sendto(s, data, (int)(cp - data), 0,
(struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
// Problem sending request
*err = TFTP_NETERR;