summaryrefslogtreecommitdiff
path: root/tftpy/TftpClient.py
diff options
context:
space:
mode:
authorMichael P. Soulier <msoulier@digitaltorque.ca>2008-10-04 20:42:27 -0400
committerMichael P. Soulier <msoulier@digitaltorque.ca>2008-10-04 20:42:27 -0400
commit07416bf84823f06a29c87c0ab90db6aa8ffef078 (patch)
tree8e7b889b395dbca9e8f8ba6ecf5f326d06f3ce18 /tftpy/TftpClient.py
parent8a0162b31739bc05bcec1b846834de33f5830b37 (diff)
downloadtftpy-07416bf84823f06a29c87c0ab90db6aa8ffef078.tar.gz
Rebased tsize branch and added a --tsize option to the client.
Now sending all packets to the progresshook, not just DAT packets, so that the client can see the OACK. Not yet making use of the returned tsize. Need to test this on a server that supports tsize.
Diffstat (limited to 'tftpy/TftpClient.py')
-rw-r--r--tftpy/TftpClient.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/tftpy/TftpClient.py b/tftpy/TftpClient.py
index c64245b..5ce3b32 100644
--- a/tftpy/TftpClient.py
+++ b/tftpy/TftpClient.py
@@ -97,6 +97,13 @@ class TftpClient(TftpSession):
% (raddress, rport,
self.host, self.port))
continue
+
+ # If there is a packethook defined, call it. We unconditionally
+ # pass all packets, it's up to the client to screen out different
+ # kinds of packets. This way, the client is privy to things like
+ # negotiated options.
+ if packethook:
+ packethook(recvpkt)
if not self.port and self.state.state == 'rrq':
self.port = rport
@@ -126,11 +133,8 @@ class TftpClient(TftpSession):
% len(recvpkt.data))
outputfile.write(recvpkt.data)
bytes += len(recvpkt.data)
- # If there is a packethook defined, call it.
- if packethook:
- packethook(recvpkt)
# Check for end-of-file, any less than full data packet.
- if len(recvpkt.data) < self.options['blksize']:
+ if len(recvpkt.data) < int(self.options['blksize']):
logger.info("end of file detected")
break
@@ -165,6 +169,8 @@ class TftpClient(TftpSession):
if recvpkt.options.keys() > 0:
if recvpkt.match_options(self.options):
logger.info("Successful negotiation of options")
+ # Set options to OACK options
+ self.options = recvpkt.options
for key in self.options:
logger.info(" %s = %s" % (key, self.options[key]))
logger.debug("sending ACK to OACK")