Coverage Report

Created: 2025-11-09 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/ripe_atlas.c
Line
Count
Source
1
/*
2
 * ripe_atlas.c
3
 *
4
 * Copyright (C) 2024 - ntop.org
5
 *
6
 * This file is part of nDPI, an open source deep packet inspection
7
 * library based on the OpenDPI and PACE technology by ipoque GmbH
8
 *
9
 * nDPI is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Lesser General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * nDPI is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Lesser General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with nDPI.  If not, see <http://www.gnu.org/licenses/>.
21
 *
22
 */
23
24
#include "ndpi_protocol_ids.h"
25
26
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_RIPE_ATLAS
27
28
#include "ndpi_api.h"
29
#include "ndpi_private.h"
30
31
32
static void ndpi_int_ripe_atlas_add_connection(struct ndpi_detection_module_struct *ndpi_struct,
33
                                               struct ndpi_flow_struct *flow)
34
161
{
35
161
  NDPI_LOG_DBG(ndpi_struct, "found (Magellan) Ripe Atlas Tool\n");
36
161
  ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_RIPE_ATLAS,
37
161
                             NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
38
161
}
39
40
static void ndpi_search_ripe_atlas(struct ndpi_detection_module_struct *ndpi_struct,
41
                                   struct ndpi_flow_struct *flow)
42
532k
{
43
532k
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
44
532k
  char const * const payload = (char const *)packet->payload;
45
532k
  char const needle[] = "MGLNDD";
46
47
532k
  NDPI_LOG_DBG(ndpi_struct, "search (Magellan) Ripe Atlas Tool\n");
48
49
532k
  if (packet->payload_packet_len != 25) {
50
527k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
51
527k
    return;
52
527k
  }
53
54
4.69k
  if (strncmp(payload, needle, NDPI_STATICSTRING_LEN(needle)) == 0) {
55
161
    ndpi_int_ripe_atlas_add_connection(ndpi_struct, flow);
56
161
    return;
57
161
  }
58
59
4.53k
  NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
60
4.53k
}
61
62
void init_ripe_atlas_dissector(struct ndpi_detection_module_struct *ndpi_struct)
63
7.96k
{
64
7.96k
  register_dissector("RipeAtlas", ndpi_struct,
65
7.96k
                     ndpi_search_ripe_atlas,
66
7.96k
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
67
7.96k
                     1, NDPI_PROTOCOL_RIPE_ATLAS);
68
7.96k
}