Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-bfcp.c
blobf6402bcff18ea66c30cd039758431e1c238bbb37
1 /* packet-bfcp.c
2 * Routines for Binary Floor Control Protocol(BFCP) dissection
3 * Copyright 2012, Nitinkumar Yemul <nitinkumaryemul@gmail.com>
5 * Updated with attribute dissection
6 * Copyright 2012, Anders Broman <anders.broman@ericsson.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
14 * BFCP Message structure is defined in RFC 8855
16 #include "config.h"
18 #include <epan/packet.h>
19 #include <epan/prefs.h>
20 #include <epan/expert.h>
21 #include <epan/conversation.h>
22 #include <epan/proto_data.h>
23 #include <epan/tfs.h>
25 #include "packet-bfcp.h"
27 void proto_register_bfcp(void);
28 void proto_reg_handoff_bfcp(void);
30 /* Initialize protocol and registered fields */
31 static int proto_bfcp;
33 static int hf_bfcp_version;
34 static int hf_bfcp_hdr_r_bit;
35 static int hf_bfcp_hdr_f_bit;
36 static int hf_bfcp_primitive;
37 static int hf_bfcp_payload_length;
38 static int hf_bfcp_conference_id;
39 static int hf_bfcp_transaction_id;
40 static int hf_bfcp_user_id;
41 static int hf_bfcp_fragment_offset;
42 static int hf_bfcp_fragment_length;
43 static int hf_bfcp_payload;
44 static int hf_bfcp_attribute_types;
45 static int hf_bfcp_attribute_types_m_bit;
46 static int hf_bfcp_attribute_length;
47 static int hf_bfcp_beneficiary_id;
48 static int hf_bfcp_floor_id;
49 static int hf_bfcp_floor_request_id;
50 static int hf_bfcp_priority;
51 static int hf_bfcp_request_status;
52 static int hf_bfcp_queue_pos;
53 static int hf_bfcp_error_code;
54 static int hf_bfcp_error_info_text;
55 static int hf_bfcp_part_prov_info_text;
56 static int hf_bfcp_status_info_text;
57 static int hf_bfcp_supp_attr;
58 static int hf_bfcp_supp_prim;
59 static int hf_bfcp_user_disp_name;
60 static int hf_bfcp_user_uri;
61 static int hf_bfcp_req_by_id;
62 static int hf_bfcp_padding;
63 static int hf_bfcp_error_specific_details;
64 /* BFCP setup fields */
65 static int hf_bfcp_setup;
66 static int hf_bfcp_setup_frame;
67 static int hf_bfcp_setup_method;
69 /* Initialize subtree pointers */
70 static int ett_bfcp;
71 static int ett_bfcp_setup;
72 static int ett_bfcp_attr;
74 static expert_field ei_bfcp_attribute_length_too_small;
76 static dissector_handle_t bfcp_handle;
78 #define BFCP_HDR_LEN 12
80 /* Initialize BFCP primitives */
81 static const value_string map_bfcp_primitive[] = {
82 { 0, "<Invalid Primitive>"},
83 { 1, "FloorRequest"},
84 { 2, "FloorRelease"},
85 { 3, "FloorRequestQuery"},
86 { 4, "FloorRequestStatus"},
87 { 5, "UserQuery"},
88 { 6, "UserStatus"},
89 { 7, "FloorQuery"},
90 { 8, "FloorStatus"},
91 { 9, "ChairAction"},
92 { 10, "ChairActionAck"},
93 { 11, "Hello"},
94 { 12, "HelloAck"},
95 { 13, "Error"},
96 { 14, "FloorRequestStatusAck"},
97 { 15, "FloorStatusAck"},
98 { 16, "Goodbye"},
99 { 17, "GoodbyeAck"},
100 { 0, NULL},
103 static const value_string map_bfcp_attribute_types[] = {
104 { 0, "<Invalid Primitive>"},
105 { 1, "BeneficiaryID"},
106 { 2, "FloorID"},
107 { 3, "FloorRequestID"},
108 { 4, "Priority"},
109 { 5, "RequestStatus"},
110 { 6, "ErrorCode"},
111 { 7, "ErrorInfo"},
112 { 8, "ParticipantProvidedInfo"},
113 { 9, "StatusInfo"},
114 { 10, "SupportedAttributes"},
115 { 11, "SupportedPrimitives"},
116 { 12, "UserDisplayName"},
117 { 13, "UserURI"},
118 { 14, "BeneficiaryInformation"},
119 { 15, "FloorRequestInformation"},
120 { 16, "RequestedByInformation"},
121 { 17, "FloorRequestStatus"},
122 { 18, "OverallRequestStatus"},
123 { 0, NULL},
126 static const value_string map_bfcp_request_status[] = {
127 { 0, "<Invalid Primitive>"},
128 { 1, "Pending"},
129 { 2, "Accepted"},
130 { 3, "Granted"},
131 { 4, "Denied"},
132 { 5, "Cancelled"},
133 { 6, "Released"},
134 { 7, "Revoked"},
135 { 0, NULL},
138 /* 5.2.6. ERROR-CODE */
139 static const value_string bfcp_error_code_valuse[] = {
140 { 1, "Conference does not Exist"},
141 { 2, "User does not Exist"},
142 { 3, "Unknown Primitive"},
143 { 4, "Unknown Mandatory Attribute"},
144 { 5, "Unauthorized Operation"},
145 { 6, "Invalid Floor ID"},
146 { 7, "Floor Request ID Does Not Exist"},
147 { 8, "You have Already Reached the Maximum Number of Ongoing Floor Requests for this Floor"},
148 { 9, "Use TLS"},
149 { 10, "Unable to Parse Message"},
150 { 11, "Use DTLS"},
151 { 12, "Unsupported Version"},
152 { 13, "Incorrect Message Length"},
153 { 14, "Generic Error"},
155 { 0, NULL},
158 /*Define offset for fields in BFCP packet */
159 #define BFCP_OFFSET_TRANSACTION_INITIATOR 0
160 #define BFCP_OFFSET_PRIMITIVE 1
161 #define BFCP_OFFSET_PAYLOAD_LENGTH 2
162 #define BFCP_OFFSET_CONFERENCE_ID 4
163 #define BFCP_OFFSET_TRANSACTION_ID 8
164 #define BFCP_OFFSET_USER_ID 10
165 #define BFCP_OFFSET_PAYLOAD 12
167 /* Set up an BFCP conversation using the info given */
168 void
169 bfcp_add_address( packet_info *pinfo, port_type ptype,
170 address *addr, int port,
171 const char *setup_method, uint32_t setup_frame_number)
173 address null_addr;
174 conversation_t* p_conv;
175 struct _bfcp_conversation_info *p_conv_data = NULL;
178 * If this isn't the first time this packet has been processed,
179 * we've already done this work, so we don't need to do it
180 * again.
182 if (PINFO_FD_VISITED(pinfo)) {
183 return;
186 clear_address(&null_addr);
189 * Check if the ip address and port combination is not
190 * already registered as a conversation.
192 p_conv = find_conversation( pinfo->num, addr, &null_addr, conversation_pt_to_conversation_type(ptype), port, 0,
193 NO_ADDR_B | NO_PORT_B);
196 * If not, create a new conversation.
198 if (!p_conv) {
199 p_conv = conversation_new( pinfo->num, addr, &null_addr, conversation_pt_to_conversation_type(ptype),
200 (uint32_t)port, 0,
201 NO_ADDR2 | NO_PORT2);
204 /* Set dissector */
205 conversation_set_dissector(p_conv, bfcp_handle);
208 * Check if the conversation has data associated with it.
210 p_conv_data = (struct _bfcp_conversation_info *)conversation_get_proto_data(p_conv, proto_bfcp);
213 * If not, add a new data item.
215 if (!p_conv_data) {
216 /* Create conversation data */
217 p_conv_data = wmem_new0(wmem_file_scope(), struct _bfcp_conversation_info);
218 conversation_add_proto_data(p_conv, proto_bfcp, p_conv_data);
222 * Update the conversation data.
224 p_conv_data->setup_method_set = true;
225 (void) g_strlcpy(p_conv_data->setup_method, setup_method, MAX_BFCP_SETUP_METHOD_SIZE);
226 p_conv_data->setup_frame_number = setup_frame_number;
229 /* Look for conversation info and display any setup info found */
230 static void
231 show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
233 /* Conversation and current data */
234 conversation_t *p_conv = NULL;
235 struct _bfcp_conversation_info *p_conv_data = NULL;
237 /* Use existing packet data if available */
238 p_conv_data = (struct _bfcp_conversation_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_bfcp, 0);
240 if (!p_conv_data) {
241 /* First time, get info from conversation */
242 p_conv = find_conversation(pinfo->num, &pinfo->net_dst, &pinfo->net_src,
243 conversation_pt_to_conversation_type(pinfo->ptype),
244 pinfo->destport, pinfo->srcport, 0);
246 if (p_conv) {
247 /* Look for data in conversation */
248 struct _bfcp_conversation_info *p_conv_packet_data;
249 p_conv_data = (struct _bfcp_conversation_info *)conversation_get_proto_data(p_conv, proto_bfcp);
251 if (p_conv_data) {
252 /* Save this conversation info into packet info */
253 p_conv_packet_data = (struct _bfcp_conversation_info *)wmem_memdup(wmem_file_scope(),
254 p_conv_data, sizeof(struct _bfcp_conversation_info));
256 p_add_proto_data(wmem_file_scope(), pinfo, proto_bfcp, 0, p_conv_packet_data);
261 /* Create setup info subtree with summary info. */
262 if (p_conv_data && p_conv_data->setup_method_set) {
263 proto_tree *bfcp_setup_tree;
264 proto_item *ti = proto_tree_add_string_format(tree, hf_bfcp_setup, tvb, 0, 0,
266 "Stream setup by %s (frame %u)",
267 p_conv_data->setup_method,
268 p_conv_data->setup_frame_number);
269 proto_item_set_generated(ti);
270 bfcp_setup_tree = proto_item_add_subtree(ti, ett_bfcp_setup);
271 if (bfcp_setup_tree) {
272 /* Add details into subtree */
273 proto_item* item = proto_tree_add_uint(bfcp_setup_tree, hf_bfcp_setup_frame,
274 tvb, 0, 0, p_conv_data->setup_frame_number);
275 proto_item_set_generated(item);
276 item = proto_tree_add_string(bfcp_setup_tree, hf_bfcp_setup_method,
277 tvb, 0, 0, p_conv_data->setup_method);
278 proto_item_set_generated(item);
283 static int
284 // NOLINTNEXTLINE(misc-no-recursion)
285 dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int bfcp_payload_length)
287 proto_item *ti, *item;
288 proto_tree *bfcp_attr_tree = NULL;
289 int attr_start_offset;
290 int length;
291 uint8_t attribute_type;
292 int read_attr = 0;
293 uint8_t first_byte, pad_len;
295 increment_dissection_depth(pinfo);
296 while ((tvb_reported_length_remaining(tvb, offset) >= 2) &&
297 ((bfcp_payload_length - read_attr) >= 2))
300 attr_start_offset = offset;
301 first_byte = tvb_get_uint8(tvb, offset);
303 /* Padding so continue to next attribute */
304 if (first_byte == 0){
305 read_attr++;
306 continue;
309 ti = proto_tree_add_item(tree, hf_bfcp_attribute_types, tvb, offset, 1, ENC_BIG_ENDIAN);
310 bfcp_attr_tree = proto_item_add_subtree(ti, ett_bfcp_attr);
311 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_attribute_types_m_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
313 attribute_type = (first_byte & 0xFE) >> 1;
314 offset++;
316 /* Length: This 8-bit field contains the length of the attribute in
317 * octets, excluding any padding defined for specific attributes. The
318 * length of attributes that are not grouped includes the Type, 'M' bit,
319 * and Length fields. The Length in grouped attributes is the length of
320 * the grouped attribute itself (including Type, 'M' bit, and Length
321 * fields) plus the total length (including padding) of all the included
322 * attributes.
325 item = proto_tree_add_item(bfcp_attr_tree, hf_bfcp_attribute_length, tvb, offset, 1, ENC_BIG_ENDIAN);
326 length = tvb_get_uint8(tvb, offset);
327 /* At least Type, M bit and Length fields */
328 if (length < 2){
329 expert_add_info_format(pinfo, item, &ei_bfcp_attribute_length_too_small,
330 "Attribute length is too small (%d bytes - minimum valid is 2)", length);
331 break;
333 offset++;
335 switch(attribute_type){
336 case 1: /* Beneficiary ID */
337 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_beneficiary_id, tvb, offset, 2, ENC_BIG_ENDIAN);
338 offset+=2;
339 break;
340 case 2: /* FLOOR-ID */
341 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
342 offset+=2;
343 break;
344 case 3: /* FLOOR-REQUEST-ID */
345 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_request_id, tvb, offset, 2, ENC_BIG_ENDIAN);
346 offset+=2;
347 break;
348 case 4: /* PRIORITY */
349 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_priority, tvb, offset, 2, ENC_BIG_ENDIAN);
350 offset+=2;
351 break;
352 case 5: /* REQUEST-STATUS */
353 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_request_status, tvb, offset,1, ENC_BIG_ENDIAN);
354 offset++;
355 /* Queue Position */
356 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_queue_pos, tvb, offset,1, ENC_BIG_ENDIAN);
357 offset++;
358 break;
359 case 6: /* ERROR-CODE */
360 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_code, tvb, offset, 1, ENC_BIG_ENDIAN);
361 offset++;
362 if(length>3){
363 /* We have Error Specific Details */
364 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_specific_details, tvb, offset, length-3, ENC_NA);
366 offset = offset + length-3;
367 pad_len = length & 0x03;
368 if(pad_len != 0){
369 pad_len = 4 - pad_len;
370 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
372 offset = offset + pad_len;
373 break;
374 case 7: /* ERROR-INFO */
375 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_info_text, tvb, offset, length-2, ENC_ASCII);
376 offset = offset + length-2;
377 pad_len = length & 0x03;
378 if(pad_len != 0){
379 pad_len = 4 - pad_len;
380 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
382 offset = offset + pad_len;
383 break;
384 case 8: /* PARTICIPANT-PROVIDED-INFO */
385 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_part_prov_info_text, tvb, offset, length-2, ENC_ASCII);
386 offset = offset + length-2;
387 pad_len = length & 0x03;
388 if(pad_len != 0){
389 pad_len = 4 - pad_len;
390 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
392 offset = offset + pad_len;
393 break;
394 case 9: /* STATUS-INFO */
395 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_status_info_text, tvb, offset, length-2, ENC_ASCII);
396 offset = offset + length-2;
397 pad_len = length & 0x03;
398 if(pad_len != 0){
399 pad_len = 4 - pad_len;
400 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
402 offset = offset + pad_len;
403 break;
404 case 10: /* SUPPORTED-ATTRIBUTES */
406 while(offset < (attr_start_offset+length)){
407 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_supp_attr, tvb, offset, 1, ENC_BIG_ENDIAN);
408 offset+=1;
410 pad_len = length & 0x03;
411 if(pad_len != 0){
412 pad_len = 4 - pad_len;
413 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
415 offset = offset + pad_len;
416 break;
417 case 11: /* SUPPORTED-PRIMITIVES */
419 while(offset < (attr_start_offset+length)){
420 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_supp_prim, tvb, offset, 1, ENC_BIG_ENDIAN);
421 offset+=1;
423 pad_len = length & 0x03;
424 if(pad_len != 0){
425 pad_len = 4 - pad_len;
426 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
428 offset = offset + pad_len;
429 break;
430 case 12: /* USER-DISPLAY-NAME */
431 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_disp_name, tvb, offset, length-2, ENC_ASCII);
432 offset = offset + length-2;
433 pad_len = length & 0x03;
434 if(pad_len != 0){
435 pad_len = 4 - pad_len;
436 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
438 offset = offset + pad_len;
439 break;
440 case 13: /* USER-URI */
441 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_uri, tvb, offset, length-2, ENC_ASCII);
442 offset = offset + length-2;
443 pad_len = length & 0x03;
444 if(pad_len != 0){
445 pad_len = 4 - pad_len;
446 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
448 offset = offset + pad_len;
449 break;
450 case 14: /* BENEFICIARY-INFORMATION */
451 /* The BENEFICIARY-INFORMATION attribute is a grouped attribute that
452 * consists of a header, which is referred to as BENEFICIARY-
453 * INFORMATION-HEADER, followed by a sequence of attributes.
455 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_beneficiary_id, tvb, offset, 2, ENC_BIG_ENDIAN);
456 offset+=2;
457 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
458 break;
459 case 15: /* FLOOR-REQUEST-INFORMATION */
460 /* The FLOOR-REQUEST-INFORMATION attribute is a grouped attribute that
461 * consists of a header, which is referred to as FLOOR-REQUEST-
462 * INFORMATION-HEADER, followed by a sequence of attributes.
464 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_request_id, tvb, offset, 2, ENC_BIG_ENDIAN);
465 offset+=2;
466 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
467 break;
468 case 16: /* REQUESTED-BY-INFORMATION */
469 /* The REQUESTED-BY-INFORMATION attribute is a grouped attribute that
470 * consists of a header, which is referred to as FLOOR-REQUEST-STATUS-
471 * -HEADER, followed by a sequence of attributes.
473 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_req_by_id, tvb, offset, 2, ENC_BIG_ENDIAN);
474 offset+=2;
475 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
476 break;
477 case 17: /* FLOOR-REQUEST-STATUS */
478 /* The FLOOR-REQUEST-STATUS attribute is a grouped attribute that
479 * consists of a header, which is referred to as OVERALL-REQUEST-STATUS-
480 * -HEADER, followed by a sequence of attributes.
482 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
483 offset+=2;
484 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
485 break;
486 case 18: /* OVERALL-REQUEST-STATUS */
487 /* The OVERALL-REQUEST-STATUS attribute is a grouped attribute that
488 * consists of a header, which is referred to as FLOOR-REQUEST-
489 * INFORMATION-HEADER, followed by a sequence of attributes.
491 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_request_id, tvb, offset, 2, ENC_BIG_ENDIAN);
492 offset+=2;
493 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
494 break;
496 default:
497 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_payload, tvb, offset, length-2, ENC_NA);
498 /* Advance by any length attributable to payload */
499 offset = offset + length - 2;
500 break;
502 read_attr = read_attr + length;
504 decrement_dissection_depth(pinfo);
506 return offset;
510 static bool
511 dissect_bfcp_heur_check(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
513 uint8_t primitive;
514 uint8_t first_byte;
515 const char *str;
518 /* Size of smallest BFCP packet: 12 octets */
519 if (tvb_captured_length(tvb) < BFCP_HDR_LEN)
520 return false;
522 /* Check version and reserved bits in first byte */
523 first_byte = tvb_get_uint8(tvb, 0);
525 /* If first_byte of bfcp_packet is a combination of the
526 * version, the R-bit and the F-bit. The value must be:
527 * 0x20 || 0x30 || 0x40 || 0x48 || 0x50 || 0x58
528 * if the bit is set, otherwise it is not BFCP.
530 if ((first_byte != 0x20) && (first_byte != 0x30) && (first_byte != 0x40) && (first_byte != 0x48) && (first_byte != 0x50) && (first_byte != 0x58))
531 return false;
533 primitive = tvb_get_uint8(tvb, 1);
535 if ((primitive < 1) || (primitive > 18))
536 return false;
538 str = try_val_to_str(primitive, map_bfcp_primitive);
539 if (NULL == str)
540 return false;
542 return true;
545 /* Code to actually dissect BFCP packets */
546 static int
547 dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
549 int offset = 0;
550 uint8_t primitive;
551 const char *str;
552 int bfcp_payload_length;
553 bool f_bit;
554 proto_tree *bfcp_tree;
555 proto_item *ti;
557 if (!dissect_bfcp_heur_check(tvb, pinfo, tree, data))
558 return 0;
560 primitive = tvb_get_uint8(tvb, 1);
561 str = try_val_to_str(primitive, map_bfcp_primitive);
563 /* Make entries in Protocol column and Info column on summary display*/
564 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BFCP");
565 col_add_str(pinfo->cinfo, COL_INFO, str);
567 ti = proto_tree_add_item(tree, proto_bfcp, tvb, 0, -1, ENC_NA);
568 bfcp_tree = proto_item_add_subtree(ti, ett_bfcp);
569 show_setup_info(tvb, pinfo, bfcp_tree);
571 The following is the format of the common header.
573 0 1 2 3
574 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
575 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
576 | Ver |R|F| Res | Primitive | Payload Length |
577 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
578 | Conference ID |
579 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
580 | Transaction ID | User ID |
581 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
582 | Fragment Offset (if F is set) | Fragment Length (if F is set) |
583 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
587 /* Add items to BFCP tree */
588 proto_tree_add_item(bfcp_tree, hf_bfcp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
589 proto_tree_add_item(bfcp_tree, hf_bfcp_hdr_r_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
590 proto_tree_add_item_ret_boolean(bfcp_tree, hf_bfcp_hdr_f_bit, tvb, offset, 1, ENC_BIG_ENDIAN, &f_bit);
591 /* Ver should be 1 over a reliable transport (TCP) and 2 over an
592 * unreliable transport (UDP). R and F should only be set on an
593 * unreliable transport. They should be ignored on a reliable
594 * transport.
596 * XXX: If it's version 1 and an unreliable transport, it may be
597 * a draft implementation.
598 * ( https://www.ietf.org/archive/id/draft-sandbakken-dispatch-bfcp-udp-03.html )
600 offset++;
601 proto_tree_add_item(bfcp_tree, hf_bfcp_primitive, tvb, offset, 1, ENC_BIG_ENDIAN);
602 offset++;
603 proto_tree_add_item(bfcp_tree, hf_bfcp_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN);
604 offset+=2;
605 proto_tree_add_item(bfcp_tree, hf_bfcp_conference_id, tvb, offset, 4, ENC_BIG_ENDIAN);
606 offset+=4;
607 proto_tree_add_item(bfcp_tree, hf_bfcp_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);
608 offset+=2;
609 proto_tree_add_item(bfcp_tree, hf_bfcp_user_id, tvb, offset, 2, ENC_BIG_ENDIAN);
610 offset+=2;
611 if (f_bit) {
612 proto_tree_add_item(bfcp_tree, hf_bfcp_fragment_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
613 offset+=2;
614 proto_tree_add_item(bfcp_tree, hf_bfcp_fragment_length, tvb, offset, 2, ENC_BIG_ENDIAN);
615 offset+=2;
618 bfcp_payload_length = tvb_get_ntohs(tvb,
619 BFCP_OFFSET_PAYLOAD_LENGTH) * 4;
621 /*offset = */dissect_bfcp_attributes(tvb, pinfo, bfcp_tree, offset, bfcp_payload_length);
623 return tvb_captured_length(tvb);
626 static bool
627 dissect_bfcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
629 if (!dissect_bfcp_heur_check(tvb, pinfo, tree, data))
630 return false;
632 dissect_bfcp(tvb, pinfo, tree, data);
633 return true;
636 void proto_register_bfcp(void)
638 module_t *bfcp_module;
639 expert_module_t* expert_bfcp;
641 static hf_register_info hf[] = {
643 &hf_bfcp_version,
644 { "Version(ver)", "bfcp.ver",
645 FT_UINT8, BASE_DEC, NULL, 0xe0,
646 NULL, HFILL }
649 &hf_bfcp_hdr_r_bit,
650 { "Transaction Responder (R)", "bfcp.hdr_r_bit",
651 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
652 NULL, HFILL }
655 &hf_bfcp_hdr_f_bit,
656 { "Fragmentation (F)", "bfcp.hdr_f_bit",
657 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x08,
658 NULL, HFILL }
661 &hf_bfcp_primitive,
662 { "Primitive", "bfcp.primitive",
663 FT_UINT8, BASE_DEC, VALS(map_bfcp_primitive), 0x0,
664 NULL, HFILL }
667 &hf_bfcp_payload_length,
668 { "Payload Length", "bfcp.payload_length",
669 FT_UINT16, BASE_DEC, NULL, 0x0,
670 "Length in 4-octet units, excluding the COMMON-HEADER", HFILL }
673 &hf_bfcp_conference_id,
674 { "Conference ID", "bfcp.conference_id",
675 FT_UINT32, BASE_DEC, NULL, 0x0,
676 NULL, HFILL }
679 &hf_bfcp_transaction_id,
680 { "Transaction ID", "bfcp.transaction_id",
681 FT_UINT16, BASE_DEC, NULL, 0x0,
682 NULL, HFILL }
685 &hf_bfcp_user_id,
686 { "User ID", "bfcp.user_id",
687 FT_UINT16, BASE_DEC, NULL, 0x0,
688 NULL, HFILL }
691 &hf_bfcp_fragment_offset,
692 { "Fragment Offset", "bfcp.fragment_offset",
693 FT_UINT16, BASE_DEC, NULL, 0x0,
694 "Number of 4-octet units contained in previous fragments, excluding the COMMON-HEADER", HFILL }
697 &hf_bfcp_fragment_length,
698 { "Fragment Length", "bfcp.fragment_length",
699 FT_UINT16, BASE_DEC, NULL, 0x0,
700 "Number of 4-octet units contained in this fragment, excluding the COMMON-HEADER", HFILL }
703 &hf_bfcp_payload,
704 { "Payload", "bfcp.payload",
705 FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
706 HFILL }
709 &hf_bfcp_attribute_types,
710 { "Attribute Type", "bfcp.attribute_type",
711 FT_UINT8, BASE_DEC, VALS(map_bfcp_attribute_types), 0xFE,
712 NULL, HFILL }
715 &hf_bfcp_attribute_types_m_bit,
716 { "Mandatory bit(M)", "bfcp.attribute_types_m_bit",
717 FT_BOOLEAN, 8, NULL, 0x01,
718 NULL, HFILL }
721 &hf_bfcp_attribute_length,
722 { "Attribute Length", "bfcp.attribute_length",
723 FT_UINT16, BASE_DEC, NULL, 0x0,
724 NULL, HFILL }
727 &hf_bfcp_beneficiary_id,
728 { "BENEFICIARY-ID", "bfcp.beneficiary_id",
729 FT_UINT16, BASE_DEC, NULL, 0x0,
730 NULL, HFILL }
733 &hf_bfcp_floor_id,
734 { "FLOOR-ID", "bfcp.floor_id",
735 FT_UINT16, BASE_DEC, NULL, 0x0,
736 NULL, HFILL }
739 &hf_bfcp_floor_request_id,
740 { "FLOOR-REQUEST-ID", "bfcp.floorrequest_id",
741 FT_UINT16, BASE_DEC, NULL, 0x0,
742 NULL, HFILL }
745 &hf_bfcp_priority,
746 { "FLOOR-REQUEST-ID", "bfcp.priority",
747 FT_UINT16, BASE_DEC, NULL, 0xe000,
748 NULL, HFILL }
751 &hf_bfcp_request_status,
752 { "Request Status", "bfcp.request_status",
753 FT_UINT8, BASE_DEC, VALS(map_bfcp_request_status), 0x0,
754 NULL, HFILL }
757 &hf_bfcp_queue_pos,
758 { "Queue Position", "bfcp.queue_pos",
759 FT_UINT8, BASE_DEC, NULL, 0x0,
760 NULL, HFILL }
763 &hf_bfcp_error_code,
764 { "Error Code", "bfcp.error_code",
765 FT_UINT8, BASE_DEC, VALS(bfcp_error_code_valuse), 0x0,
766 NULL, HFILL }
769 &hf_bfcp_error_info_text,
770 { "Text", "bfcp.error_info_text",
771 FT_STRING, BASE_NONE, NULL, 0x0,
772 NULL, HFILL }
775 &hf_bfcp_part_prov_info_text,
776 { "Text", "bfcp.part_prov_info_text",
777 FT_STRING, BASE_NONE, NULL, 0x0,
778 NULL, HFILL }
781 &hf_bfcp_status_info_text,
782 { "Text", "bfcp.status_info_text",
783 FT_STRING, BASE_NONE, NULL, 0x0,
784 NULL, HFILL }
787 &hf_bfcp_supp_attr,
788 { "Supported Attribute", "bfcp.supp_attr",
789 FT_UINT8, BASE_DEC, VALS(map_bfcp_attribute_types), 0xFE,
790 NULL, HFILL }
793 &hf_bfcp_supp_prim,
794 { "Supported Primitive", "bfcp.supp_primitive",
795 FT_UINT8, BASE_DEC, VALS(map_bfcp_primitive), 0x0,
796 NULL, HFILL }
799 &hf_bfcp_user_disp_name,
800 { "Name", "bfcp.user_disp_name",
801 FT_STRING, BASE_NONE, NULL, 0x0,
802 NULL, HFILL }
805 &hf_bfcp_user_uri,
806 { "URI", "bfcp.user_uri",
807 FT_STRING, BASE_NONE, NULL, 0x0,
808 NULL, HFILL }
811 &hf_bfcp_req_by_id,
812 { "Requested-by ID", "bfcp.req_by_i",
813 FT_UINT16, BASE_DEC, NULL, 0x0,
814 NULL, HFILL }
817 &hf_bfcp_padding,
818 { "Padding", "bfcp.padding",
819 FT_BYTES, BASE_NONE, NULL, 0x0,
820 NULL, HFILL }
823 &hf_bfcp_error_specific_details,
824 { "Error Specific Details", "bfcp.error_specific_details",
825 FT_BYTES, BASE_NONE, NULL, 0x0,
826 NULL, HFILL }
828 { &hf_bfcp_setup,
829 { "Stream setup", "bfcp.setup",
830 FT_STRING, BASE_NONE, NULL, 0x0,
831 "Stream setup, method and frame number", HFILL}
833 { &hf_bfcp_setup_frame,
834 { "Setup frame", "bfcp.setup-frame",
835 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
836 "Frame that set up this stream", HFILL}
838 { &hf_bfcp_setup_method,
839 { "Setup Method", "bfcp.setup-method",
840 FT_STRING, BASE_NONE, NULL, 0x0,
841 "Method used to set up this stream", HFILL}
845 static int *ett[] = {
846 &ett_bfcp,
847 &ett_bfcp_setup,
848 &ett_bfcp_attr,
851 static ei_register_info ei[] = {
852 { &ei_bfcp_attribute_length_too_small, { "bfcp.attribute_length.too_small", PI_MALFORMED, PI_ERROR, "Attribute length is too small", EXPFILL }},
855 /* Register protocol name and description */
856 proto_bfcp = proto_register_protocol("Binary Floor Control Protocol", "BFCP", "bfcp");
858 bfcp_handle = register_dissector("bfcp", dissect_bfcp, proto_bfcp);
860 bfcp_module = prefs_register_protocol(proto_bfcp, NULL);
862 prefs_register_obsolete_preference(bfcp_module, "enable");
864 /* Register field and subtree array */
865 proto_register_field_array(proto_bfcp, hf, array_length(hf));
866 proto_register_subtree_array(ett, array_length(ett));
868 expert_bfcp = expert_register_protocol(proto_bfcp);
869 expert_register_field_array(expert_bfcp, ei, array_length(ei));
872 void proto_reg_handoff_bfcp(void)
874 /* "Decode As" is always available;
875 * Heuristic dissection in disabled by default since
876 * the heuristic is quite weak.
878 heur_dissector_add("tcp", dissect_bfcp_heur, "BFCP over TCP", "bfcp_tcp", proto_bfcp, HEURISTIC_DISABLE);
879 heur_dissector_add("udp", dissect_bfcp_heur, "BFCP over UDP", "bfcp_udp", proto_bfcp, HEURISTIC_DISABLE);
880 dissector_add_for_decode_as_with_preference("tcp.port", bfcp_handle);
881 dissector_add_for_decode_as_with_preference("udp.port", bfcp_handle);
885 * Editor modelines - https://www.wireshark.org/tools/modelines.html
887 * Local variables:
888 * c-basic-offset: 8
889 * tab-width: 8
890 * indent-tabs-mode: t
891 * End:
893 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
894 * :indentSize=8:tabSize=8:noTabs=false: