aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/mail_smtp.c
diff options
context:
space:
mode:
authorVitaly Lavrov <vel21ripn@gmail.com>2017-10-14 14:38:48 +0300
committerVitaly Lavrov <vel21ripn@gmail.com>2017-10-26 20:41:22 +0300
commit2787c2390cdd7129c2dcf50b0d4990d3f7d1bccc (patch)
treedb110f640b9c1de43a0a64a43974ea90776c6588 /src/lib/protocols/mail_smtp.c
parent4f72b954da705f8d54a9dd61eae46b2b36b24dc0 (diff)
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()
Diffstat (limited to 'src/lib/protocols/mail_smtp.c')
-rw-r--r--src/lib/protocols/mail_smtp.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/lib/protocols/mail_smtp.c b/src/lib/protocols/mail_smtp.c
index 422ed0dc2..252c74ffe 100644
--- a/src/lib/protocols/mail_smtp.c
+++ b/src/lib/protocols/mail_smtp.c
@@ -23,10 +23,15 @@
*/
-#include "ndpi_protocols.h"
+#include "ndpi_protocol_ids.h"
#ifdef NDPI_PROTOCOL_MAIL_SMTP
+#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_MAIL_SMTP
+
+#include "ndpi_api.h"
+
+
#define SMTP_BIT_220 0x01
#define SMTP_BIT_250 0x02
#define SMTP_BIT_235 0x04
@@ -53,12 +58,7 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct
{
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_MAIL_SMTP, ndpi_struct, NDPI_LOG_DEBUG, "search mail_smtp.\n");
-
+ NDPI_LOG_DBG(ndpi_struct, "search mail_smtp\n");
if (packet->payload_packet_len > 2 && ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a) {
u_int8_t a;
@@ -152,11 +152,11 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct
bit_count += (flow->l4.tcp.smtp_command_bitmask >> a) & 0x01;
}
}
- NDPI_LOG(NDPI_PROTOCOL_MAIL_SMTP, ndpi_struct, NDPI_LOG_DEBUG, "seen smtp commands and responses: %u.\n",
+ NDPI_LOG_DBG2(ndpi_struct, "seen smtp commands and responses: %u\n",
bit_count);
if (bit_count >= 3) {
- NDPI_LOG(NDPI_PROTOCOL_MAIL_SMTP, ndpi_struct, NDPI_LOG_DEBUG, "mail smtp identified\n");
+ NDPI_LOG_INFO(ndpi_struct, "mail smtp identified\n");
ndpi_int_mail_smtp_add_connection(ndpi_struct, flow);
return;
}
@@ -169,12 +169,11 @@ void ndpi_search_mail_smtp_tcp(struct ndpi_detection_module_struct
packet->payload_packet_len >= 4 &&
(ntohs(get_u_int16_t(packet->payload, packet->payload_packet_len - 2)) == 0x0d0a
|| memcmp(packet->payload, "220", 3) == 0 || memcmp(packet->payload, "EHLO", 4) == 0)) {
- NDPI_LOG(NDPI_PROTOCOL_MAIL_SMTP, ndpi_struct, NDPI_LOG_DEBUG, "maybe SMTP, need next packet.\n");
+ NDPI_LOG_DBG2(ndpi_struct, "maybe SMTP, need next packet\n");
return;
}
- NDPI_LOG(NDPI_PROTOCOL_MAIL_SMTP, ndpi_struct, NDPI_LOG_DEBUG, "exclude smtp\n");
- NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_MAIL_SMTP);
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}