aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/postgres.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/protocols/postgres.c')
-rw-r--r--src/lib/protocols/postgres.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/lib/protocols/postgres.c b/src/lib/protocols/postgres.c
index f1dc352a7..e23d316e4 100644
--- a/src/lib/protocols/postgres.c
+++ b/src/lib/protocols/postgres.c
@@ -23,9 +23,14 @@
*/
-#include "ndpi_protocols.h"
+#include "ndpi_protocol_ids.h"
+
#ifdef NDPI_PROTOCOL_POSTGRES
+#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_POSTGRES
+
+#include "ndpi_api.h"
+
static void ndpi_int_postgres_add_connection(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
@@ -37,10 +42,6 @@ void ndpi_search_postgres_tcp(struct ndpi_detection_module_struct
*ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &flow->packet;
-
-// struct ndpi_id_struct *src=ndpi_struct->src;
-// struct ndpi_id_struct *dst=ndpi_struct->dst;
-
u_int16_t size;
if (flow->l4.tcp.postgres_stage == 0) {
@@ -65,13 +66,13 @@ void ndpi_search_postgres_tcp(struct ndpi_detection_module_struct
if (flow->l4.tcp.postgres_stage == 2 - packet->packet_direction) {
//SSL accepted
if (packet->payload_packet_len == 1 && packet->payload[0] == 'S') {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "PostgreSQL detected, SSL accepted.\n");
+ NDPI_LOG_INFO(ndpi_struct, "PostgreSQL detected, SSL accepted\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
//SSL denied
if (packet->payload_packet_len == 1 && packet->payload[0] == 'N') {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "PostgreSQL detected, SSL denied.\n");
+ NDPI_LOG_INFO(ndpi_struct, "PostgreSQL detected, SSL denied\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
@@ -81,40 +82,40 @@ void ndpi_search_postgres_tcp(struct ndpi_detection_module_struct
if (packet->payload_packet_len > 8 &&
ntohl(get_u_int32_t(packet->payload, 5)) < 10 &&
ntohl(get_u_int32_t(packet->payload, 1)) == packet->payload_packet_len - 1 && packet->payload[0] == 0x52) {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "PostgreSQL detected, no SSL.\n");
+ NDPI_LOG_INFO(ndpi_struct, "PostgreSQL detected, no SSL\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
if (flow->l4.tcp.postgres_stage == 6
&& ntohl(get_u_int32_t(packet->payload, 1)) == packet->payload_packet_len - 1 && packet->payload[0] == 'p') {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "found postgres asymmetrically.\n");
+ NDPI_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
if (flow->l4.tcp.postgres_stage == 5 && packet->payload[0] == 'R') {
if (ntohl(get_u_int32_t(packet->payload, 1)) == packet->payload_packet_len - 1) {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "found postgres asymmetrically.\n");
+ NDPI_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
size = (u_int16_t)ntohl(get_u_int32_t(packet->payload, 1)) + 1;
if (packet->payload[size - 1] == 'S') {
if ((size + get_u_int32_t(packet->payload, (size + 1))) == packet->payload_packet_len) {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "found postgres asymmetrically.\n");
+ NDPI_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
}
size += get_u_int32_t(packet->payload, (size + 1)) + 1;
if (packet->payload[size - 1] == 'S') {
- NDPI_LOG(NDPI_PROTOCOL_POSTGRES, ndpi_struct, NDPI_LOG_DEBUG, "found postgres asymmetrically.\n");
+ NDPI_LOG_INFO(ndpi_struct, "found postgres asymmetrically\n");
ndpi_int_postgres_add_connection(ndpi_struct, flow);
return;
}
}
}
- NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_POSTGRES);
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}