Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def on_flow_update(self, packet_information, flow, direction):
NFStreamClassifier.on_flow_update(self, packet_information, flow, direction)
if flow.classifiers[self.name]['detection_completed'] == 0: # process till not completed
flow.classifiers[self.name]['detected_protocol'] = ndpi.ndpi_detection_process_packet(
self.mod,
byref(flow.classifiers[self.name]['ndpi_flow']),
cast(cast(c_char_p(packet_information.raw), c_void_p), POINTER(c_uint8)),
len(packet_information.raw),
int(packet_information.timestamp),
flow.classifiers[self.name]['src_id'],
flow.classifiers[self.name]['dst_id']
)
enough_packets = ((flow.ip_protocol == 6) and ((flow.src_to_dst_pkts + flow.dst_to_src_pkts) >
self.max_num_tcp_dissected_pkts)) or \
((flow.ip_protocol == 17) and ((flow.src_to_dst_pkts + flow.dst_to_src_pkts) >
self.max_num_udp_dissected_pkts))