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