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