diff options
Diffstat (limited to 'src/lib/protocols/fasttrack.c')
-rw-r--r-- | src/lib/protocols/fasttrack.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/src/lib/protocols/fasttrack.c b/src/lib/protocols/fasttrack.c index 49a4abdce..8fb20924f 100644 --- a/src/lib/protocols/fasttrack.c +++ b/src/lib/protocols/fasttrack.c @@ -37,47 +37,48 @@ static void ndpi_int_fasttrack_add_connection(struct ndpi_detection_module_struc void ndpi_search_fasttrack_tcp(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) { - struct ndpi_packet_struct *packet = &flow->packet; + struct ndpi_packet_struct *packet = &flow->packet; - NDPI_LOG_DBG(ndpi_struct, "search FASTTRACK\n"); - - if ( (packet->payload != NULL) - && (packet->payload_packet_len > 6) - && (ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a)) { - NDPI_LOG_DBG2(ndpi_struct, "detected 0d0a at the end of the packet\n"); - - if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) { - u_int16_t i; - for (i = 5; i < (packet->payload_packet_len - 2); i++) { - // make shure that the argument to GIVE is numeric - if (!(packet->payload[i] >= '0' && packet->payload[i] <= '9')) { - goto exclude_fasttrack; - } - } - - NDPI_LOG_INFO(ndpi_struct, "found FASTTRACK\n"); - ndpi_int_fasttrack_add_connection(ndpi_struct, flow); - return; - } - - if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) { - u_int8_t a = 0; - NDPI_LOG_DBG2(ndpi_struct, "detected GET /. \n"); - ndpi_parse_packet_line_info(ndpi_struct, flow); - for (a = 0; a < packet->parsed_lines; a++) { - if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0) - || (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) { - NDPI_LOG_INFO(ndpi_struct, - "found FASTTRACK X-Kazaa-Username: || User-Agent: PeerEnabler/\n"); - ndpi_int_fasttrack_add_connection(ndpi_struct, flow); - return; - } - } - } + NDPI_LOG_DBG(ndpi_struct, "search FASTTRACK\n"); + + if ( (packet->payload != NULL) + && (packet->payload_packet_len > 6) + && (ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a)) { + NDPI_LOG_DBG2(ndpi_struct, "detected 0d0a at the end of the packet\n"); + + if (memcmp(packet->payload, "GIVE ", 5) == 0 && packet->payload_packet_len >= 8) { + u_int16_t i; + for (i = 5; i < (packet->payload_packet_len - 2); i++) { + // make shure that the argument to GIVE is numeric + if (!(packet->payload[i] >= '0' && packet->payload[i] <= '9')) { + goto exclude_fasttrack; + } + } + + NDPI_LOG_INFO(ndpi_struct, "found FASTTRACK\n"); + ndpi_int_fasttrack_add_connection(ndpi_struct, flow); + return; + } + + if (packet->payload_packet_len > 50 && memcmp(packet->payload, "GET /", 5) == 0) { + u_int16_t a = 0; + NDPI_LOG_DBG2(ndpi_struct, "detected GET /. \n"); + + ndpi_parse_packet_line_info(ndpi_struct, flow); + for (a = 0; a < packet->parsed_lines; a++) { + if ((packet->line[a].len > 17 && memcmp(packet->line[a].ptr, "X-Kazaa-Username: ", 18) == 0) + || (packet->line[a].len > 23 && memcmp(packet->line[a].ptr, "User-Agent: PeerEnabler/", 24) == 0)) { + NDPI_LOG_INFO(ndpi_struct, + "found FASTTRACK X-Kazaa-Username: || User-Agent: PeerEnabler/\n"); + ndpi_int_fasttrack_add_connection(ndpi_struct, flow); + return; } + } + } + } - exclude_fasttrack: - NDPI_EXCLUDE_PROTO(ndpi_struct, flow); + exclude_fasttrack: + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); } |