diff options
author | Chris Johns <chrisj@rtems.org> | 2021-09-07 14:04:12 +1000 |
---|---|---|
committer | Chris Johns <chrisj@rtems.org> | 2021-09-09 18:33:54 +1000 |
commit | cb969f359f4eb0bfcc58b6eeaf2df36b11b9b7a0 (patch) | |
tree | 373d37dc947a3b5620290881a2ff78af2120d70b /misc | |
parent | tester/zynqmp: Limit the restarts to 3 (diff) | |
download | rtems-tools-cb969f359f4eb0bfcc58b6eeaf2df36b11b9b7a0.tar.bz2 |
misc/tftprpoxy: Correctly scale the protocol timeout
- Fix data decoding
- Fix get MAC call
Diffstat (limited to 'misc')
-rw-r--r-- | misc/tools/tftpproxy.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/misc/tools/tftpproxy.py b/misc/tools/tftpproxy.py index c0aebb0..a388912 100644 --- a/misc/tools/tftpproxy.py +++ b/misc/tools/tftpproxy.py @@ -113,10 +113,11 @@ class tftp_session(object): block = (data[2] << 8) | data[3] s += ' ' + self.opcodes[opcode] + ', ' s += '#' + str(block) + ', ' - if dlen > 4: + if dlen > 8: s += '%02x%02x..%02x%02x' % (data[4], data[5], data[-2], data[-1]) else: - s += '%02x%02x%02x%02x' % (data[4], data[5], data[6], data[6]) + for i in range(4, dlen): + s += '%02x' % (data[i]) s += ',' + str(dlen - 4) elif opcode == 4: block = (data[2] << 8) | data[3] @@ -162,8 +163,8 @@ class tftp_session(object): return None def get_timeout(self, default_timeout, timeout_guard): - if self.timeout == 0: - return self.timeout + timeout_guard + if self.timeout != 0: + return self.timeout * timeout_guard return default_timeout def get_block_size(self): @@ -178,7 +179,7 @@ class udp_handler(socketserver.BaseRequestHandler): session = tftp_session() finished = session.data(client_ip, client_port, self.request[0]) if not finished: - timeout = session.get_timeout(self.server.proxy.session_timeout, 1) + timeout = session.get_timeout(self.server.proxy.session_timeout, 4) host = self.server.proxy.get_host(client_ip) if host is not None: session_count = self.server.proxy.get_session_count() @@ -325,7 +326,7 @@ class proxy_server(object): if client in self.clients: host = self.clients[client] else: - mac = getmac.get_mac_address(ip = client) + mac = misc.tools.getmac.get_mac_address(ip = client) if mac in self.clients: host = self.clients[mac] finally: |