2 * Routines for Kismet Drone/Server Protocol packet disassembly
3 * By Kyle Feuz <kyle.feuz@aggiemail.usu.edu>
4 * Copyright 2011 Kyle Feuz
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include <epan/prefs.h>
32 #include <epan/expert.h>
33 #include "packet-tcp.h"
35 #define KDSP_PORT 2502
36 #define FRAME_HEADER_LEN 12
45 #define CPT_FLAG 0x80000000
46 #define FCS_FLAG 0x00000004
47 #define GPS_FLAG 0x00000002
48 #define RADIO_FLAG 0x00000001
50 #define RADIO_ACCURACY_FLAG 0x000000
51 #define RADIO_FREQ_MHZ_FLAG 0x000000
52 #define RADIO_SIGNAL_DBM_FLAG 0x000000
53 #define RADIO_NOISE_DBM_FLAG 0x000000
54 #define RADIO_CARRIER_FLAG 0x000000
55 #define RADIO_ENCODING_FLAG 0x000000
56 #define RADIO_DATARATE_FLAG 0x000000
57 #define RADIO_SIGNAL_RSSI_FLAG 0x000000
58 #define RADIO_NOISE_RSSI_FLAG 0x000000
60 #define GPS_FIX_FLAG 0x000000
61 #define GPS_LAT_FLAG 0x000000
62 #define GPS_LON_FLAG 0x000000
63 #define GPS_ALT_FLAG 0x000000
64 #define GPS_SPD_FLAG 0x000000
65 #define GPS_HEADING_FLAG 0x000000
67 #define DATA_UUID_FLAG 0x000010
68 #define DATA_PACKLEN_FLAG 0x000008
69 #define DATA_TVSEC_FLAG 0x000004
70 #define DATA_TVUSEC_FLAG 0x000002
71 #define DATA_DLT_FLAG 0x000001
73 #define CH_UUID_FLAG 0x00000001
74 #define CH_CMD_FLAG 0x00000002
75 #define CH_CURCH_FLAG 0x00000004
76 #define CH_HOP_FLAG 0x00000008
77 #define CH_NUMCH_FLAG 0x00000010
78 #define CH_CHANNELS_FLAG 0x00000020
79 #define CH_DWELL_FLAG 0x00000040
80 #define CH_RATE_FLAG 0x00000080
81 #define CH_HOPDWELL_FLAG 0x00000100
83 #define SRC_UUID_FLAG 0x00000001
84 #define SRC_INVALID_FLAG 0x00000002
85 #define SRC_NAMESTR_FLAG 0x00000004
86 #define SRC_INTSTR_FLAG 0x00000008
87 #define SRC_TYPESTR_FLAG 0x00000010
88 #define SRC_HOP_FLAG 0x00000020
89 #define SRC_DWELL_FLAG 0x00000040
90 #define SRC_RATE_FLAG 0x00000080
92 #define REPORT_UUID_FLAG 0x000000
93 #define REPORT_FLAGS_FLAG 0x000000
94 #define REPORT_HOP_TM_SEC_FLAG 0x000000
95 #define REPORT_HOP_TM_USEC_FLAG 0x000000
97 #define DATALINK_WLAN 0x69
98 #define DATALINK_RADIOTAP 0x7F
100 void proto_reg_handoff_kdsp(void);
102 static int proto_kdsp
= -1;
104 static dissector_table_t subdissector_dlt_table
;
105 static guint global_kdsp_tcp_port
= KDSP_PORT
;
107 static const value_string packettypenames
[] = {
118 static const value_string payloadtypenames
[] = {
119 {DATALINK_WLAN
, "802.11"},
120 {DATALINK_RADIOTAP
, "RADIOTAP"},
124 static const value_string channelcmds
[] = {
129 {4, "SET HOP/DWELL"},
134 static gint hf_kdsp_sentinel
= -1;
135 static gint hf_kdsp_cmdnum
= -1;
136 static gint hf_kdsp_length
= -1;
138 static gint hf_kdsp_version
= -1;
139 static gint hf_kdsp_server_version
= -1;
140 static gint hf_kdsp_hostname
= -1;
142 static gint hf_kdsp_str_flags
= -1;
143 static gint hf_kdsp_str_len
= -1;
144 static gint hf_kdsp_str_msg
= -1;
146 static gint hf_kdsp_cpt_bitmap
= -1;
147 static gint hf_kdsp_cpt_flag_cpt
= -1;
148 static gint hf_kdsp_cpt_flag_fcs
= -1;
149 static gint hf_kdsp_cpt_flag_gps
= -1;
150 static gint hf_kdsp_cpt_flag_radio
= -1;
151 static gint hf_kdsp_cpt_offset
= -1;
153 static gint hf_kdsp_fcs
= -1;
154 static gint hf_kdsp_fcs_data
= -1;
156 static gint hf_kdsp_radio_hdr
= -1;
157 static gint hf_kdsp_radio_hdr_len
= -1;
158 static gint hf_kdsp_radio_content_bitmap
= -1;
159 static gint hf_kdsp_radio_accuracy
= -1;
160 static gint hf_kdsp_radio_freq_mhz
= -1;
161 static gint hf_kdsp_radio_signal_dbm
= -1;
162 static gint hf_kdsp_radio_noise_dbm
= -1;
163 static gint hf_kdsp_radio_carrier
= -1;
164 static gint hf_kdsp_radio_encoding
= -1;
165 static gint hf_kdsp_radio_datarate
= -1;
166 static gint hf_kdsp_radio_signal_rssi
= -1;
167 static gint hf_kdsp_radio_noise_rssi
= -1;
169 static gint hf_kdsp_gps_hdr
= -1;
170 static gint hf_kdsp_gps_hdr_len
= -1;
171 static gint hf_kdsp_gps_content_bitmap
= -1;
172 static gint hf_kdsp_gps_fix
= -1;
173 static gint hf_kdsp_gps_lat
= -1;
174 static gint hf_kdsp_gps_lon
= -1;
175 static gint hf_kdsp_gps_alt
= -1;
176 static gint hf_kdsp_gps_spd
= -1;
177 static gint hf_kdsp_gps_heading
= -1;
179 static gint hf_kdsp_cpt_data_hdr
= -1;
180 static gint hf_kdsp_cpt_data_hdr_len
= -1;
181 static gint hf_kdsp_cpt_data_content_bitmap
= -1;
182 static gint hf_kdsp_cpt_dc_flag_uuid
= -1;
183 static gint hf_kdsp_cpt_dc_flag_len
= -1;
184 static gint hf_kdsp_cpt_dc_flag_sec
= -1;
185 static gint hf_kdsp_cpt_dc_flag_usec
= -1;
186 static gint hf_kdsp_cpt_dc_flag_dlt
= -1;
187 static gint hf_kdsp_cpt_uuid
= -1;
188 static gint hf_kdsp_cpt_packet_len
= -1;
189 static gint hf_kdsp_cpt_tv_sec
= -1;
190 static gint hf_kdsp_cpt_tv_usec
= -1;
191 static gint hf_kdsp_cpt_dlt
= -1;
193 static gint hf_kdsp_ch_length
= -1;
194 static gint hf_kdsp_ch_bitmap
= -1;
195 static gint hf_kdsp_ch_flag_uuid
= -1;
196 static gint hf_kdsp_ch_flag_cmd
= -1;
197 static gint hf_kdsp_ch_flag_curch
= -1;
198 static gint hf_kdsp_ch_flag_hop
= -1;
199 static gint hf_kdsp_ch_flag_numch
= -1;
200 static gint hf_kdsp_ch_flag_channels
= -1;
201 static gint hf_kdsp_ch_flag_dwell
= -1;
202 static gint hf_kdsp_ch_flag_rate
= -1;
203 static gint hf_kdsp_ch_flag_hopdwell
= -1;
204 static gint hf_kdsp_ch_uuid
= -1;
205 static gint hf_kdsp_ch_cmd
= -1;
206 static gint hf_kdsp_ch_cur_ch
= -1;
207 static gint hf_kdsp_ch_hop
= -1;
208 static gint hf_kdsp_ch_num_ch
= -1;
209 static gint hf_kdsp_ch_data
= -1;
210 static gint hf_kdsp_ch_ch
= -1;
211 static gint hf_kdsp_ch_dwell
= -1;
212 static gint hf_kdsp_ch_start
= -1;
213 static gint hf_kdsp_ch_end
= -1;
214 static gint hf_kdsp_ch_width
= -1;
215 static gint hf_kdsp_ch_iter
= -1;
216 static gint hf_kdsp_ch_rate
= -1;
217 static gint hf_kdsp_ch_ch_dwell
= -1;
219 static gint hf_kdsp_source_length
= -1;
220 static gint hf_kdsp_source_bitmap
= -1;
221 static gint hf_kdsp_source_uuid
= -1;
222 static gint hf_kdsp_source_invalidate
= -1;
223 static gint hf_kdsp_source_name
= -1;
224 static gint hf_kdsp_source_interface
= -1;
225 static gint hf_kdsp_source_type
= -1;
226 static gint hf_kdsp_source_hop
= -1;
227 static gint hf_kdsp_source_dwell
= -1;
228 static gint hf_kdsp_source_rate
= -1;
230 static gint hf_kdsp_report_hdr_len
= -1;
231 static gint hf_kdsp_report_content_bitmap
= -1;
232 static gint hf_kdsp_report_uuid
= -1;
233 static gint hf_kdsp_report_flags
= -1;
234 static gint hf_kdsp_report_hop_tm_sec
= -1;
235 static gint hf_kdsp_report_hop_tm_usec
= -1;
237 static gint ett_kdsp_pdu
= -1;
238 static gint ett_cpt_bitmap
= -1;
239 static gint ett_cpt_data_content_bitmap
= -1;
240 static gint ett_ch_bitmap
= -1;
241 static gint ett_ch_data
= -1;
242 static gint ett_sub_fcs
= -1;
243 static gint ett_sub_radio
= -1;
244 static gint ett_sub_gps
= -1;
245 static gint ett_sub_cpt
= -1;
247 static expert_field ei_kdsp_payload_expected
= EI_INIT
;
248 static expert_field ei_kdsp_payload_unexpected
= EI_INIT
;
249 static expert_field ei_kdsp_cpt_data_hdr_len
= EI_INIT
;
250 static expert_field ei_kdsp_cmdnum
= EI_INIT
;
252 /* determine PDU length of protocol */
254 get_kdsp_message_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
)
256 return tvb_get_ntohl(tvb
, offset
+8) + FRAME_HEADER_LEN
; /* length is at offset 8 */
259 /* This method dissects fully reassembled messages */
261 dissect_kdsp_message(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
264 guint32 command
, length
, numChan
, bitmap
, cptbitmap
;
265 guint32 i
, datalink_type
=0, payload_len
;
266 guint16 type
, reported_payload_len
=0, data_hdr_len
, data_hdr_len_check
;
267 proto_item
*kdsp_item
, *sub_item
, *subsub_item
, *data_len_item
, *command_item
;
268 proto_tree
*kdsp_tree
, *sub_tree
, *subsub_tree
;
269 tvbuff_t
*payload_tvb
;
271 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "KDSP");
272 col_clear(pinfo
->cinfo
, COL_INFO
);
274 command
= tvb_get_ntohl(tvb
, 4);
275 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Command %s; ",
276 val_to_str(command
, packettypenames
, "Unknown (0x%02x)"));
277 col_set_fence(pinfo
->cinfo
, COL_INFO
);
279 kdsp_item
= proto_tree_add_item(tree
, proto_kdsp
, tvb
, 0, -1, ENC_NA
);
280 kdsp_tree
= proto_item_add_subtree(kdsp_item
, ett_kdsp_pdu
);
281 proto_tree_add_item(kdsp_tree
, hf_kdsp_sentinel
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
283 command_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_cmdnum
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
285 proto_item_append_text(kdsp_item
, ", Command %s",
286 val_to_str(command
, packettypenames
, "Unknown (0x%02x)"));
288 proto_tree_add_item(kdsp_tree
, hf_kdsp_length
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
289 length
= tvb_get_ntohl(tvb
, offset
);
295 proto_tree_add_item(kdsp_tree
, hf_kdsp_version
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
297 proto_tree_add_item(kdsp_tree
, hf_kdsp_server_version
,
298 tvb
, offset
, 32, ENC_ASCII
|ENC_NA
);
300 proto_tree_add_item(kdsp_tree
, hf_kdsp_hostname
, tvb
, offset
, 32, ENC_ASCII
|ENC_NA
);
304 proto_tree_add_item(kdsp_tree
, hf_kdsp_str_flags
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
306 proto_tree_add_item(kdsp_tree
, hf_kdsp_str_len
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
308 proto_tree_add_item(kdsp_tree
, hf_kdsp_str_msg
, tvb
, offset
, -1, ENC_ASCII
|ENC_NA
);
311 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_cpt_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
312 sub_tree
= proto_item_add_subtree(sub_item
, ett_cpt_bitmap
);
313 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_cpt
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
314 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_fcs
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
315 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_gps
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
316 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_flag_radio
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
317 bitmap
= tvb_get_ntohl(tvb
, offset
);
319 proto_tree_add_item(kdsp_tree
, hf_kdsp_cpt_offset
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
321 if (bitmap
& FCS_FLAG
) {
322 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_fcs
, tvb
, offset
, 4, ENC_NA
);
323 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_fcs
);
325 proto_tree_add_item(sub_tree
, hf_kdsp_fcs_data
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
328 if (bitmap
& RADIO_FLAG
) {
329 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_radio_hdr
, tvb
, offset
, 30, ENC_NA
);
330 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_radio
);
332 proto_tree_add_item(sub_tree
, hf_kdsp_radio_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
334 proto_tree_add_item(sub_tree
, hf_kdsp_radio_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
336 proto_tree_add_item(sub_tree
, hf_kdsp_radio_accuracy
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
338 proto_tree_add_item(sub_tree
, hf_kdsp_radio_freq_mhz
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
340 proto_tree_add_item(sub_tree
, hf_kdsp_radio_signal_dbm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
342 proto_tree_add_item(sub_tree
, hf_kdsp_radio_noise_dbm
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
344 proto_tree_add_item(sub_tree
, hf_kdsp_radio_carrier
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
346 proto_tree_add_item(sub_tree
, hf_kdsp_radio_encoding
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
348 proto_tree_add_item(sub_tree
, hf_kdsp_radio_datarate
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
350 proto_tree_add_item(sub_tree
, hf_kdsp_radio_signal_rssi
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
352 proto_tree_add_item(sub_tree
, hf_kdsp_radio_noise_rssi
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
355 if (bitmap
& GPS_FLAG
) {
356 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_gps_hdr
, tvb
, offset
, 68, ENC_NA
);
357 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_gps
);
359 proto_tree_add_item(sub_tree
, hf_kdsp_gps_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
361 proto_tree_add_item(sub_tree
, hf_kdsp_gps_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
363 proto_tree_add_item(sub_tree
, hf_kdsp_gps_fix
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
365 proto_tree_add_item(sub_tree
, hf_kdsp_gps_lat
, tvb
, offset
, 12, ENC_NA
);
367 proto_tree_add_item(sub_tree
, hf_kdsp_gps_lon
, tvb
, offset
, 12, ENC_NA
);
369 proto_tree_add_item(sub_tree
, hf_kdsp_gps_alt
, tvb
, offset
, 12, ENC_NA
);
371 proto_tree_add_item(sub_tree
, hf_kdsp_gps_spd
, tvb
, offset
, 12, ENC_NA
);
373 proto_tree_add_item(sub_tree
, hf_kdsp_gps_heading
, tvb
, offset
, 12, ENC_NA
);
376 if (bitmap
& CPT_FLAG
) {
377 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_cpt_data_hdr
, tvb
, offset
, 44, ENC_NA
);
378 sub_tree
= proto_item_add_subtree(sub_item
, ett_sub_cpt
);
380 data_len_item
= proto_tree_add_item(sub_tree
, hf_kdsp_cpt_data_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
381 data_hdr_len
= tvb_get_ntohs(tvb
, offset
);
384 subsub_item
= proto_tree_add_item(sub_tree
, hf_kdsp_cpt_data_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
385 subsub_tree
= proto_item_add_subtree(subsub_item
, ett_cpt_data_content_bitmap
);
386 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_uuid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
387 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_len
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
388 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_sec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
389 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_usec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
390 proto_tree_add_item(subsub_tree
, hf_kdsp_cpt_dc_flag_dlt
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
391 cptbitmap
= tvb_get_ntohl(tvb
, offset
);
394 data_hdr_len_check
= 6; /* len(len) + len(bitmap) */
395 if (cptbitmap
& DATA_UUID_FLAG
) data_hdr_len_check
+= 16;
396 if (cptbitmap
& DATA_PACKLEN_FLAG
) data_hdr_len_check
+= 2;
397 if (cptbitmap
& DATA_TVSEC_FLAG
) data_hdr_len_check
+= 8;
398 if (cptbitmap
& DATA_TVUSEC_FLAG
) data_hdr_len_check
+= 8;
399 if (cptbitmap
& DATA_DLT_FLAG
) data_hdr_len_check
+= 4;
401 if (data_hdr_len_check
!= data_hdr_len
) {
402 expert_add_info(pinfo
, data_len_item
, &ei_kdsp_cpt_data_hdr_len
);
405 if (cptbitmap
& DATA_UUID_FLAG
) {
406 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_uuid
, tvb
, offset
, 16, ENC_NA
);
409 if (cptbitmap
& DATA_PACKLEN_FLAG
) {
410 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_packet_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
411 reported_payload_len
= tvb_get_ntohs(tvb
, offset
);
414 if (cptbitmap
& DATA_TVSEC_FLAG
) {
415 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_tv_sec
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
418 if (cptbitmap
& DATA_TVUSEC_FLAG
) {
419 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_tv_usec
, tvb
, offset
, 8, ENC_BIG_ENDIAN
);
422 if (cptbitmap
& DATA_DLT_FLAG
) {
423 proto_tree_add_item(sub_tree
, hf_kdsp_cpt_dlt
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
424 datalink_type
= tvb_get_ntohl(tvb
, offset
);
427 payload_len
= (length
+ FRAME_HEADER_LEN
) - offset
;
428 if (cptbitmap
& DATA_PACKLEN_FLAG
) {
429 payload_tvb
= tvb_new_subset(tvb
, offset
, payload_len
, reported_payload_len
);
430 if (cptbitmap
& DATA_DLT_FLAG
) {
431 dissector_try_uint(subdissector_dlt_table
, datalink_type
, payload_tvb
, pinfo
, tree
);
433 /* XXX - Restore protocol column */
434 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "KDSP");
436 } else if (payload_len
> 0) {
437 proto_tree_add_expert(sub_tree
, pinfo
, &ei_kdsp_payload_expected
, tvb
, offset
, payload_len
);
439 } else if (payload_len
> 0) {
440 proto_tree_add_expert(sub_tree
, pinfo
, &ei_kdsp_payload_unexpected
, tvb
, offset
, payload_len
);
445 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
447 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
448 sub_tree
= proto_item_add_subtree(sub_item
, ett_ch_bitmap
);
449 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_uuid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
450 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_cmd
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
451 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_curch
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
452 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_hop
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
453 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_numch
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
454 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_channels
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
455 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_dwell
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
456 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_rate
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
457 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_hopdwell
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
459 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_uuid
, tvb
, offset
, 16, ENC_NA
);
461 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_cmd
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
463 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_cur_ch
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
465 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_hop
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
467 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_num_ch
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
468 numChan
= tvb_get_ntohs(tvb
, offset
);
470 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_data
, tvb
, offset
, 2046, ENC_NA
);
471 sub_tree
= proto_item_add_subtree(sub_item
, ett_ch_data
);
473 for(i
= 0; i
<numChan
; i
++) {
474 type
= tvb_get_ntohs(tvb
, offset
);
476 if (!type
) {/* Highest bit (1 << 15) == 0 if channel */
477 proto_tree_add_item(sub_tree
, hf_kdsp_ch_ch
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
479 proto_tree_add_item(sub_tree
, hf_kdsp_ch_dwell
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
482 else{/* Highest bit (1 << 15) == 1 if range */
483 proto_tree_add_item(sub_tree
, hf_kdsp_ch_start
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
485 proto_tree_add_item(sub_tree
, hf_kdsp_ch_end
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
487 proto_tree_add_item(sub_tree
, hf_kdsp_ch_width
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
489 proto_tree_add_item(sub_tree
, hf_kdsp_ch_iter
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
493 offset
= length
+FRAME_HEADER_LEN
-4;
494 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_rate
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
496 proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_ch_dwell
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
500 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
502 sub_item
= proto_tree_add_item(kdsp_tree
, hf_kdsp_ch_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
503 sub_tree
= proto_item_add_subtree(sub_item
, ett_ch_bitmap
);
504 proto_tree_add_item(sub_tree
, hf_kdsp_ch_flag_uuid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
505 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
507 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_uuid
, tvb
, offset
, 16, ENC_NA
);
509 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_invalidate
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
511 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_name
, tvb
, offset
, 16, ENC_ASCII
|ENC_NA
);
513 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_interface
, tvb
, offset
, 16, ENC_ASCII
|ENC_NA
);
515 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_type
, tvb
, offset
, 16, ENC_ASCII
|ENC_NA
);
517 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_hop
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
519 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_dwell
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
521 proto_tree_add_item(kdsp_tree
, hf_kdsp_source_rate
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
525 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_hdr_len
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
527 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_content_bitmap
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
529 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_uuid
, tvb
, offset
, 16, ENC_NA
);
531 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_flags
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
533 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_hop_tm_sec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
535 proto_tree_add_item(kdsp_tree
, hf_kdsp_report_hop_tm_usec
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
539 expert_add_info(pinfo
, command_item
, &ei_kdsp_cmdnum
);
542 return tvb_length(tvb
);
546 dissect_kdsp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
548 tcp_dissect_pdus(tvb
, pinfo
, tree
, TRUE
, FRAME_HEADER_LEN
,
549 get_kdsp_message_len
, dissect_kdsp_message
, data
);
550 return tvb_length(tvb
);
554 proto_register_kdsp(void)
556 module_t
*kdsp_module
;
558 static hf_register_info hf
[] = {
560 { "Sentinel", "kdsp.sentinel",
566 { "Command", "kdsp.command",
568 VALS(packettypenames
), 0x0,
572 { "Length", "kdsp.length",
578 { "KDSP Version", "kdsp.version",
583 { &hf_kdsp_server_version
,
584 { "Server Version", "kdsp.server.version",
585 FT_STRING
, BASE_NONE
,
590 { "Hostname", "kdsp.hostname",
591 FT_STRING
, BASE_NONE
,
595 { &hf_kdsp_str_flags
,
596 { "String Flags", "kdsp.str.flags",
602 { "String Length", "kdsp.str.length",
608 { "Message", "kdsp.str.message",
609 FT_STRING
, BASE_NONE
,
613 { &hf_kdsp_cpt_bitmap
,
614 { "Bitmap", "kdsp.cpt.bitmap",
619 { &hf_kdsp_cpt_flag_cpt
,
620 { "Capture Packet Flag", "kdsp.cpt.flag.cpt",
625 { &hf_kdsp_cpt_flag_fcs
,
626 { "Capture FCS Flag", "kdsp.cpt.flag.fcs",
631 { &hf_kdsp_cpt_flag_gps
,
632 { "Capture GPS Flag", "kdsp.cpt.flag.gps",
637 { &hf_kdsp_cpt_flag_radio
,
638 { "Capture Radio Flag", "kdsp.cpt.flag.radio",
643 { &hf_kdsp_cpt_offset
,
644 { "Offset Capture Packet Header", "kdsp.cpt.offset",
650 { "Capture FCS Header", "kdsp.fcs",
656 { "Frame Checksum", "kdsp.fcs.data",
661 { &hf_kdsp_radio_hdr
,
662 { "Capture Radio Header", "kdsp.radio",
667 { &hf_kdsp_radio_hdr_len
,
668 { "Length", "kdsp.radio.length",
673 { &hf_kdsp_radio_content_bitmap
,
674 { "Bitmap", "kdsp.radio.bitmap",
679 { &hf_kdsp_radio_accuracy
,
680 { "Accuracy", "kdsp.radio.accuracy",
685 { &hf_kdsp_radio_freq_mhz
,
686 { "Frequency", "kdsp.radio.freq",
691 { &hf_kdsp_radio_signal_dbm
,
692 { "Signal dbm", "kdsp.radio.signal_dbm",
697 { &hf_kdsp_radio_noise_dbm
,
698 { "Noise dbm", "kdsp.radio.noise_dbm",
703 { &hf_kdsp_radio_carrier
,
704 { "Carrier", "kdsp.radio.car",
709 { &hf_kdsp_radio_encoding
,
710 { "Encoding", "kdsp.radio.enc",
715 { &hf_kdsp_radio_datarate
,
716 { "Data Rate", "kdsp.radio.datarate",
721 { &hf_kdsp_radio_signal_rssi
,
722 { "Signal rssi", "kdsp.radio.signal_rssi",
727 { &hf_kdsp_radio_noise_rssi
,
728 { "Noise rssi", "kdsp.radio.noise_rssi",
734 { "Capture GPS Header", "kdsp.gps",
739 { &hf_kdsp_gps_hdr_len
,
740 { "GPS Length", "kdsp.gps.length",
745 { &hf_kdsp_gps_content_bitmap
,
746 { "Bitmap", "kdsp.gps.bitmap",
752 { "GPS fix", "kdsp.gps.fix",
758 { "Latitude", "kdsp.gps.lat",
764 { "Longitude", "kdsp.gps.lon",
770 { "Alt", "kdsp.gps.alt",
776 { "Spd", "kdsp.gps.spd",
781 { &hf_kdsp_gps_heading
,
782 { "Heading", "kdsp.gps.heading",
787 { &hf_kdsp_cpt_data_hdr
,
788 { "Capture Packet Header", "kdsp.cpt",
793 { &hf_kdsp_cpt_data_hdr_len
,
794 { "Length", "kdsp.cpt.length",
799 { &hf_kdsp_cpt_data_content_bitmap
,
800 { "Bitmap", "kdsp.cpt.bitmap",
805 { &hf_kdsp_cpt_dc_flag_uuid
,
806 { "Capture Content UUID Flag", "kdsp.cpt.cd.flag.uuid",
808 NULL
, DATA_UUID_FLAG
,
811 { &hf_kdsp_cpt_dc_flag_len
,
812 { "Capture Content Length Flag", "kdsp.cpt.cd.flag.len",
814 NULL
, DATA_PACKLEN_FLAG
,
817 { &hf_kdsp_cpt_dc_flag_sec
,
818 { "Capture Content Second Flag", "kdsp.cpt.cd.flag.sec",
820 NULL
, DATA_TVSEC_FLAG
,
823 { &hf_kdsp_cpt_dc_flag_usec
,
824 { "Capture Content Microsecond Flag", "kdsp.cpt.cd.flag.usec",
826 NULL
, DATA_TVUSEC_FLAG
,
829 { &hf_kdsp_cpt_dc_flag_dlt
,
830 { "Capture Content Datalink Type Flag", "kdsp.cpt.cd.flag.dlt",
836 { "UUID", "kdsp.cpt.uuid",
841 { &hf_kdsp_cpt_packet_len
,
842 { "Packet Length", "kdsp.cpt.pkt_len",
847 { &hf_kdsp_cpt_tv_sec
,
848 { "TV sec", "kdsp.cpt.tv_sec",
853 { &hf_kdsp_cpt_tv_usec
,
854 { "TV usec", "kdsp.cpt.tv_usec",
860 { "Data Link Type", "kdsp.cpt.dlt",
862 VALS(payloadtypenames
), 0x0,
865 { &hf_kdsp_ch_length
,
866 { "Length", "kdsp.chset.length",
871 { &hf_kdsp_ch_bitmap
,
872 { "Bitmap", "kdsp.chset.bitmap",
877 { &hf_kdsp_ch_flag_uuid
,
878 { "UUID Flag", "kdsp.ch.flag.uuid",
883 { &hf_kdsp_ch_flag_cmd
,
884 { "Command Flag", "kdsp.ch.flag.cmd",
889 { &hf_kdsp_ch_flag_curch
,
890 { "Current Channel Flag", "kdsp.ch.flag.curch",
895 { &hf_kdsp_ch_flag_hop
,
896 { "Hop Flag", "kdsp.ch.flag.hop",
901 { &hf_kdsp_ch_flag_numch
,
902 { "Num Channels Flag", "kdsp.ch.flag.numch",
907 { &hf_kdsp_ch_flag_channels
,
908 { "Channels Flag", "kdsp.ch.flag.channels",
910 NULL
, CH_CHANNELS_FLAG
,
913 { &hf_kdsp_ch_flag_dwell
,
914 { "Dwell Flag", "kdsp.ch.flag.dwell",
919 { &hf_kdsp_ch_flag_rate
,
920 { "Rate Flag", "kdsp.ch.flag.rate",
925 { &hf_kdsp_ch_flag_hopdwell
,
926 { "Hop-Dwell Flag", "kdsp.ch.flag.hopdwell",
928 NULL
, CH_HOPDWELL_FLAG
,
932 { "UUID", "kdsp.chset.uuid",
938 { "Command", "kdsp.chset.cmd",
940 VALS(channelcmds
), 0x0,
943 { &hf_kdsp_ch_cur_ch
,
944 { "Current Channel", "kdsp.chset.cur_ch",
950 { "Channel Hop", "kdsp.chset.hop",
955 { &hf_kdsp_ch_num_ch
,
956 { "Number of Channels", "kdsp.chset.num_ch",
962 { "Channel Data", "kdsp.chset.data",
968 { "Channel", "kdsp.chset.ch",
974 { "Dwell", "kdsp.chset.dwell",
980 { "Start", "kdsp.chset.start",
986 { "End", "kdsp.chset.end",
992 { "Width", "kdsp.chset.width",
998 { "Iter", "kdsp.chset.iter",
1004 { "Rate", "kdsp.chset.rate",
1005 FT_UINT16
, BASE_DEC
,
1009 { &hf_kdsp_ch_ch_dwell
,
1010 { "Dwell", "kdsp.chset.dwell",
1011 FT_UINT16
, BASE_DEC
,
1015 { &hf_kdsp_source_length
,
1016 { "Length", "kdsp.source.length",
1017 FT_UINT16
, BASE_DEC
,
1021 { &hf_kdsp_source_bitmap
,
1022 { "Source Bitmap", "kdsp.source.bitmap",
1023 FT_UINT32
, BASE_HEX
,
1027 { &hf_kdsp_source_uuid
,
1028 { "UUID", "kdsp.source.uuid",
1033 { &hf_kdsp_source_invalidate
,
1034 { "Source Invalidate", "kdsp.source.invalidate",
1035 FT_UINT16
, BASE_HEX
,
1039 { &hf_kdsp_source_name
,
1040 { "Source Name", "kdsp.source.name",
1041 FT_STRING
, BASE_NONE
,
1045 { &hf_kdsp_source_interface
,
1046 { "Interface", "kdsp.source.interface",
1047 FT_STRING
, BASE_NONE
,
1051 { &hf_kdsp_source_type
,
1052 { "Type", "kdsp.source.type",
1053 FT_STRING
, BASE_NONE
,
1057 { &hf_kdsp_source_hop
,
1058 { "Source Hop", "kdsp.source.hop",
1063 { &hf_kdsp_source_dwell
,
1064 { "Source Dwell", "kdsp.source.dwell",
1065 FT_UINT16
, BASE_DEC
,
1069 { &hf_kdsp_source_rate
,
1070 { "Source Rate", "kdsp.source.rate",
1071 FT_UINT16
, BASE_DEC
,
1075 { &hf_kdsp_report_hdr_len
,
1076 { "Length", "kdsp.report.length",
1077 FT_UINT16
, BASE_DEC
,
1081 { &hf_kdsp_report_content_bitmap
,
1082 { "Bitmap", "kdsp.report.bitmap",
1083 FT_UINT32
, BASE_HEX
,
1087 { &hf_kdsp_report_uuid
,
1088 { "UUID", "kdsp.report.uuid",
1093 { &hf_kdsp_report_flags
,
1094 { "flags", "kdsp.report.flags",
1099 { &hf_kdsp_report_hop_tm_sec
,
1100 { "Hop Time (sec)", "kdsp.report.sec",
1101 FT_UINT32
, BASE_DEC
,
1105 { &hf_kdsp_report_hop_tm_usec
,
1106 { "Hop Time (usec)", "kdsp.report.usec",
1107 FT_UINT32
, BASE_DEC
,
1114 /* Setup protocol subtree array */
1115 static gint
*ett
[] = {
1118 &ett_cpt_data_content_bitmap
,
1127 static ei_register_info ei
[] = {
1128 { &ei_kdsp_payload_expected
, { "kdsp.payload_expected", PI_MALFORMED
, PI_ERROR
, "Payload expected but no link type specified. Can not decode.", EXPFILL
}},
1129 { &ei_kdsp_payload_unexpected
, { "kdsp.payload_unexpected", PI_MALFORMED
, PI_ERROR
, "No payload expected but found some data", EXPFILL
}},
1130 { &ei_kdsp_cpt_data_hdr_len
, { "kdsp.cpt.length.invalid", PI_MALFORMED
, PI_ERROR
, "Calculated header length does not match reported header length. "
1131 "It is likely the dissector does not support all flags", EXPFILL
}},
1132 { &ei_kdsp_cmdnum
, { "kdsp.command.unknown", PI_UNDECODED
, PI_WARN
, "Unknown command, can not parse message", EXPFILL
}},
1134 expert_module_t
* expert_kdsp
;
1136 proto_kdsp
= proto_register_protocol(
1137 "Kismet Drone/Server Protocol",
1142 proto_register_field_array(proto_kdsp
, hf
, array_length(hf
));
1143 proto_register_subtree_array(ett
, array_length(ett
));
1145 kdsp_module
= prefs_register_protocol(proto_kdsp
, proto_reg_handoff_kdsp
);
1146 expert_kdsp
= expert_register_protocol(proto_kdsp
);
1147 expert_register_field_array(expert_kdsp
, ei
, array_length(ei
));
1149 subdissector_dlt_table
= register_dissector_table("kdsp.cpt.dlt", "KDSP DLT Type", FT_UINT32
, BASE_DEC
);
1151 prefs_register_uint_preference(kdsp_module
, "tcp.port",
1152 "Kismet Drone TCP Port",
1153 "Set the port for Kismet Drone/Server messages (if other"
1154 " than the default of 2502)", 10,
1155 &global_kdsp_tcp_port
);
1161 proto_reg_handoff_kdsp(void)
1163 static gboolean initialized
= FALSE
;
1164 static guint tcp_port
;
1165 static dissector_handle_t kdsp_handle
;
1166 dissector_handle_t dlt_handle
;
1170 kdsp_handle
= new_create_dissector_handle(dissect_kdsp
, proto_kdsp
);
1171 dlt_handle
= find_dissector("radiotap");
1173 dissector_add_uint( "kdsp.cpt.dlt", DATALINK_RADIOTAP
, dlt_handle
);
1175 dlt_handle
= find_dissector("wlan");
1177 dissector_add_uint( "kdsp.cpt.dlt", DATALINK_WLAN
, dlt_handle
);
1180 dissector_delete_uint("tcp.port", tcp_port
, kdsp_handle
);
1183 tcp_port
= global_kdsp_tcp_port
;
1185 dissector_add_uint("tcp.port", global_kdsp_tcp_port
, kdsp_handle
);
1190 * Editor modelines - http://www.wireshark.org/tools/modelines.html
1195 * indent-tabs-mode: nil
1198 * vi: set shiftwidth=2 tabstop=8 expandtab:
1199 * :indentSize=2:tabSize=8:noTabs=true: