def datagramReceived(self, data, (host, port)):
        if len(data) < 5:
            #bogus packet, discard
            return

        if data[:2] == "\x00\x01":
            opcode="READ"
        elif data[:2] == "\x00\x02":
            opcode="WRITE"
        else:
            #don't log other opcodes
            return

        try:
            (filename, mode, ignore) = data[2:].split("\x00")
        except ValueError:
            return

        logdata={'FILENAME': filename, 'OPCODE': opcode, 'MODE': mode}
        self.transport.getPeer = lambda: IPv4Address('UDP', host, port)
        self.factory.log(logdata=logdata, transport=self.transport)
dataset/ETHPy150Open thinkst/opencanary/opencanary/modules/tftp.py/Tftp.datagramReceived/original