Coverage Report

Created: 2026-03-01 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ndpi/src/lib/protocols/riotgames.c
Line
Count
Source
1
/*
2
 * riotgames.c
3
 *
4
 * Copyright (C) 2022-23 - 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
22
#include "ndpi_protocol_ids.h"
23
24
#define NDPI_CURRENT_PROTO NDPI_PROTOCOL_RIOTGAMES
25
26
#include "ndpi_api.h"
27
#include "ndpi_private.h"
28
29
static void ndpi_int_riotgames_add_connection(struct ndpi_detection_module_struct * const ndpi_struct,
30
                                              struct ndpi_flow_struct * const flow)
31
0
{
32
0
  NDPI_LOG_INFO(ndpi_struct, "found RiotGames\n");
33
0
  ndpi_set_detected_protocol(ndpi_struct, flow,
34
0
                             NDPI_PROTOCOL_UNKNOWN,
35
0
                             NDPI_PROTOCOL_RIOTGAMES,
36
0
                             NDPI_CONFIDENCE_DPI);
37
0
}
38
39
static void ndpi_search_riotgames(struct ndpi_detection_module_struct *ndpi_struct,
40
                                  struct ndpi_flow_struct *flow)
41
0
{
42
0
  struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
43
44
0
  NDPI_LOG_DBG(ndpi_struct, "searching RiotGames\n");
45
46
0
  if (packet->payload_packet_len > 8 &&
47
0
      ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 8)) == 0xaaaaaaaa &&
48
0
      ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 4)) == 0xbbbbbbbb)
49
0
  {
50
0
    ndpi_int_riotgames_add_connection(ndpi_struct, flow);
51
0
    return;
52
0
  }
53
54
0
  if (packet->payload_packet_len == 53 &&
55
0
      ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 4)) == 0xea23460c &&
56
0
      ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 8)) == 0x3cb11f2d)
57
0
  {
58
0
    ndpi_int_riotgames_add_connection(ndpi_struct, flow);
59
0
    return;
60
0
  }
61
62
  /*
63
   * Please add new patterns for games made by RiotGames here
64
   */
65
66
0
  NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow);
67
0
  return;
68
0
}
69
70
void init_riotgames_dissector(struct ndpi_detection_module_struct *ndpi_struct)
71
1
{
72
1
  ndpi_register_dissector("RiotGames", ndpi_struct,
73
1
                     ndpi_search_riotgames,
74
1
                     NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD,
75
1
                     1, NDPI_PROTOCOL_RIOTGAMES);
76
1
}