1 /* packet-btbredr.c
2 * Routines for Bluetooth baseband dissection
3 * Copyright 2014, Dominic Spill <[email protected]>
4 * Copyright 2009, Michael Ossmann <[email protected]>
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <[email protected]>
8 * Copyright 1998 Gerald Combs
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 */
24
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #else
28 #include <wireshark/config.h>
29 #endif
30
31 #include <epan/packet.h>
32 #include <epan/prefs.h>
33
34 #include <stdio.h>
35
36 /* function prototypes */
37 void proto_reg_handoff_btbredr(void);
38
39 /* initialize the protocol and registered fields */
40 static int proto_btbredr = -1;
41 static int hf_btbredr_meta = -1;
42 static int hf_btbredr_channel = -1;
43 static int hf_btbredr_signal = -1;
44 static int hf_btbredr_noise = -1;
45 static int hf_btbredr_ac_offenses = -1;
46 static int hf_btbredr_mod = -1;
47 static int hf_btbredr_transport = -1;
48 static int hf_btbredr_corrected_header = -1;
49 static int hf_btbredr_corrected_payload = -1;
50 static int hf_btbredr_lap = -1;
51 static int hf_btbredr_ref_lap = -1;
52 static int hf_btbredr_ref_uap = -1;
53 static int hf_btbredr_pkthdr = -1;
54 static int hf_btbredr_ltaddr = -1;
55 static int hf_btbredr_type = -1;
56 static int hf_btbredr_flags = -1;
57 static int hf_btbredr_flow = -1;
58 static int hf_btbredr_arqn = -1;
59 static int hf_btbredr_seqn = -1;
60 static int hf_btbredr_hec = -1;
61 static int hf_btbredr_payload = -1;
62 static int hf_btbredr_pldhdr = -1;
63 static int hf_btbredr_llid = -1;
64 static int hf_btbredr_pldflow = -1;
65 static int hf_btbredr_length = -1;
66 static int hf_btbredr_pldbody = -1;
67 static int hf_btbredr_crc = -1;
68 static int hf_btbredr_fhs_parity = -1;
69 static int hf_btbredr_fhs_lap = -1;
70 static int hf_btbredr_fhs_eir = -1;
71 static int hf_btbredr_fhs_sr = -1;
72 static int hf_btbredr_fhs_uap = -1;
73 static int hf_btbredr_fhs_nap = -1;
74 static int hf_btbredr_fhs_class = -1;
75 static int hf_btbredr_fhs_ltaddr = -1;
76 static int hf_btbredr_fhs_clk = -1;
77 static int hf_btbredr_fhs_psmode = -1;
78
79 /* field values */
80 static const true_false_string direction = {
81 "Slave to Master",
82 "Master to Slave"
83 };
84
85 static const true_false_string clock_bits = {
86 "27",
87 "6"
88 };
89
90 static const true_false_string valid_flags = {
91 "Invalid",
92 "Valid"
93 };
94
95 static const value_string modulation[] = {
96 { 0x0, "Basic Rate (GFSK)" },
97 { 0x1, "Enhanced Data Rate (PI/2-DQPSK)" },
98 { 0x2, "Enhanced Data Rate (8DPSK)" }
99 };
100
101 static const value_string transports[] = {
102 { 0x0, "unknown" },
103 { 0x1, "SCO" },
104 { 0x2, "eSCO" },
105 { 0x3, "ACL" },
106 { 0x4, "CSB" }
107 };
108
109 static const value_string packet_types[] = {
110 /* generic names for unknown logical transport */
111 { 0x0, "NULL" },
112 { 0x1, "POLL" },
113 { 0x2, "FHS" },
114 { 0x3, "DM1" },
115 { 0x4, "DH1/2-DH1" },
116 { 0x5, "HV1" },
117 { 0x6, "HV2/2-EV3" },
118 { 0x7, "HV3/EV3/3-EV3" },
119 { 0x8, "DV/3-DH1" },
120 { 0x9, "AUX1" },
121 { 0xa, "DM3/2-DH3" },
122 { 0xb, "DH3/3-DH3" },
123 { 0xc, "EV4/2-EV5" },
124 { 0xd, "EV5/3-EV5" },
125 { 0xe, "DM5/2-DH5" },
126 { 0xf, "DH5/3-DH5" },
127 { 0, NULL }
128 };
129
130 static const value_string sr_modes[] = {
131 { 0x0, "R0" },
132 { 0x1, "R1" },
133 { 0x2, "R2" },
134 { 0x3, "Reserved" },
135 { 0, NULL }
136 };
137
138 static const range_string ps_modes[] = {
139 { 0x0, 0x0, "Mandatory scan mode" },
140 { 0x1, 0x7, "Reserved" },
141 { 0, 0, NULL }
142 };
143
144 static const value_string llid_codes[] = {
145 { 0x0, "undefined" },
146 { 0x1, "Continuation fragment of an L2CAP message (ACL-U)" },
147 { 0x2, "Start of an L2CAP message or no fragmentation (ACL-U)" },
148 { 0x3, "LMP message (ACL-C)" },
149 { 0, NULL }
150 };
151
152 /* initialize the subtree pointers */
153 static gint ett_btbredr = -1;
154 static gint ett_btbredr_meta = -1;
155 static gint ett_btbredr_pkthdr = -1;
156 static gint ett_btbredr_flags = -1;
157 static gint ett_btbredr_payload = -1;
158 static gint ett_btbredr_pldhdr = -1;
159
160 /* subdissectors */
161 static dissector_handle_t btlmp_handle = NULL;
162 static dissector_handle_t btl2cap_handle = NULL;
163
164 /* packet header flags */
165 static const int *flag_fields[] = {
166 &hf_btbredr_flow,
167 &hf_btbredr_arqn,
168 &hf_btbredr_seqn,
169 NULL
170 };
171
172 /* one byte payload header */
173 int
dissect_payload_header1(proto_tree * tree,tvbuff_t * tvb,int offset)174 dissect_payload_header1(proto_tree *tree, tvbuff_t *tvb, int offset)
175 {
176 proto_item *hdr_item;
177 proto_tree *hdr_tree;
178
179 DISSECTOR_ASSERT(tvb_length_remaining(tvb, offset) >= 1);
180
181 hdr_item = proto_tree_add_item(tree, hf_btbredr_pldhdr, tvb, offset, 1, ENC_NA);
182 hdr_tree = proto_item_add_subtree(hdr_item, ett_btbredr_pldhdr);
183
184 proto_tree_add_item(hdr_tree, hf_btbredr_llid, tvb, offset, 1, ENC_NA);
185 proto_tree_add_item(hdr_tree, hf_btbredr_pldflow, tvb, offset, 1, ENC_NA);
186 proto_tree_add_item(hdr_tree, hf_btbredr_length, tvb, offset, 1, ENC_NA);
187
188 /* payload length */
189 return tvb_get_guint8(tvb, offset) >> 3;
190 }
191
192 void
dissect_fhs(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,int offset)193 dissect_fhs(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
194 {
195 proto_item *fhs_item, *psmode_item;
196 proto_tree *fhs_tree;
197 const gchar *description;
198 guint8 psmode;
199
200 if(tvb_length_remaining(tvb, offset) != 20) {
201 col_add_str(pinfo->cinfo, COL_INFO, "Encrypted or malformed payload data");
202 return;
203 }
204
205 fhs_item = proto_tree_add_item(tree, hf_btbredr_payload, tvb, offset, -1, ENC_NA);
206 fhs_tree = proto_item_add_subtree(fhs_item, ett_btbredr_payload);
207
208 /* Use proto_tree_add_bits_item() to get around 32bit limit on bitmasks */
209 proto_tree_add_bits_item(fhs_tree, hf_btbredr_fhs_parity, tvb, offset*8, 34, ENC_LITTLE_ENDIAN);
210 /* proto_tree_add_item(fhs_tree, hf_btbredr_fhs_parity, tvb, offset, 5, ENC_LITTLE_ENDIAN); */
211 offset += 4;
212
213 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_lap, tvb, offset, 4, ENC_LITTLE_ENDIAN);
214 offset += 3;
215
216 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_eir, tvb, offset, 1, ENC_NA);
217 /* skipping 1 undefined bit */
218 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_sr, tvb, offset, 1, ENC_NA);
219 /* skipping 2 reserved bits */
220 offset += 1;
221
222 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_uap, tvb, offset, 1, ENC_NA);
223 offset += 1;
224
225 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_nap, tvb, offset, 2, ENC_LITTLE_ENDIAN);
226 offset += 2;
227
228 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_class, tvb, offset, 3, ENC_LITTLE_ENDIAN);
229 offset += 3;
230
231 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_ltaddr, tvb, offset, 1, ENC_NA);
232 proto_tree_add_item(fhs_tree, hf_btbredr_fhs_clk, tvb, offset, 4, ENC_LITTLE_ENDIAN);
233 offset += 3;
234
235 psmode = tvb_get_guint8(tvb, offset);
236 description = try_rval_to_str(psmode, ps_modes);
237 psmode_item = proto_tree_add_item(fhs_tree, hf_btbredr_fhs_psmode, tvb, offset, 1, ENC_NA);
238 if (description)
239 proto_item_append_text(psmode_item, " (%s)", description);
240 offset += 1;
241
242 proto_tree_add_item(fhs_tree, hf_btbredr_crc, tvb, offset, 2, ENC_LITTLE_ENDIAN);
243 offset += 2;
244 }
245
246 void
dissect_dm1(proto_tree * tree,tvbuff_t * tvb,packet_info * pinfo,int offset)247 dissect_dm1(proto_tree *tree, tvbuff_t *tvb, packet_info *pinfo, int offset)
248 {
249 int len; /* payload length indicated by payload header */
250 int llid; /* logical link id */
251 int l2len; /* length indicated by l2cap header */
252 proto_item *dm1_item;
253 proto_tree *dm1_tree;
254 tvbuff_t *pld_tvb;
255
256 /*
257 * FIXME
258 * I'm probably doing a terrible, terrible thing here, but it gets my
259 * initial test cases working.
260 */
261 guint16 fake_acl_data;
262
263 if(tvb_length_remaining(tvb, offset) < 3) {
264 col_add_str(pinfo->cinfo, COL_INFO, "Encrypted or malformed payload data");
265 return;
266 }
267
268 dm1_item = proto_tree_add_item(tree, hf_btbredr_payload, tvb, offset, -1, ENC_NA);
269 dm1_tree = proto_item_add_subtree(dm1_item, ett_btbredr_payload);
270
271 len = dissect_payload_header1(dm1_tree, tvb, offset);
272 llid = tvb_get_guint8(tvb, offset) & 0x3;
273 offset += 1;
274
275 if(tvb_length_remaining(tvb, offset) < len + 2) {
276 col_add_str(pinfo->cinfo, COL_INFO, "Encrypted or malformed payload data");
277 return;
278 }
279
280 if (llid == 3 && btlmp_handle) {
281 /* LMP */
282 pld_tvb = tvb_new_subset(tvb, offset, len, len);
283 call_dissector(btlmp_handle, pld_tvb, pinfo, dm1_tree);
284 } else if (llid == 2 && btl2cap_handle) {
285 /* unfragmented L2CAP or start of fragment */
286 l2len = tvb_get_letohs(tvb, offset);
287 if (l2len + 4 == len) {
288 /* unfragmented */
289 pinfo->private_data = &fake_acl_data;
290 pld_tvb = tvb_new_subset(tvb, offset, len, len);
291 call_dissector(btl2cap_handle, pld_tvb, pinfo, dm1_tree);
292 } else {
293 /* start of fragment */
294 proto_tree_add_item(dm1_tree, hf_btbredr_pldbody, tvb, offset, len, ENC_NA);
295 }
296 } else {
297 proto_tree_add_item(dm1_tree, hf_btbredr_pldbody, tvb, offset, len, ENC_NA);
298 }
299 offset += len;
300
301 proto_tree_add_item(dm1_tree, hf_btbredr_crc, tvb, offset, 2, ENC_LITTLE_ENDIAN);
302 offset += 2;
303 }
304
305 /* dissect a packet */
306 static int
dissect_btbredr(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data _U_)307 dissect_btbredr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
308 {
309 proto_item *btbredr_item, *meta_item, *pkthdr_item;
310 proto_tree *btbredr_tree, *meta_tree, *pkthdr_tree;
311 int offset;
312 /* Avoid error: 'type' may be used uninitialized in this function */
313 guint8 type = 0xff;
314 const gchar *info;
315
316 /* sanity check: length */
317 if (tvb_length(tvb) > 0 && tvb_length(tvb) < 9)
318 /* bad length: look for a different dissector */
319 return 0;
320
321 /* maybe should verify HEC */
322
323 /* make entries in protocol column and info column on summary display */
324 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bluetooth");
325
326 if (tvb_length(tvb) == 0) {
327 info = "ID";
328 } else {
329 type = (tvb_get_guint8(tvb, 16) >> 3) & 0x0f;
330 info = val_to_str(type, packet_types, "Unknown type: 0x%x");
331 }
332
333 col_clear(pinfo->cinfo, COL_INFO);
334 col_add_str(pinfo->cinfo, COL_INFO, info);
335
336 /* see if we are being asked for details */
337 if (tree) {
338
339 /* create display subtree for the protocol */
340 offset = 0;
341 btbredr_item = proto_tree_add_item(tree, proto_btbredr, tvb, offset, -1, ENC_NA);
342 btbredr_tree = proto_item_add_subtree(btbredr_item, ett_btbredr);
343
344 /* ID packets have no header, no payload */
345 if (tvb_length(tvb) == 0)
346 return 1;
347
348 /* meta data */
349 meta_item = proto_tree_add_item(btbredr_tree, hf_btbredr_meta, tvb, offset, 3, ENC_NA);
350 meta_tree = proto_item_add_subtree(meta_item, ett_btbredr_meta);
351
352 proto_tree_add_item(meta_tree, hf_btbredr_channel, tvb, offset, 1, ENC_NA);
353 offset += 1;
354 proto_tree_add_item(meta_tree, hf_btbredr_signal, tvb, offset, 1, ENC_NA);
355 offset += 1;
356 proto_tree_add_item(meta_tree, hf_btbredr_noise, tvb, offset, 1, ENC_NA);
357 offset += 1;
358 proto_tree_add_item(meta_tree, hf_btbredr_ac_offenses, tvb, offset, 1, ENC_NA);
359 offset += 1;
360
361 proto_tree_add_item(meta_tree, hf_btbredr_mod, tvb, offset, 1, ENC_NA);
362 proto_tree_add_item(meta_tree, hf_btbredr_transport, tvb, offset, 1, ENC_NA);
363 offset += 1;
364
365 proto_tree_add_item(meta_tree, hf_btbredr_corrected_header, tvb, offset, 1, ENC_NA);
366 offset += 1;
367 proto_tree_add_item(meta_tree, hf_btbredr_corrected_payload, tvb, offset, 2, ENC_LITTLE_ENDIAN);
368 offset += 2;
369
370 proto_tree_add_item(meta_tree, hf_btbredr_lap, tvb, offset, 4, ENC_LITTLE_ENDIAN);
371 offset += 4;
372 proto_tree_add_item(meta_tree, hf_btbredr_ref_lap, tvb, offset, 3, ENC_LITTLE_ENDIAN);
373 offset += 3;
374 proto_tree_add_item(meta_tree, hf_btbredr_ref_uap, tvb, offset, 1, ENC_NA);
375 offset += 1;
376
377
378 /* packet header */
379 pkthdr_item = proto_tree_add_item(btbredr_tree, hf_btbredr_pkthdr, tvb, offset, 3, ENC_NA);
380 pkthdr_tree = proto_item_add_subtree(pkthdr_item, ett_btbredr_pkthdr);
381
382 proto_tree_add_item(pkthdr_tree, hf_btbredr_ltaddr, tvb, offset, 1, ENC_NA);
383 proto_tree_add_item(pkthdr_tree, hf_btbredr_type, tvb, offset, 1, ENC_NA);
384 offset += 1;
385 proto_tree_add_bitmask(pkthdr_tree, tvb, offset, hf_btbredr_flags,
386 ett_btbredr_flags, flag_fields, ENC_NA);
387 offset += 1;
388 proto_tree_add_item(pkthdr_tree, hf_btbredr_hec, tvb, offset, 1, ENC_NA);
389 offset += 2;
390
391 /* payload */
392 switch (type) {
393 case 0x0: /* NULL */
394 case 0x1: /* POLL */
395 break;
396 case 0x2: /* FHS */
397 dissect_fhs(btbredr_tree, tvb, pinfo, offset);
398 break;
399 case 0x3: /* DM1 */
400 dissect_dm1(btbredr_tree, tvb, pinfo, offset);
401 break;
402 case 0x4: /* DH1/2-DH1 */
403 dissect_dm1(btbredr_tree, tvb, pinfo, offset);
404 break;
405 case 0x5: /* HV1 */
406 case 0x6: /* HV2/2-EV3 */
407 case 0x7: /* HV3/EV3/3-EV3 */
408 case 0x8: /* DV/3-DH1 */
409 case 0x9: /* AUX1 */
410 case 0xa: /* DM3/2-DH3 */
411 case 0xb: /* DH3/3-DH3 */
412 case 0xc: /* EV4/2-EV5 */
413 case 0xd: /* EV5/3-EV5 */
414 case 0xe: /* DM5/2-DH5 */
415 case 0xf: /* DH5/3-DH5 */
416 proto_tree_add_item(btbredr_tree, hf_btbredr_payload, tvb, offset, -1, ENC_NA);
417 break;
418 default:
419 break;
420 }
421 }
422
423 /* Return the amount of data this dissector was able to dissect */
424 return tvb_length(tvb);
425 }
426
427 /* register the protocol with Wireshark */
428 void
proto_register_btbredr(void)429 proto_register_btbredr(void)
430 {
431 /* list of fields */
432 static hf_register_info hf[] = {
433 { &hf_btbredr_meta,
434 { "Meta Data", "btbredr.meta",
435 FT_NONE, BASE_NONE, NULL, 0x0,
436 "Meta Data About the Packet", HFILL }
437 },
438 { &hf_btbredr_channel,
439 { "Channel", "btbredr.channel",
440 FT_UINT8, BASE_DEC, NULL, 0x0,
441 "Channel (0-78)", HFILL }
442 },
443 { &hf_btbredr_signal,
444 { "Signal", "btbredr.signal",
445 FT_UINT8, BASE_DEC, NULL, 0x0,
446 "Signal Power", HFILL }
447 },
448 { &hf_btbredr_noise,
449 { "Noise", "btbredr.noise",
450 FT_UINT8, BASE_DEC, NULL, 0x0,
451 "Noise Power", HFILL }
452 },
453 { &hf_btbredr_ac_offenses,
454 { "AC Offenses", "btbredr.ac_offenses",
455 FT_UINT8, BASE_DEC, NULL, 0x0,
456 "Access Code Offenses", HFILL }
457 },
458 { &hf_btbredr_mod,
459 { "Transport Rate", "btbredr.mod",
460 FT_UINT8, BASE_HEX, VALS(&modulation), 0x02,
461 "Transport Data Rate", HFILL }
462 },
463 { &hf_btbredr_transport,
464 { "Transport", "btbredr.transport",
465 FT_UINT8, BASE_HEX, VALS(&transports), 0x70,
466 "Logical Transport", HFILL }
467 },
468 { &hf_btbredr_corrected_header,
469 { "Corrected Header", "btbredr.corrected_header",
470 FT_UINT8, BASE_DEC, NULL, 0x0,
471 "Corrected Header Bits", HFILL }
472 },
473 { &hf_btbredr_corrected_payload,
474 { "Corrected Payload", "btbredr.corrected_payload",
475 FT_UINT16, BASE_DEC, NULL, 0x0,
476 "Corrected Payload Bits", HFILL }
477 },
478 { &hf_btbredr_lap,
479 { "LAP", "btbredr.lap",
480 FT_UINT32, BASE_HEX, NULL, 0x0,
481 "Lower Address Part", HFILL }
482 },
483 { &hf_btbredr_ref_lap,
484 { "Ref. LAP", "btbredr.ref_lap",
485 FT_UINT32, BASE_HEX, NULL, 0x0,
486 "Reference LAP", HFILL }
487 },
488 { &hf_btbredr_ref_uap,
489 { "Ref. UAP", "btbredr.ref_uap",
490 FT_UINT8, BASE_HEX, NULL, 0x0,
491 "Reference UAP", HFILL }
492 },
493 { &hf_btbredr_pkthdr,
494 { "Packet Header", "btbredr.pkthdr",
495 FT_NONE, BASE_NONE, NULL, 0x0,
496 "Bluetooth Baseband Packet Header", HFILL }
497 },
498 { &hf_btbredr_ltaddr,
499 { "LT_ADDR", "btbredr.lt_addr",
500 FT_UINT8, BASE_HEX, NULL, 0x07,
501 "Logical Transport Address", HFILL }
502 },
503 { &hf_btbredr_type,
504 { "TYPE", "btbredr.type",
505 FT_UINT8, BASE_HEX, VALS(packet_types), 0x78,
506 "Packet Type", HFILL }
507 },
508 { &hf_btbredr_flags,
509 { "Flags", "btbredr.flags",
510 FT_UINT8, BASE_HEX, NULL, 0x0,
511 "Packet Header Flags", HFILL }
512 },
513 { &hf_btbredr_flow,
514 { "FLOW", "btbredr.flow",
515 FT_BOOLEAN, 8, NULL, 0x01,
516 "Flow control indication", HFILL }
517 },
518 { &hf_btbredr_arqn,
519 { "ARQN", "btbredr.arqn",
520 FT_BOOLEAN, 8, NULL, 0x02,
521 "Acknowledgment indication", HFILL }
522 },
523 { &hf_btbredr_seqn,
524 { "SEQN", "btbredr.seqn",
525 FT_BOOLEAN, 8, NULL, 0x04,
526 "Sequence number", HFILL }
527 },
528 { &hf_btbredr_hec,
529 { "HEC", "btbredr.lt_addr",
530 FT_UINT8, BASE_HEX, NULL, 0x0,
531 "Header Error Check", HFILL }
532 },
533 { &hf_btbredr_payload,
534 { "Payload", "btbredr.payload",
535 FT_NONE, BASE_NONE, NULL, 0x0,
536 NULL, HFILL }
537 },
538 { &hf_btbredr_llid,
539 { "LLID", "btbredr.llid",
540 FT_UINT8, BASE_HEX, VALS(llid_codes), 0x03,
541 "Logical Link ID", HFILL }
542 },
543 { &hf_btbredr_pldflow,
544 { "Flow", "btbredr.flow",
545 FT_BOOLEAN, 8, NULL, 0x04,
546 "Payload Flow indication", HFILL }
547 },
548 { &hf_btbredr_length,
549 { "Length", "btbredr.length",
550 FT_UINT8, BASE_DEC, NULL, 0xf8,
551 "Payload Length", HFILL }
552 },
553 { &hf_btbredr_pldhdr,
554 { "Payload Header", "btbredr.pldhdr",
555 FT_NONE, BASE_NONE, NULL, 0x0,
556 NULL, HFILL }
557 },
558 { &hf_btbredr_pldbody,
559 { "Payload Body", "btbredr.pldbody",
560 FT_BYTES, BASE_NONE, NULL, 0x0,
561 NULL, HFILL }
562 },
563 { &hf_btbredr_crc,
564 { "CRC", "btbredr.crc",
565 FT_UINT16, BASE_HEX, NULL, 0x0,
566 "Payload CRC", HFILL }
567 },
568 { &hf_btbredr_fhs_parity,
569 { "Parity", "btbredr.parity",
570 /* FIXME this doesn't work because bitmasks can only be 32 bits */
571 FT_UINT64, BASE_HEX, NULL, /*0x00000003ffffffffULL,*/ 0x0,
572 "LAP parity", HFILL }
573 },
574 { &hf_btbredr_fhs_lap,
575 { "LAP", "btbredr.lap",
576 FT_UINT24, BASE_HEX, NULL, 0x03fffffc,
577 "Lower Address Part", HFILL }
578 },
579 { &hf_btbredr_fhs_eir,
580 { "EIR", "btbredr.eir",
581 FT_BOOLEAN, 8, NULL, 0x04,
582 "Extended Inquiry Response packet may follow", HFILL }
583 },
584 { &hf_btbredr_fhs_sr,
585 { "SR", "btbredr.sr",
586 FT_UINT8, BASE_HEX, VALS(sr_modes), 0x30,
587 "Scan Repetition", HFILL }
588 },
589 { &hf_btbredr_fhs_uap,
590 { "UAP", "btbredr.uap",
591 FT_UINT8, BASE_HEX, NULL, 0x0,
592 "Upper Address Part", HFILL }
593 },
594 { &hf_btbredr_fhs_nap,
595 { "NAP", "btbredr.nap",
596 FT_UINT16, BASE_HEX, NULL, 0x0,
597 "Non-Significant Address Part", HFILL }
598 },
599 { &hf_btbredr_fhs_class, /* FIXME break out further */
600 { "Class of Device", "btbredr.class",
601 FT_UINT24, BASE_HEX, NULL, 0x0,
602 NULL, HFILL }
603 },
604 { &hf_btbredr_fhs_ltaddr,
605 { "LT_ADDR", "btbredr.lt_addr",
606 FT_UINT8, BASE_HEX, NULL, 0x07,
607 "Logical Transport Address", HFILL }
608 },
609 { &hf_btbredr_fhs_clk,
610 { "CLK", "btbredr.clk",
611 FT_UINT32, BASE_HEX, NULL, 0x1ffffff8,
612 "Clock bits 2 through 27", HFILL }
613 },
614 { &hf_btbredr_fhs_psmode,
615 { "Page Scan Mode", "btbredr.psmode",
616 FT_UINT8, BASE_HEX, NULL, 0xe0,
617 NULL, HFILL }
618 },
619 };
620
621 /* protocol subtree arrays */
622 static gint *ett[] = {
623 &ett_btbredr,
624 &ett_btbredr_meta,
625 &ett_btbredr_pkthdr,
626 &ett_btbredr_flags,
627 &ett_btbredr_payload,
628 &ett_btbredr_pldhdr,
629 };
630
631 /* register the protocol name and description */
632 proto_btbredr = proto_register_protocol(
633 "Bluetooth BR/EDR Baseband", /* full name */
634 "BT BR/EDR Baseband", /* short name */
635 "btbredr" /* abbreviation (e.g. for filters) */
636 );
637
638 /* register the header fields and subtrees used */
639 proto_register_field_array(proto_btbredr, hf, array_length(hf));
640 proto_register_subtree_array(ett, array_length(ett));
641 }
642
643 /* Remove this once recent Wireshark/TCPdump releases are more common */
644 #ifndef WTAP_ENCAP_BLUETOOTH_BREDR_BB
645 #define WTAP_ENCAP_BLUETOOTH_BREDR_BB 161
646 #endif
647
648 void
proto_reg_handoff_btbredr(void)649 proto_reg_handoff_btbredr(void)
650 {
651 dissector_handle_t btbredr_handle;
652 btbredr_handle = new_create_dissector_handle(dissect_btbredr,
653 proto_btbredr);
654 dissector_add_uint("wtap_encap",
655 WTAP_ENCAP_BLUETOOTH_BREDR_BB,
656 btbredr_handle);
657
658 btlmp_handle = find_dissector("btlmp");
659 btl2cap_handle = find_dissector("btl2cap");
660 }
661
662 /*
663 * Editor modelines - http://www.wireshark.org/tools/modelines.html
664 *
665 * Local variables:
666 * c-basic-offset: 4
667 * tab-width: 8
668 * indent-tabs-mode: nil
669 * End:
670 *
671 * vi: set shiftwidth=4 tabstop=8 expandtab:
672 * :indentSize=4:tabSize=8:noTabs=true:
673 */
674