/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 | | #define NDPI_CURRENT_PROTO NDPI_PROTOCOL_KISMET |
25 | | |
26 | | #include "ndpi_api.h" |
27 | | #include "ndpi_private.h" |
28 | | |
29 | | static void ndpi_int_kismet_add_connection(struct ndpi_detection_module_struct * const ndpi_struct, |
30 | | struct ndpi_flow_struct * const flow) |
31 | 224 | { |
32 | 224 | NDPI_LOG_INFO(ndpi_struct, "found kismet\n"); |
33 | 224 | ndpi_set_detected_protocol(ndpi_struct, flow, |
34 | 224 | NDPI_PROTOCOL_KISMET, |
35 | 224 | NDPI_PROTOCOL_UNKNOWN, |
36 | 224 | NDPI_CONFIDENCE_DPI); |
37 | 224 | } |
38 | | |
39 | | static void ndpi_search_kismet(struct ndpi_detection_module_struct *ndpi_struct, |
40 | | struct ndpi_flow_struct *flow) |
41 | 3.85M | { |
42 | 3.85M | struct ndpi_packet_struct const * const packet = &ndpi_struct->packet; |
43 | | |
44 | 3.85M | NDPI_LOG_DBG(ndpi_struct, "search kismet\n"); |
45 | | |
46 | 3.85M | if (packet->payload_packet_len < NDPI_STATICSTRING_LEN("*KISMET: ")) |
47 | 1.16M | { |
48 | 1.16M | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
49 | 1.16M | return; |
50 | 1.16M | } |
51 | | |
52 | 2.69M | if (strncmp((char const *)packet->payload, "*KISMET: ", NDPI_STATICSTRING_LEN("*KISMET: ")) == 0) |
53 | 224 | { |
54 | 224 | ndpi_int_kismet_add_connection(ndpi_struct, flow); |
55 | 224 | return; |
56 | 224 | } |
57 | | |
58 | 2.69M | NDPI_EXCLUDE_DISSECTOR(ndpi_struct, flow); |
59 | 2.69M | } |
60 | | |
61 | | void init_kismet_dissector(struct ndpi_detection_module_struct *ndpi_struct) |
62 | 15.7k | { |
63 | 15.7k | ndpi_register_dissector("kismet", ndpi_struct, |
64 | 15.7k | ndpi_search_kismet, |
65 | 15.7k | NDPI_SELECTION_BITMASK_PROTOCOL_V4_V6_TCP_WITH_PAYLOAD_WITHOUT_RETRANSMISSION, |
66 | 15.7k | 1, NDPI_PROTOCOL_KISMET); |
67 | 15.7k | } |