/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 | 429 | { |
32 | 429 | NDPI_LOG_INFO(ndpi_struct, "found RiotGames\n"); |
33 | 429 | ndpi_set_detected_protocol(ndpi_struct, flow, |
34 | 429 | NDPI_PROTOCOL_UNKNOWN, |
35 | 429 | NDPI_PROTOCOL_RIOTGAMES, |
36 | 429 | NDPI_CONFIDENCE_DPI); |
37 | 429 | } |
38 | | |
39 | | static void ndpi_search_riotgames(struct ndpi_detection_module_struct *ndpi_struct, |
40 | | struct ndpi_flow_struct *flow) |
41 | 622k | { |
42 | 622k | struct ndpi_packet_struct const * const packet = &ndpi_struct->packet; |
43 | | |
44 | 622k | NDPI_LOG_DBG(ndpi_struct, "searching RiotGames\n"); |
45 | | |
46 | 622k | if (packet->payload_packet_len > 8 && |
47 | 622k | ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 8)) == 0xaaaaaaaa && |
48 | 622k | ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 4)) == 0xbbbbbbbb) |
49 | 275 | { |
50 | 275 | ndpi_int_riotgames_add_connection(ndpi_struct, flow); |
51 | 275 | return; |
52 | 275 | } |
53 | | |
54 | 621k | if (packet->payload_packet_len == 53 && |
55 | 621k | ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 4)) == 0xea23460c && |
56 | 621k | ntohl(get_u_int32_t(packet->payload, packet->payload_packet_len - 8)) == 0x3cb11f2d) |
57 | 154 | { |
58 | 154 | ndpi_int_riotgames_add_connection(ndpi_struct, flow); |
59 | 154 | return; |
60 | 154 | } |
61 | | |
62 | | /* |
63 | | * Please add new patterns for games made by RiotGames here |
64 | | */ |
65 | | |
66 | 621k | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
67 | 621k | return; |
68 | 621k | } |
69 | | |
70 | | void init_riotgames_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
71 | 17.7k | { |
72 | 17.7k | register_dissector("RiotGames", ndpi_struct, |
73 | 17.7k | ndpi_search_riotgames, |
74 | 17.7k | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD, |
75 | 17.7k | 1, NDPI_PROTOCOL_RIOTGAMES); |
76 | 17.7k | } |