Refactoring the debugging output.
levels of debug output: 0 - ERROR: Only for errors. 1 - TRACE: Start of each packets and if found protocol. 2 - DEBUG: Start of searching each protocol and excluding protocols. 3 - DEBUG_EXTRA: For all other messages. Added field ndpi_struct->debug_logging for enable debug output of each protocols. Simple macros for debugging output are added: NDPI_LOG_ERR(), NDPI_LOG_INFO(), NDPI_LOG_DBG(), NDPI_LOG_DBG2(), NDPI_EXCLUDE_PROTO()
This commit is contained in:
@@ -22,10 +22,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ndpi_protocol_ids.h"
|
||||
|
||||
#include "ndpi_protocols.h"
|
||||
#ifdef NDPI_PROTOCOL_TVUPLAYER
|
||||
|
||||
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_TVUPLAYER
|
||||
|
||||
#include "ndpi_api.h"
|
||||
|
||||
static void ndpi_int_tvuplayer_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
struct ndpi_flow_struct *flow/* , */
|
||||
@@ -39,19 +42,14 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
struct ndpi_packet_struct *packet = &flow->packet;
|
||||
|
||||
|
||||
// struct ndpi_id_struct *src=ndpi_struct->src;
|
||||
// struct ndpi_id_struct *dst=ndpi_struct->dst;
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "search tvuplayer. \n");
|
||||
|
||||
|
||||
NDPI_LOG_DBG(ndpi_struct, "search tvuplayer. \n");
|
||||
|
||||
if (packet->tcp != NULL) {
|
||||
if ((packet->payload_packet_len == 36 || packet->payload_packet_len == 24)
|
||||
&& packet->payload[0] == 0x00
|
||||
&& ntohl(get_u_int32_t(packet->payload, 2)) == 0x31323334
|
||||
&& ntohl(get_u_int32_t(packet->payload, 6)) == 0x35363837 && packet->payload[10] == 0x01) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer over tcp. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer over tcp. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -62,7 +60,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
NDPI_PARSE_PACKET_LINE_INFO(ndpi_struct, flow, packet);
|
||||
if (packet->user_agent_line.ptr != NULL &&
|
||||
packet->user_agent_line.len >= 8 && (memcmp(packet->user_agent_line.ptr, "MacTVUP", 7) == 0)) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "Found user agent as MacTVUP.\n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "Found user agent as MacTVUP\n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -79,7 +77,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
&& packet->payload[12] == 0x02 && packet->payload[13] == 0xff
|
||||
&& packet->payload[19] == 0x2c && ((packet->payload[26] == 0x05 && packet->payload[27] == 0x14)
|
||||
|| (packet->payload[26] == 0x14 && packet->payload[27] == 0x05))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type I. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type I. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -91,7 +89,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
&& packet->payload[33] == 0xff && packet->payload[34] == 0x01
|
||||
&& packet->payload[39] == 0x32 && ((packet->payload[46] == 0x05 && packet->payload[47] == 0x14)
|
||||
|| (packet->payload[46] == 0x14 && packet->payload[47] == 0x05))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type II. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type II. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -103,7 +101,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
|| packet->payload[11] == 0x06 || packet->payload[11] == 0x22)
|
||||
&& packet->payload[12] == 0x01 && (packet->payload[13] == 0xff || packet->payload[13] == 0x01)
|
||||
&& packet->payload[19] == 0x14) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type III. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type III. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -113,7 +111,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
&& packet->payload[12] == 0x01 && packet->payload[13] == 0xff
|
||||
&& packet->payload[19] == 0x14 && packet->payload[32] == 0x03
|
||||
&& packet->payload[33] == 0xff && packet->payload[34] == 0x01 && packet->payload[39] == 0x34) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type IV. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type IV. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -122,7 +120,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
&& packet->payload[10] == 0x00 && packet->payload[11] == 0x00
|
||||
&& packet->payload[12] == 0x01 && packet->payload[13] == 0xff
|
||||
&& packet->payload[19] == 0x14 && packet->payload[33] == 0xff && packet->payload[39] == 0x14) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type V. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type V. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -131,7 +129,7 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
&& packet->payload[12] == 0x03 && packet->payload[13] == 0xff
|
||||
&& packet->payload[19] == 0x32 && ((packet->payload[26] == 0x05 && packet->payload[27] == 0x14)
|
||||
|| (packet->payload[26] == 0x14 && packet->payload[27] == 0x05))) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type VI. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type VI. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
@@ -140,14 +138,13 @@ void ndpi_search_tvuplayer(struct ndpi_detection_module_struct *ndpi_struct, str
|
||||
&& packet->payload[0] == 0x00 && packet->payload[2] == 0x00
|
||||
&& packet->payload[10] == 0x00 && packet->payload[11] == 0x00
|
||||
&& packet->payload[12] == 0x06 && packet->payload[13] == 0x00 && packet->payload[19] == 0x30) {
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "found tvuplayer pattern type VII. \n");
|
||||
NDPI_LOG_INFO(ndpi_struct, "found tvuplayer pattern type VII. \n");
|
||||
ndpi_int_tvuplayer_add_connection(ndpi_struct, flow);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
NDPI_LOG(NDPI_PROTOCOL_TVUPLAYER, ndpi_struct, NDPI_LOG_DEBUG, "exclude tvuplayer. \n");
|
||||
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_TVUPLAYER);
|
||||
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user