This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for tftp client code


The enclosed patch prevents tftp_get_client from prematurely ending
transmission without an error if a paket is received out of sequence.
The original code would interpret such a paket as being the legitimate
end of transfer, which IMO is wrong no matter how you read RFC 1350
(which is not terribly clear on how the client should react in such a
case) -- the tftp_get_client function should either return an error, or
simply ignore the paket and wait for the server to send the right paket.
I chose the later approach, which works with the tftp server supplied
with SuSE 8.2 Linux (according to the man page, this is the version by
H. Peter Anvin).
--
--------------------------------------------------------------------
|     Eric Doenges              |     DynaPel Laboratories GmbH    |
|     Tel: +49 89 962428 23     |     Fraunhoferstrasse 9/2        |
|     Fax: +49 89 962428 90     |     D - 85737 Ismaning, Germany  |
--------------------------------------------------------------------
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/ChangeLog,v
retrieving revision 1.42
diff -b -u -5 -r1.42 ChangeLog
--- ChangeLog	6 Oct 2003 19:07:50 -0000	1.42
+++ ChangeLog	9 Oct 2003 14:31:41 -0000
@@ -1,5 +1,10 @@
+2003-10-09  Eric Doenges <Eric.Doenges@DynaPel.com>
+
+        * src/tftp_client.c: Changed code so that an out of sequence DATA
+        packet does not prematurely end transmission.
+
 2003-10-06  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/bridge.c: Build the test when we have the bridge
 	handler code enabled and so presumably a bridge.
 
Index: src/tftp_client.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/net/net/common/current/src/tftp_client.c,v
retrieving revision 1.6
diff -b -u -5 -r1.6 tftp_client.c
--- src/tftp_client.c	12 May 2003 10:13:38 -0000	1.6
+++ src/tftp_client.c	9 Oct 2003 14:31:42 -0000
@@ -236,10 +236,14 @@
 		    *err = TFTP_TOOLARGE;
 		    goto out;
 		  }
 		}
 		last_good_block++;
+	      } else {
+                // To prevent an out-of-sequence paket from terminating
+                // transmission prematurely, set actual_len to SEGSIZE
+		actual_len = SEGSIZE;
 	      }
 	      // Send out the ACK
 	      hdr->th_opcode = htons(ACK);
 	      hdr->th_block = htons(last_good_block);
 	      if (sendto(s, data, 4 /* FIXME */, 0, 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]