Define some fcns & vars as static...
[metze/wireshark/wip.git] / epan / dissectors / packet-btamp.c
1 /* packet-btamp.c
2  * Routines for the Bluetooth AMP dissection
3  *
4  * Copyright 2009, Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
5  *
6  * $Id$
7  *
8  * Wireshark - Network traffic analyzer
9  * By Gerald Combs <gerald@wireshark.org>
10  * Copyright 1998 Gerald Combs
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <glib.h>
32
33 #include <epan/packet.h>
34 #include "packet-btl2cap.h"
35
36 /* Initialize the protocol and registered fields */
37 static int proto_btamp = -1;
38 static int hf_btamp_command = -1;
39 static int hf_btamp_cmd_code = -1;
40 static int hf_btamp_cmd_ident = -1;
41 static int hf_btamp_cmd_length = -1;
42 static int hf_btamp_cmd_data = -1;
43 static int hf_btamp_rej_reason = -1;
44 static int hf_btamp_mtu = -1;
45 static int hf_btamp_extfeatures = -1;
46 static int hf_btamp_lcontroller_id = -1;
47 static int hf_btamp_rcontroller_id = -1;
48 static int hf_btamp_controller_list = -1;
49 static int hf_btamp_controllers = -1;
50 static int hf_btamp_controller_id = -1;
51 static int hf_btamp_controller_type = -1;
52 static int hf_btamp_controller_status = -1;
53 static int hf_btamp_status = -1;
54 static int hf_btamp_create_status = -1;
55 static int hf_btamp_disc_status = -1;
56 static int hf_btamp_total_bw = -1;
57 static int hf_btamp_max_guaran_bw = -1;
58 static int hf_btamp_min_latency = -1;
59 static int hf_btamp_pal_caps_guaranteed = -1;
60 static int hf_btamp_pal_caps_mask = -1;
61 static int hf_btamp_amp_assoc_size = -1;
62 static int hf_btamp_amp_assoc = -1;
63
64 /* Initialize the subtree pointers */
65 static gint ett_btamp = -1;
66 static gint ett_btamp_cmd = -1;
67 static gint ett_btamp_caps = -1;
68 static gint ett_btamp_controller_entry = -1;
69 static gint ett_btamp_controller_list = -1;
70
71 static const value_string command_code_vals[] = {
72     { 0x01, "AMP Command Reject" },
73     { 0x02, "AMP Discover Request" },
74     { 0x03, "AMP Discover Response" },
75     { 0x04, "AMP Change Notify" },
76     { 0x05, "AMP Change Response" },
77     { 0x06, "AMP Get Info Request" },
78     { 0x07, "AMP Get Info Response" },
79     { 0x08, "AMP Get AMP Assoc Request" },
80     { 0x09, "AMP Get AMP Assoc Response" },
81     { 0x0A, "AMP Create Physical Link Request" },
82     { 0x0B, "AMP Create Physical Link Response" },
83     { 0x0C, "AMP Disconnect Physical Link Request" },
84     { 0x0D, "AMP Disconnect Physical Link Response" },
85     { 0, NULL }
86 };
87
88 static const value_string reason_vals[] = {
89     { 0x0000,   "Command not understood" },
90     { 0, NULL }
91 };
92
93 static const value_string controller_type_vals[] = {
94     { 0x0000, "Bluetooth BR/EDR" },
95     { 0x0001, "802.11" },
96     { 0x0002, "ECMA-368" },
97     { 0, NULL }
98 };
99
100 static const value_string controller_status_vals[] = {
101     { 0x0000, "Controller available but currently physically powered down" },
102     { 0x0001, "Controller used exclusively by Bluetooth BR/EDR" },
103     { 0x0002, "Controller has no capacity available for Bluetooth operation" },
104     { 0x0003, "Controller has low capacity available for Bluetooth operation" },
105     { 0x0004, "Controller has medium capacity available for Bluetooth operation" },
106     { 0x0005, "Controller has high capacity available for Bluetooth operation" },
107     { 0x0006, "Controller has full capacity available for Bluetooth operation" },
108     { 0, NULL }
109 };
110
111 static const value_string status_vals[] = {
112     { 0x0000,   "Success" },
113     { 0x0001,   "Invalid Controller ID" },
114     { 0, NULL }
115 };
116
117 static const value_string create_status_vals[] = {
118     { 0x0000,   "Success" },
119     { 0x0001,   "Invalid Controller ID" },
120     { 0x0002,   "Failed - Unable to start link creation" },
121     { 0x0003,   "Failed - Collision Occurred" },
122     { 0x0004,   "Failed - AMP Disconnected Physical Link Request packet received" },
123     { 0x0005,   "Failed - Physical Link Already Exists" },
124     { 0, NULL }
125 };
126
127 static const value_string disc_status_vals[] = {
128     { 0x0000,   "Success" },
129     { 0x0001,   "Invalid Controller ID" },
130     { 0x0002,   "Failed - No Physical Link exists and no Physical Link creation is in progress" },
131     { 0, NULL }
132 };
133
134 static int
135 dissect_comrej(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
136 {
137     guint16 reason;
138
139     reason = tvb_get_letohs(tvb, offset);
140     proto_tree_add_item(tree, hf_btamp_rej_reason, tvb, offset, 2, TRUE);
141     offset+=2;
142
143     switch(reason){
144     case 0x0000: /* Command not understood */
145         break;
146
147     default:
148         break;
149     }
150
151     return offset;
152 }
153
154 static int
155 dissect_discoverrequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
156 {
157     proto_tree_add_item(tree, hf_btamp_mtu, tvb, offset, 2, TRUE);
158     offset+=2;
159
160     proto_tree_add_item(tree, hf_btamp_extfeatures, tvb, offset, 2, TRUE);
161     offset+=2;
162
163     return offset;
164 }
165
166 static int
167 dissect_controller_entry(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint16 idx)
168 {
169     proto_tree *btamp_controller_entry_tree=NULL;
170     proto_item *ti_controller_entry=NULL;
171
172     ti_controller_entry=proto_tree_add_none_format(tree,
173             hf_btamp_controllers, tvb,
174             offset, 3,
175             "Entry: %u", idx);
176     btamp_controller_entry_tree=proto_item_add_subtree(ti_controller_entry, ett_btamp_controller_entry);
177
178     proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_id, tvb, offset, 1, TRUE);
179     offset+=1;
180
181     proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_type, tvb, offset, 1, TRUE);
182     offset+=1;
183
184     proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_status, tvb, offset, 1, TRUE);
185     offset+=1;
186
187     return offset;
188 }
189
190 static int
191 dissect_discoverresponse(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
192 {
193     guint16 length;
194     guint16 idx = 1;
195     proto_tree *btamp_controller_list_tree=NULL;
196     proto_item *ti_controller_list=NULL;
197
198     proto_tree_add_item(tree, hf_btamp_mtu, tvb, offset, 2, TRUE);
199     offset+=2;
200
201     proto_tree_add_item(tree, hf_btamp_extfeatures, tvb, offset, 2, TRUE);
202     offset+=2;
203
204     length = tvb_length_remaining(tvb, offset);
205     ti_controller_list=proto_tree_add_none_format(tree,
206             hf_btamp_controller_list, tvb,
207             offset, length,
208             "Controller list");
209     btamp_controller_list_tree=proto_item_add_subtree(ti_controller_list, ett_btamp_controller_list);
210
211     while ((length = tvb_length_remaining(tvb, offset)) >= 3) {
212         offset = dissect_controller_entry(tvb, offset, pinfo, btamp_controller_list_tree, idx);
213         ++idx;
214     }
215
216     return offset;
217 }
218
219 static int
220 dissect_changenotify(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
221 {
222     guint16 length;
223     guint16 idx = 1;
224     proto_tree *btamp_controller_list_tree=NULL;
225     proto_item *ti_controller_list=NULL;
226
227     length = tvb_length_remaining(tvb, offset);
228     ti_controller_list=proto_tree_add_none_format(tree,
229             hf_btamp_controller_list, tvb,
230             offset, length,
231             "Controller list");
232     btamp_controller_list_tree=proto_item_add_subtree(ti_controller_list, ett_btamp_controller_list);
233
234     while ((length = tvb_length_remaining(tvb, offset)) >= 3) {
235         offset = dissect_controller_entry(tvb, offset, pinfo, btamp_controller_list_tree, idx);
236         ++idx;
237     }
238
239     return offset;
240 }
241
242 static int
243 dissect_changeresponse(tvbuff_t *tvb _U_, int offset, packet_info *pinfo _U_, proto_tree *tree _U_)
244 {
245     return offset;
246 }
247
248 static int
249 dissect_getinforequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
250 {
251     proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, TRUE);
252     offset+=1;
253
254     return offset;
255 }
256
257 static int
258 dissect_getinforesponse(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
259 {
260     proto_tree *btamp_controller_tree=NULL;
261     proto_item *ti_controller=NULL;
262
263     proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, TRUE);
264     offset+=1;
265
266     proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, TRUE);
267     offset+=1;
268
269     proto_tree_add_item(tree, hf_btamp_total_bw, tvb, offset, 4, TRUE);
270     offset+=4;
271
272     proto_tree_add_item(tree, hf_btamp_max_guaran_bw, tvb, offset, 4, TRUE);
273     offset+=4;
274
275     proto_tree_add_item(tree, hf_btamp_min_latency, tvb, offset, 4, TRUE);
276     offset+=4;
277
278     ti_controller=proto_tree_add_none_format(tree,
279             hf_btamp_pal_caps_mask, tvb,
280             offset, 2,
281             "PAL Capabilities");
282     btamp_controller_tree=proto_item_add_subtree(ti_controller, ett_btamp_caps);
283     proto_tree_add_item(btamp_controller_tree, hf_btamp_pal_caps_guaranteed, tvb, offset, 2, TRUE);
284     offset+=2;
285
286     proto_tree_add_item(tree, hf_btamp_amp_assoc_size, tvb, offset, 2, TRUE);
287     offset+=2;
288
289     return offset;
290 }
291
292 static int
293 dissect_getampassocrequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
294 {
295     proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, TRUE);
296     offset+=1;
297
298     return offset;
299 }
300
301 static int
302 dissect_ampassoc(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
303 {
304     proto_tree_add_item(tree, hf_btamp_amp_assoc, tvb, offset, tvb_length_remaining(tvb, offset), TRUE);
305     offset+=tvb_length_remaining(tvb, offset);
306
307     return offset;
308 }
309
310 static int
311 dissect_getampassocresponse(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
312 {
313     proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, TRUE);
314     offset+=1;
315
316     proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, TRUE);
317     offset+=1;
318
319     offset=dissect_ampassoc(tvb, offset, pinfo, tree);
320
321     return offset;
322 }
323
324 static int
325 dissect_createphysicalrequest(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
326 {
327     proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, TRUE);
328     offset+=1;
329
330     proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, TRUE);
331     offset+=1;
332
333     offset=dissect_ampassoc(tvb, offset, pinfo, tree);
334
335     return offset;
336 }
337
338 static int
339 dissect_createphysicalresponse(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
340 {
341     proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, TRUE);
342     offset+=1;
343
344     proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, TRUE);
345     offset+=1;
346
347     proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, TRUE);
348     offset+=1;
349
350     return offset;
351 }
352
353 static int
354 dissect_discphysicalchanrequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
355 {
356     proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, TRUE);
357     offset+=1;
358
359     proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, TRUE);
360     offset+=1;
361
362     return offset;
363 }
364
365 static int
366 dissect_discphysicalchanresponse(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
367 {
368     proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, TRUE);
369     offset+=1;
370
371     proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, TRUE);
372     offset+=1;
373
374     proto_tree_add_item(tree, hf_btamp_controller_status, tvb, offset, 1, TRUE);
375     offset+=1;
376
377     return offset;
378 }
379
380 static void dissect_btamp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
381 {
382     int offset=0;
383     proto_item *ti=NULL;
384     proto_tree *btamp_tree=NULL;
385     guint16 length;
386     proto_tree *btamp_cmd_tree=NULL;
387     proto_item *ti_command=NULL;
388     guint8 cmd_code;
389     guint16 cmd_length;
390
391     col_set_str(pinfo->cinfo, COL_PROTOCOL, "AMP");
392     col_set_str(pinfo->cinfo, COL_INFO, pinfo->p2p_dir == P2P_DIR_SENT ? "Sent " : "Rcvd ");
393
394     if(tree){
395         ti=proto_tree_add_item(tree, proto_btamp, tvb, offset, -1, FALSE);
396         btamp_tree=proto_item_add_subtree(ti, ett_btamp);
397     }
398
399     length = tvb_length_remaining(tvb, offset);
400     ti_command=proto_tree_add_none_format(btamp_tree,
401             hf_btamp_command, tvb,
402             offset, length,
403             "Command: ");
404     btamp_cmd_tree=proto_item_add_subtree(ti_command, ett_btamp_cmd);
405
406     cmd_code=tvb_get_guint8(tvb, offset);
407     proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_code, tvb, offset, 1, TRUE);
408     offset++;
409
410     proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_ident, tvb, offset, 1, TRUE);
411     offset++;
412
413     cmd_length=tvb_get_letohs(tvb, offset);
414     proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_length, tvb, offset, 2, TRUE);
415     proto_item_set_len(ti_command, cmd_length+4);
416     offset+=2;
417
418     switch(cmd_code) {
419     case 0x01: /* Command Reject */
420         offset=dissect_comrej(tvb, offset, pinfo, btamp_cmd_tree);
421         break;
422
423     case 0x02: /* Discover Request */
424         offset=dissect_discoverrequest(tvb, offset, pinfo, btamp_cmd_tree);
425         break;
426
427     case 0x03: /* Discover Response */
428         offset=dissect_discoverresponse(tvb, offset, pinfo, btamp_cmd_tree);
429         break;
430
431     case 0x04: /* AMP Change Notify */
432         offset=dissect_changenotify(tvb, offset, pinfo, btamp_cmd_tree);
433         break;
434
435     case 0x05: /* AMP Change Response */
436         offset=dissect_changeresponse(tvb, offset, pinfo, btamp_cmd_tree);
437         break;
438
439     case 0x06: /* AMP Get Info Request */
440         offset=dissect_getinforequest(tvb, offset, pinfo, btamp_cmd_tree);
441         break;
442
443     case 0x07: /* AMP Get Info Response */
444         offset=dissect_getinforesponse(tvb, offset, pinfo, btamp_cmd_tree);
445         break;
446
447     case 0x08: /* Get AMP Assoc Request */
448         offset=dissect_getampassocrequest(tvb, offset, pinfo, btamp_cmd_tree);
449         break;
450
451     case 0x09: /* Get AMP Assoc Response */
452         offset=dissect_getampassocresponse(tvb, offset, pinfo, btamp_cmd_tree);
453         break;
454
455     case 0x0A: /* Create Physical Link Request */
456         offset=dissect_createphysicalrequest(tvb, offset, pinfo, btamp_cmd_tree);
457         break;
458
459     case 0x0B: /* Create Physical Link Response */
460         offset=dissect_createphysicalresponse(tvb, offset, pinfo, btamp_cmd_tree);
461         break;
462
463     case 0x0c: /* Disconnect Physical Link Request */
464         offset=dissect_discphysicalchanrequest(tvb, offset, pinfo, btamp_cmd_tree);
465         break;
466
467     case 0x0d: /* Disconnect Physical Link Response */
468         offset=dissect_discphysicalchanresponse(tvb, offset, pinfo, btamp_cmd_tree);
469         break;
470
471     default:
472         proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_data, tvb, offset, -1, TRUE);
473         offset+=tvb_length_remaining(tvb, offset);
474         break;
475     }
476
477     proto_item_append_text(ti_command, "%s", val_to_str(cmd_code, command_code_vals, "Unknown PDU (%u)"));
478     col_append_str(pinfo->cinfo, COL_INFO, val_to_str(cmd_code, command_code_vals, "Unknown PDU (%u)"));
479 }
480
481 /* Register the protocol with Wireshark */
482 void
483 proto_register_btamp(void)
484 {
485     /* Setup list of header fields  See Section 1.6.1 for details*/
486     static hf_register_info hf[] = {
487         { &hf_btamp_command,
488             { "Command",           "btamp.command",
489                 FT_NONE, BASE_NONE, NULL, 0x0,
490                 "L2CAP Command", HFILL }
491         },
492         { &hf_btamp_cmd_code,
493             { "Command Code",           "btamp.cmd_code",
494                 FT_UINT8, BASE_HEX, VALS(command_code_vals), 0x0,
495                 "L2CAP Command Code", HFILL }
496         },
497         { &hf_btamp_cmd_ident,
498             { "Command Identifier",           "btamp.cmd_ident",
499                 FT_UINT8, BASE_HEX, NULL, 0x0,
500                 "L2CAP Command Identifier", HFILL }
501         },
502         { &hf_btamp_cmd_length,
503             { "Command Length",           "btamp.cmd_length",
504                 FT_UINT8, BASE_DEC, NULL, 0x0,
505                 "L2CAP Command Length", HFILL }
506         },
507         { &hf_btamp_cmd_data,
508             { "Command Data",           "btamp.cmd_data",
509                 FT_NONE, BASE_NONE, NULL, 0x0,
510                 "L2CAP Command Data", HFILL }
511         },
512         { &hf_btamp_rej_reason,
513             { "Reason",           "btl2cap.rej_reason",
514                 FT_UINT16, BASE_HEX, VALS(reason_vals), 0x0,
515                 NULL, HFILL }
516         },
517         { &hf_btamp_mtu,
518             { "MPS/MTU",           "btamp.mps",
519                 FT_UINT16, BASE_HEX, NULL, 0x0,
520                 "MPS/MTU Size", HFILL }
521         },
522         { &hf_btamp_extfeatures,
523             { "Extended Features",           "btamp.extfeatures",
524                 FT_UINT16, BASE_HEX, NULL, 0x0,
525                 "Extended Features Mask", HFILL }
526         },
527         { &hf_btamp_controllers,
528             { "Controller entry",           "btamp.ctrl_entry",
529                 FT_NONE, BASE_NONE, NULL, 0x0,
530                 NULL, HFILL }
531         },
532         { &hf_btamp_controller_list,
533             { "Controller list",           "btamp.ctrl_list",
534                 FT_NONE, BASE_NONE, NULL, 0x0,
535                 NULL, HFILL }
536         },
537         { &hf_btamp_lcontroller_id,
538             { "Local Controller ID",           "btamp.lctrl_id",
539                 FT_UINT8, BASE_DEC, NULL, 0x0,
540                 NULL, HFILL }
541         },
542         { &hf_btamp_rcontroller_id,
543             { "Remote Controller ID",           "btamp.rctrl_id",
544                 FT_UINT8, BASE_DEC, NULL, 0x0,
545                 NULL, HFILL }
546         },
547         { &hf_btamp_controller_id,
548             { "Controller ID",           "btamp.ctrl_id",
549                 FT_UINT8, BASE_DEC, NULL, 0x0,
550                 NULL, HFILL }
551         },
552         { &hf_btamp_controller_type,
553             { "Controller Type",           "btamp.ctrl_type",
554                 FT_UINT8, BASE_DEC, VALS(controller_type_vals), 0x0,
555                 NULL, HFILL }
556         },
557         { &hf_btamp_controller_status,
558             { "Controller Status",           "btamp.ctrl_status",
559                 FT_UINT8, BASE_DEC, VALS(controller_status_vals), 0x0,
560                 NULL, HFILL }
561         },
562         { &hf_btamp_status,
563             { "Status",           "btamp.status",
564                 FT_UINT8, BASE_DEC, VALS(status_vals), 0x0,
565                 NULL, HFILL }
566         },
567         { &hf_btamp_create_status,
568             { "Status",           "btamp.create_status",
569                 FT_UINT8, BASE_DEC, VALS(create_status_vals), 0x0,
570                 NULL, HFILL }
571         },
572         { &hf_btamp_disc_status,
573             { "Status",           "btamp.disc_status",
574                 FT_UINT8, BASE_DEC, VALS(disc_status_vals), 0x0,
575                 NULL, HFILL }
576         },
577         { &hf_btamp_pal_caps_mask,
578             { "PAL Capabilities Mask",           "btamp.pal_caps_mask",
579                 FT_NONE, BASE_NONE, NULL, 0x0,
580                 NULL, HFILL }
581         },
582         { &hf_btamp_pal_caps_guaranteed,
583             { "Guaranteed Service type",           "btamp.guaranteed_type",
584                 FT_BOOLEAN, 16, NULL, 0x01,
585                 NULL, HFILL }
586         },
587         { &hf_btamp_total_bw,
588             { "Total Bandwidth",           "btamp.total_bw",
589                 FT_UINT32, BASE_HEX, NULL, 0x0,
590                 NULL, HFILL }
591         },
592         { &hf_btamp_max_guaran_bw,
593             { "Max Guaranteed Bandwidth",           "btamp.max_guaran_bw",
594                 FT_UINT32, BASE_HEX, NULL, 0x0,
595                 NULL, HFILL }
596         },
597         { &hf_btamp_min_latency,
598             { "Minimum latency",           "btamp.min_latency",
599                 FT_UINT32, BASE_HEX, NULL, 0x0,
600                 NULL, HFILL }
601         },
602         { &hf_btamp_amp_assoc_size,
603             { "Assoc Size",           "btamp.assoc_size",
604                 FT_UINT16, BASE_HEX, NULL, 0x0,
605                 NULL, HFILL }
606         },
607         { &hf_btamp_amp_assoc,
608             { "Assoc",        "btamp.assoc",
609                 FT_BYTES, BASE_NONE, NULL, 0x0,
610                 NULL, HFILL }
611         },
612     };
613
614     /* Setup protocol subtree array */
615     static gint *ett[] = {
616         &ett_btamp,
617         &ett_btamp_cmd,
618         &ett_btamp_caps,
619         &ett_btamp_controller_entry,
620         &ett_btamp_controller_list,
621     };
622
623     /* Register the protocol name and description */
624     proto_btamp = proto_register_protocol("Bluetooth AMP Packet", "AMP", "btamp");
625
626     register_dissector("btamp", dissect_btamp, proto_btamp);
627
628     /* Required function calls to register the header fields and subtrees used */
629     proto_register_field_array(proto_btamp, hf, array_length(hf));
630     proto_register_subtree_array(ett, array_length(ett));
631 }
632
633 void
634 proto_reg_handoff_btamp(void)
635 {
636     dissector_handle_t btamp_handle;
637
638     btamp_handle = find_dissector("btamp");
639     dissector_add("btl2cap.cid", BTL2CAP_FIXED_CID_AMP_MAN, btamp_handle);
640 }
641