Coverage Report

Created: 2025-11-11 06:59

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/gearup_booster.c
Line
Count
Source
1
/*
2
 * gearup_booster.c
3
 *
4
 * Copyright (C) 2011-25 - 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_GEARUP_BOOSTER
24
25
#include "ndpi_api.h"
26
#include "ndpi_private.h"
27
28
static void ndpi_int_gearup_booster_add_connection(struct ndpi_detection_module_struct * const ndpi_struct,
29
                                                   struct ndpi_flow_struct * const flow)
30
10.8k
{
31
10.8k
  NDPI_LOG_INFO(ndpi_struct, "found GearUP Booster\n");
32
10.8k
  ndpi_set_detected_protocol(ndpi_struct, flow,
33
10.8k
                             NDPI_PROTOCOL_GEARUP_BOOSTER,
34
10.8k
                             NDPI_PROTOCOL_UNKNOWN,
35
10.8k
                             NDPI_CONFIDENCE_DPI);
36
10.8k
}
37
38
static void ndpi_search_gearup_booster(struct ndpi_detection_module_struct *ndpi_struct,
39
                                       struct ndpi_flow_struct *flow)
40
532k
{
41
532k
  struct ndpi_packet_struct * const packet = &ndpi_struct->packet;
42
43
532k
  NDPI_LOG_DBG(ndpi_struct, "search GearUP Booster\n");
44
45
532k
  if (packet->udp->source != htons(9999) && packet->udp->dest != htons(9999))
46
501k
  {
47
501k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
48
501k
    return;
49
501k
  }
50
51
30.6k
  if (flow->packet_counter == 1)
52
30.6k
  {
53
30.6k
    if (packet->packet_direction != 0 || packet->udp->dest != htons(9999))
54
10.4k
    {
55
10.4k
      NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
56
10.4k
      return;
57
10.4k
    }
58
30.6k
  }
59
60
20.2k
  if (packet->payload_packet_len == 4)
61
10.5k
  {
62
    // mobile version
63
10.5k
    if (ntohl(get_u_int32_t(packet->payload, 0)) == 0x00000000)
64
40
    {
65
40
      NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
66
40
      return;
67
40
    }
68
10.5k
  } else if (packet->payload_packet_len == 8)
69
947
  {
70
    // desktop version
71
947
    if (ntohl(get_u_int32_t(packet->payload, 0)) == 0x00000000 ||
72
922
        packet->payload[7] != 0x00 || packet->payload[6] != 0x00 || packet->payload[5] != 0x00)
73
617
    {
74
617
      NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
75
617
      return;
76
617
    }
77
8.69k
  } else {
78
8.69k
    NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
79
8.69k
    return;
80
8.69k
  }
81
82
10.8k
  ndpi_int_gearup_booster_add_connection(ndpi_struct, flow);
83
10.8k
}
84
85
void init_gearup_booster_dissector(struct ndpi_detection_module_struct *ndpi_struct)
86
8.07k
{
87
8.07k
  register_dissector("GeaUP_Booster", ndpi_struct,
88
8.07k
                     ndpi_search_gearup_booster,
89
8.07k
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
90
8.07k
                     1, NDPI_PROTOCOL_GEARUP_BOOSTER);
91
8.07k
}
92