1 /*
2 * zabbix.c
3 *
4 * Copyright (C) 2019 - ntop.org
5 *
6 * nDPI is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * nDPI is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with nDPI. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #include "ndpi_protocol_ids.h"
22
23 #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_ZABBIX
24
25 #include "ndpi_api.h"
26
27 /* *************************************************** */
28
ndpi_int_zabbix_add_connection(struct ndpi_detection_module_struct * ndpi_struct,struct ndpi_flow_struct * flow)29 static void ndpi_int_zabbix_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
30 struct ndpi_flow_struct *flow/* , */
31 /* ndpi_protocol_type_t protocol_type */) {
32 ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ZABBIX, NDPI_PROTOCOL_UNKNOWN);
33 }
34
35 /* *************************************************** */
36
ndpi_search_zabbix(struct ndpi_detection_module_struct * ndpi_struct,struct ndpi_flow_struct * flow)37 void ndpi_search_zabbix(struct ndpi_detection_module_struct *ndpi_struct,
38 struct ndpi_flow_struct *flow) {
39 struct ndpi_packet_struct *packet = &flow->packet;
40 u_int8_t tomatch[] = { 'Z', 'B', 'X', 'D', 0x1 };
41
42 NDPI_LOG_DBG(ndpi_struct, "search Zabbix\n");
43
44 if((packet->payload_packet_len > 4)
45 && (memcmp(packet->payload, tomatch, 5) == 0))
46 ndpi_int_zabbix_add_connection(ndpi_struct, flow);
47 else
48 NDPI_EXCLUDE_PROTO(ndpi_struct, flow);
49 }
50
51 /* *************************************************** */
52
init_zabbix_dissector(struct ndpi_detection_module_struct * ndpi_struct,u_int32_t * id,NDPI_PROTOCOL_BITMASK * detection_bitmask)53 void init_zabbix_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int32_t *id,
54 NDPI_PROTOCOL_BITMASK *detection_bitmask) {
55 ndpi_set_bitmask_protocol_detection("Zabbix", ndpi_struct, detection_bitmask, *id,
56 NDPI_PROTOCOL_ZABBIX,
57 ndpi_search_zabbix,
58 NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
59 SAVE_DETECTION_BITMASK_AS_UNKNOWN,
60 ADD_TO_DETECTION_BITMASK);
61
62 *id += 1;
63 }
64