Coverage Report

Created: 2026-01-02 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wireshark/epan/dissectors/packet-btbnep.c
Line
Count
Source
1
/* packet-btbnep.c
2
 * Routines for Bluetooth BNEP dissection
3
 *
4
 * Copyright 2012, Michal Labedzki for Tieto Corporation
5
 *
6
 * Wireshark - Network traffic analyzer
7
 * By Gerald Combs <gerald@wireshark.org>
8
 * Copyright 1998 Gerald Combs
9
 *
10
 * SPDX-License-Identifier: GPL-2.0-or-later
11
 */
12
13
#include "config.h"
14
15
#include <epan/packet.h>
16
#include <epan/prefs.h>
17
#include <epan/etypes.h>
18
#include <epan/expert.h>
19
20
#include "packet-bluetooth.h"
21
#include "packet-btl2cap.h"
22
#include "packet-btsdp.h"
23
24
4
#define BNEP_TYPE_GENERAL_ETHERNET                                          0x00
25
2
#define BNEP_TYPE_CONTROL                                                   0x01
26
#define BNEP_TYPE_COMPRESSED_ETHERNET                                       0x02
27
1
#define BNEP_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY                           0x03
28
1
#define BNEP_TYPE_COMPRESSED_ETHERNET_DESTINATION_ONLY                      0x04
29
#define RESERVED_802                                                        0x7F
30
31
static int proto_btbnep;
32
static int hf_btbnep_bnep_type;
33
static int hf_btbnep_extension_flag;
34
static int hf_btbnep_extension_type;
35
static int hf_btbnep_extension_length;
36
static int hf_btbnep_dst;
37
static int hf_btbnep_src;
38
static int hf_btbnep_len;
39
static int hf_btbnep_invalid_lentype;
40
static int hf_btbnep_type;
41
static int hf_btbnep_addr;
42
static int hf_btbnep_lg;
43
static int hf_btbnep_ig;
44
static int hf_btbnep_control_type;
45
static int hf_btbnep_unknown_control_type;
46
static int hf_btbnep_uuid_size;
47
static int hf_btbnep_destination_service_uuid;
48
static int hf_btbnep_source_service_uuid;
49
static int hf_btbnep_setup_connection_response_message;
50
static int hf_btbnep_filter_net_type_response_message;
51
static int hf_btbnep_filter_multi_addr_response_message;
52
static int hf_btbnep_list_length;
53
static int hf_btbnep_network_type_start;
54
static int hf_btbnep_network_type_end;
55
static int hf_btbnep_multicast_address_start;
56
static int hf_btbnep_multicast_address_end;
57
58
static int ett_btbnep;
59
static int ett_addr;
60
61
static expert_field ei_btbnep_src_not_group_address;
62
static expert_field ei_btbnep_invalid_lentype;
63
static expert_field ei_btbnep_len_past_end;
64
65
static dissector_handle_t btbnep_handle;
66
67
static bool top_dissect                                              = true;
68
69
static dissector_handle_t llc_handle;
70
static dissector_handle_t ipx_handle;
71
static dissector_handle_t ethertype_handle;
72
73
static const true_false_string ig_tfs = {
74
    "Group address (multicast/broadcast)",
75
    "Individual address (unicast)"
76
};
77
78
static const true_false_string lg_tfs = {
79
    "Locally administered address (this is NOT the factory default)",
80
    "Globally unique address (factory default)"
81
};
82
83
static const value_string bnep_type_vals[] = {
84
    { 0x00,   "General Ethernet" },
85
    { 0x01,   "Control" },
86
    { 0x02,   "Compressed Ethernet" },
87
    { 0x03,   "Compressed Ethernet Source Only" },
88
    { 0x04,   "Compressed Ethernet Destination Only" },
89
    { 0x7F,   "Reserved for 802.2 LLC Packets for IEEE 802.15.1 WG" },
90
    { 0, NULL }
91
};
92
93
static const value_string control_type_vals[] = {
94
    { 0x00,   "Command Not Understood" },
95
    { 0x01,   "Setup Connection Request" },
96
    { 0x02,   "Setup Connection Response" },
97
    { 0x03,   "Filter Net Type Set" },
98
    { 0x04,   "Filter Net Type Response" },
99
    { 0x05,   "Filter Multi Addr Set" },
100
    { 0x06,   "Filter Multi Addr Response" },
101
    { 0, NULL }
102
};
103
104
static const value_string extension_type_vals[] = {
105
    { 0x00,   "Extension Control" },
106
    { 0, NULL }
107
};
108
109
static const value_string setup_connection_response_message_vals[] = {
110
    { 0x0000,   "Operation Successful" },
111
    { 0x0001,   "Operation FAIL: Invalid Destination Service UUID" },
112
    { 0x0002,   "Operation FAIL: Invalid Source Service UUID" },
113
    { 0x0003,   "Operation FAIL: Invalid Service UUID Size" },
114
    { 0x0004,   "Operation FAIL: Connection Not Allowed" },
115
    { 0, NULL }
116
};
117
118
static const value_string filter_net_type_response_message_vals[] = {
119
    { 0x0000,   "Operation Successful" },
120
    { 0x0001,   "Unsupported Request" },
121
    { 0x0002,   "Operation FAIL: Invalid Networking Protocol Type Range" },
122
    { 0x0003,   "Operation FAIL: Too many filters" },
123
    { 0x0004,   "Operation FAIL: Unable to fulfill request due to security reasons" },
124
    { 0, NULL }
125
};
126
127
static const value_string filter_multi_addr_response_message_vals[] = {
128
    { 0x0000,   "Operation Successful" },
129
    { 0x0001,   "Unsupported Request" },
130
    { 0x0002,   "Operation FAIL: Invalid Multicast Address" },
131
    { 0x0003,   "Operation FAIL: Too many filters" },
132
    { 0x0004,   "Operation FAIL: Unable to fulfill request due to security reasons" },
133
    { 0, NULL }
134
};
135
136
void proto_register_btbnep(void);
137
void proto_reg_handoff_btbnep(void);
138
139
static int
140
dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
141
0
{
142
0
    proto_item  *pitem = NULL;
143
0
    unsigned     control_type;
144
0
    uint8_t      unknown_control_type;
145
0
    uint8_t      uuid_size;
146
0
    uint16_t     uuid_dst;
147
0
    uint16_t     uuid_src;
148
0
    uint16_t     response_message;
149
0
    uint16_t     list_length;
150
0
    unsigned     i_item;
151
152
0
    proto_tree_add_item(tree, hf_btbnep_control_type, tvb, offset, 1, ENC_BIG_ENDIAN);
153
0
    control_type = tvb_get_uint8(tvb, offset);
154
0
    offset += 1;
155
156
0
    col_append_fstr(pinfo->cinfo, COL_INFO, " - %s", val_to_str_const(control_type, control_type_vals,  "Unknown type"));
157
158
0
    switch(control_type) {
159
0
        case 0x00: /* Command Not Understood */
160
0
            proto_tree_add_item(tree, hf_btbnep_unknown_control_type, tvb, offset, 1, ENC_BIG_ENDIAN);
161
0
            unknown_control_type = tvb_get_uint8(tvb, offset);
162
0
            offset += 1;
163
164
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " - Unknown(%s)", val_to_str_const(unknown_control_type, control_type_vals,  "Unknown type"));
165
166
0
            break;
167
0
        case 0x01: /* Setup Connection Request */
168
0
            proto_tree_add_item(tree, hf_btbnep_uuid_size, tvb, offset, 1, ENC_BIG_ENDIAN);
169
0
            uuid_size = tvb_get_uint8(tvb, offset);
170
0
            offset += 1;
171
172
0
            pitem = proto_tree_add_item(tree, hf_btbnep_destination_service_uuid, tvb, offset, uuid_size, ENC_NA);
173
0
            uuid_dst = tvb_get_ntohs(tvb, offset);
174
0
            proto_item_append_text(pitem, " (%s)", val_to_str_ext_const(uuid_dst, &bluetooth_uuid_vals_ext,  "Unknown uuid"));
175
0
            offset += uuid_size;
176
177
0
            pitem = proto_tree_add_item(tree, hf_btbnep_source_service_uuid, tvb, offset, uuid_size, ENC_NA);
178
0
            uuid_src = tvb_get_ntohs(tvb, offset);
179
0
            proto_item_append_text(pitem, " (%s)", val_to_str_ext_const(uuid_src, &bluetooth_uuid_vals_ext,  "Unknown uuid"));
180
0
            offset += uuid_size;
181
182
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " - dst: <%s>, src: <%s>",
183
0
                    val_to_str_ext_const(uuid_dst, &bluetooth_uuid_vals_ext,  "Unknown uuid"),
184
0
                    val_to_str_ext_const(uuid_src, &bluetooth_uuid_vals_ext,  "Unknown uuid"));
185
0
            break;
186
0
        case 0x02: /* Setup Connection Response */
187
0
            proto_tree_add_item(tree, hf_btbnep_setup_connection_response_message, tvb, offset, 2, ENC_BIG_ENDIAN);
188
0
            response_message = tvb_get_ntohs(tvb, offset);
189
0
            offset += 2;
190
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
191
0
                    val_to_str_const(response_message, setup_connection_response_message_vals,  "Unknown response message"));
192
0
            break;
193
0
        case 0x03: /* Filter Net Type Set */
194
0
            proto_tree_add_item(tree, hf_btbnep_list_length, tvb, offset, 2, ENC_BIG_ENDIAN);
195
0
            list_length = tvb_get_ntohs(tvb, offset);
196
0
            offset += 2;
197
198
0
            for (i_item = 0; i_item + 4 > i_item && i_item < list_length; i_item += 4) {
199
0
                proto_tree_add_item(tree, hf_btbnep_network_type_start, tvb, offset, 2, ENC_BIG_ENDIAN);
200
0
                offset += 2;
201
202
0
                proto_tree_add_item(tree, hf_btbnep_network_type_end, tvb, offset, 2, ENC_BIG_ENDIAN);
203
0
                offset += 2;
204
0
            }
205
0
            break;
206
0
        case 0x04: /* Filter Net Type Response */
207
0
            proto_tree_add_item(tree, hf_btbnep_filter_net_type_response_message, tvb, offset, 2, ENC_BIG_ENDIAN);
208
0
            response_message = tvb_get_ntohs(tvb, offset);
209
0
            offset += 2;
210
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
211
0
                    val_to_str_const(response_message, filter_net_type_response_message_vals,  "Unknown response message"));
212
0
            break;
213
0
        case 0x05: /*Filter Multi Addr Set*/
214
0
            proto_tree_add_item(tree, hf_btbnep_list_length, tvb, offset, 2, ENC_BIG_ENDIAN);
215
0
            list_length = tvb_get_ntohs(tvb, offset);
216
0
            offset += 2;
217
218
0
            for (i_item = 0; i_item + 12 > i_item && i_item < list_length; i_item += 12) {
219
0
                proto_tree_add_item(tree, hf_btbnep_multicast_address_start, tvb, offset, FT_ETHER_LEN, ENC_NA);
220
0
                offset += FT_ETHER_LEN;
221
222
0
                proto_tree_add_item(tree, hf_btbnep_multicast_address_end, tvb, offset, FT_ETHER_LEN, ENC_NA);
223
0
                offset += FT_ETHER_LEN;
224
0
            }
225
0
            break;
226
0
        case 0x06: /* Filter Multi Addr Response */
227
0
            proto_tree_add_item(tree, hf_btbnep_filter_multi_addr_response_message, tvb, offset, 2, ENC_BIG_ENDIAN);
228
0
            response_message = tvb_get_ntohs(tvb, offset);
229
0
            offset += 2;
230
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " - %s",
231
0
                    val_to_str_const(response_message, filter_multi_addr_response_message_vals,  "Unknown response message"));
232
0
            break;
233
234
0
    };
235
236
0
    return offset;
237
0
}
238
239
static int
240
// NOLINTNEXTLINE(misc-no-recursion)
241
dissect_extension(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
242
0
{
243
0
    uint8_t extension_flag;
244
0
    uint8_t extension_type;
245
0
    uint16_t extension_length;
246
0
    uint8_t type;
247
248
0
    proto_tree_add_item(tree, hf_btbnep_extension_type, tvb, offset, 1, ENC_BIG_ENDIAN);
249
0
    proto_tree_add_item(tree, hf_btbnep_extension_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
250
0
    type = tvb_get_uint8(tvb, offset);
251
0
    extension_flag = type & 0x01;
252
0
    extension_type = type >> 1;
253
0
    offset += 1;
254
255
0
    proto_tree_add_item(tree, hf_btbnep_extension_length, tvb, offset, 1, ENC_BIG_ENDIAN);
256
0
    extension_length = tvb_get_ntohs(tvb, offset);
257
0
    offset += 2;
258
259
0
    if (extension_type == 0x00) {
260
        /* Extension Control */
261
0
        offset = dissect_control(tvb, pinfo, tree, offset);
262
0
    } else {
263
0
        offset += extension_length;
264
0
    }
265
266
0
    increment_dissection_depth(pinfo);
267
0
    if (extension_flag) offset = dissect_extension(tvb, pinfo, tree, offset);
268
0
    decrement_dissection_depth(pinfo);
269
270
0
    return offset;
271
0
}
272
273
static int
274
dissect_btbnep(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
275
1
{
276
1
    proto_item   *pi;
277
1
    proto_tree   *btbnep_tree;
278
1
    int           offset = 0;
279
1
    unsigned      bnep_type;
280
1
    unsigned      extension_flag;
281
1
    unsigned      len_type = 0;
282
1
    proto_item   *addr_item;
283
1
    proto_tree   *addr_tree = NULL;
284
1
    proto_item   *length_ti = NULL;
285
286
1
    pi = proto_tree_add_item(tree, proto_btbnep, tvb, offset, -1, ENC_NA);
287
1
    btbnep_tree = proto_item_add_subtree(pi, ett_btbnep);
288
289
1
    col_set_str(pinfo->cinfo, COL_PROTOCOL, "BNEP");
290
1
    col_clear(pinfo->cinfo, COL_INFO);
291
292
1
    switch (pinfo->p2p_dir) {
293
0
        case P2P_DIR_SENT:
294
0
            col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
295
0
            break;
296
0
        case P2P_DIR_RECV:
297
0
            col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
298
0
            break;
299
1
        default:
300
1
            col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection ");
301
1
            break;
302
1
    }
303
304
1
    proto_tree_add_item(btbnep_tree, hf_btbnep_extension_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
305
1
    proto_tree_add_item(btbnep_tree, hf_btbnep_bnep_type, tvb, offset, 1, ENC_BIG_ENDIAN);
306
1
    bnep_type = tvb_get_uint8(tvb, offset);
307
1
    extension_flag = bnep_type & 0x80;
308
1
    bnep_type = bnep_type & 0x7F;
309
1
    offset += 1;
310
311
1
    col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(bnep_type, bnep_type_vals,  "Unknown type"));
312
1
    if (extension_flag) col_append_str(pinfo->cinfo, COL_INFO, "+E");
313
314
1
    if (bnep_type == BNEP_TYPE_GENERAL_ETHERNET || bnep_type == BNEP_TYPE_COMPRESSED_ETHERNET_DESTINATION_ONLY) {
315
0
        set_address_tvb(&pinfo->dl_dst, AT_ETHER, 6, tvb, offset);
316
0
        copy_address_shallow(&pinfo->dst, &pinfo->dl_dst);
317
318
0
        addr_item = proto_tree_add_item(btbnep_tree, hf_btbnep_dst, tvb, offset, FT_ETHER_LEN, ENC_NA);
319
0
        addr_tree = proto_item_add_subtree(addr_item, ett_addr);
320
0
        proto_tree_add_item(addr_tree, hf_btbnep_addr, tvb, offset, FT_ETHER_LEN, ENC_NA);
321
0
        proto_tree_add_item(addr_tree, hf_btbnep_lg, tvb, offset, 3, ENC_BIG_ENDIAN);
322
0
        proto_tree_add_item(addr_tree, hf_btbnep_ig, tvb, offset, 3, ENC_BIG_ENDIAN);
323
0
        offset += FT_ETHER_LEN;
324
0
    }
325
326
1
    if (bnep_type == BNEP_TYPE_GENERAL_ETHERNET || bnep_type == BNEP_TYPE_COMPRESSED_ETHERNET_SOURCE_ONLY) {
327
0
        set_address_tvb(&pinfo->dl_src, AT_ETHER, 6, tvb, offset);
328
0
        copy_address_shallow(&pinfo->src, &pinfo->dl_src);
329
330
0
        addr_item = proto_tree_add_item(btbnep_tree, hf_btbnep_src, tvb, offset, FT_ETHER_LEN, ENC_NA);
331
0
        addr_tree = proto_item_add_subtree(addr_item, ett_addr);
332
0
        if (tvb_get_uint8(tvb, offset) & 0x01) {
333
0
            expert_add_info(pinfo, addr_item, &ei_btbnep_src_not_group_address);
334
0
        }
335
336
0
        proto_tree_add_item(addr_tree, hf_btbnep_addr, tvb, offset, FT_ETHER_LEN, ENC_NA);
337
0
        proto_tree_add_item(addr_tree, hf_btbnep_lg, tvb, offset, 3, ENC_BIG_ENDIAN);
338
0
        proto_tree_add_item(addr_tree, hf_btbnep_ig, tvb, offset, 3, ENC_BIG_ENDIAN);
339
0
        offset += FT_ETHER_LEN;
340
0
    }
341
342
1
    if (bnep_type != BNEP_TYPE_CONTROL) {
343
1
        len_type = tvb_get_ntohs(tvb, offset);
344
1
        if (len_type <= IEEE_802_3_MAX_LEN) {
345
            /*
346
             * The BNEP Version 1.0 spec says, for BNEP_GENERAL_ETHERNET
347
             * packets, "Note: Networking Protocol Types as used in this
348
             * specification SHALL be taken to include values in the range
349
             * 0x0000-0x05dc, used to represent the IEEE802.3 length
350
             * interpretation of the IEEE802.3 length/type field.",
351
             * although it says that it's not mandatory to process
352
             * those packets.
353
             */
354
1
            length_ti = proto_tree_add_item(btbnep_tree, hf_btbnep_len, tvb, offset, 2, ENC_BIG_ENDIAN);
355
1
        } else if (len_type < ETHERNET_II_MIN_LEN) {
356
            /*
357
             * Not a valid Ethernet length, not a valid Ethernet type.
358
             */
359
0
            proto_item *ti;
360
361
0
            ti = proto_tree_add_item(btbnep_tree, hf_btbnep_invalid_lentype, tvb, offset, 2, ENC_BIG_ENDIAN);
362
0
            expert_add_info_format(pinfo, ti, &ei_btbnep_invalid_lentype,
363
0
                                   "Invalid length/type: 0x%04x (%u)",
364
0
                                   len_type, len_type);
365
0
        } else {
366
            /*
367
             * Ethernet type.
368
             */
369
0
            if (!top_dissect)
370
0
                proto_tree_add_item(btbnep_tree, hf_btbnep_type, tvb, offset, 2, ENC_BIG_ENDIAN);
371
0
            col_append_fstr(pinfo->cinfo, COL_INFO, " - Type: %s", val_to_str_const(len_type, etype_vals, "unknown"));
372
0
        }
373
1
        offset += 2;
374
1
    } else {
375
0
        offset = dissect_control(tvb, pinfo, btbnep_tree, offset);
376
0
    }
377
378
1
    if (extension_flag) {
379
0
        offset = dissect_extension(tvb, pinfo, btbnep_tree, offset);
380
0
    }
381
382
1
    if (bnep_type != BNEP_TYPE_CONTROL) {
383
        /* dissect normal network */
384
1
        if (top_dissect) {
385
1
            if (len_type <= IEEE_802_3_MAX_LEN) {
386
1
                bool is_802_2;
387
1
                int reported_length;
388
1
                tvbuff_t  *next_tvb;
389
390
                /*
391
                 * The BNEP Version 1.0 spec says, for BNEP_GENERAL_ETHERNET
392
                 * packets, "Note: Networking Protocol Types as used in this
393
                 * specification SHALL be taken to include values in the range
394
                 * 0x0000-0x05dc, used to represent the IEEE802.3 length
395
                 * interpretation of the IEEE802.3 length/type field.",
396
                 * although it says that it's not mandatory to process
397
                 * those packets.
398
                 */
399
400
                /*
401
                 * Is there an 802.2 layer? I can tell by looking at the
402
                 * first 2 bytes of the payload. If they are 0xffff, then
403
                 * the payload is IPX.
404
                 *
405
                 * (Probably won't happen, but we might as well do this
406
                 * anyway.)
407
                 */
408
1
                is_802_2 = true;
409
410
                /* Don't throw an exception for this check (even a BoundsError) */
411
1
                if (tvb_bytes_exist(tvb, offset, 2)) {
412
1
                    if (tvb_get_ntohs(tvb, offset) == 0xffff) {
413
0
                        is_802_2 = false;
414
0
                    }
415
1
                }
416
417
1
                reported_length = tvb_reported_length_remaining(tvb, offset);
418
419
                /*
420
                 * Make sure the length doesn't go past the end of the
421
                 * payload.
422
                 */
423
1
                if (reported_length >= 0 && len_type > (unsigned)reported_length) {
424
1
                    len_type = reported_length;
425
1
                    expert_add_info(pinfo, length_ti, &ei_btbnep_len_past_end);
426
1
                }
427
428
                /* Give the next dissector only 'len_type' number of bytes. */
429
1
                next_tvb = tvb_new_subset_length(tvb, offset, len_type);
430
1
                if (is_802_2) {
431
1
                    call_dissector(llc_handle, next_tvb, pinfo, tree);
432
1
                } else {
433
0
                    call_dissector(ipx_handle, next_tvb, pinfo, tree);
434
0
                }
435
1
            } else if (len_type < ETHERNET_II_MIN_LEN) {
436
                /*
437
                 * Not a valid packet.
438
                 */
439
0
                tvbuff_t  *next_tvb;
440
441
0
                next_tvb = tvb_new_subset_remaining(tvb, offset);
442
0
                call_data_dissector(next_tvb, pinfo, tree);
443
0
            } else {
444
                /*
445
                 * Valid Ethertype.
446
                 */
447
0
                ethertype_data_t ethertype_data;
448
449
0
                proto_tree_add_uint(btbnep_tree, hf_btbnep_type, tvb,
450
0
                                    offset - 2, 2, len_type);
451
452
0
                ethertype_data.etype = len_type;
453
0
                ethertype_data.payload_offset = offset;
454
0
                ethertype_data.fh_tree = btbnep_tree;
455
0
                ethertype_data.trailer_id = 0;
456
0
                ethertype_data.fcs_len = 0;
457
458
0
                call_dissector_with_data(ethertype_handle, tvb, pinfo, tree, &ethertype_data);
459
0
            }
460
1
        } else {
461
0
            tvbuff_t  *next_tvb;
462
463
0
            next_tvb = tvb_new_subset_remaining(tvb, offset);
464
0
            call_data_dissector(next_tvb, pinfo, tree);
465
0
        }
466
1
    }
467
468
1
    return offset;
469
1
}
470
471
void
472
proto_register_btbnep(void)
473
14
{
474
14
    module_t *module;
475
14
    expert_module_t* expert_btbnep;
476
477
14
    static hf_register_info hf[] = {
478
14
        { &hf_btbnep_bnep_type,
479
14
            { "BNEP Type",                         "btbnep.bnep_type",
480
14
            FT_UINT8, BASE_HEX, VALS(bnep_type_vals), 0x7F,
481
14
            NULL, HFILL }
482
14
        },
483
14
        { &hf_btbnep_extension_flag,
484
14
            { "Extension Flag",                    "btbnep.extension_flag",
485
14
            FT_BOOLEAN, 8, NULL, 0x80,
486
14
            NULL, HFILL }
487
14
        },
488
14
        { &hf_btbnep_control_type,
489
14
            { "Control Type",                      "btbnep.control_type",
490
14
            FT_UINT8, BASE_HEX, VALS(control_type_vals), 0x00,
491
14
            NULL, HFILL }
492
14
        },
493
14
        { &hf_btbnep_extension_type,
494
14
            { "Extension Type",                    "btbnep.extension_type",
495
14
            FT_UINT8, BASE_HEX, VALS(extension_type_vals), 0x00,
496
14
            NULL, HFILL }
497
14
        },
498
14
        { &hf_btbnep_extension_length,
499
14
            { "Extension Length",                  "btbnep.extension_length",
500
14
            FT_UINT16, BASE_DEC, NULL, 0x00,
501
14
            NULL, HFILL }
502
14
        },
503
14
        { &hf_btbnep_unknown_control_type,
504
14
            { "Unknown Control Type",              "btbnep.unknown_control_type",
505
14
            FT_UINT8, BASE_HEX, VALS(control_type_vals), 0x00,
506
14
            NULL, HFILL }
507
14
        },
508
14
        { &hf_btbnep_uuid_size,
509
14
            { "UIDD Size",                         "btbnep.uuid_size",
510
14
            FT_UINT8, BASE_DEC, NULL, 0x00,
511
14
            NULL, HFILL }
512
14
        },
513
14
        { &hf_btbnep_destination_service_uuid,
514
14
            { "Destination Service UUID",          "btbnep.destination_service_uuid",
515
14
            FT_NONE, BASE_NONE, NULL, 0x00,
516
14
            NULL, HFILL }
517
14
        },
518
14
        { &hf_btbnep_source_service_uuid,
519
14
            { "Source Service UUID",               "btbnep.source_service_uuid",
520
14
            FT_NONE, BASE_NONE, NULL, 0x00,
521
14
            NULL, HFILL }
522
14
        },
523
14
        { &hf_btbnep_setup_connection_response_message,
524
14
            { "Response Message",                  "btbnep.setup_connection_response_message",
525
14
            FT_UINT16, BASE_HEX, VALS(setup_connection_response_message_vals), 0x00,
526
14
            NULL, HFILL }
527
14
        },
528
14
        { &hf_btbnep_filter_net_type_response_message,
529
14
            { "Response Message",                  "btbnep.filter_net_type_response_message",
530
14
            FT_UINT16, BASE_HEX, VALS(filter_net_type_response_message_vals), 0x00,
531
14
            NULL, HFILL }
532
14
        },
533
14
        { &hf_btbnep_filter_multi_addr_response_message,
534
14
            { "Response Message",                  "btbnep.filter_multi_addr_response_message",
535
14
            FT_UINT16, BASE_HEX, VALS(filter_multi_addr_response_message_vals), 0x00,
536
14
            NULL, HFILL }
537
14
        },
538
14
        { &hf_btbnep_list_length,
539
14
            { "List Length",                       "btbnep.list_length",
540
14
            FT_UINT16, BASE_DEC, NULL, 0x00,
541
14
            NULL, HFILL }
542
14
        },
543
        /* http://www.iana.org/assignments/ethernet-numbers */
544
14
        { &hf_btbnep_network_type_start,
545
14
            { "Network Protocol Type Range Start", "btbnep.network_type_start",
546
14
            FT_UINT16, BASE_HEX, VALS(etype_vals), 0x00,
547
14
            NULL, HFILL }
548
14
        },
549
14
        { &hf_btbnep_network_type_end,
550
14
            { "Network Protocol Type Range End",   "btbnep.network_type_end",
551
14
            FT_UINT16, BASE_HEX, VALS(etype_vals), 0x00,
552
14
            NULL, HFILL }
553
14
        },
554
14
        { &hf_btbnep_multicast_address_start,
555
14
            { "Multicast Address Start",           "btbnep.multicast_address_start",
556
14
            FT_ETHER, BASE_NONE, NULL, 0x00,
557
14
            NULL, HFILL }
558
14
        },
559
14
        { &hf_btbnep_multicast_address_end,
560
14
            { "Multicast Address End",             "btbnep.multicast_address_end",
561
14
            FT_ETHER, BASE_NONE, NULL, 0x00,
562
14
            NULL, HFILL }
563
14
        },
564
14
        { &hf_btbnep_dst,
565
14
            { "Destination",                       "btbnep.dst",
566
14
            FT_ETHER, BASE_NONE, NULL, 0x0,
567
14
            "Destination Hardware Address", HFILL }
568
14
        },
569
14
        { &hf_btbnep_src,
570
14
            { "Source",                            "btbnep.src",
571
14
            FT_ETHER, BASE_NONE, NULL, 0x0,
572
14
            "Source Hardware Address", HFILL }
573
14
        },
574
14
        { &hf_btbnep_len,
575
14
            { "Length",                            "btbnep.len",
576
14
            FT_UINT16, BASE_DEC, NULL, 0x0,
577
14
            NULL, HFILL }
578
14
        },
579
14
        { &hf_btbnep_invalid_lentype,
580
14
            { "Invalid length/type",               "btbnep.invalid_lentype",
581
14
            FT_UINT16, BASE_HEX_DEC, NULL, 0x0,
582
14
            NULL, HFILL }
583
14
        },
584
14
        { &hf_btbnep_type,
585
14
            { "Type",                              "btbnep.type",
586
14
            FT_UINT16, BASE_HEX, VALS(etype_vals), 0x0,
587
14
            NULL, HFILL }
588
14
        },
589
14
        { &hf_btbnep_addr,
590
14
            { "Address",                           "btbnep.addr",
591
14
            FT_ETHER, BASE_NONE, NULL, 0x0,
592
14
            "Source or Destination Hardware Address", HFILL }
593
14
        },
594
14
        { &hf_btbnep_lg,
595
14
            { "LG bit",                            "btbnep.lg",
596
14
            FT_BOOLEAN, 24, TFS(&lg_tfs), 0x020000,
597
14
            "Specifies if this is a locally administered or globally unique (IEEE assigned) address", HFILL }
598
14
        },
599
14
        { &hf_btbnep_ig,
600
14
            { "IG bit",                            "btbnep.ig",
601
14
            FT_BOOLEAN, 24, TFS(&ig_tfs), 0x010000,
602
14
            "Specifies if this is an individual (unicast) or group (broadcast/multicast) address", HFILL }
603
14
        }
604
14
    };
605
606
14
    static int *ett[] = {
607
14
        &ett_btbnep,
608
14
        &ett_addr
609
14
    };
610
611
14
    static ei_register_info ei[] = {
612
14
        { &ei_btbnep_src_not_group_address, { "btbnep.src.not_group_address", PI_PROTOCOL, PI_WARN, "Source MAC must not be a group address: IEEE 802.3-2002, Section 3.2.3(b)", EXPFILL }},
613
14
        { &ei_btbnep_invalid_lentype, { "btbnep.invalid_lentype.expert", PI_PROTOCOL, PI_WARN, "Invalid length/type", EXPFILL }},
614
14
        { &ei_btbnep_len_past_end, { "btbnep.len.past_end", PI_MALFORMED, PI_ERROR, "Length field value goes past the end of the payload", EXPFILL }},
615
14
    };
616
617
14
    proto_btbnep = proto_register_protocol("Bluetooth BNEP Protocol", "BT BNEP", "btbnep");
618
14
    btbnep_handle = register_dissector("btbnep", dissect_btbnep, proto_btbnep);
619
620
14
    proto_register_field_array(proto_btbnep, hf, array_length(hf));
621
14
    proto_register_subtree_array(ett, array_length(ett));
622
14
    expert_btbnep = expert_register_protocol(proto_btbnep);
623
14
    expert_register_field_array(expert_btbnep, ei, array_length(ei));
624
625
14
    module = prefs_register_protocol_subtree("Bluetooth", proto_btbnep, NULL);
626
14
    prefs_register_static_text_preference(module, "bnep.version",
627
14
            "Bluetooth Protocol BNEP version: 1.0",
628
14
            "Version of protocol supported by this dissector.");
629
630
14
    prefs_register_bool_preference(module, "bnep.top_dissect",
631
14
            "Dissecting the top protocols", "Dissecting the top protocols",
632
14
            &top_dissect);
633
14
}
634
635
void
636
proto_reg_handoff_btbnep(void)
637
14
{
638
14
    ipx_handle    = find_dissector_add_dependency("ipx", proto_btbnep);
639
14
    llc_handle    = find_dissector_add_dependency("llc", proto_btbnep);
640
14
    ethertype_handle = find_dissector_add_dependency("ethertype", proto_btbnep);
641
642
14
    dissector_add_string("bluetooth.uuid", "1115", btbnep_handle);
643
14
    dissector_add_string("bluetooth.uuid", "1116", btbnep_handle);
644
14
    dissector_add_string("bluetooth.uuid", "1117", btbnep_handle);
645
646
14
    dissector_add_uint("btl2cap.psm", BTL2CAP_PSM_BNEP, btbnep_handle);
647
14
    dissector_add_for_decode_as("btl2cap.cid", btbnep_handle);
648
14
}
649
650
/*
651
 * Editor modelines  -  https://www.wireshark.org/tools/modelines.html
652
 *
653
 * Local variables:
654
 * c-basic-offset: 4
655
 * tab-width: 8
656
 * indent-tabs-mode: nil
657
 * End:
658
 *
659
 * vi: set shiftwidth=4 tabstop=8 expandtab:
660
 * :indentSize=4:tabSize=8:noTabs=true:
661
 */