Add Remote Management Control Protocol (RMCP).

Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
This commit is contained in:
Toni Uhlig
2023-10-19 19:50:57 +02:00
committed by Ivan Nardi
parent c59fe0b2b5
commit f69909d49b
84 changed files with 226 additions and 79 deletions
+1
View File
@@ -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"
+1
View File
@@ -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);
+7
View File
@@ -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
+98
View File
@@ -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;
}