Add Ethernet Global Data support (#2437)

This commit is contained in:
Vladimir Gavrilov
2024-05-11 16:49:16 +02:00
committed by GitHub
parent 8c5e6e9761
commit 2d33431948
81 changed files with 187 additions and 75 deletions
+1
View File
@@ -917,6 +917,7 @@ void init_ldp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3
void init_knxnet_ip_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_bfcp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_iqiyi_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_egd_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
#endif
+1 -1
View File
@@ -177,7 +177,7 @@ typedef enum {
NDPI_PROTOCOL_RADIUS = 146,
NDPI_PROTOCOL_WINDOWS_UPDATE = 147,
NDPI_PROTOCOL_TEAMVIEWER = 148,
NDPI_PROTOCOL_FREE_149 = 149, /* FREE */
NDPI_PROTOCOL_EGD = 149,
NDPI_PROTOCOL_LOTUS_NOTES = 150,
NDPI_PROTOCOL_SAP = 151,
NDPI_PROTOCOL_GTP = 152,
+5 -2
View File
@@ -2292,8 +2292,8 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
"KNXnet_IP", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
ndpi_build_default_ports(ports_a, 3671, 0, 0, 0, 0) /* TCP */,
ndpi_build_default_ports(ports_b, 3671, 0, 0, 0, 0) /* UDP */);
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_FREE_149,
"Free149", NDPI_PROTOCOL_CATEGORY_VOIP,
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_EGD,
"EthernetGlobalData", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
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_ACCEPTABLE, NDPI_PROTOCOL_BFCP,
@@ -6220,6 +6220,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
/* iQIYI */
init_iqiyi_dissector(ndpi_str, &a);
/* Ethernet Global Data */
init_egd_dissector(ndpi_str, &a);
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_main_init.c"
#endif
+65
View File
@@ -0,0 +1,65 @@
/*
* egd.c
*
* Ethernet Global Data
*
* Copyright (C) 2024 - ntop.org
* Copyright (C) 2024 - V.G <v.gavrilov@securitycode.ru>
*
* 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_EGD
#include "ndpi_api.h"
#include "ndpi_private.h"
static void ndpi_search_egd(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 Ethernet Global Data\n");
if (packet->payload_packet_len > 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0D01)
{
if (get_u_int32_t(packet->payload, 4) == packet->iph->saddr && /* ProducerID */
ntohl(get_u_int32_t(packet->payload, 24)) < 31 && /* Status */
get_u_int32_t(packet->payload, 28) == 0) /* Reserved */
{
NDPI_LOG_INFO(ndpi_struct, "found Ethernet Global Data\n");
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EGD, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
return;
}
}
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
}
void init_egd_dissector(struct ndpi_detection_module_struct *ndpi_struct,u_int32_t *id)
{
ndpi_set_bitmask_protocol_detection("EthernetGlobalData", ndpi_struct, *id,
NDPI_PROTOCOL_EGD,
ndpi_search_egd,
NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD,
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
ADD_TO_DETECTION_BITMASK);
*id += 1;
}