Skip to content

Commit 3d09b25

Browse files
authored
Add Ceph protocol dissector (#2242)
* Add Ceph protocol dissector * Update protocols.rst
1 parent f23e9dc commit 3d09b25

File tree

101 files changed

+1732
-1622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1732
-1622
lines changed

doc/protocols.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,12 @@ Notes:
447447
HL7 is a range of global standards for the transfer of clinical and administrative health data between applications.
448448

449449
References: `Main site <https://www.hl7.org/>`_
450+
451+
452+
.. _Proto 381:
453+
454+
`NDPI_PROTOCOL_CEPH`
455+
=========================
456+
Ceph is a scalable distributed storage system.
457+
458+
References: `Main site <https://ceph.io/en/>`_

src/include/ndpi_protocol_ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ typedef enum {
409409
NDPI_PROTOCOL_NOMACHINE = 378,
410410
NDPI_PROTOCOL_IEC62056 = 379,
411411
NDPI_PROTOCOL_HL7 = 380,
412+
NDPI_PROTOCOL_CEPH = 381,
412413

413414
#ifdef CUSTOM_NDPI_PROTOCOLS
414415
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"

src/lib/ndpi_main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,6 +2231,10 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
22312231
"HL7", NDPI_PROTOCOL_CATEGORY_RPC,
22322232
ndpi_build_default_ports(ports_a, 2575, 0, 0, 0, 0) /* TCP */,
22332233
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
2234+
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_CEPH,
2235+
"Ceph", NDPI_PROTOCOL_CATEGORY_DATA_TRANSFER,
2236+
ndpi_build_default_ports(ports_a, 3300, 6789, 0, 0, 0) /* TCP */,
2237+
ndpi_build_default_ports(ports_b, 0, 0, 0, 0, 0) /* UDP */);
22342238

22352239
#ifdef CUSTOM_NDPI_PROTOCOLS
22362240
#include "../../../nDPI-custom/custom_ndpi_main.c"
@@ -5746,6 +5750,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
57465750
/* HL7 */
57475751
init_hl7_dissector(ndpi_str, &a);
57485752

5753+
/* Ceph */
5754+
init_ceph_dissector(ndpi_str, &a);
5755+
57495756
#ifdef CUSTOM_NDPI_PROTOCOLS
57505757
#include "../../../nDPI-custom/custom_ndpi_main_init.c"
57515758
#endif

src/lib/ndpi_private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ void init_kafka_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_in
643643
void init_nomachine_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
644644
void init_iec62056_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
645645
void init_hl7_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
646+
void init_ceph_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
646647

647648
#endif
648649

src/lib/protocols/ceph.c

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* ceph.c
3+
*
4+
* Copyright (C) 2023 - ntop.org
5+
* Copyright (C) 2023 - V.G <[email protected]>
6+
*
7+
* This file is part of nDPI, an open source deep packet inspection
8+
* library based on the OpenDPI and PACE technology by ipoque GmbH
9+
*
10+
* nDPI is free software: you can redistribute it and/or modify
11+
* it under the terms of the GNU Lesser General Public License as published by
12+
* the Free Software Foundation, either version 3 of the License, or
13+
* (at your option) any later version.
14+
*
15+
* nDPI is distributed in the hope that it will be useful,
16+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+
* GNU Lesser General Public License for more details.
19+
*
20+
* You should have received a copy of the GNU Lesser General Public License
21+
* along with nDPI. If not, see <http://www.gnu.org/licenses/>.
22+
*
23+
*/
24+
25+
#include "ndpi_protocol_ids.h"
26+
27+
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_CEPH
28+
29+
#include "ndpi_api.h"
30+
#include "ndpi_private.h"
31+
32+
static void ndpi_search_ceph(struct ndpi_detection_module_struct *ndpi_struct,
33+
struct ndpi_flow_struct *flow)
34+
{
35+
struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
36+
37+
NDPI_LOG_DBG(ndpi_struct, "search Ceph\n");
38+
39+
/* The protocol starts with a handshake, where the client's request and
40+
* the server's response always contain a Ceph version string (ceph v027
41+
* for example). */
42+
if (packet->payload_packet_len > NDPI_STATICSTRING_LEN("ceph v") &&
43+
memcmp(packet->payload, "ceph v", NDPI_STATICSTRING_LEN("ceph v")) == 0)
44+
{
45+
NDPI_LOG_INFO(ndpi_struct, "found Ceph\n");
46+
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_CEPH,
47+
NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
48+
return;
49+
}
50+
51+
NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
52+
}
53+
54+
void init_ceph_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id)
55+
{
56+
ndpi_set_bitmask_protocol_detection("Ceph", ndpi_struct, *id,
57+
NDPI_PROTOCOL_CEPH,
58+
ndpi_search_ceph,
59+
NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
60+
SAVE_DETECTION_BITMASK_AS_UNKNOWN,
61+
ADD_TO_DETECTION_BITMASK);
62+
*id += 1;
63+
}

tests/cfgs/caches_cfg/result/ookla.pcap.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Guessed flow protos: 1
33
DPI Packets (TCP): 40 (6.67 pkts/flow)
44
Confidence Match by port : 1 (flows)
55
Confidence DPI : 5 (flows)
6-
Num dissector calls: 553 (92.17 diss/flow)
6+
Num dissector calls: 556 (92.67 diss/flow)
77
LRU cache ookla: 0/0/0 (insert/search/found)
88
LRU cache bittorrent: 0/3/0 (insert/search/found)
99
LRU cache zoom: 0/0/0 (insert/search/found)

tests/cfgs/caches_cfg/result/teams.pcap.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ DPI Packets (other): 1 (1.00 pkts/flow)
66
Confidence Unknown : 1 (flows)
77
Confidence Match by port : 2 (flows)
88
Confidence DPI : 80 (flows)
9-
Num dissector calls: 531 (6.40 diss/flow)
9+
Num dissector calls: 532 (6.41 diss/flow)
1010
LRU cache ookla: 0/0/0 (insert/search/found)
1111
LRU cache bittorrent: 0/9/0 (insert/search/found)
1212
LRU cache zoom: 0/0/0 (insert/search/found)

tests/cfgs/default/pcap/ceph.pcap

13.7 KB
Binary file not shown.

tests/cfgs/default/result/1kxun.pcap.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DPI Packets (UDP): 120 (1.21 pkts/flow)
55
Confidence Unknown : 14 (flows)
66
Confidence Match by port : 6 (flows)
77
Confidence DPI : 177 (flows)
8-
Num dissector calls: 4880 (24.77 diss/flow)
8+
Num dissector calls: 4883 (24.79 diss/flow)
99
LRU cache ookla: 0/0/0 (insert/search/found)
1010
LRU cache bittorrent: 0/60/0 (insert/search/found)
1111
LRU cache zoom: 0/0/0 (insert/search/found)

tests/cfgs/default/result/443-chrome.pcap.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Guessed flow protos: 1
22

33
DPI Packets (TCP): 1 (1.00 pkts/flow)
44
Confidence Match by port : 1 (flows)
5-
Num dissector calls: 137 (137.00 diss/flow)
5+
Num dissector calls: 138 (138.00 diss/flow)
66
LRU cache ookla: 0/0/0 (insert/search/found)
77
LRU cache bittorrent: 0/3/0 (insert/search/found)
88
LRU cache zoom: 0/0/0 (insert/search/found)

0 commit comments

Comments
 (0)