Coverage Report

Created: 2026-03-01 06:45

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/atg.c
Line
Count
Source
1
/*
2
 * atg.c
3
 *
4
 * Copyright (C) 2024 - 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_ATG
24
25
#include "ndpi_api.h"
26
#include "ndpi_private.h"
27
28
static void ndpi_int_atg_add_connection(struct ndpi_detection_module_struct
29
172
            *ndpi_struct, struct ndpi_flow_struct *flow) {
30
172
  ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_ATG,
31
172
           NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
32
172
}
33
34
35
static void ndpi_search_atg(struct ndpi_detection_module_struct *ndpi_struct,
36
4.32M
            struct ndpi_flow_struct *flow) {
37
4.32M
  struct ndpi_packet_struct *packet = &ndpi_struct->packet;
38
39
4.32M
  NDPI_LOG_DBG(ndpi_struct, "search for ATG\n");
40
41
4.32M
  if(packet->payload_packet_len >= 8) {
42
3.10M
    u_int16_t atg_port = ntohs(10001);
43
44
3.10M
    if((packet->tcp->source == atg_port) || (packet->tcp->dest == atg_port)) {
45
3.93k
      if(packet->payload[0] == 0x01 &&
46
779
         (packet->payload[1] == 0x49 || packet->payload[1] == 0x69 || packet->payload[1] == 0x53 || packet->payload[1] == 0x73 ) &&
47
543
         memcmp(&packet->payload[packet->payload_packet_len - 2], "\r\n", 2) == 0) {
48
172
        NDPI_LOG_INFO(ndpi_struct, "found atg\n");
49
172
        ndpi_int_atg_add_connection(ndpi_struct, flow);
50
172
        return;
51
172
      }
52
3.93k
    }
53
3.10M
  }
54
55
4.32M
  NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
56
4.32M
}
57
58
14.9k
void init_atg_dissector(struct ndpi_detection_module_struct *ndpi_struct) {
59
14.9k
  ndpi_register_dissector("ATG", ndpi_struct,
60
14.9k
                     ndpi_search_atg,
61
14.9k
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION,
62
14.9k
                     1, NDPI_PROTOCOL_ATG);
63
14.9k
}