qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Herve Poussineau <hpoussin@reactos.org>
To: qemu-devel@nongnu.org
Cc: "Herv� Poussineau" <hpoussin@reactos.org>
Subject: [Qemu-devel] [PATCH 2/3] slirp: Handle more than 65535 blocks in TFTP transfers
Date: Mon, 11 Apr 2011 19:10:53 +0000	[thread overview]
Message-ID: <1302549054-2248-3-git-send-email-hpoussin@reactos.org> (raw)
In-Reply-To: <1302549054-2248-2-git-send-email-hpoussin@reactos.org>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 2136 bytes --]

From: Hervé Poussineau <hpoussin@reactos.org>

RFC 1350 does not mention block count-roll over. However, a lot of TFTP servers
implement it to be able to transmit big files, so do it also

Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
---
 slirp/tftp.c |    9 +++++----
 slirp/tftp.h |    1 +
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/slirp/tftp.c b/slirp/tftp.c
index 7ef44c9..7e63269 100644
--- a/slirp/tftp.c
+++ b/slirp/tftp.c
@@ -92,7 +92,7 @@ static int tftp_session_find(Slirp *slirp, struct tftp_t *tp)
   return -1;
 }
 
-static int tftp_read_data(struct tftp_session *spt, uint16_t block_nr,
+static int tftp_read_data(struct tftp_session *spt, uint32_t block_nr,
                           uint8_t *buf, int len)
 {
   int fd;
@@ -196,7 +196,7 @@ out:
 }
 
 static int tftp_send_data(struct tftp_session *spt,
-                          uint16_t block_nr,
+                          uint32_t block_nr,
 			  struct tftp_t *recv_tp)
 {
   struct sockaddr_in saddr, daddr;
@@ -221,7 +221,7 @@ static int tftp_send_data(struct tftp_session *spt,
   m->m_data += sizeof(struct udpiphdr);
 
   tp->tp_op = htons(TFTP_DATA);
-  tp->x.tp_data.tp_block_nr = htons(block_nr);
+  tp->x.tp_data.tp_block_nr = htons(block_nr & 0xffff);
 
   saddr.sin_addr = recv_tp->ip.ip_dst;
   saddr.sin_port = recv_tp->udp.uh_dport;
@@ -253,6 +253,7 @@ static int tftp_send_data(struct tftp_session *spt,
     tftp_session_terminate(spt);
   }
 
+  spt->block_nr = block_nr;
   return 0;
 }
 
@@ -407,7 +408,7 @@ static void tftp_handle_ack(Slirp *slirp, struct tftp_t *tp, int pktlen)
   }
 
   if (tftp_send_data(&slirp->tftp_sessions[s],
-		     ntohs(tp->x.tp_data.tp_block_nr) + 1,
+		     slirp->tftp_sessions[s].block_nr + 1,
 		     tp) < 0) {
     return;
   }
diff --git a/slirp/tftp.h b/slirp/tftp.h
index 72e5e91..471f22e 100644
--- a/slirp/tftp.h
+++ b/slirp/tftp.h
@@ -36,6 +36,7 @@ struct tftp_session {
 
     struct in_addr client_ip;
     uint16_t client_port;
+    uint32_t block_nr;
 
     int timestamp;
 };
-- 
1.6.0.2.GIT

  reply	other threads:[~2011-04-12  1:42 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-11 19:10 [Qemu-devel] [PATCH 0/3] slirp: misc fixes Herve Poussineau
2011-04-11 19:10 ` [Qemu-devel] [PATCH 1/3] slirp: Implement TFTP Blocksize option Herve Poussineau
2011-04-11 19:10   ` Herve Poussineau [this message]
2011-04-11 19:10     ` [Qemu-devel] [PATCH 3/3] slirp: improve TFTP performance Herve Poussineau
2011-04-18 14:04       ` Aurelien Jarno
2011-04-18 14:02     ` [Qemu-devel] [PATCH 2/3] slirp: Handle more than 65535 blocks in TFTP transfers Aurelien Jarno
2011-04-16  9:15   ` [Qemu-devel] [PATCH 1/3] slirp: Implement TFTP Blocksize option Stefan Hajnoczi
2011-04-17 18:16     ` Hervé Poussineau
2011-04-17 19:53       ` Stefan Hajnoczi
2011-04-17 12:39   ` Avi Kivity
2011-04-18 14:02   ` Aurelien Jarno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1302549054-2248-3-git-send-email-hpoussin@reactos.org \
    --to=hpoussin@reactos.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).