How to use the fbtftp.constants.OPCODE_OACK function in fbtftp

To help you get started, we’ve selected a few fbtftp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github facebook / fbtftp / fbtftp / base_handler.py View on Github external
def _transmit_oack(self):
        """Method that deals with sending OACK datagrams on the wire."""
        opts = []
        for key, val in self._options.items():
            fmt = str("%dsx%ds" % (len(key), len(val)))
            opts.append(
                struct.pack(
                    fmt, bytes(key.encode("latin-1")), bytes(val.encode("latin-1"))
                )
            )
        opts.append(b"")
        fmt = str("!H")
        packet = struct.pack(fmt, constants.OPCODE_OACK) + b"\x00".join(opts)
        self._get_listener().sendto(packet, self._peer)
        self._stats.packets_sent += 1