diff options
author | Luca Deri <deri@ntop.org> | 2020-09-24 23:26:03 +0200 |
---|---|---|
committer | Luca Deri <deri@ntop.org> | 2020-09-24 23:26:03 +0200 |
commit | 044ed14b4f23708ec05f5b5c85ca29acbf4b59db (patch) | |
tree | a03aea7d48eb8ec6b5d83da71c7ab2c40fcbc10c /src/lib/protocols/tftp.c | |
parent | 51e86346d31f270099d4169cd2ebcb0146e5e593 (diff) |
Various optimizations to reduce not-necessary calls
Optimized various UDP dissectors
Removed dead protocols such as pando and pplive
Diffstat (limited to 'src/lib/protocols/tftp.c')
-rw-r--r-- | src/lib/protocols/tftp.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/lib/protocols/tftp.c b/src/lib/protocols/tftp.c index 941520b25..a9d7a21d3 100644 --- a/src/lib/protocols/tftp.c +++ b/src/lib/protocols/tftp.c @@ -41,26 +41,31 @@ void ndpi_search_tftp(struct ndpi_detection_module_struct NDPI_LOG_DBG(ndpi_struct, "search TFTP\n"); - if (packet->payload_packet_len > 3 && flow->l4.udp.tftp_stage == 0 - && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00030001) { + if ((packet->payload_packet_len > 3) + && (flow->l4.udp.tftp_stage == 0) + && (ntohl(get_u_int32_t(packet->payload, 0)) == 0x00030001)) { NDPI_LOG_DBG2(ndpi_struct, "maybe tftp. need next packet\n"); flow->l4.udp.tftp_stage = 1; return; } - if (packet->payload_packet_len > 3 && (flow->l4.udp.tftp_stage == 1) - && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040001) { - NDPI_LOG_INFO(ndpi_struct, "found tftp\n"); - ndpi_int_tftp_add_connection(ndpi_struct, flow); - return; - } - if (packet->payload_packet_len > 1 - && ((packet->payload[0] == 0 && packet->payload[packet->payload_packet_len - 1] == 0) - || (packet->payload_packet_len == 4 && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040000))) { - NDPI_LOG_DBG2(ndpi_struct, "skip initial packet\n"); - return; - } + if(flow->l4.udp.tftp_stage == 1) { + if (packet->payload_packet_len > 3 && (flow->l4.udp.tftp_stage == 1) + && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040001) { + + NDPI_LOG_INFO(ndpi_struct, "found tftp\n"); + ndpi_int_tftp_add_connection(ndpi_struct, flow); + return; + } + if (packet->payload_packet_len > 1 + && ((packet->payload[0] == 0 && packet->payload[packet->payload_packet_len - 1] == 0) + || (packet->payload_packet_len == 4 && ntohl(get_u_int32_t(packet->payload, 0)) == 0x00040000))) { + NDPI_LOG_DBG2(ndpi_struct, "skip initial packet\n"); + return; + } + } + NDPI_EXCLUDE_PROTO(ndpi_struct, flow); } |