diff options
Diffstat (limited to 'src/lib/protocols/bittorrent.c')
-rw-r--r-- | src/lib/protocols/bittorrent.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/lib/protocols/bittorrent.c b/src/lib/protocols/bittorrent.c index 01080906f..6c77e29ef 100644 --- a/src/lib/protocols/bittorrent.c +++ b/src/lib/protocols/bittorrent.c @@ -2,7 +2,7 @@ * bittorrent.c * * Copyright (C) 2009-11 - ipoque GmbH - * Copyright (C) 2011-24 - ntop.org + * Copyright (C) 2011-25 - ntop.org * * This file is part of nDPI, an open source deep packet inspection * library based on the OpenDPI and PACE technology by ipoque GmbH @@ -184,13 +184,15 @@ static void ndpi_add_connection_as_bittorrent(struct ndpi_detection_module_struc struct ndpi_flow_struct *flow, int bt_offset, int check_hash, ndpi_confidence_t confidence) { - if(check_hash) + if(ndpi_struct->cfg.bittorrent_hash_enabled && + check_hash) ndpi_search_bittorrent_hash(ndpi_struct, flow, bt_offset); ndpi_set_detected_protocol_keeping_master(ndpi_struct, flow, NDPI_PROTOCOL_BITTORRENT, confidence); - if(flow->protos.bittorrent.hash[0] == '\0') { + if(ndpi_struct->cfg.bittorrent_hash_enabled && + flow->protos.bittorrent.hash[0] == '\0') { /* Don't use just 1 as in TCP DNS more packets could be returned (e.g. ACK). */ flow->max_extra_packets_to_check = 3; flow->extra_packets_func = search_bittorrent_again; @@ -511,10 +513,12 @@ static u_int8_t is_port(u_int16_t a, u_int16_t b, u_int16_t what) { static void ndpi_skip_bittorrent(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { + if(flow->detected_protocol_stack[0] == NDPI_PROTOCOL_BITTORRENT) + return; if(search_into_bittorrent_cache(ndpi_struct, flow)) ndpi_add_connection_as_bittorrent(ndpi_struct, flow, -1, 0, NDPI_CONFIDENCE_DPI_CACHE); else - NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); } /* ************************************* */ @@ -537,7 +541,7 @@ static void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_str if(is_port(sport, dport, 3544) /* teredo */ || is_port(sport, dport, 5246) || is_port(sport, dport, 5247) /* CAPWAP */) { exclude_bt: - NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); return; } } @@ -649,14 +653,10 @@ static void ndpi_search_bittorrent(struct ndpi_detection_module_struct *ndpi_str /* ************************************* */ -void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct, - u_int32_t *id) +void init_bittorrent_dissector(struct ndpi_detection_module_struct *ndpi_struct) { - ndpi_set_bitmask_protocol_detection("BitTorrent", ndpi_struct, *id, - NDPI_PROTOCOL_BITTORRENT, - ndpi_search_bittorrent, - NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, - SAVE_DETECTION_BITMASK_AS_UNKNOWN, - ADD_TO_DETECTION_BITMASK); - *id += 1; + register_dissector("BitTorrent", ndpi_struct, + ndpi_search_bittorrent, + NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, + 1, NDPI_PROTOCOL_BITTORRENT); } |