/src/ndpi/src/lib/protocols/xdmcp.c
Line | Count | Source |
1 | | /* |
2 | | * xdmcp.c |
3 | | * |
4 | | * Copyright (C) 2009-11 - ipoque GmbH |
5 | | * Copyright (C) 2011-25 - ntop.org |
6 | | * |
7 | | * This file is part of nDPI, an open source deep packet inspection |
8 | | * library based on the OpenDPI and PACE technology by ipoque GmbH |
9 | | * |
10 | | * nDPI is free software: you can redistribute it and/or modify |
11 | | * it under the terms of the GNU Lesser General Public License as published by |
12 | | * the Free Software Foundation, either version 3 of the License, or |
13 | | * (at your option) any later version. |
14 | | * |
15 | | * nDPI is distributed in the hope that it will be useful, |
16 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | | * GNU Lesser General Public License for more details. |
19 | | * |
20 | | * You should have received a copy of the GNU Lesser General Public License |
21 | | * along with nDPI. If not, see <http://www.gnu.org/licenses/>. |
22 | | * |
23 | | */ |
24 | | |
25 | | #include "ndpi_protocol_ids.h" |
26 | | |
27 | | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_XDMCP |
28 | | |
29 | | #include "ndpi_api.h" |
30 | | #include "ndpi_private.h" |
31 | | |
32 | | |
33 | | static void ndpi_int_xdmcp_add_connection(struct ndpi_detection_module_struct |
34 | | *ndpi_struct, struct ndpi_flow_struct *flow) |
35 | 0 | { |
36 | 0 | ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_XDMCP, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); |
37 | 0 | } |
38 | | |
39 | | static void ndpi_search_xdmcp(struct ndpi_detection_module_struct *ndpi_struct, |
40 | | struct ndpi_flow_struct *flow) |
41 | 0 | { |
42 | 0 | struct ndpi_packet_struct *packet = &ndpi_struct->packet; |
43 | | |
44 | 0 | NDPI_LOG_DBG(ndpi_struct, "search xdmcp\n"); |
45 | |
|
46 | 0 | if (packet->tcp != NULL && (ntohs(packet->tcp->dest) >= 6000 && ntohs(packet->tcp->dest) <= 6005) |
47 | 0 | && packet->payload_packet_len == 48 |
48 | 0 | && packet->payload[0] == 0x6c && packet->payload[1] == 0x00 |
49 | 0 | && ntohs(get_u_int16_t(packet->payload, 6)) == 0x1200 && ntohs(get_u_int16_t(packet->payload, 8)) == 0x1000) { |
50 | |
|
51 | 0 | NDPI_LOG_INFO(ndpi_struct, "found xdmcp over tcp\n"); |
52 | 0 | ndpi_int_xdmcp_add_connection(ndpi_struct, flow); |
53 | 0 | return; |
54 | 0 | } |
55 | 0 | if (packet->udp != NULL && ntohs(packet->udp->dest) == 177 |
56 | 0 | && packet->payload_packet_len >= 6 && packet->payload_packet_len == 6 + ntohs(get_u_int16_t(packet->payload, 4)) |
57 | 0 | && ntohs(get_u_int16_t(packet->payload, 0)) == 0x0001 && ntohs(get_u_int16_t(packet->payload, 2)) == 0x0002) { |
58 | |
|
59 | 0 | NDPI_LOG_INFO(ndpi_struct, "found xdmcp over udp\n"); |
60 | 0 | ndpi_int_xdmcp_add_connection(ndpi_struct, flow); |
61 | 0 | return; |
62 | 0 | } |
63 | | |
64 | 0 | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
65 | 0 | } |
66 | | |
67 | | |
68 | | void init_xdmcp_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
69 | 0 | { |
70 | 0 | register_dissector("XDMCP", ndpi_struct, |
71 | 0 | ndpi_search_xdmcp, |
72 | 0 | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_OR_UDP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, |
73 | 0 | 1, NDPI_PROTOCOL_XDMCP); |
74 | 0 | } |