2 * Routines for Bluetooth HCRP dissection
4 * Copyright 2013, Michal Labedzki for Tieto Corporation
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <epan/prefs.h>
17 #include <epan/expert.h>
19 #include "packet-btl2cap.h"
20 #include "packet-btsdp.h"
23 FORCE_CLIENT_DEFAULT
= 0,
28 static int proto_bthcrp
;
30 static int hf_bthcrp_notification_pdu_id
;
31 static int hf_bthcrp_control_pdu_id
;
32 static int hf_bthcrp_control_transaction_id
;
33 static int hf_bthcrp_control_parameter_length
;
34 static int hf_bthcrp_control_status
;
35 static int hf_bthcrp_callback_context_id
;
36 static int hf_bthcrp_control_callback_timeout
;
37 static int hf_bthcrp_control_timeout
;
38 static int hf_bthcrp_control_1284_id
;
39 static int hf_bthcrp_control_register
;
40 static int hf_bthcrp_control_start_byte
;
41 static int hf_bthcrp_control_number_of_bytes
;
42 static int hf_bthcrp_control_client_credit_granted
;
43 static int hf_bthcrp_control_server_credit_granted
;
44 static int hf_bthcrp_control_client_credit_return
;
45 static int hf_bthcrp_control_server_credit_return
;
46 static int hf_bthcrp_control_client_credit_query
;
47 static int hf_bthcrp_control_server_credit_query
;
48 static int hf_bthcrp_control_status_reserved_76
;
49 static int hf_bthcrp_control_status_paper_empty
;
50 static int hf_bthcrp_control_status_select
;
51 static int hf_bthcrp_control_status_not_error
;
52 static int hf_bthcrp_control_status_reserved_20
;
53 static int hf_bthcrp_data
;
55 static int ett_bthcrp
;
57 static expert_field ei_bthcrp_control_parameter_length
;
58 static expert_field ei_bthcrp_unexpected_data
;
60 static dissector_handle_t bthcrp_handle
;
62 static int force_client
= FORCE_CLIENT_DEFAULT
;
63 static int psm_control
;
64 static int psm_data_stream
;
65 static int psm_notification
;
67 static const value_string control_pdu_id_vals
[] = {
68 { 0x0001, "CR_DataChannelCreditGrant" },
69 { 0x0002, "CR_DataChannelCreditRequest" },
70 { 0x0003, "CR_DataChannelCreditReturn" },
71 { 0x0004, "CR_DataChannelCreditQuery" },
72 { 0x0005, "CR_GetLPTStatus" },
73 { 0x0006, "CR_Get1284ID" },
74 { 0x0007, "CR_SoftReset" },
75 { 0x0008, "CR_HardReset" },
76 { 0x0009, "CR_RegisterNotification" },
77 { 0x000A, "CR_NotificationConnectionAlive" },
81 static const value_string status_vals
[] = {
82 { 0x0000, "Feature Unsupported" },
83 { 0x0001, "Success" },
84 { 0x0002, "Credit Synchronization Error" },
85 { 0xFFFF, "Generic Failure" },
89 static const value_string notification_pdu_id_vals
[] = {
90 { 0x0001, "N_Notification" },
94 static const value_string register_vals
[] = {
95 { 0x00, "Remove Client From Receiver Notification" },
96 { 0x01, "Add Client To Receiver Notification" },
100 static const enum_val_t force_client_enum
[] = {
101 { "default", "Default", FORCE_CLIENT_DEFAULT
},
102 { "yes", "Yes", FORCE_CLIENT_YES
},
103 { "no", "No", FORCE_CLIENT_NO
},
107 void proto_register_bthcrp(void);
108 void proto_reg_handoff_bthcrp(void);
112 dissect_control(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
113 int offset
, bool is_client_message
)
115 /* flow: requests: only client -> server; responses: only server -> */
117 uint16_t control_pdu_id
;
121 unsigned notification_register
;
123 int parameter_length
;
125 pitem
= proto_tree_add_item(tree
, hf_bthcrp_control_pdu_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
126 control_pdu_id
= tvb_get_ntohs(tvb
, offset
);
129 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "Control: %s %s",
130 ((is_client_message
) ? "Request" : "Response"),
131 val_to_str_const(control_pdu_id
, control_pdu_id_vals
, "Unknown PDU ID"));
133 if (control_pdu_id
>= 0x8000) {
134 proto_item_append_text(pitem
, " (Vendor Specific)");
135 col_append_str(pinfo
->cinfo
, COL_INFO
, " (Vendor Specific)");
136 } else if (control_pdu_id
== 0x0000 || control_pdu_id
>= 0x000B ) {
137 proto_item_append_text(pitem
, " (Reserved)");
138 col_append_str(pinfo
->cinfo
, COL_INFO
, " (Reserved)");
141 proto_tree_add_item(tree
, hf_bthcrp_control_transaction_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
144 pitem
= proto_tree_add_item(tree
, hf_bthcrp_control_parameter_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
145 parameter_length
= tvb_get_ntohs(tvb
, offset
);
148 if (!is_client_message
&& parameter_length
< 2) {
149 expert_add_info_format(pinfo
, pitem
, &ei_bthcrp_control_parameter_length
,
150 "Parameter length is shorter than 2 in response");
153 if (parameter_length
< tvb_reported_length_remaining(tvb
, offset
)) {
154 expert_add_info_format(pinfo
, pitem
, &ei_bthcrp_control_parameter_length
,
155 "Parameter length is shorter than payload length");
156 } else if (parameter_length
> tvb_reported_length_remaining(tvb
, offset
)) {
157 expert_add_info_format(pinfo
, pitem
, &ei_bthcrp_control_parameter_length
,
158 "Parameter length is larger than payload length");
161 if (!is_client_message
) {
162 proto_tree_add_item(tree
, hf_bthcrp_control_status
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
166 if (control_pdu_id
>= 0x8000) {
167 if (tvb_reported_length_remaining(tvb
, offset
)) {
168 proto_tree_add_item(tree
, hf_bthcrp_data
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), ENC_NA
);
169 offset
+= tvb_reported_length_remaining(tvb
, offset
);
171 } else switch(control_pdu_id
) {
172 case 0x0001: /* CR_DataChannelCreditGrant */
173 if (is_client_message
) {
174 proto_tree_add_item(tree
, hf_bthcrp_control_client_credit_granted
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
175 credits
= tvb_get_ntohl(tvb
, offset
);
176 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - CreditGranted: %u", credits
);
180 case 0x0002: /* CR_DataChannelCreditRequest */
181 if (!is_client_message
) {
182 proto_tree_add_item(tree
, hf_bthcrp_control_server_credit_granted
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
183 credits
= tvb_get_ntohl(tvb
, offset
);
184 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - CreditGranted: %u", credits
);
188 case 0x0003: /* CR_DataChannelCreditReturn */
189 if (is_client_message
) {
190 proto_tree_add_item(tree
, hf_bthcrp_control_client_credit_return
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
191 credits
= tvb_get_ntohl(tvb
, offset
);
192 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Client Credit Return: %u", credits
);
195 proto_tree_add_item(tree
, hf_bthcrp_control_server_credit_return
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
196 credits
= tvb_get_ntohl(tvb
, offset
);
197 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Server Credit Return: %u", credits
);
201 case 0x0004: /* CR_DataChannelCreditQuery */
202 if (is_client_message
) {
203 proto_tree_add_item(tree
, hf_bthcrp_control_client_credit_query
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
204 credits
= tvb_get_ntohl(tvb
, offset
);
205 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Client Credit: %u", credits
);
208 proto_tree_add_item(tree
, hf_bthcrp_control_server_credit_query
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
209 credits
= tvb_get_ntohl(tvb
, offset
);
210 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Server Credit: %u", credits
);
214 case 0x0005: /* CR_GetLPTStatus */
215 if (!is_client_message
) {
216 proto_tree_add_item(tree
, hf_bthcrp_control_status_reserved_76
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
217 proto_tree_add_item(tree
, hf_bthcrp_control_status_paper_empty
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
218 proto_tree_add_item(tree
, hf_bthcrp_control_status_select
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
219 proto_tree_add_item(tree
, hf_bthcrp_control_status_not_error
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
220 proto_tree_add_item(tree
, hf_bthcrp_control_status_reserved_20
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
224 case 0x0006: /* CR_Get1284ID */
225 if (is_client_message
) {
226 proto_tree_add_item(tree
, hf_bthcrp_control_start_byte
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
227 number
= tvb_get_ntohs(tvb
, offset
);
228 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Start Byte: %u", number
);
231 proto_tree_add_item(tree
, hf_bthcrp_control_number_of_bytes
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
232 number
= tvb_get_ntohs(tvb
, offset
);
233 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Number Of Bytes: %u", number
);
238 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
);
239 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - 1284 ID: %s", id
);
240 offset
+= tvb_reported_length_remaining(tvb
, offset
);
243 case 0x0007: /* CR_SoftReset */
244 case 0x0008: /* CR_HardReset */
246 case 0x0009: /* CR_RegisterNotification */
247 if (is_client_message
) {
248 proto_tree_add_item(tree
, hf_bthcrp_control_register
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
249 notification_register
= tvb_get_uint8(tvb
, offset
);
250 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Register: %s", val_to_str_const(notification_register
, register_vals
, "unknown register"));
253 proto_tree_add_item(tree
, hf_bthcrp_callback_context_id
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
254 context_id
= tvb_get_ntohl(tvb
, offset
);
255 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Callback ContextID: %u", context_id
);
258 proto_tree_add_item(tree
, hf_bthcrp_control_callback_timeout
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
259 timeout
= tvb_get_ntohl(tvb
, offset
);
260 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Callback Timeout: %u", timeout
);
263 proto_tree_add_item(tree
, hf_bthcrp_control_timeout
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
264 timeout
= tvb_get_ntohl(tvb
, offset
);
265 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Timeout: %u", timeout
);
268 proto_tree_add_item(tree
, hf_bthcrp_control_callback_timeout
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
269 timeout
= tvb_get_ntohl(tvb
, offset
);
270 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Callback Timeout: %u", timeout
);
274 case 0x000A: /* CR_NotificationConnectionAlive */
275 if (!is_client_message
) {
276 proto_tree_add_item(tree
, hf_bthcrp_control_timeout
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
277 timeout
= tvb_get_ntohl(tvb
, offset
);
278 col_append_fstr(pinfo
->cinfo
, COL_INFO
, " - Timeout: %u", timeout
);
289 dissect_data(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, int offset
)
291 /* flow: server <-> client */
294 col_append_str(pinfo
->cinfo
, COL_INFO
, "HCRP data stream");
296 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
297 call_data_dissector(next_tvb
, pinfo
, tree
);
299 offset
+= tvb_reported_length_remaining(tvb
, offset
);
306 dissect_notification(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
,
307 int offset
, bool is_client_message
)
309 /* flow: only server -> client */
310 uint16_t notification_pdu_id
;
313 if (is_client_message
) {
314 col_append_str(pinfo
->cinfo
, COL_INFO
, "Notification: unexpected notification stream");
318 pitem
= proto_tree_add_item(tree
, hf_bthcrp_notification_pdu_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
319 notification_pdu_id
= tvb_get_ntohs(tvb
, offset
);
322 col_append_fstr(pinfo
->cinfo
, COL_INFO
, "Notification: %s", val_to_str_const(notification_pdu_id
, notification_pdu_id_vals
, "Unknown PDU ID"));
324 if (notification_pdu_id
>= 0x8000) {
325 proto_item_append_text(pitem
, " (Vendor Specific)");
326 col_append_str(pinfo
->cinfo
, COL_INFO
, " (Vendor Specific)");
327 if (tvb_reported_length_remaining(tvb
, offset
)) {
328 proto_tree_add_item(tree
, hf_bthcrp_data
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), ENC_NA
);
329 offset
+= tvb_reported_length_remaining(tvb
, offset
);
331 } else if (notification_pdu_id
!= 0x001) {
332 proto_item_append_text(pitem
, " (Reserved)");
333 col_append_str(pinfo
->cinfo
, COL_INFO
, " (Reserved)");
336 switch(notification_pdu_id
) {
337 case 0x01: /* N_NOTIFICATION */
338 proto_tree_add_item(tree
, hf_bthcrp_callback_context_id
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
347 dissect_bthcrp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data
)
349 proto_item
*main_item
;
350 proto_tree
*main_tree
;
353 bool is_client_message
= false;
356 previous_proto
= (GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_frame_prev(wmem_list_tail(pinfo
->layers
)))));
357 if (previous_proto
== proto_btl2cap
) {
358 btl2cap_data_t
*l2cap_data
;
359 wmem_tree_key_t key
[10];
360 uint32_t interface_id
;
362 uint32_t sdp_psm
= SDP_PSM_DEFAULT
;
364 uint32_t bd_addr_oui
;
366 uint32_t service_type
;
367 uint32_t service_channel
;
368 uint32_t frame_number
;
369 service_info_t
*service_info
;
371 l2cap_data
= (btl2cap_data_t
*) data
;
373 interface_id
= l2cap_data
->interface_id
;
374 adapter_id
= l2cap_data
->adapter_id
;
376 direction
= (l2cap_data
->is_local_psm
) ? P2P_DIR_SENT
: P2P_DIR_RECV
;
377 if (direction
== P2P_DIR_RECV
) {
378 bd_addr_oui
= l2cap_data
->remote_bd_addr_oui
;
379 bd_addr_id
= l2cap_data
->remote_bd_addr_id
;
385 service_type
= BTSDP_L2CAP_PROTOCOL_UUID
;
386 service_channel
= l2cap_data
->psm
;
387 frame_number
= pinfo
->num
;
390 key
[0].key
= &interface_id
;
392 key
[1].key
= &adapter_id
;
394 key
[2].key
= &sdp_psm
;
396 key
[3].key
= &direction
;
398 key
[4].key
= &bd_addr_oui
;
400 key
[5].key
= &bd_addr_id
;
402 key
[6].key
= &service_type
;
404 key
[7].key
= &service_channel
;
406 key
[8].key
= &frame_number
;
410 service_info
= btsdp_get_service_info(key
);
411 if (service_info
&& service_info
->interface_id
== interface_id
&&
412 service_info
->adapter_id
== adapter_id
&&
413 service_info
->sdp_psm
== SDP_PSM_DEFAULT
&&
414 ((service_info
->direction
== P2P_DIR_RECV
&&
415 service_info
->bd_addr_oui
== bd_addr_oui
&&
416 service_info
->bd_addr_id
== bd_addr_id
) ||
417 (service_info
->direction
!= P2P_DIR_RECV
&&
418 service_info
->bd_addr_oui
== 0 &&
419 service_info
->bd_addr_id
== 0)) &&
420 service_info
->type
== BTSDP_L2CAP_PROTOCOL_UUID
&&
421 service_info
->channel
== l2cap_data
->psm
) {
423 if ((service_info
->protocol
== BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID
||
424 service_info
->protocol
== BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID
) &&
425 ((!l2cap_data
->is_local_psm
&& pinfo
->p2p_dir
== P2P_DIR_SENT
) ||
426 (l2cap_data
->is_local_psm
&& pinfo
->p2p_dir
== P2P_DIR_RECV
))) {
427 is_client_message
= true;
428 } else if (service_info
->protocol
== BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID
&&
429 ((l2cap_data
->is_local_psm
&& pinfo
->p2p_dir
== P2P_DIR_SENT
) ||
430 (!l2cap_data
->is_local_psm
&& pinfo
->p2p_dir
== P2P_DIR_RECV
))) {
431 is_client_message
= true;
434 protocol
= service_info
->protocol
;
437 if (psm_control
!= 0 && l2cap_data
->psm
== psm_control
) {
438 protocol
= BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID
;
439 } else if (psm_data_stream
!= 0 && l2cap_data
->psm
== psm_data_stream
) {
440 protocol
= BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID
;
441 } else if (psm_notification
!= 0 && l2cap_data
->psm
== psm_notification
) {
442 protocol
= BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID
;
447 main_item
= proto_tree_add_item(tree
, proto_bthcrp
, tvb
, offset
, -1, ENC_NA
);
448 main_tree
= proto_item_add_subtree(main_item
, ett_bthcrp
);
450 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "HCRP");
452 switch (pinfo
->p2p_dir
) {
454 col_set_str(pinfo
->cinfo
, COL_INFO
, "Sent ");
457 col_set_str(pinfo
->cinfo
, COL_INFO
, "Rcvd ");
460 col_set_str(pinfo
->cinfo
, COL_INFO
, "UnknownDirection ");
464 if (force_client
!= FORCE_CLIENT_DEFAULT
) {
465 is_client_message
= (force_client
== FORCE_CLIENT_YES
&& pinfo
->p2p_dir
== P2P_DIR_SENT
) ||
466 (force_client
!= FORCE_CLIENT_YES
&& pinfo
->p2p_dir
== P2P_DIR_RECV
);
469 if (protocol
== BTSDP_HARDCOPY_CONTROL_CHANNEL_PROTOCOL_UUID
) {
470 offset
= dissect_control(tvb
, pinfo
, main_tree
, offset
, is_client_message
);
471 } else if (protocol
== BTSDP_HARDCOPY_DATA_CHANNEL_PROTOCOL_UUID
) {
472 offset
= dissect_data(tvb
, pinfo
, main_tree
, offset
);
473 } else if (protocol
== BTSDP_HARDCOPY_NOTIFICATION_PROTOCOL_UUID
) {
474 offset
= dissect_notification(tvb
, pinfo
, main_tree
, offset
, is_client_message
);
476 col_append_str(pinfo
->cinfo
, COL_INFO
, "HCRP stream");
479 if (tvb_reported_length_remaining(tvb
, offset
)) {
482 pitem
= proto_tree_add_item(main_tree
, hf_bthcrp_data
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), ENC_NA
);
483 expert_add_info(pinfo
, pitem
, &ei_bthcrp_unexpected_data
);
491 proto_register_bthcrp(void)
494 expert_module_t
* expert_bthcrp
;
496 static hf_register_info hf
[] = {
497 { &hf_bthcrp_control_pdu_id
,
498 { "Control PDU ID", "bthcrp.control.pdu_id",
499 FT_UINT16
, BASE_HEX
, VALS(control_pdu_id_vals
), 0x00,
502 { &hf_bthcrp_control_transaction_id
,
503 { "Transaction ID", "bthcrp.control.transaction_id",
504 FT_UINT16
, BASE_HEX
, NULL
, 0x00,
507 { &hf_bthcrp_control_parameter_length
,
508 { "Parameter Length", "bthcrp.control.parameter_length",
509 FT_UINT16
, BASE_HEX
, NULL
, 0x00,
512 { &hf_bthcrp_control_status
,
513 { "Status", "bthcrp.control.status",
514 FT_UINT16
, BASE_HEX
, VALS(status_vals
), 0x00,
517 { &hf_bthcrp_notification_pdu_id
,
518 { "Notification PDU ID", "bthcrp.notification.pdu_id",
519 FT_UINT16
, BASE_HEX
, VALS(notification_pdu_id_vals
), 0x00,
522 { &hf_bthcrp_callback_context_id
,
523 { "Callback Context ID", "bthcrp.callback.context_id",
524 FT_UINT32
, BASE_HEX
, NULL
, 0x00,
527 { &hf_bthcrp_control_callback_timeout
,
528 { "Callback Timeout", "bthcrp.callback.timeout",
529 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
532 { &hf_bthcrp_control_timeout
,
533 { "Timeout", "bthcrp.timeout",
534 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
537 { &hf_bthcrp_control_register
,
538 { "Register", "bthcrp.register",
539 FT_UINT8
, BASE_HEX
, VALS(register_vals
), 0x00,
542 { &hf_bthcrp_control_1284_id
,
543 { "1284 ID", "bthcrp.1284_id",
544 FT_STRING
, BASE_NONE
, NULL
, 0x00,
547 { &hf_bthcrp_control_start_byte
,
548 { "Start Byte", "bthcrp.start_byte",
549 FT_UINT16
, BASE_DEC
, NULL
, 0x00,
552 { &hf_bthcrp_control_number_of_bytes
,
553 { "Number Of Bytes", "bthcrp.number_of_bytes",
554 FT_UINT16
, BASE_DEC
, NULL
, 0x00,
557 { &hf_bthcrp_control_client_credit_granted
,
558 { "Client Credit Granted", "bthcrp.client_credit_granted",
559 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
562 { &hf_bthcrp_control_server_credit_granted
,
563 { "Server Credit Granted", "bthcrp.server_credit_granted",
564 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
567 { &hf_bthcrp_control_client_credit_return
,
568 { "Client Credit Return", "bthcrp.client_credit_return",
569 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
572 { &hf_bthcrp_control_server_credit_return
,
573 { "Server Credit Return", "bthcrp.server_credit_return",
574 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
577 { &hf_bthcrp_control_client_credit_query
,
578 { "Client Credit Query", "bthcrp.client_credit_query",
579 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
582 { &hf_bthcrp_control_server_credit_query
,
583 { "Server Credit Query", "bthcrp.server_credit_query",
584 FT_UINT32
, BASE_DEC
, NULL
, 0x00,
587 { &hf_bthcrp_control_status_reserved_76
,
588 { "Reserved", "bthcrp.status.reserved76",
589 FT_UINT8
, BASE_DEC
, NULL
, 0xC0,
592 { &hf_bthcrp_control_status_paper_empty
,
593 { "Paper Empty", "bthcrp.status.paper_empty",
594 FT_BOOLEAN
, 8, NULL
, 0x20,
597 { &hf_bthcrp_control_status_select
,
598 { "Select", "bthcrp.status.select",
599 FT_BOOLEAN
, 8, NULL
, 0x10,
602 { &hf_bthcrp_control_status_not_error
,
603 { "Not Error", "bthcrp.status.not_error",
604 FT_BOOLEAN
, 8, NULL
, 0x08,
607 { &hf_bthcrp_control_status_reserved_20
,
608 { "Reserved", "bthcrp.status.reserved210",
609 FT_UINT8
, BASE_HEX
, NULL
, 0x07,
613 { "Data", "bthcrp.data",
614 FT_NONE
, BASE_NONE
, NULL
, 0x00,
619 static int *ett
[] = {
623 static ei_register_info ei
[] = {
624 { &ei_bthcrp_control_parameter_length
, { "bthcrp.control_parameter_length.bad", PI_PROTOCOL
, PI_WARN
, "Length bad", EXPFILL
}},
625 { &ei_bthcrp_unexpected_data
, { "bthcrp.unexpected_data", PI_PROTOCOL
, PI_WARN
, "Unexpected data", EXPFILL
}},
628 proto_bthcrp
= proto_register_protocol("Bluetooth HCRP Profile", "BT HCRP", "bthcrp");
629 bthcrp_handle
= register_dissector("bthcrp", dissect_bthcrp
, proto_bthcrp
);
631 proto_register_field_array(proto_bthcrp
, hf
, array_length(hf
));
632 proto_register_subtree_array(ett
, array_length(ett
));
633 expert_bthcrp
= expert_register_protocol(proto_bthcrp
);
634 expert_register_field_array(expert_bthcrp
, ei
, array_length(ei
));
636 module
= prefs_register_protocol_subtree("Bluetooth", proto_bthcrp
, NULL
);
637 prefs_register_static_text_preference(module
, "hcrp.version",
638 "Bluetooth Profile HCRP version: 1.2",
639 "Version of profile supported by this dissector.");
641 prefs_register_obsolete_preference(module
, "hcrp.is_client");
643 prefs_register_enum_preference(module
, "hcrp.force_client", "Force Client",
644 "If \"yes\" localhost will be treat as Client, \"no\" as Server",
645 &force_client
, force_client_enum
, false);
647 prefs_register_uint_preference(module
, "hcrp.control.psm", "L2CAP PSM for Control",
648 "L2CAP PSM for Control",
650 prefs_register_uint_preference(module
, "hcrp.data.psm", "L2CAP PSM for Data",
651 "L2CAP PSM for Data",
652 10, &psm_data_stream
);
653 prefs_register_uint_preference(module
, "hcrp.notification.psm", "L2CAP PSM for Notification",
654 "L2CAP PSM for Notification",
655 10, &psm_notification
);
659 proto_reg_handoff_bthcrp(void)
661 dissector_add_string("bluetooth.uuid", "12", bthcrp_handle
);
662 dissector_add_string("bluetooth.uuid", "14", bthcrp_handle
);
663 dissector_add_string("bluetooth.uuid", "16", bthcrp_handle
);
664 dissector_add_string("bluetooth.uuid", "1125", bthcrp_handle
);
665 dissector_add_string("bluetooth.uuid", "1126", bthcrp_handle
);
666 dissector_add_string("bluetooth.uuid", "1127", bthcrp_handle
);
668 dissector_add_for_decode_as("btl2cap.psm", bthcrp_handle
);
669 dissector_add_for_decode_as("btl2cap.cid", bthcrp_handle
);
673 * Editor modelines - https://www.wireshark.org/tools/modelines.html
678 * indent-tabs-mode: nil
681 * vi: set shiftwidth=4 tabstop=8 expandtab:
682 * :indentSize=4:tabSize=8:noTabs=true: