/src/ndpi/src/lib/protocols/dropbox.c
Line | Count | Source |
1 | | /* |
2 | | * dropbox.c |
3 | | * |
4 | | * Copyright (C) 2012-18 by ntop.org |
5 | | * |
6 | | * This file is part of nDPI, an open source deep packet inspection |
7 | | * library based on the OpenDPI and PACE technology by ipoque GmbH |
8 | | * |
9 | | * nDPI is free software: you can redistribute it and/or modify |
10 | | * it under the terms of the GNU Lesser General Public License as published by |
11 | | * the Free Software Foundation, either version 3 of the License, or |
12 | | * (at your option) any later version. |
13 | | * |
14 | | * nDPI is distributed in the hope that it will be useful, |
15 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | | * GNU Lesser General Public License for more details. |
18 | | * |
19 | | * You should have received a copy of the GNU Lesser General Public License |
20 | | * along with nDPI. If not, see <http://www.gnu.org/licenses/>. |
21 | | * |
22 | | */ |
23 | | |
24 | | #include "ndpi_protocol_ids.h" |
25 | | |
26 | | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_DROPBOX |
27 | | |
28 | | #include "ndpi_api.h" |
29 | | #include "ndpi_private.h" |
30 | | |
31 | | |
32 | | #define DB_LSP_PORT 17500 |
33 | | |
34 | | static void ndpi_int_dropbox_add_connection(struct ndpi_detection_module_struct *ndpi_struct, |
35 | 1.77k | struct ndpi_flow_struct *flow) { |
36 | 1.77k | ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_DROPBOX, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI); |
37 | 1.77k | } |
38 | | |
39 | | |
40 | | static void ndpi_check_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) |
41 | 618k | { |
42 | 618k | struct ndpi_packet_struct *packet = &ndpi_struct->packet; |
43 | 618k | u_int32_t payload_len = packet->payload_packet_len; |
44 | 618k | u_int16_t dropbox_port = htons(DB_LSP_PORT); |
45 | | |
46 | 618k | if(packet->udp->dest == dropbox_port) { |
47 | 2.56k | if(packet->udp->source == dropbox_port) { |
48 | 1.75k | if(payload_len > 10) { |
49 | 1.74k | if(ndpi_strnstr((const char *)packet->payload, "\"host_int\"", payload_len) != NULL) { |
50 | 1.38k | NDPI_LOG_INFO(ndpi_struct, "found dropbox\n"); |
51 | 1.38k | ndpi_int_dropbox_add_connection(ndpi_struct, flow); |
52 | 1.38k | return; |
53 | 1.38k | } |
54 | 1.74k | } |
55 | 1.75k | } else { |
56 | 810 | if(payload_len > 10) { |
57 | 764 | if(ndpi_strnstr((const char *)packet->payload, "Bus17Cmd", payload_len) != NULL) { |
58 | 388 | NDPI_LOG_INFO(ndpi_struct, "found dropbox\n"); |
59 | 388 | ndpi_int_dropbox_add_connection(ndpi_struct, flow); |
60 | 388 | return; |
61 | 388 | } |
62 | 764 | } |
63 | 810 | } |
64 | 2.56k | } |
65 | | |
66 | 617k | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
67 | 617k | } |
68 | | |
69 | | static void ndpi_search_dropbox(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow) |
70 | 618k | { |
71 | 618k | NDPI_LOG_DBG(ndpi_struct, "search dropbox\n"); |
72 | | |
73 | 618k | ndpi_check_dropbox(ndpi_struct, flow); |
74 | 618k | } |
75 | | |
76 | | |
77 | | void init_dropbox_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
78 | 8.35k | { |
79 | 8.35k | register_dissector("DROPBOX", ndpi_struct, |
80 | 8.35k | ndpi_search_dropbox, |
81 | 8.35k | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_UDP_WITH_PAYLOAD, |
82 | 8.35k | 1, NDPI_PROTOCOL_DROPBOX); |
83 | 8.35k | } |