2 * Routines for Kismet Drone/Server Protocol packet disassembly
3 * By Kyle Feuz <kyle.feuz@aggiemail.usu.edu>
4 * Copyright 2011 Kyle Feuz
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <epan/expert.h>
17 #include "packet-tcp.h"
19 void proto_register_kdsp(void);
20 void proto_reg_handoff_kdsp(void);
22 static dissector_handle_t kdsp_handle
;
24 #define KDSP_PORT 2502 /* Not IANA registered */
25 #define FRAME_HEADER_LEN 12
34 #define CPT_FLAG 0x80000000
35 #define FCS_FLAG 0x00000004
36 #define GPS_FLAG 0x00000002
37 #define RADIO_FLAG 0x00000001
39 #define RADIO_ACCURACY_FLAG 0x000000
40 #define RADIO_FREQ_MHZ_FLAG 0x000000
41 #define RADIO_SIGNAL_DBM_FLAG 0x000000
42 #define RADIO_NOISE_DBM_FLAG 0x000000
43 #define RADIO_CARRIER_FLAG 0x000000
44 #define RADIO_ENCODING_FLAG 0x000000
45 #define RADIO_DATARATE_FLAG 0x000000
46 #define RADIO_SIGNAL_RSSI_FLAG 0x000000
47 #define RADIO_NOISE_RSSI_FLAG 0x000000
49 #define GPS_FIX_FLAG 0x000000
50 #define GPS_LAT_FLAG 0x000000
51 #define GPS_LON_FLAG 0x000000
52 #define GPS_ALT_FLAG 0x000000
53 #define GPS_SPD_FLAG 0x000000
54 #define GPS_HEADING_FLAG 0x000000
56 #define DATA_UUID_FLAG 0x00000010
57 #define DATA_PACKLEN_FLAG 0x00000008
58 #define DATA_TVSEC_FLAG 0x00000004
59 #define DATA_TVUSEC_FLAG 0x00000002
60 #define DATA_DLT_FLAG 0x00000001
62 #define CH_UUID_FLAG 0x00000001
63 #define CH_CMD_FLAG 0x00000002
64 #define CH_CURCH_FLAG 0x00000004
65 #define CH_HOP_FLAG 0x00000008
66 #define CH_NUMCH_FLAG 0x00000010
67 #define CH_CHANNELS_FLAG 0x00000020
68 #define CH_DWELL_FLAG 0x00000040
69 #define CH_RATE_FLAG 0x00000080
70 #define CH_HOPDWELL_FLAG 0x00000100
72 #define SRC_UUID_FLAG 0x00000001
73 #define SRC_INVALID_FLAG 0x00000002
74 #define SRC_NAMESTR_FLAG 0x00000004
75 #define SRC_INTSTR_FLAG 0x00000008
76 #define SRC_TYPESTR_FLAG 0x00000010
77 #define SRC_HOP_FLAG 0x00000020
78 #define SRC_DWELL_FLAG 0x00000040
79 #define SRC_RATE_FLAG 0x00000080
81 #define REPORT_UUID_FLAG 0x000000
82 #define REPORT_FLAGS_FLAG 0x000000
83 #define REPORT_HOP_TM_SEC_FLAG 0x000000
84 #define REPORT_HOP_TM_USEC_FLAG 0x000000
86 #define DATALINK_WLAN 0x69
87 #define DATALINK_RADIOTAP 0x7F
89 static int proto_kdsp
;
91 static dissector_table_t subdissector_dlt_table
;
93 static const value_string packettypenames
[] = {
104 static const value_string payloadtypenames
[] = {
105 {DATALINK_WLAN
, "802.11"},
106 {DATALINK_RADIOTAP
, "RADIOTAP"},
110 static const value_string channelcmds
[] = {
115 {4, "SET HOP/DWELL"},
120 static int hf_kdsp_sentinel
;
121 static int hf_kdsp_cmdnum
;
122 static int hf_kdsp_length
;
124 static int hf_kdsp_version
;
125 static int hf_kdsp_server_version
;
126 static int hf_kdsp_hostname
;
128 static int hf_kdsp_str_flags
;
129 static int hf_kdsp_str_len
;
130 static int hf_kdsp_str_msg
;
132 static int hf_kdsp_cpt_bitmap
;
133 static int hf_kdsp_cpt_flag_cpt
;
134 static int hf_kdsp_cpt_flag_fcs
;
135 static int hf_kdsp_cpt_flag_gps
;
136 static int hf_kdsp_cpt_flag_radio
;
137 static int hf_kdsp_cpt_offset
;
139 static int hf_kdsp_fcs
;
140 static int hf_kdsp_fcs_data
;
142 static int hf_kdsp_radio_hdr
;
143 static int hf_kdsp_radio_hdr_len
;
144 static int hf_kdsp_radio_content_bitmap
;
145 static int hf_kdsp_radio_accuracy
;
146 static int hf_kdsp_radio_freq_mhz
;
147 static int hf_kdsp_radio_signal_dbm
;
148 static int hf_kdsp_radio_noise_dbm
;
149 static int hf_kdsp_radio_carrier
;
150 static int hf_kdsp_radio_encoding
;
151 static int hf_kdsp_radio_datarate
;
152 static int hf_kdsp_radio_signal_rssi
;
153 static int hf_kdsp_radio_noise_rssi
;
155 static int hf_kdsp_gps_hdr
;
156 static int hf_kdsp_gps_hdr_len
;
157 static int hf_kdsp_gps_content_bitmap
;
158 static int hf_kdsp_gps_fix
;
159 static int hf_kdsp_gps_lat
;
160 static int hf_kdsp_gps_lon
;
161 static int hf_kdsp_gps_alt
;
162 static int hf_kdsp_gps_spd
;
163 static int hf_kdsp_gps_heading
;
165 static int hf_kdsp_cpt_data_hdr
;
166 static int hf_kdsp_cpt_data_hdr_len
;
167 static int hf_kdsp_cpt_data_content_bitmap
;
168 static int hf_kdsp_cpt_dc_flag_uuid
;
169 static int hf_kdsp_cpt_dc_flag_len
;
170 static int hf_kdsp_cpt_dc_flag_sec
;
171 static int hf_kdsp_cpt_dc_flag_usec
;
172 static int hf_kdsp_cpt_dc_flag_dlt
;
173 static int hf_kdsp_cpt_uuid
;
174 static int hf_kdsp_cpt_packet_len
;
175 static int hf_kdsp_cpt_tv_sec
;
176 static int hf_kdsp_cpt_tv_usec
;
177 static int hf_kdsp_cpt_dlt
;
179 static int hf_kdsp_ch_length
;
180 static int hf_kdsp_ch_bitmap
;
181 static int hf_kdsp_ch_flag_uuid
;
182 static int hf_kdsp_ch_flag_cmd
;
183 static int hf_kdsp_ch_flag_curch
;
184 static int hf_kdsp_ch_flag_hop
;
185 static int hf_kdsp_ch_flag_numch
;
186 static int hf_kdsp_ch_flag_channels
;
187 static int hf_kdsp_ch_flag_dwell
;
188 static int hf_kdsp_ch_flag_rate
;
189 static int hf_kdsp_ch_flag_hopdwell
;
190 static int hf_kdsp_ch_uuid
;
191 static int hf_kdsp_ch_cmd
;
192 static int hf_kdsp_ch_cur_ch
;
193 static int hf_kdsp_ch_hop
;
194 static int hf_kdsp_ch_num_ch
;
195 static int hf_kdsp_ch_data
;
196 static int hf_kdsp_ch_ch
;
197 static int hf_kdsp_ch_dwell
;
198 static int hf_kdsp_ch_start
;
199 static int hf_kdsp_ch_end
;
200 static int hf_kdsp_ch_width
;
201 static int hf_kdsp_ch_iter
;
202 static int hf_kdsp_ch_rate
;
203 static int hf_kdsp_ch_ch_dwell
;
205 static int hf_kdsp_source_length
;
206 static int hf_kdsp_source_bitmap
;
207 static int hf_kdsp_source_uuid
;
208 static int hf_kdsp_source_invalidate
;
209 static int hf_kdsp_source_name
;
210 static int hf_kdsp_source_interface
;
211 static int hf_kdsp_source_type
;
212 static int hf_kdsp_source_hop
;
213 static int hf_kdsp_source_dwell
;
214 static int hf_kdsp_source_rate
;
216 static int hf_kdsp_report_hdr_len
;
217 static int hf_kdsp_report_content_bitmap
;
218 static int hf_kdsp_report_uuid
;
219 static int hf_kdsp_report_flags
;
220 static int hf_kdsp_report_hop_tm_sec
;
221 static int hf_kdsp_report_hop_tm_usec
;
223 static int ett_kdsp_pdu
;
224 static int ett_cpt_bitmap
;
225 static int ett_cpt_data_content_bitmap
;
226 static int ett_ch_bitmap
;
227 static int ett_ch_data
;
228 static int ett_sub_fcs
;
229 static int ett_sub_radio
;
230 static int ett_sub_gps
;
231 static int ett_sub_cpt
;
233 static expert_field ei_kdsp_payload_expected
;
234 static expert_field ei_kdsp_payload_unexpected
;
235 static expert_field ei_kdsp_cpt_data_hdr_len
;
236 static expert_field ei_kdsp_cmdnum
;
238 /* determine PDU length of protocol */
240 get_kdsp_message_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
,
241 int offset
, void *data _U_
)
243 return tvb_get_ntohl(tvb
, offset
+8) + FRAME_HEADER_LEN
; /* length is at offset 8 */
246 /* This method dissects fully reassembled messages */
248 dissect_kdsp_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
251 uint32_t command
, length
, numChan
, bitmap
, cptbitmap
;
252 uint32_t i
, datalink_type
=0, payload_len
;
253 uint16_t type
, reported_payload_len
=0, data_hdr_len
, data_hdr_len_check
;
254 proto_item
*kdsp_item
, *sub_item
, *subsub_item
, *data_len_item
, *command_item
;
255 proto_tree
*kdsp_tree
, *sub_tree
, *subsub_tree
;
256 tvbuff_t
*payload_tvb
;
258 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "KDSP");
259 col_clear(pinfo
->cinfo
, COL_INFO
);
261 command
= tvb_get_ntohl(tvb
, 4);
262 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Command %s; ",
263 val_to_str(command
, packettypenames
, "Unknown (0x%02x)"));
264 col_set_fence(pinfo
->cinfo
, COL_INFO
);
266 kdsp_item
= proto_tree_add_item(tree
, proto_kdsp
, tvb
, 0, -1, ENC_NA
);
267 kdsp_tree
= proto_item_add_subtree(kdsp_item
, ett_kdsp_pdu
);
268 proto_tree_add_item(kdsp_tree
, hf_kdsp_sentinel
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
270 command_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_cmdnum
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
272 proto_item_append_text(kdsp_item
, ", Command %s",
273 val_to_str(command
, packettypenames
, "Unknown (0x%02x)"));
275 proto_tree_add_item(kdsp_tree
, hf_kdsp_length
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
276 length
= tvb_get_ntohl(tvb
, offset
);
282 proto_tree_add_item(kdsp_tree
, hf_kdsp_version
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
284 proto_tree_add_item(kdsp_tree
, hf_kdsp_server_version
,
285 tvb
, offset
, 32, ENC_ASCII
);
287 proto_tree_add_item(kdsp_tree
, hf_kdsp_hostname
, tvb
, offset
, 32, ENC_ASCII
);
291 proto_tree_add_item(kdsp_tree
, hf_kdsp_str_flags
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
293 proto_tree_add_item(kdsp_tree
, hf_kdsp_str_len
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
295 proto_tree_add_item(kdsp_tree
, hf_kdsp_str_msg
, tvb
, offset
, -1, ENC_ASCII
);
298 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_cpt_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
299 sub_tree
= proto_item_add_subtree(sub_item
, ett_cpt_bitmap
);
300 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_cpt
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
301 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_fcs
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
302 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_gps
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
303 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_radio
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
304 bitmap
= tvb_get_ntohl(tvb
, offset
);
306 proto_tree_add_item(kdsp_tree
, hf_kdsp_cpt_offset
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
308 if (bitmap
& FCS_FLAG
) {
309 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_fcs
, tvb
, offset
, 4, ENC_NA
);
310 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_fcs
);
312 proto_tree_add_item(sub_tree
, hf_kdsp_fcs_data
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
315 if (bitmap
& RADIO_FLAG
) {
316 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_radio_hdr
, tvb
, offset
, 30, ENC_NA
);
317 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_radio
);
319 proto_tree_add_item(sub_tree
, hf_kdsp_radio_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
321 proto_tree_add_item(sub_tree
, hf_kdsp_radio_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
323 proto_tree_add_item(sub_tree
, hf_kdsp_radio_accuracy
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
325 proto_tree_add_item(sub_tree
, hf_kdsp_radio_freq_mhz
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
327 proto_tree_add_item(sub_tree
, hf_kdsp_radio_signal_dbm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
329 proto_tree_add_item(sub_tree
, hf_kdsp_radio_noise_dbm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
331 proto_tree_add_item(sub_tree
, hf_kdsp_radio_carrier
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
333 proto_tree_add_item(sub_tree
, hf_kdsp_radio_encoding
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
335 proto_tree_add_item(sub_tree
, hf_kdsp_radio_datarate
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
337 proto_tree_add_item(sub_tree
, hf_kdsp_radio_signal_rssi
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
339 proto_tree_add_item(sub_tree
, hf_kdsp_radio_noise_rssi
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
342 if (bitmap
& GPS_FLAG
) {
343 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_gps_hdr
, tvb
, offset
, 68, ENC_NA
);
344 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_gps
);
346 proto_tree_add_item(sub_tree
, hf_kdsp_gps_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
348 proto_tree_add_item(sub_tree
, hf_kdsp_gps_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
350 proto_tree_add_item(sub_tree
, hf_kdsp_gps_fix
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
352 proto_tree_add_item(sub_tree
, hf_kdsp_gps_lat
, tvb
, offset
, 12, ENC_NA
);
354 proto_tree_add_item(sub_tree
, hf_kdsp_gps_lon
, tvb
, offset
, 12, ENC_NA
);
356 proto_tree_add_item(sub_tree
, hf_kdsp_gps_alt
, tvb
, offset
, 12, ENC_NA
);
358 proto_tree_add_item(sub_tree
, hf_kdsp_gps_spd
, tvb
, offset
, 12, ENC_NA
);
360 proto_tree_add_item(sub_tree
, hf_kdsp_gps_heading
, tvb
, offset
, 12, ENC_NA
);
363 if (bitmap
& CPT_FLAG
) {
364 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_cpt_data_hdr
, tvb
, offset
, 44, ENC_NA
);
365 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_cpt
);
367 data_len_item
= proto_tree_add_item(sub_tree
, hf_kdsp_cpt_data_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
368 data_hdr_len
= tvb_get_ntohs(tvb
, offset
);
371 subsub_item
= proto_tree_add_item(sub_tree
, hf_kdsp_cpt_data_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
372 subsub_tree
= proto_item_add_subtree(subsub_item
, ett_cpt_data_content_bitmap
);
373 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_uuid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
374 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_len
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
375 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_sec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
376 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_usec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
377 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_dlt
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
378 cptbitmap
= tvb_get_ntohl(tvb
, offset
);
381 data_hdr_len_check
= 6; /* len(len) + len(bitmap) */
382 if (cptbitmap
& DATA_UUID_FLAG
) data_hdr_len_check
+= 16;
383 if (cptbitmap
& DATA_PACKLEN_FLAG
) data_hdr_len_check
+= 2;
384 if (cptbitmap
& DATA_TVSEC_FLAG
) data_hdr_len_check
+= 8;
385 if (cptbitmap
& DATA_TVUSEC_FLAG
) data_hdr_len_check
+= 8;
386 if (cptbitmap
& DATA_DLT_FLAG
) data_hdr_len_check
+= 4;
388 if (data_hdr_len_check
!= data_hdr_len
) {
389 expert_add_info(pinfo
, data_len_item
, &ei_kdsp_cpt_data_hdr_len
);
392 if (cptbitmap
& DATA_UUID_FLAG
) {
393 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_uuid
, tvb
, offset
, 16, ENC_NA
);
396 if (cptbitmap
& DATA_PACKLEN_FLAG
) {
397 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_packet_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
398 reported_payload_len
= tvb_get_ntohs(tvb
, offset
);
401 if (cptbitmap
& DATA_TVSEC_FLAG
) {
402 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_tv_sec
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
405 if (cptbitmap
& DATA_TVUSEC_FLAG
) {
406 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_tv_usec
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
409 if (cptbitmap
& DATA_DLT_FLAG
) {
410 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_dlt
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
411 datalink_type
= tvb_get_ntohl(tvb
, offset
);
414 payload_len
= (length
+ FRAME_HEADER_LEN
) - offset
;
415 if (cptbitmap
& DATA_PACKLEN_FLAG
) {
416 payload_tvb
= tvb_new_subset_length_caplen(tvb
, offset
, payload_len
, reported_payload_len
);
417 if (cptbitmap
& DATA_DLT_FLAG
) {
418 dissector_try_uint(subdissector_dlt_table
, datalink_type
, payload_tvb
, pinfo
, tree
);
420 /* XXX - Restore protocol column */
421 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "KDSP");
423 } else if (payload_len
> 0) {
424 proto_tree_add_expert(sub_tree
, pinfo
, &ei_kdsp_payload_expected
, tvb
, offset
, payload_len
);
426 } else if (payload_len
> 0) {
427 proto_tree_add_expert(sub_tree
, pinfo
, &ei_kdsp_payload_unexpected
, tvb
, offset
, payload_len
);
432 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
434 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
435 sub_tree
= proto_item_add_subtree(sub_item
, ett_ch_bitmap
);
436 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_uuid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
437 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_cmd
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
438 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_curch
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
439 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_hop
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
440 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_numch
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
441 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_channels
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
442 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_dwell
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
443 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_rate
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
444 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_hopdwell
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
446 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_uuid
, tvb
, offset
, 16, ENC_NA
);
448 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_cmd
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
450 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_cur_ch
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
452 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_hop
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
454 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_num_ch
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
455 numChan
= tvb_get_ntohs(tvb
, offset
);
457 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_data
, tvb
, offset
, 2046, ENC_NA
);
458 sub_tree
= proto_item_add_subtree(sub_item
, ett_ch_data
);
460 for(i
= 0; i
<numChan
; i
++) {
461 type
= tvb_get_ntohs(tvb
, offset
);
463 if (!type
) {/* Highest bit (1 << 15) == 0 if channel */
464 proto_tree_add_item(sub_tree
, hf_kdsp_ch_ch
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
466 proto_tree_add_item(sub_tree
, hf_kdsp_ch_dwell
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
469 else{/* Highest bit (1 << 15) == 1 if range */
470 proto_tree_add_item(sub_tree
, hf_kdsp_ch_start
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
472 proto_tree_add_item(sub_tree
, hf_kdsp_ch_end
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
474 proto_tree_add_item(sub_tree
, hf_kdsp_ch_width
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
476 proto_tree_add_item(sub_tree
, hf_kdsp_ch_iter
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
480 offset
= length
+FRAME_HEADER_LEN
-4;
481 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_rate
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
483 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_ch_dwell
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
487 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
489 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
490 sub_tree
= proto_item_add_subtree(sub_item
, ett_ch_bitmap
);
491 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_uuid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
492 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
494 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_uuid
, tvb
, offset
, 16, ENC_NA
);
496 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_invalidate
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
498 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_name
, tvb
, offset
, 16, ENC_ASCII
);
500 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_interface
, tvb
, offset
, 16, ENC_ASCII
);
502 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_type
, tvb
, offset
, 16, ENC_ASCII
);
504 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_hop
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
506 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_dwell
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
508 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_rate
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
512 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
514 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
516 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_uuid
, tvb
, offset
, 16, ENC_NA
);
518 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_flags
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
520 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_hop_tm_sec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
522 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_hop_tm_usec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
526 expert_add_info(pinfo
, command_item
, &ei_kdsp_cmdnum
);
529 return tvb_captured_length(tvb
);
533 dissect_kdsp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
535 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, FRAME_HEADER_LEN
,
536 get_kdsp_message_len
, dissect_kdsp_message
, data
);
537 return tvb_captured_length(tvb
);
541 proto_register_kdsp(void)
543 static hf_register_info hf
[] = {
545 { "Sentinel", "kdsp.sentinel",
551 { "Command", "kdsp.command",
553 VALS(packettypenames
), 0x0,
557 { "Length", "kdsp.length",
563 { "KDSP Version", "kdsp.version",
568 { &hf_kdsp_server_version
,
569 { "Server Version", "kdsp.server.version",
570 FT_STRING
, BASE_NONE
,
575 { "Hostname", "kdsp.hostname",
576 FT_STRING
, BASE_NONE
,
580 { &hf_kdsp_str_flags
,
581 { "String Flags", "kdsp.str.flags",
587 { "String Length", "kdsp.str.length",
593 { "Message", "kdsp.str.message",
594 FT_STRING
, BASE_NONE
,
598 { &hf_kdsp_cpt_bitmap
,
599 { "Bitmap", "kdsp.cpt.bitmap",
604 { &hf_kdsp_cpt_flag_cpt
,
605 { "Capture Packet Flag", "kdsp.cpt.flag.cpt",
610 { &hf_kdsp_cpt_flag_fcs
,
611 { "Capture FCS Flag", "kdsp.cpt.flag.fcs",
616 { &hf_kdsp_cpt_flag_gps
,
617 { "Capture GPS Flag", "kdsp.cpt.flag.gps",
622 { &hf_kdsp_cpt_flag_radio
,
623 { "Capture Radio Flag", "kdsp.cpt.flag.radio",
628 { &hf_kdsp_cpt_offset
,
629 { "Offset Capture Packet Header", "kdsp.cpt.offset",
635 { "Capture FCS Header", "kdsp.fcs",
641 { "Frame Checksum", "kdsp.fcs.data",
646 { &hf_kdsp_radio_hdr
,
647 { "Capture Radio Header", "kdsp.radio",
652 { &hf_kdsp_radio_hdr_len
,
653 { "Length", "kdsp.radio.length",
658 { &hf_kdsp_radio_content_bitmap
,
659 { "Bitmap", "kdsp.radio.bitmap",
664 { &hf_kdsp_radio_accuracy
,
665 { "Accuracy", "kdsp.radio.accuracy",
670 { &hf_kdsp_radio_freq_mhz
,
671 { "Frequency", "kdsp.radio.freq",
676 { &hf_kdsp_radio_signal_dbm
,
677 { "Signal dbm", "kdsp.radio.signal_dbm",
682 { &hf_kdsp_radio_noise_dbm
,
683 { "Noise dbm", "kdsp.radio.noise_dbm",
688 { &hf_kdsp_radio_carrier
,
689 { "Carrier", "kdsp.radio.car",
694 { &hf_kdsp_radio_encoding
,
695 { "Encoding", "kdsp.radio.enc",
700 { &hf_kdsp_radio_datarate
,
701 { "Data Rate", "kdsp.radio.datarate",
706 { &hf_kdsp_radio_signal_rssi
,
707 { "Signal rssi", "kdsp.radio.signal_rssi",
712 { &hf_kdsp_radio_noise_rssi
,
713 { "Noise rssi", "kdsp.radio.noise_rssi",
719 { "Capture GPS Header", "kdsp.gps",
724 { &hf_kdsp_gps_hdr_len
,
725 { "GPS Length", "kdsp.gps.length",
730 { &hf_kdsp_gps_content_bitmap
,
731 { "Bitmap", "kdsp.gps.bitmap",
737 { "GPS fix", "kdsp.gps.fix",
743 { "Latitude", "kdsp.gps.lat",
749 { "Longitude", "kdsp.gps.lon",
755 { "Alt", "kdsp.gps.alt",
761 { "Spd", "kdsp.gps.spd",
766 { &hf_kdsp_gps_heading
,
767 { "Heading", "kdsp.gps.heading",
772 { &hf_kdsp_cpt_data_hdr
,
773 { "Capture Packet Header", "kdsp.cpt",
778 { &hf_kdsp_cpt_data_hdr_len
,
779 { "Length", "kdsp.cpt.length",
784 { &hf_kdsp_cpt_data_content_bitmap
,
785 { "Bitmap", "kdsp.cpt.bitmap",
790 { &hf_kdsp_cpt_dc_flag_uuid
,
791 { "Capture Content UUID Flag", "kdsp.cpt.cd.flag.uuid",
793 NULL
, DATA_UUID_FLAG
,
796 { &hf_kdsp_cpt_dc_flag_len
,
797 { "Capture Content Length Flag", "kdsp.cpt.cd.flag.len",
799 NULL
, DATA_PACKLEN_FLAG
,
802 { &hf_kdsp_cpt_dc_flag_sec
,
803 { "Capture Content Second Flag", "kdsp.cpt.cd.flag.sec",
805 NULL
, DATA_TVSEC_FLAG
,
808 { &hf_kdsp_cpt_dc_flag_usec
,
809 { "Capture Content Microsecond Flag", "kdsp.cpt.cd.flag.usec",
811 NULL
, DATA_TVUSEC_FLAG
,
814 { &hf_kdsp_cpt_dc_flag_dlt
,
815 { "Capture Content Datalink Type Flag", "kdsp.cpt.cd.flag.dlt",
821 { "UUID", "kdsp.cpt.uuid",
826 { &hf_kdsp_cpt_packet_len
,
827 { "Packet Length", "kdsp.cpt.pkt_len",
832 { &hf_kdsp_cpt_tv_sec
,
833 { "TV sec", "kdsp.cpt.tv_sec",
838 { &hf_kdsp_cpt_tv_usec
,
839 { "TV usec", "kdsp.cpt.tv_usec",
845 { "Data Link Type", "kdsp.cpt.dlt",
847 VALS(payloadtypenames
), 0x0,
850 { &hf_kdsp_ch_length
,
851 { "Length", "kdsp.chset.length",
856 { &hf_kdsp_ch_bitmap
,
857 { "Bitmap", "kdsp.chset.bitmap",
862 { &hf_kdsp_ch_flag_uuid
,
863 { "UUID Flag", "kdsp.ch.flag.uuid",
868 { &hf_kdsp_ch_flag_cmd
,
869 { "Command Flag", "kdsp.ch.flag.cmd",
874 { &hf_kdsp_ch_flag_curch
,
875 { "Current Channel Flag", "kdsp.ch.flag.curch",
880 { &hf_kdsp_ch_flag_hop
,
881 { "Hop Flag", "kdsp.ch.flag.hop",
886 { &hf_kdsp_ch_flag_numch
,
887 { "Num Channels Flag", "kdsp.ch.flag.numch",
892 { &hf_kdsp_ch_flag_channels
,
893 { "Channels Flag", "kdsp.ch.flag.channels",
895 NULL
, CH_CHANNELS_FLAG
,
898 { &hf_kdsp_ch_flag_dwell
,
899 { "Dwell Flag", "kdsp.ch.flag.dwell",
904 { &hf_kdsp_ch_flag_rate
,
905 { "Rate Flag", "kdsp.ch.flag.rate",
910 { &hf_kdsp_ch_flag_hopdwell
,
911 { "Hop-Dwell Flag", "kdsp.ch.flag.hopdwell",
913 NULL
, CH_HOPDWELL_FLAG
,
917 { "UUID", "kdsp.chset.uuid",
923 { "Command", "kdsp.chset.cmd",
925 VALS(channelcmds
), 0x0,
928 { &hf_kdsp_ch_cur_ch
,
929 { "Current Channel", "kdsp.chset.cur_ch",
935 { "Channel Hop", "kdsp.chset.hop",
940 { &hf_kdsp_ch_num_ch
,
941 { "Number of Channels", "kdsp.chset.num_ch",
947 { "Channel Data", "kdsp.chset.data",
953 { "Channel", "kdsp.chset.ch",
959 { "Dwell", "kdsp.chset.dwell",
965 { "Start", "kdsp.chset.start",
971 { "End", "kdsp.chset.end",
977 { "Width", "kdsp.chset.width",
983 { "Iter", "kdsp.chset.iter",
989 { "Rate", "kdsp.chset.rate",
994 { &hf_kdsp_ch_ch_dwell
,
995 { "Dwell", "kdsp.chset.dwell",
1000 { &hf_kdsp_source_length
,
1001 { "Length", "kdsp.source.length",
1002 FT_UINT16
, BASE_DEC
,
1006 { &hf_kdsp_source_bitmap
,
1007 { "Source Bitmap", "kdsp.source.bitmap",
1008 FT_UINT32
, BASE_HEX
,
1012 { &hf_kdsp_source_uuid
,
1013 { "UUID", "kdsp.source.uuid",
1018 { &hf_kdsp_source_invalidate
,
1019 { "Source Invalidate", "kdsp.source.invalidate",
1020 FT_UINT16
, BASE_HEX
,
1024 { &hf_kdsp_source_name
,
1025 { "Source Name", "kdsp.source.name",
1026 FT_STRING
, BASE_NONE
,
1030 { &hf_kdsp_source_interface
,
1031 { "Interface", "kdsp.source.interface",
1032 FT_STRING
, BASE_NONE
,
1036 { &hf_kdsp_source_type
,
1037 { "Type", "kdsp.source.type",
1038 FT_STRING
, BASE_NONE
,
1042 { &hf_kdsp_source_hop
,
1043 { "Source Hop", "kdsp.source.hop",
1048 { &hf_kdsp_source_dwell
,
1049 { "Source Dwell", "kdsp.source.dwell",
1050 FT_UINT16
, BASE_DEC
,
1054 { &hf_kdsp_source_rate
,
1055 { "Source Rate", "kdsp.source.rate",
1056 FT_UINT16
, BASE_DEC
,
1060 { &hf_kdsp_report_hdr_len
,
1061 { "Length", "kdsp.report.length",
1062 FT_UINT16
, BASE_DEC
,
1066 { &hf_kdsp_report_content_bitmap
,
1067 { "Bitmap", "kdsp.report.bitmap",
1068 FT_UINT32
, BASE_HEX
,
1072 { &hf_kdsp_report_uuid
,
1073 { "UUID", "kdsp.report.uuid",
1078 { &hf_kdsp_report_flags
,
1079 { "flags", "kdsp.report.flags",
1084 { &hf_kdsp_report_hop_tm_sec
,
1085 { "Hop Time (sec)", "kdsp.report.sec",
1086 FT_UINT32
, BASE_DEC
,
1090 { &hf_kdsp_report_hop_tm_usec
,
1091 { "Hop Time (usec)", "kdsp.report.usec",
1092 FT_UINT32
, BASE_DEC
,
1099 /* Setup protocol subtree array */
1100 static int *ett
[] = {
1103 &ett_cpt_data_content_bitmap
,
1112 static ei_register_info ei
[] = {
1113 { &ei_kdsp_payload_expected
, { "kdsp.payload_expected", PI_MALFORMED
, PI_ERROR
, "Payload expected but no link type specified. Can not decode.", EXPFILL
}},
1114 { &ei_kdsp_payload_unexpected
, { "kdsp.payload_unexpected", PI_MALFORMED
, PI_ERROR
, "No payload expected but found some data", EXPFILL
}},
1115 { &ei_kdsp_cpt_data_hdr_len
, { "kdsp.cpt.length.invalid", PI_MALFORMED
, PI_ERROR
, "Calculated header length does not match reported header length. "
1116 "It is likely the dissector does not support all flags", EXPFILL
}},
1117 { &ei_kdsp_cmdnum
, { "kdsp.command.unknown", PI_UNDECODED
, PI_WARN
, "Unknown command, can not parse message", EXPFILL
}},
1119 expert_module_t
* expert_kdsp
;
1121 proto_kdsp
= proto_register_protocol("Kismet Drone/Server Protocol", "KDSP", "kdsp");
1123 proto_register_field_array(proto_kdsp
, hf
, array_length(hf
));
1124 proto_register_subtree_array(ett
, array_length(ett
));
1126 expert_kdsp
= expert_register_protocol(proto_kdsp
);
1127 expert_register_field_array(expert_kdsp
, ei
, array_length(ei
));
1129 subdissector_dlt_table
= register_dissector_table("kdsp.cpt.dlt", "KDSP DLT Type", proto_kdsp
, FT_UINT32
, BASE_DEC
);
1131 kdsp_handle
= register_dissector("kdsp", dissect_kdsp
, proto_kdsp
);
1136 proto_reg_handoff_kdsp(void)
1138 dissector_handle_t dlt_handle
;
1140 /* XXX - Should be done in respective dissectors? */
1141 dlt_handle
= find_dissector("radiotap");
1143 dissector_add_uint( "kdsp.cpt.dlt", DATALINK_RADIOTAP
, dlt_handle
);
1145 dlt_handle
= find_dissector("wlan");
1147 dissector_add_uint( "kdsp.cpt.dlt", DATALINK_WLAN
, dlt_handle
);
1149 dissector_add_uint_with_preference("tcp.port", KDSP_PORT
, kdsp_handle
);
1153 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1158 * indent-tabs-mode: nil
1161 * vi: set shiftwidth=2 tabstop=8 expandtab:
1162 * :indentSize=2:tabSize=8:noTabs=true: