xref: /libbtbb/wireshark/plugins/btbb/packet-btbb.c (revision 25d64f63a355f4c01d10cf4f69da1c2246b040d9)
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
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_reported_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
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_reported_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
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_reported_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_reported_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 			pld_tvb = tvb_new_subset(tvb, offset, len, len);
260 			call_dissector_with_data(btl2cap_handle, pld_tvb, pinfo, dm1_tree, &fake_acl_data);
261 		} else {
262 			/* start of fragment */
263 			proto_tree_add_item(dm1_tree, hf_btbb_pldbody, tvb, offset, len, ENC_NA);
264 		}
265 	} else {
266 		proto_tree_add_item(dm1_tree, hf_btbb_pldbody, tvb, offset, len, ENC_NA);
267 	}
268 	offset += len;
269 
270 	proto_tree_add_item(dm1_tree, hf_btbb_crc, tvb, offset, 2, ENC_LITTLE_ENDIAN);
271 	offset += 2;
272 }
273 
274 /* dissect a packet */
275 static int
276 dissect_btbb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
277 {
278 	proto_item *btbb_item, *meta_item, *pkthdr_item;
279 	proto_tree *btbb_tree, *meta_tree, *pkthdr_tree;
280 	int offset;
281 	/* Avoid error: 'type' may be used uninitialized in this function */
282 	guint8 type = 0xff;
283 	const gchar *info;
284 
285 	/* sanity check: length */
286 	if (tvb_reported_length(tvb) > 0 && tvb_reported_length(tvb) < 9)
287 		/* bad length: look for a different dissector */
288 		return 0;
289 
290 	/* maybe should verify HEC */
291 
292 	/* make entries in protocol column and info column on summary display */
293 	col_set_str(pinfo->cinfo, COL_PROTOCOL, "Bluetooth");
294 
295 	if (tvb_reported_length(tvb) == 0) {
296 		info = "ID";
297 	} else {
298 		type = (tvb_get_guint8(tvb, 6) >> 3) & 0x0f;
299 		info = val_to_str(type, packet_types, "Unknown type: 0x%x");
300 	}
301 
302 	col_clear(pinfo->cinfo, COL_INFO);
303 	col_add_str(pinfo->cinfo, COL_INFO, info);
304 
305 	/* see if we are being asked for details */
306 	if (tree) {
307 
308 		/* create display subtree for the protocol */
309 		offset = 0;
310 		btbb_item = proto_tree_add_item(tree, proto_btbb, tvb, offset, -1, ENC_NA);
311 		btbb_tree = proto_item_add_subtree(btbb_item, ett_btbb);
312 
313 		/* ID packets have no header, no payload */
314 		if (tvb_reported_length(tvb) == 0)
315 			return 1;
316 
317 		/* meta data */
318 		meta_item = proto_tree_add_item(btbb_tree, hf_btbb_meta, tvb, offset, 3, ENC_NA);
319 		meta_tree = proto_item_add_subtree(meta_item, ett_btbb_meta);
320 
321 		proto_tree_add_item(meta_tree, hf_btbb_dir, tvb, offset, 1, ENC_NA);
322 		proto_tree_add_item(meta_tree, hf_btbb_clk, tvb, offset, 4, ENC_LITTLE_ENDIAN);
323 		offset += 4;
324 
325 		proto_tree_add_item(meta_tree, hf_btbb_channel, tvb, offset, 1, ENC_NA);
326 		offset += 1;
327 
328 		proto_tree_add_item(meta_tree, hf_btbb_clkbits, tvb, offset, 1, ENC_NA);
329 		proto_tree_add_item(meta_tree, hf_btbb_addrbits, tvb, offset, 1, ENC_NA);
330 		offset += 1;
331 
332 		/* packet header */
333 		pkthdr_item = proto_tree_add_item(btbb_tree, hf_btbb_pkthdr, tvb, offset, 3, ENC_NA);
334 		pkthdr_tree = proto_item_add_subtree(pkthdr_item, ett_btbb_pkthdr);
335 
336 		proto_tree_add_item(pkthdr_tree, hf_btbb_ltaddr, tvb, offset, 1, ENC_NA);
337 		proto_tree_add_item(pkthdr_tree, hf_btbb_type, tvb, offset, 1, ENC_NA);
338 		offset += 1;
339 		proto_tree_add_bitmask(pkthdr_tree, tvb, offset, hf_btbb_flags,
340 			ett_btbb_flags, flag_fields, ENC_NA);
341 		offset += 1;
342 		proto_tree_add_item(pkthdr_tree, hf_btbb_hec, tvb, offset, 1, ENC_NA);
343 		offset += 1;
344 
345 		/* payload */
346 		switch (type) {
347 		case 0x0: /* NULL */
348 		case 0x1: /* POLL */
349 			break;
350 		case 0x2: /* FHS */
351 			dissect_fhs(btbb_tree, tvb, offset);
352 			break;
353 		case 0x3: /* DM1 */
354 			dissect_dm1(btbb_tree, tvb, pinfo, offset);
355 			break;
356 		case 0x4: /* DH1/2-DH1 */
357 			dissect_dm1(btbb_tree, tvb, pinfo, offset);
358 			break;
359 		case 0x5: /* HV1 */
360 		case 0x6: /* HV2/2-EV3 */
361 		case 0x7: /* HV3/EV3/3-EV3 */
362 		case 0x8: /* DV/3-DH1 */
363 		case 0x9: /* AUX1 */
364 		case 0xa: /* DM3/2-DH3 */
365 		case 0xb: /* DH3/3-DH3 */
366 		case 0xc: /* EV4/2-EV5 */
367 		case 0xd: /* EV5/3-EV5 */
368 		case 0xe: /* DM5/2-DH5 */
369 		case 0xf: /* DH5/3-DH5 */
370 			proto_tree_add_item(btbb_tree, hf_btbb_payload, tvb, offset, -1, ENC_NA);
371 			break;
372 		default:
373 			break;
374 		}
375 	}
376 
377 	/* Return the amount of data this dissector was able to dissect */
378 	return tvb_reported_length(tvb);
379 }
380 
381 /* register the protocol with Wireshark */
382 void
383 proto_register_btbb(void)
384 {
385 	/* list of fields */
386 	static hf_register_info hf[] = {
387 		{ &hf_btbb_meta,
388 			{ "Meta Data", "btbb.meta",
389 			FT_NONE, BASE_NONE, NULL, 0x0,
390 			"Meta Data About the Packet", HFILL }
391 		},
392 		{ &hf_btbb_dir,
393 			{ "Direction", "btbb.dir",
394 			FT_BOOLEAN, 8, TFS(&direction), 0x01,
395 			"Direction of Transmission", HFILL }
396 		},
397 		{ &hf_btbb_clk,
398 			{ "CLK", "btbb.clk",
399 			FT_UINT32, BASE_HEX, NULL, 0x0,
400 			"Clock bits 1 through 27", HFILL }
401 		},
402 		{ &hf_btbb_channel,
403 			{ "Channel", "btbb.channel",
404 			FT_UINT8, BASE_DEC, NULL, 0x0,
405 			"Channel (0-78)", HFILL }
406 		},
407 		{ &hf_btbb_clkbits,
408 			{ "Known Clock Bits", "btbb.clkbits",
409 			FT_BOOLEAN, 8, TFS(&clock_bits), 0x01,
410 			"Number of Known Master CLK Bits (6 or 27)", HFILL }
411 		},
412 		{ &hf_btbb_addrbits,
413 			{ "Known Address Bits", "btbb.addrbits",
414 			FT_BOOLEAN, 8, TFS(&address_bits), 0x02,
415 			"Number of Known Bits of BD_ADDR (32 or 48)", HFILL }
416 		},
417 		{ &hf_btbb_pkthdr,
418 			{ "Packet Header", "btbb.pkthdr",
419 			FT_NONE, BASE_NONE, NULL, 0x0,
420 			"Bluetooth Baseband Packet Header", HFILL }
421 		},
422 		{ &hf_btbb_ltaddr,
423 			{ "LT_ADDR", "btbb.lt_addr",
424 			FT_UINT8, BASE_HEX, NULL, 0x07,
425 			"Logical Transport Address", HFILL }
426 		},
427 		{ &hf_btbb_type,
428 			{ "TYPE", "btbb.type",
429 			FT_UINT8, BASE_HEX, VALS(packet_types), 0x78,
430 			"Packet Type", HFILL }
431 		},
432 		{ &hf_btbb_flags,
433 			{ "Flags", "btbb.flags",
434 			FT_UINT8, BASE_HEX, NULL, 0x0,
435 			"Packet Header Flags", HFILL }
436 		},
437 		{ &hf_btbb_flow,
438 			{ "FLOW", "btbb.flow",
439 			FT_BOOLEAN, 8, NULL, 0x01,
440 			"Flow control indication", HFILL }
441 		},
442 		{ &hf_btbb_arqn,
443 			{ "ARQN", "btbb.arqn",
444 			FT_BOOLEAN, 8, NULL, 0x02,
445 			"Acknowledgment indication", HFILL }
446 		},
447 		{ &hf_btbb_seqn,
448 			{ "SEQN", "btbb.seqn",
449 			FT_BOOLEAN, 8, NULL, 0x04,
450 			"Sequence number", HFILL }
451 		},
452 		{ &hf_btbb_hec,
453 			{ "HEC", "btbb.lt_addr",
454 			FT_UINT8, BASE_HEX, NULL, 0x0,
455 			"Header Error Check", HFILL }
456 		},
457 		{ &hf_btbb_payload,
458 			{ "Payload", "btbb.payload",
459 			FT_NONE, BASE_NONE, NULL, 0x0,
460 			NULL, HFILL }
461 		},
462 		{ &hf_btbb_llid,
463 			{ "LLID", "btbb.llid",
464 			FT_UINT8, BASE_HEX, VALS(llid_codes), 0x03,
465 			"Logical Link ID", HFILL }
466 		},
467 		{ &hf_btbb_pldflow,
468 			{ "Flow", "btbb.flow",
469 			FT_BOOLEAN, 8, NULL, 0x04,
470 			"Payload Flow indication", HFILL }
471 		},
472 		{ &hf_btbb_length,
473 			{ "Length", "btbb.length",
474 			FT_UINT8, BASE_DEC, NULL, 0xf8,
475 			"Payload Length", HFILL }
476 		},
477 		{ &hf_btbb_pldhdr,
478 			{ "Payload Header", "btbb.pldhdr",
479 			FT_NONE, BASE_NONE, NULL, 0x0,
480 			NULL, HFILL }
481 		},
482 		{ &hf_btbb_pldbody,
483 			{ "Payload Body", "btbb.pldbody",
484 			FT_BYTES, BASE_NONE, NULL, 0x0,
485 			NULL, HFILL }
486 		},
487 		{ &hf_btbb_crc,
488 			{ "CRC", "btbb.crc",
489 			FT_UINT16, BASE_HEX, NULL, 0x0,
490 			"Payload CRC", HFILL }
491 		},
492 		{ &hf_btbb_fhs_parity,
493 			{ "Parity", "btbb.parity",
494 			/* FIXME this doesn't work because bitmasks can only be 32 bits */
495 			FT_UINT64, BASE_HEX, NULL, /*0x00000003ffffffffULL,*/ 0x0,
496 			"LAP parity", HFILL }
497 		},
498 		{ &hf_btbb_fhs_lap,
499 			{ "LAP", "btbb.lap",
500 			FT_UINT24, BASE_HEX, NULL, 0x03fffffc,
501 			"Lower Address Part", HFILL }
502 		},
503 		{ &hf_btbb_fhs_eir,
504 			{ "EIR", "btbb.eir",
505 			FT_BOOLEAN, 8, NULL, 0x04,
506 			"Extended Inquiry Response packet may follow", HFILL }
507 		},
508 		{ &hf_btbb_fhs_sr,
509 			{ "SR", "btbb.sr",
510 			FT_UINT8, BASE_HEX, VALS(sr_modes), 0x30,
511 			"Scan Repetition", HFILL }
512 		},
513 		{ &hf_btbb_fhs_uap,
514 			{ "UAP", "btbb.uap",
515 			FT_UINT8, BASE_HEX, NULL, 0x0,
516 			"Upper Address Part", HFILL }
517 		},
518 		{ &hf_btbb_fhs_nap,
519 			{ "NAP", "btbb.nap",
520 			FT_UINT16, BASE_HEX, NULL, 0x0,
521 			"Non-Significant Address Part", HFILL }
522 		},
523 		{ &hf_btbb_fhs_class, /* FIXME break out further */
524 			{ "Class of Device", "btbb.class",
525 			FT_UINT24, BASE_HEX, NULL, 0x0,
526 			NULL, HFILL }
527 		},
528 		{ &hf_btbb_fhs_ltaddr,
529 			{ "LT_ADDR", "btbb.lt_addr",
530 			FT_UINT8, BASE_HEX, NULL, 0x07,
531 			"Logical Transport Address", HFILL }
532 		},
533 		{ &hf_btbb_fhs_clk,
534 			{ "CLK", "btbb.clk",
535 			FT_UINT32, BASE_HEX, NULL, 0x1ffffff8,
536 			"Clock bits 2 through 27", HFILL }
537 		},
538 		{ &hf_btbb_fhs_psmode,
539 			{ "Page Scan Mode", "btbb.psmode",
540 			FT_UINT8, BASE_HEX, NULL, 0xe0,
541 			NULL, HFILL }
542 		},
543 	};
544 
545 	/* protocol subtree arrays */
546 	static gint *ett[] = {
547 		&ett_btbb,
548 		&ett_btbb_meta,
549 		&ett_btbb_pkthdr,
550 		&ett_btbb_flags,
551 		&ett_btbb_payload,
552 		&ett_btbb_pldhdr,
553 	};
554 
555 	/* register the protocol name and description */
556 	proto_btbb = proto_register_protocol(
557 		"Bluetooth Baseband",	/* full name */
558 		"BT Baseband",			/* short name */
559 		"btbb"			/* abbreviation (e.g. for filters) */
560 		);
561 
562 	/* register the header fields and subtrees used */
563 	proto_register_field_array(proto_btbb, hf, array_length(hf));
564 	proto_register_subtree_array(ett, array_length(ett));
565 }
566 
567 void
568 proto_reg_handoff_btbb(void)
569 {
570 	dissector_handle_t btbb_handle;
571 
572 	btbb_handle = new_create_dissector_handle(dissect_btbb, proto_btbb);
573 	/* hijacking this ethertype */
574 	dissector_add_uint("ethertype", 0xFFF0, btbb_handle);
575 	/* dissector_add_uint("wtap_encap", WTAP_ENCAP_BLUETOOTH_BASEBAND, btbb_handle); */
576 
577 	btbrlmp_handle = find_dissector("btbrlmp");
578 	btl2cap_handle = find_dissector("btl2cap");
579 }
580 
581 /*
582  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
583  *
584  * Local variables:
585  * c-basic-offset: 4
586  * tab-width: 8
587  * indent-tabs-mode: nil
588  * End:
589  *
590  * vi: set shiftwidth=4 tabstop=8 expandtab:
591  * :indentSize=4:tabSize=8:noTabs=true:
592  */
593