Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
-----------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -----------------------------------------------
"""
def __init__(self):
TftpPacketInitial.__init__(self)
self.opcode = 1
def __str__(self):
s = 'RRQ packet: filename = %s' % self.filename
s += ' mode = %s' % self.mode
if self.options:
s += '\n options = %s' % self.options
return s
class TftpPacketWRQ(TftpPacketInitial):
"""
::
2 bytes string 1 byte string 1 byte
-----------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -----------------------------------------------
"""
def __init__(self):
TftpPacketInitial.__init__(self)
self.opcode = 2
def __str__(self):
s = 'WRQ packet: filename = %s' % self.filename
s += ' mode = %s' % self.mode
if self.options:
-----------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -----------------------------------------------
"""
def __init__(self):
TftpPacketInitial.__init__(self)
self.opcode = 1
def __str__(self):
s = 'RRQ packet: filename = %s' % self.filename
s += ' mode = %s' % self.mode
if self.options:
s += '\n options = %s' % self.options
return s
class TftpPacketWRQ(TftpPacketInitial):
"""
::
2 bytes string 1 byte string 1 byte
-----------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -----------------------------------------------
"""
def __init__(self):
TftpPacketInitial.__init__(self)
self.opcode = 2
def __str__(self):
s = 'WRQ packet: filename = %s' % self.filename
s += ' mode = %s' % self.mode
if self.options:
shortbuf = subbuf[:tlength+1]
log.debug("about to unpack buffer with fmt: %s", fmt)
log.debug("unpacking buffer: %s", repr(shortbuf))
mystruct = struct.unpack(fmt, shortbuf)
tftpassert(len(mystruct) == 2, "malformed packet")
self.filename = mystruct[0].decode('ascii')
self.mode = mystruct[1].decode('ascii').lower() # force lc - bug 17
log.debug("set filename to %s", self.filename)
log.debug("set mode to %s", self.mode)
self.options = self.decode_options(subbuf[tlength+1:])
log.debug("options dict is now %s", self.options)
return self
class TftpPacketRRQ(TftpPacketInitial):
"""
::
2 bytes string 1 byte string 1 byte
-----------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -----------------------------------------------
"""
def __init__(self):
TftpPacketInitial.__init__(self)
self.opcode = 1
def __str__(self):
s = 'RRQ packet: filename = %s' % self.filename
s += ' mode = %s' % self.mode
if self.options:
shortbuf = subbuf[:tlength+1]
log.debug("about to unpack buffer with fmt: %s", fmt)
log.debug("unpacking buffer: %s", repr(shortbuf))
mystruct = struct.unpack(fmt, shortbuf)
tftpassert(len(mystruct) == 2, "malformed packet")
self.filename = mystruct[0].decode('ascii')
self.mode = mystruct[1].decode('ascii').lower() # force lc - bug 17
log.debug("set filename to %s", self.filename)
log.debug("set mode to %s", self.mode)
self.options = self.decode_options(subbuf[tlength+1:])
log.debug("options dict is now %s", self.options)
return self
class TftpPacketRRQ(TftpPacketInitial):
"""
::
2 bytes string 1 byte string 1 byte
-----------------------------------------------
RRQ/ | 01/02 | Filename | 0 | Mode | 0 |
WRQ -----------------------------------------------
"""
def __init__(self):
TftpPacketInitial.__init__(self)
self.opcode = 1
def __str__(self):
s = 'RRQ packet: filename = %s' % self.filename
s += ' mode = %s' % self.mode
if self.options: