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
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
|
/* packet-bthcrp.c
* Routines for Bluetooth HCRP dissection
*
* Copyright 2013, Michal Labedzki for Tieto Corporation
*
* 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 <epan/prefs.h>
#include <epan/expert.h>
#include "packet-btl2cap.h"
#include "packet-btsdp.h"
enum {
FORCE_CLIENT_DEFAULT = 0,
FORCE_CLIENT_YES = 1,
FORCE_CLIENT_NO = 2
};
static int proto_bthcrp = -1;
static int hf_bthcrp_notification_pdu_id = -1;
static int hf_bthcrp_control_pdu_id = -1;
static int hf_bthcrp_control_transaction_id = -1;
static int hf_bthcrp_control_parameter_length = -1;
static int hf_bthcrp_control_status = -1;
static int hf_bthcrp_callback_context_id = -1;
static int hf_bthcrp_control_callback_timeout = -1;
static int hf_bthcrp_control_timeout = -1;
static int hf_bthcrp_control_1284_id = -1;
static int hf_bthcrp_control_register = -1;
static int hf_bthcrp_control_start_byte = -1;
static int hf_bthcrp_control_number_of_bytes = -1;
static int hf_bthcrp_control_client_credit_granted = -1;
static int hf_bthcrp_control_server_credit_granted = -1;
static int hf_bthcrp_control_client_credit_return = -1;
static int hf_bthcrp_control_server_credit_return = -1;
static int hf_bthcrp_control_client_credit_query = -1;
static int hf_bthcrp_control_server_credit_query = -1;
static int hf_bthcrp_control_status_reserved_76 = -1;
static int hf_bthcrp_control_status_paper_empty = -1;
static int hf_bthcrp_control_status_select = -1;
static int hf_bthcrp_control_status_not_error = -1;
static int hf_bthcrp_control_status_reserved_20 = -1;
static int hf_bthcrp_data = -1;
static gint ett_bthcrp = -1;
static expert_field ei_bthcrp_control_parameter_length = EI_INIT;
static expert_field ei_bthcrp_unexpected_data = EI_INIT;
static dissector_handle_t bthcrp_handle;
static gint force_client = FORCE_CLIENT_DEFAULT;
static gint psm_control = 0;
static gint psm_data_stream = 0;
static gint psm_notification = 0;
static const value_string control_pdu_id_vals[] = {
{ 0x0001, "CR_DataChannelCreditGrant" },
{ 0x0002, "CR_DataChannelCreditRequest" },
{ 0x0003, "CR_DataChannelCreditReturn" },
{ 0x0004, "CR_DataChannelCreditQuery" },
{ 0x0005, "CR_GetLPTStatus" },
{ 0x0006, "CR_Get1284ID" },
{ 0x0007, "CR_SoftReset" },
{ 0x0008, "CR_HardReset" },
{ 0x0009, "CR_RegisterNotification" },
{ 0x000A, "CR_NotificationConnectionAlive" },
{ 0, NULL }
};
static const value_string status_vals[] = {
{ 0x0000, "Feature Unsupported" },
{ 0x0001, "Success" },
{ 0x0002, "Credit Synchronization Error" },
{ 0xFFFF, "Generic Failure" },
{ 0, NULL }
};
static const value_string notification_pdu_id_vals[] = {
{ 0x0001, "N_Notification" },
{ 0, NULL }
};
static const value_string register_vals[] = {
{ 0x00, "Remove Client From Receiver Notification" },
{ 0x01, "Add Client To Receiver Notification" },
{ 0, NULL }
};
static const enum_val_t force_client_enum[] = {
{ "default", "Default", FORCE_CLIENT_DEFAULT },
{ "yes", "Yes", FORCE_CLIENT_YES },
{ "no", "No", FORCE_CLIENT_NO },
{ NULL, NULL, 0 }
};
void proto_register_bthcrp(void);
void proto_reg_handoff_bthcrp(void);
static gint
dissect_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gboolean is_client_message)
{
/* flow: reqests: only client -> server; responses: only server -> */
proto_item *pitem;
guint16 control_pdu_id;
guint credits;
guint timeout;
guint context_id;
guint notification_register;
guint number;
gint parameter_length;
pitem = proto_tree_add_item(tree, hf_bthcrp_control_pdu_id, tvb, offset, 2, ENC_BIG_ENDIAN);
control_pdu_id = tvb_get_ntohs(tvb, offset);
offset += 2;
col_append_fstr(pinfo->cinfo, COL_INFO, "Control: %s %s",
((is_client_message) ? "Request" : "Response"),
val_to_str_const(control_pdu_id, control_pdu_id_vals, "Unknown PDU ID"));
if (control_pdu_id >= 0x8000) {
proto_item_append_text(pitem, " (Vendor Specific)");
col_append_str(pinfo->cinfo, COL_INFO, " (Vendor Specific)");
} else if (control_pdu_id == 0x0000 || control_pdu_id >= 0x000B ) {
proto_item_append_text(pitem, " (Reserved)");
col_append_str(pinfo->cinfo, COL_INFO, " (Reserved)");
}
proto_tree_add_item(tree, hf_bthcrp_control_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
pitem = proto_tree_add_item(tree, hf_bthcrp_control_parameter_length, tvb, offset, 2, ENC_BIG_ENDIAN);
parameter_length = tvb_get_ntohs(tvb, offset);
offset += 2;
if (!is_client_message && parameter_length < 2) {
expert_add_info_format(pinfo, pitem, &ei_bthcrp_control_parameter_length,
"Parameter length is shorter than 2 in response");
}
if (parameter_length < tvb_reported_length_remaining(tvb, offset)) {
expert_add_info_format(pinfo, pitem, &ei_bthcrp_control_parameter_length,
"Parameter length is shorter than payload length");
} else if (parameter_length > tvb_reported_length_remaining(tvb, offset)) {
expert_add_info_format(pinfo, pitem, &ei_bthcrp_control_parameter_length,
"Parameter length is larger than payload length");
}
if (!is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_status, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
}
if (control_pdu_id >= 0x8000) {
if (tvb_reported_length_remaining(tvb, offset)) {
proto_tree_add_item(tree, hf_bthcrp_data, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA);
offset += tvb_reported_length_remaining(tvb, offset);
}
} else switch(control_pdu_id) {
case 0x0001: /* CR_DataChannelCreditGrant */
if (is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_client_credit_granted, tvb, offset, 4, ENC_BIG_ENDIAN);
credits = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - CreditGranted: %u", credits);
offset += 4;
}
break;
case 0x0002: /* CR_DataChannelCreditRequest */
if (!is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_server_credit_granted, tvb, offset, 4, ENC_BIG_ENDIAN);
credits = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - CreditGranted: %u", credits);
offset += 4;
}
break;
case 0x0003: /* CR_DataChannelCreditReturn */
if (is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_client_credit_return, tvb, offset, 4, ENC_BIG_ENDIAN);
credits = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Client Credit Return: %u", credits);
offset += 4;
} else {
proto_tree_add_item(tree, hf_bthcrp_control_server_credit_return, tvb, offset, 4, ENC_BIG_ENDIAN);
credits = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Server Credit Return: %u", credits);
offset += 4;
}
break;
case 0x0004: /* CR_DataChannelCreditQuery */
if (is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_client_credit_query, tvb, offset, 4, ENC_BIG_ENDIAN);
credits = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Client Credit: %u", credits);
offset += 4;
} else {
proto_tree_add_item(tree, hf_bthcrp_control_server_credit_query, tvb, offset, 4, ENC_BIG_ENDIAN);
credits = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Server Credit: %u", credits);
offset += 4;
}
break;
case 0x0005: /* CR_GetLPTStatus */
if (!is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_status_reserved_76, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_bthcrp_control_status_paper_empty, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_bthcrp_control_status_select, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_bthcrp_control_status_not_error, tvb, offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(tree, hf_bthcrp_control_status_reserved_20, tvb, offset, 1, ENC_BIG_ENDIAN);
offset += 1;
}
break;
case 0x0006: /* CR_Get1284ID */
if (is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_start_byte, tvb, offset, 2, ENC_BIG_ENDIAN);
number = tvb_get_ntohs(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Start Byte: %u", number);
offset += 2;
proto_tree_add_item(tree, hf_bthcrp_control_number_of_bytes, tvb, offset, 2, ENC_BIG_ENDIAN);
number = tvb_get_ntohs(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Number Of Bytes: %u", number);
offset += 2;
} else {
const guint8 *id;
proto_tree_add_item_ret_string(tree, hf_bthcrp_control_1284_id, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_ASCII | ENC_NA, pinfo->pool, &id);
col_append_fstr(pinfo->cinfo, COL_INFO, " - 1284 ID: %s", id);
offset += tvb_reported_length_remaining(tvb, offset);
}
break;
case 0x0007: /* CR_SoftReset */
case 0x0008: /* CR_HardReset */
break;
case 0x0009: /* CR_RegisterNotification */
if (is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_register, tvb, offset, 1, ENC_BIG_ENDIAN);
notification_register = tvb_get_guint8(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Register: %s", val_to_str_const(notification_register, register_vals, "unknown register"));
offset += 1;
proto_tree_add_item(tree, hf_bthcrp_callback_context_id, tvb, offset, 4, ENC_BIG_ENDIAN);
context_id = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Callback ContextID: %u", context_id);
offset += 4;
proto_tree_add_item(tree, hf_bthcrp_control_callback_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
timeout = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Callback Timeout: %u", timeout);
offset += 4;
} else {
proto_tree_add_item(tree, hf_bthcrp_control_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
timeout = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Timeout: %u", timeout);
offset += 4;
proto_tree_add_item(tree, hf_bthcrp_control_callback_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
timeout = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, ", Callback Timeout: %u", timeout);
offset += 4;
}
break;
case 0x000A: /* CR_NotificationConnectionAlive */
if (!is_client_message) {
proto_tree_add_item(tree, hf_bthcrp_control_timeout, tvb, offset, 4, ENC_BIG_ENDIAN);
timeout = tvb_get_ntohl(tvb, offset);
col_append_fstr(pinfo->cinfo, COL_INFO, " - Timeout: %u", timeout);
offset += 4;
}
break;
}
return offset;
}
static gint
dissect_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gint offset)
{
/* flow: server <-> client */
tvbuff_t *next_tvb;
col_append_str(pinfo->cinfo, COL_INFO, "HCRP data stream");
next_tvb = tvb_new_subset_remaining(tvb, offset);
call_data_dissector(next_tvb, pinfo, tree);
offset += tvb_reported_length_remaining(tvb, offset);
return offset;
}
static gint
dissect_notification(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gint offset, gboolean is_client_message)
{
/* flow: only server -> client */
guint16 notification_pdu_id;
proto_item *pitem;
if (is_client_message) {
col_append_str(pinfo->cinfo, COL_INFO, "Notification: unexpected notification stream");
return offset;
}
pitem = proto_tree_add_item(tree, hf_bthcrp_notification_pdu_id, tvb, offset, 2, ENC_BIG_ENDIAN);
notification_pdu_id = tvb_get_ntohs(tvb, offset);
offset += 2;
col_append_fstr(pinfo->cinfo, COL_INFO, "Notification: %s", val_to_str_const(notification_pdu_id, notification_pdu_id_vals, "Unknown PDU ID"));
if (notification_pdu_id >= 0x8000) {
proto_item_append_text(pitem, " (Vendor Specific)");
col_append_str(pinfo->cinfo, COL_INFO, " (Vendor Specific)");
if (tvb_reported_length_remaining(tvb, offset)) {
proto_tree_add_item(tree, hf_bthcrp_data, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA);
offset += tvb_reported_length_remaining(tvb, offset);
}
} else if (notification_pdu_id != 0x001) {
proto_item_append_text(pitem, " (Reserved)");
col_append_str(pinfo->cinfo, COL_INFO, " (Reserved)");
}
switch(notification_pdu_id) {
case 0x01: /* N_NOTIFICATION */
proto_tree_add_item(tree, hf_bthcrp_callback_context_id, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
break;
}
return offset;
}
static gint
dissect_bthcrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
proto_item *main_item;
proto_tree *main_tree;
gint offset = 0;
gint protocol = -1;
gboolean is_client_message = FALSE;
gint previous_proto;
previous_proto = (GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_frame_prev(wmem_list_tail(pinfo->layers)))));
if (previous_proto == proto_btl2cap) {
btl2cap_data_t *l2cap_data;
wmem_tree_key_t key[10];
guint32 interface_id;
guint32 adapter_id;
guint32 sdp_psm = SDP_PSM_DEFAULT;
guint32 direction;
guint32 bd_addr_oui;
guint32 bd_addr_id;
guint32 service_type;
guint32 service_channel;
guint32 frame_number;
service_info_t *service_info;
l2cap_data = (btl2cap_data_t *) data;
interface_id = l2cap_data->interface_id;
adapter_id = l2cap_data->adapter_id;
direction = (l2cap_data->is_local_psm) ? P2P_DIR_SENT : P2P_DIR_RECV;
if (direction == P2P_DIR_RECV) {
bd_addr_oui = l2cap_data->remote_bd_addr_oui;
bd_addr_id = l2cap_data->remote_bd_addr_id;
} else {
bd_addr_oui = 0;
bd_addr_id = 0;
}
service_type = BTSDP_L2CAP_PROTOCOL_UUID;
service_channel = l2cap_data->psm;
frame_number = pinfo->num;
key[0].length = 1;
key[0].key = &interface_id;
key[1].length = 1;
key[1].key = &adapter_id;
key[2].length = 1;
key[2].key = &sdp_psm;
key[3].length = 1;
key[3].key = &direction;
key[4].length = 1;
key[4].key = &bd_addr_oui;
key[5].length = 1;
key[5].key = &bd_addr_id;
key[6].length = 1;
key[6].key = &service_type;
key[7].length = 1;
key[7].key = &service_channel;
key[8].length = 1;
key[8].key = &frame_number;
key[9].length = 0;
key[9].key = NULL;
service_info = btsdp_get_service_info(key);
if (service_info && service_info->interface_id == interface_id &&
service_info->adapter_id == adapter_id &&
service_info->sdp_psm == SDP_PSM_DEFAULT &&
((service_info->direction == P2P_DIR_RECV &&
service_info->bd_addr_oui == bd_addr_oui &&
service_info->bd_addr_id == bd_addr_id) ||
(service_info->direction != P2P_DIR_RECV &&
service_info->bd_addr_oui == 0 &&
service_info->bd_addr_id == 0)) &&
service_info->type == BTSDP_L2CAP_PROTOCOL_UUID &&
service_info->channel == l2cap_data->psm) {
if ((service_info->protocol == BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID ||
service_info->protocol == BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID) &&
((!l2cap_data->is_local_psm && pinfo->p2p_dir == P2P_DIR_SENT) ||
(l2cap_data->is_local_psm && pinfo->p2p_dir == P2P_DIR_RECV))) {
is_client_message = TRUE;
} else if (service_info->protocol == BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID &&
((l2cap_data->is_local_psm && pinfo->p2p_dir == P2P_DIR_SENT) ||
(!l2cap_data->is_local_psm && pinfo->p2p_dir == P2P_DIR_RECV))) {
is_client_message = TRUE;
}
protocol = service_info->protocol;
}
if (psm_control != 0 && l2cap_data->psm == psm_control) {
protocol = BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID;
} else if (psm_data_stream != 0 && l2cap_data->psm == psm_data_stream) {
protocol = BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID;
} else if (psm_notification != 0 && l2cap_data->psm == psm_notification) {
protocol = BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID;
}
}
main_item = proto_tree_add_item(tree, proto_bthcrp, tvb, offset, -1, ENC_NA);
main_tree = proto_item_add_subtree(main_item, ett_bthcrp);
col_set_str(pinfo->cinfo, COL_PROTOCOL, "HCRP");
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;
}
if (force_client != FORCE_CLIENT_DEFAULT) {
is_client_message = (force_client == FORCE_CLIENT_YES && pinfo->p2p_dir == P2P_DIR_SENT) ||
(force_client != FORCE_CLIENT_YES && pinfo->p2p_dir == P2P_DIR_RECV);
}
if (protocol == BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID) {
offset = dissect_control(tvb, pinfo, main_tree, offset, is_client_message);
} else if (protocol == BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID) {
offset = dissect_data(tvb, pinfo, main_tree, offset);
} else if (protocol == BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID) {
offset = dissect_notification(tvb, pinfo, main_tree, offset, is_client_message);
} else {
col_append_fstr(pinfo->cinfo, COL_INFO, "HCRP stream");
}
if (tvb_reported_length_remaining(tvb, offset)) {
proto_item *pitem;
pitem = proto_tree_add_item(main_tree, hf_bthcrp_data, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA);
expert_add_info(pinfo, pitem, &ei_bthcrp_unexpected_data);
}
return offset;
}
void
proto_register_bthcrp(void)
{
module_t *module;
expert_module_t* expert_bthcrp;
static hf_register_info hf[] = {
{ &hf_bthcrp_control_pdu_id,
{ "Control PDU ID", "bthcrp.control.pdu_id",
FT_UINT16, BASE_HEX, VALS(control_pdu_id_vals), 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_transaction_id,
{ "Transaction ID", "bthcrp.control.transaction_id",
FT_UINT16, BASE_HEX, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_parameter_length,
{ "Parameter Length", "bthcrp.control.parameter_length",
FT_UINT16, BASE_HEX, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_status,
{ "Status", "bthcrp.control.status",
FT_UINT16, BASE_HEX, VALS(status_vals), 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_notification_pdu_id,
{ "Notification PDU ID", "bthcrp.notification.pdu_id",
FT_UINT16, BASE_HEX, VALS(notification_pdu_id_vals), 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_callback_context_id,
{ "Callback Context ID", "bthcrp.callback.context_id",
FT_UINT32, BASE_HEX, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_callback_timeout,
{ "Callback Timeout", "bthcrp.callback.timeout",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_timeout,
{ "Timeout", "bthcrp.timeout",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_register,
{ "Register", "bthcrp.register",
FT_UINT8, BASE_HEX, VALS(register_vals), 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_1284_id,
{ "1284 ID", "bthcrp.1284_id",
FT_STRING, BASE_NONE, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_start_byte,
{ "Start Byte", "bthcrp.start_byte",
FT_UINT16, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_number_of_bytes,
{ "Number Of Bytes", "bthcrp.number_of_bytes",
FT_UINT16, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_client_credit_granted,
{ "Client Credit Granted", "bthcrp.client_credit_granted",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_server_credit_granted,
{ "Server Credit Granted", "bthcrp.server_credit_granted",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_client_credit_return,
{ "Client Credit Return", "bthcrp.client_credit_return",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_server_credit_return,
{ "Server Credit Return", "bthcrp.server_credit_return",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_client_credit_query,
{ "Client Credit Query", "bthcrp.client_credit_query",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_server_credit_query,
{ "Server Credit Query", "bthcrp.server_credit_query",
FT_UINT32, BASE_DEC, NULL, 0x00,
NULL, HFILL }
},
{ &hf_bthcrp_control_status_reserved_76,
{ "Reserved", "bthcrp.status.reserved76",
FT_UINT8, BASE_DEC, NULL, 0xC0,
NULL, HFILL }
},
{ &hf_bthcrp_control_status_paper_empty,
{ "Paper Empty", "bthcrp.status.paper_empty",
FT_BOOLEAN, 8, NULL, 0x20,
NULL, HFILL }
},
{ &hf_bthcrp_control_status_select,
{ "Select", "bthcrp.status.select",
FT_BOOLEAN, 8, NULL, 0x10,
NULL, HFILL }
},
{ &hf_bthcrp_control_status_not_error,
{ "Not Error", "bthcrp.status.not_error",
FT_BOOLEAN, 8, NULL, 0x08,
NULL, HFILL }
},
{ &hf_bthcrp_control_status_reserved_20,
{ "Reserved", "bthcrp.status.reserved210",
FT_UINT8, BASE_HEX, NULL, 0x07,
NULL, HFILL }
},
{ &hf_bthcrp_data,
{ "Data", "bthcrp.data",
FT_NONE, BASE_NONE, NULL, 0x00,
NULL, HFILL }
}
};
static gint *ett[] = {
&ett_bthcrp
};
static ei_register_info ei[] = {
{ &ei_bthcrp_control_parameter_length, { "bthcrp.control_parameter_length.bad", PI_PROTOCOL, PI_WARN, "Length bad", EXPFILL }},
{ &ei_bthcrp_unexpected_data, { "bthcrp.unexpected_data", PI_PROTOCOL, PI_WARN, "Unexpected data", EXPFILL }},
};
proto_bthcrp = proto_register_protocol("Bluetooth HCRP Profile", "BT HCRP", "bthcrp");
bthcrp_handle = register_dissector("bthcrp", dissect_bthcrp, proto_bthcrp);
proto_register_field_array(proto_bthcrp, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_bthcrp = expert_register_protocol(proto_bthcrp);
expert_register_field_array(expert_bthcrp, ei, array_length(ei));
module = prefs_register_protocol_subtree("Bluetooth", proto_bthcrp, NULL);
prefs_register_static_text_preference(module, "hcrp.version",
"Bluetooth Profile HCRP version: 1.2",
"Version of profile supported by this dissector.");
prefs_register_obsolete_preference(module, "hcrp.is_client");
prefs_register_enum_preference(module, "hcrp.force_client", "Force Client",
"If \"yes\" localhost will be treat as Client, \"no\" as Server",
&force_client, force_client_enum, FALSE);
prefs_register_uint_preference(module, "hcrp.control.psm", "L2CAP PSM for Control",
"L2CAP PSM for Control",
10, &psm_control);
prefs_register_uint_preference(module, "hcrp.data.psm", "L2CAP PSM for Data",
"L2CAP PSM for Data",
10, &psm_data_stream);
prefs_register_uint_preference(module, "hcrp.notification.psm", "L2CAP PSM for Notification",
"L2CAP PSM for Notification",
10, &psm_notification);
}
void
proto_reg_handoff_bthcrp(void)
{
dissector_add_string("bluetooth.uuid", "12", bthcrp_handle);
dissector_add_string("bluetooth.uuid", "14", bthcrp_handle);
dissector_add_string("bluetooth.uuid", "16", bthcrp_handle);
dissector_add_string("bluetooth.uuid", "1125", bthcrp_handle);
dissector_add_string("bluetooth.uuid", "1126", bthcrp_handle);
dissector_add_string("bluetooth.uuid", "1127", bthcrp_handle);
dissector_add_for_decode_as("btl2cap.psm", bthcrp_handle);
dissector_add_for_decode_as("btl2cap.cid", bthcrp_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:
*/
|