changeset 1064:c220ab07f5ed

* src/net/tftp_client.c: Define tftp_stream.last_good_block to permit downloads > 32MB. (tftp_ack): Allow last_good_block to wrap. (tftp_stream_read): Ditto.
author jlarmour
date Mon, 23 Jun 2003 23:54:45 +0000
parents e54a552c19f9
children 965fc7fbe135
files packages/redboot/current/ChangeLog packages/redboot/current/src/net/tftp_client.c
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog
+++ b/packages/redboot/current/ChangeLog
@@ -1,4 +1,10 @@
 2003-06-24  Jeroen Dobbelaere  <jeroen.dobbelaere@acunia.com>
+2003-06-24  Jonathan Larmour  <jifl@eCosCentric.com>
+
+	* src/net/tftp_client.c: Define tftp_stream.last_good_block to
+	permit downloads > 32MB.
+	(tftp_ack): Allow last_good_block to wrap.
+	(tftp_stream_read): Ditto.
 
 	* src/net/bootp.c: Use correct DHCP message type for DHCPREQUEST.
 
--- a/packages/redboot/current/src/net/tftp_client.c
+++ b/packages/redboot/current/src/net/tftp_client.c
@@ -66,7 +66,7 @@ static int get_port = 7700;
 static struct {
     bool open;
     int  total_timeouts, packets_received;
-    unsigned short last_good_block;
+    unsigned long last_good_block;
     int  avail, actual_len;
     struct sockaddr_in local_addr, from_addr;
     char data[SEGSIZE+sizeof(struct tftphdr)];
@@ -145,7 +145,7 @@ tftp_ack(int *err)
     // ACK last packet so server can shut down
     if (tftp_stream.packets_received > 0) {
         hdr->th_opcode = htons(ACK);
-        hdr->th_block = htons(tftp_stream.last_good_block);
+        hdr->th_block = htons((cyg_uint16)tftp_stream.last_good_block & 0xFFFF);
         if (__udp_sendto(tftp_stream.data, 4 /* FIXME */, 
                          &tftp_stream.from_addr, &tftp_stream.local_addr) < 0) {
             // Problem sending ACK
@@ -210,7 +210,7 @@ tftp_stream_read(char *buf,
             } else {
                 tftp_stream.packets_received++;
                 if (ntohs(hdr->th_opcode) == DATA) {
-                    if (ntohs(hdr->th_block) == (tftp_stream.last_good_block+1)) {
+                    if (ntohs(hdr->th_block) == (cyg_uint16)((tftp_stream.last_good_block+1) & 0xFFFF)) {
                         // Consume this data
                         data_len -= 4;  /* Sizeof TFTP header */
                         tftp_stream.avail = tftp_stream.actual_len = data_len;