From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59835) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBp2i-0003h6-3a for qemu-devel@nongnu.org; Mon, 18 Apr 2011 10:03:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBp2c-0006se-4S for qemu-devel@nongnu.org; Mon, 18 Apr 2011 10:03:08 -0400 Received: from hall.aurel32.net ([88.191.126.93]:44243) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBp2b-0006sL-WC for qemu-devel@nongnu.org; Mon, 18 Apr 2011 10:03:02 -0400 Date: Mon, 18 Apr 2011 16:02:57 +0200 From: Aurelien Jarno Message-ID: <20110418140257.GC16178@volta.aurel32.net> References: <1302549054-2248-1-git-send-email-hpoussin@reactos.org> <1302549054-2248-2-git-send-email-hpoussin@reactos.org> <1302549054-2248-3-git-send-email-hpoussin@reactos.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1302549054-2248-3-git-send-email-hpoussin@reactos.org> Subject: Re: [Qemu-devel] [PATCH 2/3] slirp: Handle more than 65535 blocks in TFTP transfers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Herve Poussineau Cc: qemu-devel@nongnu.org On Mon, Apr 11, 2011 at 07:10:53PM +0000, Herve Poussineau wrote: > From: Herv? Poussineau > > 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 > --- > slirp/tftp.c | 9 +++++---- > slirp/tftp.h | 1 + > 2 files changed, 6 insertions(+), 4 deletions(-) Reviewed-by: Aurelien Jarno > 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 > > > -- Aurelien Jarno GPG: 1024D/F1BCDB73 aurelien@aurel32.net http://www.aurel32.net