aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/ndpi_private.h3
-rw-r--r--src/include/ndpi_protocol_ids.h3
-rw-r--r--src/lib/ndpi_main.c11
-rw-r--r--src/lib/protocols/dicom.c75
4 files changed, 88 insertions, 4 deletions
diff --git a/src/include/ndpi_private.h b/src/include/ndpi_private.h
index 6728a95cb..cb6d31736 100644
--- a/src/include/ndpi_private.h
+++ b/src/include/ndpi_private.h
@@ -970,7 +970,8 @@ void init_trdp_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int
void init_lustre_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_dingtalk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
void init_paltalk_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
-
+void init_dicom_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id);
+
#endif
#ifdef __cplusplus
diff --git a/src/include/ndpi_protocol_ids.h b/src/include/ndpi_protocol_ids.h
index 4491a27af..8c36f7e59 100644
--- a/src/include/ndpi_protocol_ids.h
+++ b/src/include/ndpi_protocol_ids.h
@@ -408,7 +408,7 @@ typedef enum {
NDPI_PROTOCOL_APACHE_KAFKA = 377,
NDPI_PROTOCOL_NOMACHINE = 378,
NDPI_PROTOCOL_IEC62056 = 379,
- NDPI_PROTOCOL_HL7 = 380,
+ NDPI_PROTOCOL_HL7 = 380, /* Hospital Protocol */
NDPI_PROTOCOL_CEPH = 381,
NDPI_PROTOCOL_GOOGLE_CHAT = 382,
NDPI_PROTOCOL_ROUGHTIME = 383,
@@ -466,6 +466,7 @@ typedef enum {
NDPI_PROTOCOL_TEMU = 435,
NDPI_PROTOCOL_TAOBAO = 436,
NDPI_PROTOCOL_MIKROTIK = 437,
+ NDPI_PROTOCOL_DICOM = 438, /* Hospital Protocol */
#ifdef CUSTOM_NDPI_PROTOCOLS
#include "../../../nDPI-custom/custom_ndpi_protocol_ids.h"
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index 4bfc34ce0..aca8d75ee 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -2230,11 +2230,15 @@ static void ndpi_init_protocol_defaults(struct ndpi_detection_module_struct *ndp
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_IEC62056,
"IEC62056", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
ndpi_build_default_ports(ports_a, 4059, 0, 0, 0, 0) /* TCP */,
- ndpi_build_default_ports(ports_b, 4059, 0, 0, 0, 0) /* UDP */);
+ ndpi_build_default_ports(ports_b, 4059, 0, 0, 0, 0) /* UDP */);
ndpi_set_proto_defaults(ndpi_str, 1 /* cleartext */, 0 /* nw proto */, NDPI_PROTOCOL_ACCEPTABLE, NDPI_PROTOCOL_HL7,
- "HL7", NDPI_PROTOCOL_CATEGORY_RPC,
+ "HL7", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
ndpi_build_default_ports(ports_a, 2575, 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_DICOM,
+ "DICOM", NDPI_PROTOCOL_CATEGORY_IOT_SCADA,
+ ndpi_build_default_ports(ports_a, 104, 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_CEPH,
"Ceph", NDPI_PROTOCOL_CATEGORY_DATA_TRANSFER,
ndpi_build_default_ports(ports_a, 3300, 6789, 0, 0, 0) /* TCP */,
@@ -6280,6 +6284,9 @@ static int ndpi_callback_init(struct ndpi_detection_module_struct *ndpi_str) {
/* HL7 */
init_hl7_dissector(ndpi_str, &a);
+ /* DICOM */
+ init_dicom_dissector(ndpi_str, &a);
+
/* Ceph */
init_ceph_dissector(ndpi_str, &a);
diff --git a/src/lib/protocols/dicom.c b/src/lib/protocols/dicom.c
new file mode 100644
index 000000000..d8abf9ed9
--- /dev/null
+++ b/src/lib/protocols/dicom.c
@@ -0,0 +1,75 @@
+/*
+ * dicom.c
+ *
+ * Copyright (C) 2012-24 - ntop.org
+ *
+ * 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_DICOM
+
+#include "ndpi_api.h"
+#include "ndpi_private.h"
+
+PACK_ON struct dicom_header {
+ u_int8_t pdu_type, pad;
+ u_int32_t pdu_len;
+} PACK_OFF;
+
+/* ********************************* */
+
+static void ndpi_search_dicom(struct ndpi_detection_module_struct *ndpi_struct,
+ struct ndpi_flow_struct *flow) {
+ struct ndpi_packet_struct *packet = &ndpi_struct->packet;
+ u_int16_t dicom_port = ntohs(104);
+
+ NDPI_LOG_DBG(ndpi_struct, "search DICOM\n");
+
+ if(packet->iph && (packet->payload_packet_len > sizeof(struct dicom_header))) {
+ if(packet->tcp->dest == dicom_port) {
+ struct dicom_header *h = (struct dicom_header*)packet->payload;
+
+ if((h->pdu_type == 0x01 /* A-ASSOCIATE */)
+ && (h->pad == 0x0)
+ && (packet->payload_packet_len <= (ntohl(h->pdu_len)+6))
+ && (packet->payload_packet_len > 9)
+ && (packet->payload[6] == 0x0) && (packet->payload[7] == 0x1) /* Protocol Version */
+ && (packet->payload[8] == 0x0) && (packet->payload[9] == 0x0) /* Pad */
+
+ ) {
+ ndpi_set_detected_protocol(ndpi_struct, flow,
+ NDPI_PROTOCOL_DICOM,
+ NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
+ } else
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+ } else if(packet->tcp->dest != dicom_port)
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow); /* At least one port must be the DICOM port */
+ } else
+ NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
+}
+
+/* ********************************* */
+
+void init_dicom_dissector(struct ndpi_detection_module_struct *ndpi_struct,
+ u_int32_t *id) {
+ ndpi_set_bitmask_protocol_detection("DICOM", ndpi_struct,
+ *id, NDPI_PROTOCOL_DICOM, ndpi_search_dicom,
+ NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
+ SAVE_DETECTION_BITMASK_AS_UNKNOWN,
+ ADD_TO_DETECTION_BITMASK);
+
+ *id += 1;
+}