/src/ndpi/src/lib/protocols/kismet.c
Line | Count | Source |
1 | | /* |
2 | | * kismet.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 | 1.72k | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_KISMET |
25 | | |
26 | | #include "ndpi_api.h" |
27 | | |
28 | | static void ndpi_int_kismet_add_connection(struct ndpi_detection_module_struct * const ndpi_struct, |
29 | | struct ndpi_flow_struct * const flow) |
30 | 2 | { |
31 | 2 | NDPI_LOG_INFO(ndpi_struct, "found kismet\n"); |
32 | 2 | ndpi_set_detected_protocol(ndpi_struct, flow, |
33 | 2 | NDPI_PROTOCOL_KISMET, |
34 | 2 | NDPI_PROTOCOL_UNKNOWN, |
35 | 2 | NDPI_CONFIDENCE_DPI); |
36 | 2 | } |
37 | | |
38 | | static void ndpi_search_kismet(struct ndpi_detection_module_struct *ndpi_struct, |
39 | | struct ndpi_flow_struct *flow) |
40 | 1.72k | { |
41 | 1.72k | struct ndpi_packet_struct const * const packet = &ndpi_struct->packet; |
42 | | |
43 | 1.72k | NDPI_LOG_DBG(ndpi_struct, "search kismet\n"); |
44 | | |
45 | 1.72k | if (packet->payload_packet_len < NDPI_STATICSTRING_LEN("*KISMET: ")) |
46 | 84 | { |
47 | 84 | NDPI_EXCLUDE_PROTO(ndpi_struct, flow); |
48 | 84 | return; |
49 | 84 | } |
50 | | |
51 | 1.63k | if (strncmp((char const *)packet->payload, "*KISMET: ", NDPI_STATICSTRING_LEN("*KISMET: ")) == 0) |
52 | 2 | { |
53 | 2 | ndpi_int_kismet_add_connection(ndpi_struct, flow); |
54 | 2 | return; |
55 | 2 | } |
56 | | |
57 | 1.63k | NDPI_EXCLUDE_PROTO(ndpi_struct, flow); |
58 | 1.63k | } |
59 | | |
60 | | void init_kismet_dissector(struct ndpi_detection_module_struct *ndpi_struct, |
61 | | u_int32_t *id) |
62 | 8.54k | { |
63 | 8.54k | ndpi_set_bitmask_protocol_detection("kismet", ndpi_struct, *id, |
64 | 8.54k | NDPI_PROTOCOL_KISMET, |
65 | 8.54k | ndpi_search_kismet, |
66 | 8.54k | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, |
67 | 8.54k | SAVE_DETECTION_BITMASK_AS_UNKNOWN, |
68 | 8.54k | ADD_TO_DETECTION_BITMASK |
69 | 8.54k | ); |
70 | | |
71 | 8.54k | *id += 1; |
72 | 8.54k | } |