aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2023-10-18 17:06:14 +0200
committerToni Uhlig <matzeton@googlemail.com>2023-10-18 17:53:28 +0200
commita0bf9b493db93bc0ebe3017790261c01ff2eab2f (patch)
treec7c3f3385989cb43ceef6e9832c660645bf5c6cf /src
parent01f384f7ff3a989c7765b880cdd8456a682bfb7c (diff)
Add Remote Management Control Protocol (RMCP).add/rmcp
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
4 files changed, 107 insertions, 0 deletions
diff --git a/src/include/ndpi_protocol_ids.h b/src/include/ndpi_protocol_ids.h
index debf6f71e..7c5957617 100644
--- a/src/include/ndpi_protocol_ids.h
+++ b/src/include/ndpi_protocol_ids.h
@@ -379,6 +379,7 @@ typedef enum {
NDPI_PROTOCOL_MULLVAD = 348,
NDPI_PROTOCOL_HTTP2 = 349,
NDPI_PROTOCOL_HAPROXY = 350,
+ NDPI_PROTOCOL_RMCP = 351,
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"
diff --git a/src/include/ndpi_protocols.h b/src/include/ndpi_protocols.h
index b02c55c5e..008902cc0 100644
--- a/src/include/ndpi_protocols.h
+++ b/src/include/ndpi_protocols.h
@@ -246,6 +246,7 @@ void init_apache_thrift_dissector(struct ndpi_detection_module_struct *ndpi_stru
void init_slp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_http2_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_haproxy_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
+void init_rmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
/* ndpi_main.c */
extern u_int32_t ndpi_ip_port_hash_funct(u_int32_t ip, u_int16_t port);
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 89761dc26..4fa3b46fe 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2159,6 +2159,10 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
"HAProxy", NDPI_PROTOCOL_CATEGORY_WEB,
ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
+ ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_SAFE, NDPI_PROTOCOL_RMCP,
+ "RMCP", NDPI_PROTOCOL_CATEGORY_SYSTEM_OS,
+ ndpi_build_default_ports(ports_a, 0, 0, 0, 0, 0) /* TCP */,
+ ndpi_build_default_ports(ports_b, 623, 0, 0, 0, 0) /* UDP */);
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_main.c"
@@ -5236,6 +5240,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
/* HAProxy */
init_haproxy_dissector(ndpi_str, &a);
+ /* RMCP */
+ init_rmcp_dissector(ndpi_str, &a);
+
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_main_init.c"
#endif
diff --git a/src/lib/protocols/rmcp.c b/src/lib/protocols/rmcp.c
new file mode 100644
index 000000000..366f6eac8
--- /dev/null
+++ b/src/lib/protocols/rmcp.c
@@ -0,0 +1,98 @@
+/*
+ * rmcp.c
+ *
+ * Copyright (C) 2023 - ntop.org
+ *
+ * This file is part of nDPI, an open source deep packet inspection
+ * library based on the OpenDPI and PACE technology by ipoque GmbH
+ *
+ * nDPI is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * nDPI is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "ndpi_protocol_ids.h"
+
+#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_RMCP
+
+#include "ndpi_api.h"
+
+struct rmcp_header {
+ uint8_t version;
+ uint8_t reserved;
+ uint8_t sequence;
+#if defined(__BIG_ENDIAN__)
+ uint8_t type : 1; // Either Normal RMCP (0) or ACK (1)
+ uint8_t class : 7;
+#elif defined(__LITTLE_ENDIAN__)
+ uint8_t class : 7;
+ uint8_t type : 1; // Either Normal RMCP (0) or ACK (1)
+#else
+#error "Missing endian macro definitions."
+#endif
+};
+
+static void ndpi_int_rmcp_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
+ struct ndpi_flow_struct *flow)
+{
+ ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RMCP, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
+}
+
+static void ndpi_search_rmcp(struct ndpi_detection_module_struct *ndpi_struct,
+ struct ndpi_flow_struct *flow)
+{
+ struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
+
+ NDPI_LOG_DBG(ndpi_struct, "search RMCP\n");
+
+ if (packet->payload_packet_len < sizeof(struct rmcp_header)) {
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+ return;
+ }
+
+ struct rmcp_header const * const rmcp_header = (struct rmcp_header *)packet->payload;
+
+ if (rmcp_header->version != 0x06 || rmcp_header->reserved != 0x00) {
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+ return;
+ }
+
+ if (rmcp_header->type != 0 && rmcp_header->sequence == 0xFF) {
+ // No ACK allowed if SEQUENCE number is 255.
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+ return;
+ }
+
+ if (rmcp_header->class != 0x06 /* Alert Standard Forum (ASF)*/
+ && rmcp_header->class != 0x07 /* Intelligent Platform Management Interface (IPMI) */)
+ {
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+ return;
+ }
+
+ ndpi_int_rmcp_add_connection(ndpi_struct, flow);
+}
+
+
+void init_rmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
+{
+ ndpi_set_bitmask_protocol_detection("RMCP", ndpi_struct, *id,
+ NDPI_PROTOCOL_RMCP,
+ ndpi_search_rmcp,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
+ SAVE_DETECTION_BITMASK_AS_UNKNOWN,
+ ADD_TO_DETECTION_BITMASK);
+
+ *id += 1;
+}
+