Coverage Report

Created: 2026-04-20 06:19

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/lagofast.c
Line
Count
Source
1
/*
2
 * lagofast.c
3
 *
4
 * Copyright (C) 2011-26 - 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_LAGOFAST
24
25
#include "ndpi_api.h"
26
#include "ndpi_private.h"
27
28
static void ndpi_int_lagofast_add_connection(struct ndpi_detection_module_struct * const ndpi_struct,
29
                                             struct ndpi_flow_struct * const flow)
30
365
{
31
365
  NDPI_LOG_INFO(ndpi_struct, "found LagoFast\n");
32
365
  ndpi_set_detected_protocol(ndpi_struct, flow,
33
365
                             NDPI_PROTOCOL_LAGOFAST,
34
365
                             NDPI_PROTOCOL_UNKNOWN,
35
365
                             NDPI_CONFIDENCE_DPI);
36
365
}
37
38
static void ndpi_search_lagofast(struct ndpi_detection_module_struct *ndpi_struct,
39
                                 struct ndpi_flow_struct *flow)
40
863k
{
41
863k
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
42
43
863k
  NDPI_LOG_DBG(ndpi_struct, "search LagoFast\n");
44
863k
  if (packet->payload_packet_len < 6) {
45
58.6k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
46
58.6k
    return;
47
58.6k
  }
48
49
  // LagoFast identifier
50
804k
  if (get_u_int32_t(packet->payload, 0) != htonl(0x006e5d03)) {
51
803k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
52
803k
    return;
53
803k
  }
54
55
  // Check encoded length
56
675
  const uint16_t encoded_length = ntohs(get_u_int16_t(packet->payload, 4));
57
675
  if (packet->payload_packet_len != encoded_length + 6 /* identifier + length */) {
58
310
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
59
310
    return;
60
310
  }
61
62
365
  ndpi_int_lagofast_add_connection(ndpi_struct, flow);
63
365
}
64
65
void init_lagofast_dissector(struct ndpi_detection_module_struct *ndpi_struct)
66
14.2k
{
67
14.2k
  ndpi_register_dissector("LagoFast", ndpi_struct,
68
14.2k
                     ndpi_search_lagofast,
69
14.2k
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
70
14.2k
                      1, NDPI_PROTOCOL_LAGOFAST);
71
14.2k
}
72