How to use the nfstream.classifier.NFStreamClassifier function in nfstream

To help you get started, we’ve selected a few nfstream 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 aouinizied / nfstream / nfstream / classifier.py View on Github external
self.name = name

    def on_flow_init(self, flow):
        return

    def on_flow_update(self, packet_information, flow, direction):
        return

    def on_flow_terminate(self, flow):
        return

    def on_exit(self):
        return


class NDPIClassifier(NFStreamClassifier):
    def __init__(self, name):
        NFStreamClassifier.__init__(self, name)
        if ndpi.ndpi_get_api_version() != ndpi.ndpi_wrap_get_api_version():
            sys.exit("nDPI Library version mismatch. Please make sure this code and the nDPI library are in sync.")
        self.ndpi_revision = cast(ndpi.ndpi_revision(), c_char_p).value.decode('utf-8')
        # print('NDPIClassifier.ndpi_revision: {}'.format(self.ndpi_revision))
        self.mod = ndpi.ndpi_init_detection_module()
        ndpi_ndpi_finalize_initalization(self.mod)
        all = NDPIProtocolBitMask()
        ndpi.ndpi_wrap_NDPI_BITMASK_SET_ALL(pointer(all))
        ndpi.ndpi_set_protocol_detection_bitmask2(self.mod, pointer(all))
        self.max_num_udp_dissected_pkts = 16
        self.max_num_tcp_dissected_pkts = 10

    @staticmethod
    def str(field):