Split former protocol into upper and lower protocol
This commit is contained in:
+25
-30
@@ -27,44 +27,39 @@
|
||||
#ifdef NDPI_PROTOCOL_TFTP
|
||||
|
||||
static void ndpi_int_tftp_add_connection(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TFTP);
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_TFTP, NDPI_PROTOCOL_UNKNOWN);
|
||||
}
|
||||
|
||||
void ndpi_search_tftp(struct ndpi_detection_module_struct
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
*ndpi_struct, struct ndpi_flow_struct *flow)
|
||||
{
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "search TFTP.\n");
|
||||
|
||||
if (packet->payload_packet_len > 3 && flow->l4.udp.tftp_stage == 0
|
||||
&& ntohl(get_u_int32_t(packet->payload, 0)) == 0x00030001) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "search TFTP.\n");
|
||||
NDPI_LOG(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "skip initial packet.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (packet->payload_packet_len > 3 && flow->l4.udp.tftp_stage == 0
|
||||
&& ntohl(get_u_int32_t(packet->payload, 0)) == 0x00030001) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "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(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "skip initial packet.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "exclude TFTP.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_TFTP);
|
||||
NDPI_LOG(NDPI_PROTOCOL_TFTP, ndpi_struct, NDPI_LOG_DEBUG, "exclude TFTP.\n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_TFTP);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user