/src/ndpi/src/lib/protocols/avast.c
Line | Count | Source |
1 | | /* |
2 | | * avast.c |
3 | | * |
4 | | * Copyright (C) 2012-22 - ntop.org |
5 | | * |
6 | | * This module 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 | | * This module 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 | | * 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_AVAST |
24 | | |
25 | | #include <stdlib.h> |
26 | | #include "ndpi_api.h" |
27 | | #include "ndpi_private.h" |
28 | | |
29 | | static void ndpi_int_avast_add_connection(struct ndpi_detection_module_struct *ndpi_struct, |
30 | | struct ndpi_flow_struct *flow) |
31 | 322 | { |
32 | 322 | ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_AVAST, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); |
33 | 322 | } |
34 | | |
35 | | static void ndpi_search_avast(struct ndpi_detection_module_struct *ndpi_struct, |
36 | | struct ndpi_flow_struct *flow) |
37 | 2.27M | { |
38 | 2.27M | struct ndpi_packet_struct * packet = &ndpi_struct->packet; |
39 | | |
40 | 2.27M | if (packet->payload_packet_len < 6) |
41 | 570k | { |
42 | 570k | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
43 | 570k | return; |
44 | 570k | } |
45 | | |
46 | 1.70M | if (strncmp((char *)&packet->payload[0], "NOSA", NDPI_STATICSTRING_LEN("NOSA")) == 0 && |
47 | 1.70M | ntohs(*(uint16_t *)&packet->payload[4]) == packet->payload_packet_len) |
48 | 322 | { |
49 | 322 | ndpi_int_avast_add_connection(ndpi_struct, flow); |
50 | 322 | return; |
51 | 322 | } |
52 | | |
53 | 1.70M | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
54 | 1.70M | } |
55 | | |
56 | | void init_avast_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
57 | 8.03k | { |
58 | 8.03k | register_dissector("AVAST", ndpi_struct, |
59 | 8.03k | ndpi_search_avast, |
60 | 8.03k | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, |
61 | 8.03k | 1, NDPI_PROTOCOL_AVAST); |
62 | 8.03k | } |