From ca7a06a09bbfee3f623d157df9c588b52fecf4ab Mon Sep 17 00:00:00 2001 From: "Michael P. Soulier" Date: Wed, 8 Oct 2008 21:31:34 -0400 Subject: [PATCH] Fixed the use of the tsize option in RRQ packets. --- README | 6 +++--- bin/tftpy_client.py | 2 +- tftpy/TftpPacketTypes.py | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README b/README index 8a1dafb..1b33b91 100644 --- a/README +++ b/README @@ -62,7 +62,7 @@ Purpose: Tftpy is a TFTP library for the Python programming language. It includes client and server classes, with sample implementations. Hooks are included for easy inclusion in a UI for populating progress indicators. It supports RFCs -1350, 2347 and 2348. +1350, 2347, 2348 and the tsize option from RFC 2349. Dependencies: ------------- @@ -81,8 +81,8 @@ Limitations: ------------ - Server only supports downloads. - Client only supports downloads. -- Only 'octet' mode is supported -- The only option supported is blksize +- Only 'octet' mode is supported. +- The only options supported are blksize and tsize. Future: ------- diff --git a/bin/tftpy_client.py b/bin/tftpy_client.py index ba9da85..4dae29e 100755 --- a/bin/tftpy_client.py +++ b/bin/tftpy_client.py @@ -79,7 +79,7 @@ def main(): if options.blocksize: tftp_options['blksize'] = int(options.blocksize) if options.tsize: - tftp_options['tsize'] = 1 + tftp_options['tsize'] = 0 tclient = tftpy.TftpClient(options.host, int(options.port), diff --git a/tftpy/TftpPacketTypes.py b/tftpy/TftpPacketTypes.py index 7a30cec..3270e5e 100644 --- a/tftpy/TftpPacketTypes.py +++ b/tftpy/TftpPacketTypes.py @@ -151,12 +151,12 @@ class TftpPacketInitial(TftpPacket, TftpPacketWithOptions): if self.options.keys() > 0: logger.debug("there are options to encode") for key in self.options: + # Populate the option name format += "%dsx" % len(key) options_list.append(key) - # Not all options have values. - if key != 'tsize': - format += "%dsx" % len(str(self.options[key])) - options_list.append(str(self.options[key])) + # Populate the option value + format += "%dsx" % len(str(self.options[key])) + options_list.append(str(self.options[key])) logger.debug("format is %s" % format) logger.debug("options_list is %s" % options_list)