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