summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-btamp.c
blob: afb0543f2a15bd5ed1390f72f0f31ec4dc9231b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
/* packet-btamp.c
 * Routines for the Bluetooth AMP dissection
 *
 * Copyright 2009, Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
 *
 * Wireshark - Network traffic analyzer
 * By Gerald Combs <gerald@wireshark.org>
 * Copyright 1998 Gerald Combs
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "config.h"

#include <epan/packet.h>

#include "packet-btl2cap.h"

/* Initialize the protocol and registered fields */
static int proto_btamp = -1;
static int hf_btamp_command = -1;
static int hf_btamp_cmd_code = -1;
static int hf_btamp_cmd_ident = -1;
static int hf_btamp_cmd_length = -1;
static int hf_btamp_cmd_data = -1;
static int hf_btamp_rej_reason = -1;
static int hf_btamp_mtu = -1;
static int hf_btamp_extfeatures = -1;
static int hf_btamp_lcontroller_id = -1;
static int hf_btamp_rcontroller_id = -1;
static int hf_btamp_controller_list = -1;
static int hf_btamp_controllers = -1;
static int hf_btamp_controller_id = -1;
static int hf_btamp_controller_type = -1;
static int hf_btamp_controller_status = -1;
static int hf_btamp_status = -1;
/* static int hf_btamp_create_status = -1; */
/* static int hf_btamp_disc_status = -1; */
static int hf_btamp_total_bw = -1;
static int hf_btamp_max_guaran_bw = -1;
static int hf_btamp_min_latency = -1;
static int hf_btamp_pal_caps_guaranteed = -1;
static int hf_btamp_pal_caps_mask = -1;
static int hf_btamp_amp_assoc_size = -1;
static int hf_btamp_amp_assoc = -1;

/* Initialize the subtree pointers */
static gint ett_btamp = -1;
static gint ett_btamp_cmd = -1;
static gint ett_btamp_caps = -1;
static gint ett_btamp_controller_entry = -1;
static gint ett_btamp_controller_list = -1;

static dissector_handle_t btamp_handle;


static const value_string command_code_vals[] = {
    { 0x01, "AMP Command Reject" },
    { 0x02, "AMP Discover Request" },
    { 0x03, "AMP Discover Response" },
    { 0x04, "AMP Change Notify" },
    { 0x05, "AMP Change Response" },
    { 0x06, "AMP Get Info Request" },
    { 0x07, "AMP Get Info Response" },
    { 0x08, "AMP Get AMP Assoc Request" },
    { 0x09, "AMP Get AMP Assoc Response" },
    { 0x0A, "AMP Create Physical Link Request" },
    { 0x0B, "AMP Create Physical Link Response" },
    { 0x0C, "AMP Disconnect Physical Link Request" },
    { 0x0D, "AMP Disconnect Physical Link Response" },
    { 0, NULL }
};

static const value_string reason_vals[] = {
    { 0x0000, "Command not understood" },
    { 0, NULL }
};

static const value_string controller_type_vals[] = {
    { 0x0000, "Bluetooth BR/EDR" },
    { 0x0001, "802.11" },
    { 0x0002, "ECMA-368" },
    { 0, NULL }
};

static const value_string controller_status_vals[] = {
    { 0x0000, "Controller available but currently physically powered down" },
    { 0x0001, "Controller used exclusively by Bluetooth BR/EDR" },
    { 0x0002, "Controller has no capacity available for Bluetooth operation" },
    { 0x0003, "Controller has low capacity available for Bluetooth operation" },
    { 0x0004, "Controller has medium capacity available for Bluetooth operation" },
    { 0x0005, "Controller has high capacity available for Bluetooth operation" },
    { 0x0006, "Controller has full capacity available for Bluetooth operation" },
    { 0, NULL }
};

static const value_string status_vals[] = {
    { 0x0000, "Success" },
    { 0x0001, "Invalid Controller ID" },
    { 0, NULL }
};

#if 0
static const value_string create_status_vals[] = {
    { 0x0000, "Success" },
    { 0x0001, "Invalid Controller ID" },
    { 0x0002, "Failed - Unable to start link creation" },
    { 0x0003, "Failed - Collision Occurred" },
    { 0x0004, "Failed - AMP Disconnected Physical Link Request packet received" },
    { 0x0005, "Failed - Physical Link Already Exists" },
    { 0, NULL }
};

static const value_string disc_status_vals[] = {
    { 0x0000, "Success" },
    { 0x0001, "Invalid Controller ID" },
    { 0x0002, "Failed - No Physical Link exists and no Physical Link creation is in progress" },
    { 0, NULL }
};
#endif

void proto_register_btamp(void);
void proto_reg_handoff_btamp(void);

static int
dissect_comrej(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    guint16 reason;

    reason = tvb_get_letohs(tvb, offset);
    proto_tree_add_item(tree, hf_btamp_rej_reason, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    switch (reason) {
    case 0x0000: /* Command not understood */
        break;

    default:
        break;
    }

    return offset;
}

static int
dissect_discoverrequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_mtu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    proto_tree_add_item(tree, hf_btamp_extfeatures, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    return offset;
}

static int
dissect_controller_entry(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint16 idx)
{
    proto_item *ti_controller_entry;
    proto_tree *btamp_controller_entry_tree;

    ti_controller_entry = proto_tree_add_none_format(tree,
            hf_btamp_controllers, tvb,
            offset, 3,
            "Entry: %u", idx);
    btamp_controller_entry_tree = proto_item_add_subtree(ti_controller_entry, ett_btamp_controller_entry);

    proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(btamp_controller_entry_tree, hf_btamp_controller_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_discoverresponse(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
    guint16     length;
    guint16     idx = 1;
    proto_item *ti_controller_list;
    proto_tree *btamp_controller_list_tree;

    proto_tree_add_item(tree, hf_btamp_mtu, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    proto_tree_add_item(tree, hf_btamp_extfeatures, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    length = tvb_reported_length_remaining(tvb, offset);
    ti_controller_list = proto_tree_add_none_format(tree,
            hf_btamp_controller_list, tvb,
            offset, length,
            "Controller list");
    btamp_controller_list_tree = proto_item_add_subtree(ti_controller_list, ett_btamp_controller_list);

    while (tvb_reported_length_remaining(tvb, offset) >= 3) {
        offset = dissect_controller_entry(tvb, offset, pinfo, btamp_controller_list_tree, idx);
        idx += 1;
    }

    return offset;
}

static int
dissect_changenotify(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
    guint16     length;
    guint16     idx = 1;
    proto_item *ti_controller_list;
    proto_tree *btamp_controller_list_tree;

    length = tvb_reported_length_remaining(tvb, offset);
    ti_controller_list = proto_tree_add_none_format(tree,
            hf_btamp_controller_list, tvb,
            offset, length,
            "Controller list");
    btamp_controller_list_tree = proto_item_add_subtree(ti_controller_list, ett_btamp_controller_list);

    while (tvb_reported_length_remaining(tvb, offset) >= 3) {
        offset = dissect_controller_entry(tvb, offset, pinfo, btamp_controller_list_tree, idx);
        idx += 1;
    }

    return offset;
}

static int
dissect_changeresponse(tvbuff_t *tvb _U_, int offset, packet_info *pinfo _U_, proto_tree *tree _U_)
{
    return offset;
}

static int
dissect_getinforequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_getinforesponse(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_item *ti_controller;
    proto_tree *btamp_controller_tree;

    proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_total_bw, tvb, offset, 4, ENC_LITTLE_ENDIAN);
    offset += 4;

    proto_tree_add_item(tree, hf_btamp_max_guaran_bw, tvb, offset, 4, ENC_LITTLE_ENDIAN);
    offset += 4;

    proto_tree_add_item(tree, hf_btamp_min_latency, tvb, offset, 4, ENC_LITTLE_ENDIAN);
    offset += 4;

    ti_controller = proto_tree_add_none_format(tree,
            hf_btamp_pal_caps_mask, tvb,
            offset, 2,
            "PAL Capabilities");
    btamp_controller_tree = proto_item_add_subtree(ti_controller, ett_btamp_caps);
    proto_tree_add_item(btamp_controller_tree, hf_btamp_pal_caps_guaranteed, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    proto_tree_add_item(tree, hf_btamp_amp_assoc_size, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    offset += 2;

    return offset;
}

static int
dissect_getampassocrequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_ampassoc(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_amp_assoc, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA);
    return tvb_reported_length(tvb);
}

static int
dissect_getampassocresponse(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_controller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    offset = dissect_ampassoc(tvb, offset, pinfo, tree);

    return offset;
}

static int
dissect_createphysicalrequest(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    offset = dissect_ampassoc(tvb, offset, pinfo, tree);

    return offset;
}

static int
dissect_createphysicalresponse(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_discphysicalchanrequest(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_discphysicalchanresponse(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
{
    proto_tree_add_item(tree, hf_btamp_lcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_rcontroller_id, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(tree, hf_btamp_controller_status, tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    return offset;
}

static int
dissect_btamp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
    int         offset         = 0;
    proto_item *ti;
    proto_tree *btamp_tree;
    guint16     length;
    proto_item *ti_command;
    proto_tree *btamp_cmd_tree;
    guint8      cmd_code;
    guint16     cmd_length;

    col_set_str(pinfo->cinfo, COL_PROTOCOL, "AMP");

    switch (pinfo->p2p_dir) {
        case P2P_DIR_SENT:
            col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
            break;
        case P2P_DIR_RECV:
            col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
            break;
        default:
            col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection ");
            break;
    }

    ti = proto_tree_add_item(tree, proto_btamp, tvb, offset, -1, ENC_NA);
    btamp_tree = proto_item_add_subtree(ti, ett_btamp);

    length = tvb_reported_length_remaining(tvb, offset);
    ti_command = proto_tree_add_none_format(btamp_tree,
            hf_btamp_command, tvb,
            offset, length,
            "Command: ");
    btamp_cmd_tree = proto_item_add_subtree(ti_command, ett_btamp_cmd);

    cmd_code = tvb_get_guint8(tvb, offset);
    proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_code,   tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_ident,  tvb, offset, 1, ENC_LITTLE_ENDIAN);
    offset += 1;

    cmd_length = tvb_get_letohs(tvb, offset);
    proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
    proto_item_set_len(ti_command, cmd_length+4);
    offset += 2;

    switch(cmd_code) {
    case 0x01: /* Command Reject */
        offset = dissect_comrej(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x02: /* Discover Request */
        offset = dissect_discoverrequest(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x03: /* Discover Response */
        offset = dissect_discoverresponse(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x04: /* AMP Change Notify */
        offset = dissect_changenotify(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x05: /* AMP Change Response */
        offset = dissect_changeresponse(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x06: /* AMP Get Info Request */
        offset = dissect_getinforequest(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x07: /* AMP Get Info Response */
        offset = dissect_getinforesponse(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x08: /* Get AMP Assoc Request */
        offset = dissect_getampassocrequest(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x09: /* Get AMP Assoc Response */
        offset = dissect_getampassocresponse(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x0A: /* Create Physical Link Request */
        offset = dissect_createphysicalrequest(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x0B: /* Create Physical Link Response */
        offset = dissect_createphysicalresponse(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x0c: /* Disconnect Physical Link Request */
        offset = dissect_discphysicalchanrequest(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    case 0x0d: /* Disconnect Physical Link Response */
        offset = dissect_discphysicalchanresponse(tvb, offset, pinfo, btamp_cmd_tree);
        break;

    default:
        proto_tree_add_item(btamp_cmd_tree, hf_btamp_cmd_data, tvb, offset, -1, ENC_NA);
        offset = tvb_reported_length(tvb);
        break;
    }

    proto_item_append_text(ti_command, "%s", val_to_str(cmd_code, command_code_vals, "Unknown PDU (%u)"));
    col_append_str(pinfo->cinfo, COL_INFO, val_to_str(cmd_code, command_code_vals, "Unknown PDU (%u)"));

    return offset;
}

/* Register the protocol with Wireshark */
void
proto_register_btamp(void)
{
    /* Setup list of header fields  See Section 1.6.1 for details*/
    static hf_register_info hf[] = {
        { &hf_btamp_command,
            { "Command",           "btamp.command",
                FT_NONE, BASE_NONE, NULL, 0x0,
                "L2CAP Command", HFILL }
        },
        { &hf_btamp_cmd_code,
            { "Command Code",           "btamp.cmd_code",
                FT_UINT8, BASE_HEX, VALS(command_code_vals), 0x0,
                "L2CAP Command Code", HFILL }
        },
        { &hf_btamp_cmd_ident,
            { "Command Identifier",           "btamp.cmd_ident",
                FT_UINT8, BASE_HEX, NULL, 0x0,
                "L2CAP Command Identifier", HFILL }
        },
        { &hf_btamp_cmd_length,
            { "Command Length",           "btamp.cmd_length",
                FT_UINT16, BASE_DEC, NULL, 0x0,
                "L2CAP Command Length", HFILL }
        },
        { &hf_btamp_cmd_data,
            { "Command Data",           "btamp.cmd_data",
                FT_NONE, BASE_NONE, NULL, 0x0,
                "L2CAP Command Data", HFILL }
        },
        { &hf_btamp_rej_reason,
            { "Reason",           "btamp.rej_reason",
                FT_UINT16, BASE_HEX, VALS(reason_vals), 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_mtu,
            { "MPS/MTU",           "btamp.mps",
                FT_UINT16, BASE_HEX, NULL, 0x0,
                "MPS/MTU Size", HFILL }
        },
        { &hf_btamp_extfeatures,
            { "Extended Features",           "btamp.extfeatures",
                FT_UINT16, BASE_HEX, NULL, 0x0,
                "Extended Features Mask", HFILL }
        },
        { &hf_btamp_controllers,
            { "Controller entry",           "btamp.ctrl_entry",
                FT_NONE, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_controller_list,
            { "Controller list",           "btamp.ctrl_list",
                FT_NONE, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_lcontroller_id,
            { "Local Controller ID",           "btamp.lctrl_id",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_rcontroller_id,
            { "Remote Controller ID",           "btamp.rctrl_id",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_controller_id,
            { "Controller ID",           "btamp.ctrl_id",
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_controller_type,
            { "Controller Type",           "btamp.ctrl_type",
                FT_UINT8, BASE_DEC, VALS(controller_type_vals), 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_controller_status,
            { "Controller Status",           "btamp.ctrl_status",
                FT_UINT8, BASE_DEC, VALS(controller_status_vals), 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_status,
            { "Status",           "btamp.status",
                FT_UINT8, BASE_DEC, VALS(status_vals), 0x0,
                NULL, HFILL }
        },
#if 0
        { &hf_btamp_create_status,
            { "Status",           "btamp.create_status",
                FT_UINT8, BASE_DEC, VALS(create_status_vals), 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_disc_status,
            { "Status",           "btamp.disc_status",
                FT_UINT8, BASE_DEC, VALS(disc_status_vals), 0x0,
                NULL, HFILL }
        },
#endif
        { &hf_btamp_pal_caps_mask,
            { "PAL Capabilities Mask",           "btamp.pal_caps_mask",
                FT_NONE, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_pal_caps_guaranteed,
            { "Guaranteed Service type",           "btamp.guaranteed_type",
                FT_BOOLEAN, 16, NULL, 0x0001,
                NULL, HFILL }
        },
        { &hf_btamp_total_bw,
            { "Total Bandwidth",           "btamp.total_bw",
                FT_UINT32, BASE_HEX, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_max_guaran_bw,
            { "Max Guaranteed Bandwidth",           "btamp.max_guaran_bw",
                FT_UINT32, BASE_HEX, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_min_latency,
            { "Minimum latency",           "btamp.min_latency",
                FT_UINT32, BASE_HEX, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_amp_assoc_size,
            { "Assoc Size",           "btamp.assoc_size",
                FT_UINT16, BASE_HEX, NULL, 0x0,
                NULL, HFILL }
        },
        { &hf_btamp_amp_assoc,
            { "Assoc",        "btamp.assoc",
                FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
        },
    };

    /* Setup protocol subtree array */
    static gint *ett[] = {
        &ett_btamp,
        &ett_btamp_cmd,
        &ett_btamp_caps,
        &ett_btamp_controller_entry,
        &ett_btamp_controller_list,
    };

    /* Register the protocol name and description */
    proto_btamp = proto_register_protocol("Bluetooth AMP Packet", "BT AMP", "btamp");

    btamp_handle = register_dissector("btamp", dissect_btamp, proto_btamp);

    /* Required function calls to register the header fields and subtrees used */
    proto_register_field_array(proto_btamp, hf, array_length(hf));
    proto_register_subtree_array(ett, array_length(ett));
}

void
proto_reg_handoff_btamp(void)
{
    dissector_add_uint("btl2cap.cid", BTL2CAP_FIXED_CID_AMP_MAN, btamp_handle);
}

/*
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
 *
 * Local variables:
 * c-basic-offset: 4
 * tab-width: 8
 * indent-tabs-mode: nil
 * End:
 *
 * vi: set shiftwidth=4 tabstop=8 expandtab:
 * :indentSize=4:tabSize=8:noTabs=true:
 */