/src/ndpi/src/lib/protocols/egd.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * egd.c |
3 | | * |
4 | | * Ethernet Global Data |
5 | | * |
6 | | * Copyright (C) 2024 - ntop.org |
7 | | * Copyright (C) 2024 - V.G <v.gavrilov@securitycode.ru> |
8 | | * |
9 | | * This file is part of nDPI, an open source deep packet inspection |
10 | | * library based on the OpenDPI and PACE technology by ipoque GmbH |
11 | | * |
12 | | * nDPI is free software: you can redistribute it and/or modify |
13 | | * it under the terms of the GNU Lesser General Public License as published by |
14 | | * the Free Software Foundation, either version 3 of the License, or |
15 | | * (at your option) any later version. |
16 | | * |
17 | | * nDPI is distributed in the hope that it will be useful, |
18 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
20 | | * GNU Lesser General Public License for more details. |
21 | | * |
22 | | * You should have received a copy of the GNU Lesser General Public License |
23 | | * along with nDPI. If not, see <http://www.gnu.org/licenses/>. |
24 | | * |
25 | | */ |
26 | | |
27 | | #include "ndpi_protocol_ids.h" |
28 | | |
29 | | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_EGD |
30 | | |
31 | | #include "ndpi_api.h" |
32 | | #include "ndpi_private.h" |
33 | | |
34 | | static void ndpi_search_egd(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) |
35 | 470 | { |
36 | 470 | struct ndpi_packet_struct const * const packet = &ndpi_struct->packet; |
37 | | |
38 | 470 | NDPI_LOG_DBG(ndpi_struct, "search Ethernet Global Data\n"); |
39 | | |
40 | 470 | if (packet->payload_packet_len > 32 && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0D01) |
41 | 0 | { |
42 | 0 | if (get_u_int32_t(packet->payload, 4) == packet->iph->saddr && /* ProducerID */ |
43 | 0 | ntohl(get_u_int32_t(packet->payload, 24)) < 31 && /* Status */ |
44 | 0 | get_u_int32_t(packet->payload, 28) == 0) /* Reserved */ |
45 | 0 | { |
46 | 0 | NDPI_LOG_INFO(ndpi_struct, "found Ethernet Global Data\n"); |
47 | 0 | ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_EGD, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); |
48 | 0 | return; |
49 | 0 | } |
50 | 0 | } |
51 | | |
52 | 470 | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
53 | 470 | } |
54 | | |
55 | | void init_egd_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
56 | 7.49k | { |
57 | 7.49k | register_dissector("EthernetGlobalData", ndpi_struct, |
58 | 7.49k | ndpi_search_egd, |
59 | 7.49k | NDPI_SELECTION_BITMASK_PROTOCOL_UDP_WITH_PAYLOAD, |
60 | 7.49k | 1, NDPI_PROTOCOL_EGD); |
61 | 7.49k | } |