epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-bthcrp.c
blob899047ffe04a3f2cf6a7233200ada45a6219b33d
1 /* packet-bthcrp.c
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
13 #include "config.h"
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"
22 enum {
23 FORCE_CLIENT_DEFAULT = 0,
24 FORCE_CLIENT_YES = 1,
25 FORCE_CLIENT_NO = 2
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" },
78 { 0, NULL }
81 static const value_string status_vals[] = {
82 { 0x0000, "Feature Unsupported" },
83 { 0x0001, "Success" },
84 { 0x0002, "Credit Synchronization Error" },
85 { 0xFFFF, "Generic Failure" },
86 { 0, NULL }
89 static const value_string notification_pdu_id_vals[] = {
90 { 0x0001, "N_Notification" },
91 { 0, NULL }
94 static const value_string register_vals[] = {
95 { 0x00, "Remove Client From Receiver Notification" },
96 { 0x01, "Add Client To Receiver Notification" },
97 { 0, NULL }
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 },
104 { NULL, NULL, 0 }
107 void proto_register_bthcrp(void);
108 void proto_reg_handoff_bthcrp(void);
111 static int
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 -> */
116 proto_item *pitem;
117 uint16_t control_pdu_id;
118 unsigned credits;
119 unsigned timeout;
120 unsigned context_id;
121 unsigned notification_register;
122 unsigned number;
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);
127 offset += 2;
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);
142 offset += 2;
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);
146 offset += 2;
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);
163 offset += 2;
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);
177 offset += 4;
179 break;
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);
185 offset += 4;
187 break;
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);
193 offset += 4;
194 } else {
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);
198 offset += 4;
200 break;
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);
206 offset += 4;
207 } else {
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);
211 offset += 4;
213 break;
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);
221 offset += 1;
223 break;
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);
229 offset += 2;
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);
234 offset += 2;
235 } else {
236 const uint8_t *id;
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);
242 break;
243 case 0x0007: /* CR_SoftReset */
244 case 0x0008: /* CR_HardReset */
245 break;
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"));
251 offset += 1;
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);
256 offset += 4;
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);
261 offset += 4;
262 } else {
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);
266 offset += 4;
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);
271 offset += 4;
273 break;
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);
279 offset += 4;
281 break;
284 return offset;
288 static int
289 dissect_data(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
291 /* flow: server <-> client */
292 tvbuff_t *next_tvb;
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);
301 return offset;
305 static int
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;
311 proto_item *pitem;
313 if (is_client_message) {
314 col_append_str(pinfo->cinfo, COL_INFO, "Notification: unexpected notification stream");
315 return offset;
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);
320 offset += 2;
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);
339 offset += 4;
340 break;
343 return offset;
346 static int
347 dissect_bthcrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
349 proto_item *main_item;
350 proto_tree *main_tree;
351 int offset = 0;
352 int protocol = -1;
353 bool is_client_message = false;
354 int previous_proto;
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;
361 uint32_t adapter_id;
362 uint32_t sdp_psm = SDP_PSM_DEFAULT;
363 uint32_t direction;
364 uint32_t bd_addr_oui;
365 uint32_t bd_addr_id;
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;
380 } else {
381 bd_addr_oui = 0;
382 bd_addr_id = 0;
385 service_type = BTSDP_L2CAP_PROTOCOL_UUID;
386 service_channel = l2cap_data->psm;
387 frame_number = pinfo->num;
389 key[0].length = 1;
390 key[0].key = &interface_id;
391 key[1].length = 1;
392 key[1].key = &adapter_id;
393 key[2].length = 1;
394 key[2].key = &sdp_psm;
395 key[3].length = 1;
396 key[3].key = &direction;
397 key[4].length = 1;
398 key[4].key = &bd_addr_oui;
399 key[5].length = 1;
400 key[5].key = &bd_addr_id;
401 key[6].length = 1;
402 key[6].key = &service_type;
403 key[7].length = 1;
404 key[7].key = &service_channel;
405 key[8].length = 1;
406 key[8].key = &frame_number;
407 key[9].length = 0;
408 key[9].key = NULL;
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) {
453 case P2P_DIR_SENT:
454 col_set_str(pinfo->cinfo, COL_INFO, "Sent ");
455 break;
456 case P2P_DIR_RECV:
457 col_set_str(pinfo->cinfo, COL_INFO, "Rcvd ");
458 break;
459 default:
460 col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection ");
461 break;
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);
475 } else {
476 col_append_str(pinfo->cinfo, COL_INFO, "HCRP stream");
479 if (tvb_reported_length_remaining(tvb, offset)) {
480 proto_item *pitem;
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);
486 return offset;
490 void
491 proto_register_bthcrp(void)
493 module_t *module;
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,
500 NULL, HFILL }
502 { &hf_bthcrp_control_transaction_id,
503 { "Transaction ID", "bthcrp.control.transaction_id",
504 FT_UINT16, BASE_HEX, NULL, 0x00,
505 NULL, HFILL }
507 { &hf_bthcrp_control_parameter_length,
508 { "Parameter Length", "bthcrp.control.parameter_length",
509 FT_UINT16, BASE_HEX, NULL, 0x00,
510 NULL, HFILL }
512 { &hf_bthcrp_control_status,
513 { "Status", "bthcrp.control.status",
514 FT_UINT16, BASE_HEX, VALS(status_vals), 0x00,
515 NULL, HFILL }
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,
520 NULL, HFILL }
522 { &hf_bthcrp_callback_context_id,
523 { "Callback Context ID", "bthcrp.callback.context_id",
524 FT_UINT32, BASE_HEX, NULL, 0x00,
525 NULL, HFILL }
527 { &hf_bthcrp_control_callback_timeout,
528 { "Callback Timeout", "bthcrp.callback.timeout",
529 FT_UINT32, BASE_DEC, NULL, 0x00,
530 NULL, HFILL }
532 { &hf_bthcrp_control_timeout,
533 { "Timeout", "bthcrp.timeout",
534 FT_UINT32, BASE_DEC, NULL, 0x00,
535 NULL, HFILL }
537 { &hf_bthcrp_control_register,
538 { "Register", "bthcrp.register",
539 FT_UINT8, BASE_HEX, VALS(register_vals), 0x00,
540 NULL, HFILL }
542 { &hf_bthcrp_control_1284_id,
543 { "1284 ID", "bthcrp.1284_id",
544 FT_STRING, BASE_NONE, NULL, 0x00,
545 NULL, HFILL }
547 { &hf_bthcrp_control_start_byte,
548 { "Start Byte", "bthcrp.start_byte",
549 FT_UINT16, BASE_DEC, NULL, 0x00,
550 NULL, HFILL }
552 { &hf_bthcrp_control_number_of_bytes,
553 { "Number Of Bytes", "bthcrp.number_of_bytes",
554 FT_UINT16, BASE_DEC, NULL, 0x00,
555 NULL, HFILL }
557 { &hf_bthcrp_control_client_credit_granted,
558 { "Client Credit Granted", "bthcrp.client_credit_granted",
559 FT_UINT32, BASE_DEC, NULL, 0x00,
560 NULL, HFILL }
562 { &hf_bthcrp_control_server_credit_granted,
563 { "Server Credit Granted", "bthcrp.server_credit_granted",
564 FT_UINT32, BASE_DEC, NULL, 0x00,
565 NULL, HFILL }
567 { &hf_bthcrp_control_client_credit_return,
568 { "Client Credit Return", "bthcrp.client_credit_return",
569 FT_UINT32, BASE_DEC, NULL, 0x00,
570 NULL, HFILL }
572 { &hf_bthcrp_control_server_credit_return,
573 { "Server Credit Return", "bthcrp.server_credit_return",
574 FT_UINT32, BASE_DEC, NULL, 0x00,
575 NULL, HFILL }
577 { &hf_bthcrp_control_client_credit_query,
578 { "Client Credit Query", "bthcrp.client_credit_query",
579 FT_UINT32, BASE_DEC, NULL, 0x00,
580 NULL, HFILL }
582 { &hf_bthcrp_control_server_credit_query,
583 { "Server Credit Query", "bthcrp.server_credit_query",
584 FT_UINT32, BASE_DEC, NULL, 0x00,
585 NULL, HFILL }
587 { &hf_bthcrp_control_status_reserved_76,
588 { "Reserved", "bthcrp.status.reserved76",
589 FT_UINT8, BASE_DEC, NULL, 0xC0,
590 NULL, HFILL }
592 { &hf_bthcrp_control_status_paper_empty,
593 { "Paper Empty", "bthcrp.status.paper_empty",
594 FT_BOOLEAN, 8, NULL, 0x20,
595 NULL, HFILL }
597 { &hf_bthcrp_control_status_select,
598 { "Select", "bthcrp.status.select",
599 FT_BOOLEAN, 8, NULL, 0x10,
600 NULL, HFILL }
602 { &hf_bthcrp_control_status_not_error,
603 { "Not Error", "bthcrp.status.not_error",
604 FT_BOOLEAN, 8, NULL, 0x08,
605 NULL, HFILL }
607 { &hf_bthcrp_control_status_reserved_20,
608 { "Reserved", "bthcrp.status.reserved210",
609 FT_UINT8, BASE_HEX, NULL, 0x07,
610 NULL, HFILL }
612 { &hf_bthcrp_data,
613 { "Data", "bthcrp.data",
614 FT_NONE, BASE_NONE, NULL, 0x00,
615 NULL, HFILL }
619 static int *ett[] = {
620 &ett_bthcrp
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",
649 10, &psm_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);
658 void
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
675 * Local variables:
676 * c-basic-offset: 4
677 * tab-width: 8
678 * indent-tabs-mode: nil
679 * End:
681 * vi: set shiftwidth=4 tabstop=8 expandtab:
682 * :indentSize=4:tabSize=8:noTabs=true: