Fixed the use of the tsize option in RRQ packets.

master
Michael P. Soulier 2008-10-08 21:31:34 -04:00
parent 0a5df33dca
commit ca7a06a09b
3 changed files with 8 additions and 8 deletions

6
README
View File

@ -62,7 +62,7 @@ Purpose:
Tftpy is a TFTP library for the Python programming language. It includes Tftpy is a TFTP library for the Python programming language. It includes
client and server classes, with sample implementations. Hooks are included for client and server classes, with sample implementations. Hooks are included for
easy inclusion in a UI for populating progress indicators. It supports RFCs 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: Dependencies:
------------- -------------
@ -81,8 +81,8 @@ Limitations:
------------ ------------
- Server only supports downloads. - Server only supports downloads.
- Client only supports downloads. - Client only supports downloads.
- Only 'octet' mode is supported - Only 'octet' mode is supported.
- The only option supported is blksize - The only options supported are blksize and tsize.
Future: Future:
------- -------

View File

@ -79,7 +79,7 @@ def main():
if options.blocksize: if options.blocksize:
tftp_options['blksize'] = int(options.blocksize) tftp_options['blksize'] = int(options.blocksize)
if options.tsize: if options.tsize:
tftp_options['tsize'] = 1 tftp_options['tsize'] = 0
tclient = tftpy.TftpClient(options.host, tclient = tftpy.TftpClient(options.host,
int(options.port), int(options.port),

View File

@ -151,12 +151,12 @@ class TftpPacketInitial(TftpPacket, TftpPacketWithOptions):
if self.options.keys() > 0: if self.options.keys() > 0:
logger.debug("there are options to encode") logger.debug("there are options to encode")
for key in self.options: for key in self.options:
# Populate the option name
format += "%dsx" % len(key) format += "%dsx" % len(key)
options_list.append(key) options_list.append(key)
# Not all options have values. # Populate the option value
if key != 'tsize': format += "%dsx" % len(str(self.options[key]))
format += "%dsx" % len(str(self.options[key])) options_list.append(str(self.options[key]))
options_list.append(str(self.options[key]))
logger.debug("format is %s" % format) logger.debug("format is %s" % format)
logger.debug("options_list is %s" % options_list) logger.debug("options_list is %s" % options_list)