epan/dissectors/pidl/ C99 drsuapi
[wireshark-sm.git] / epan / dissectors / packet-bfcp.c
bloba8e99236cbf836718e50d012262e2a7835e87df2
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, "ErrorAck"},
98 { 16, "FloorStatusAck"},
99 { 17, "Goodbye"},
100 { 18, "GoodbyeAck"},
101 { 0, NULL},
104 static const value_string map_bfcp_attribute_types[] = {
105 { 0, "<Invalid Primitive>"},
106 { 1, "BeneficiaryID"},
107 { 2, "FloorID"},
108 { 3, "FloorRequestID"},
109 { 4, "Priority"},
110 { 5, "RequestStatus"},
111 { 6, "ErrorCode"},
112 { 7, "ErrorInfo"},
113 { 8, "ParticipantProvidedInfo"},
114 { 9, "StatusInfo"},
115 { 10, "SupportedAttributes"},
116 { 11, "SupportedPrimitives"},
117 { 12, "UserDisplayName"},
118 { 13, "UserURI"},
119 { 14, "BeneficiaryInformation"},
120 { 15, "FloorRequestInformation"},
121 { 16, "RequestedByInformation"},
122 { 17, "FloorRequestStatus"},
123 { 18, "OverallRequestStatus"},
124 { 0, NULL},
127 static const value_string map_bfcp_request_status[] = {
128 { 0, "<Invalid Primitive>"},
129 { 1, "Pending"},
130 { 2, "Accepted"},
131 { 3, "Granted"},
132 { 4, "Denied"},
133 { 5, "Cancelled"},
134 { 6, "Released"},
135 { 7, "Revoked"},
136 { 0, NULL},
139 /* 5.2.6. ERROR-CODE */
140 static const value_string bfcp_error_code_valuse[] = {
141 { 1, "Conference does not Exist"},
142 { 2, "User does not Exist"},
143 { 3, "Unknown Primitive"},
144 { 4, "Unknown Mandatory Attribute"},
145 { 5, "Unauthorized Operation"},
146 { 6, "Invalid Floor ID"},
147 { 7, "Floor Request ID Does Not Exist"},
148 { 8, "You have Already Reached the Maximum Number of Ongoing Floor Requests for this Floor"},
149 { 9, "Use TLS"},
150 { 10, "Unable to Parse Message"},
151 { 11, "Use DTLS"},
152 { 12, "Unsupported Version"},
153 { 13, "Incorrect Message Length"},
154 { 14, "Generic Error"},
156 { 0, NULL},
159 /*Define offset for fields in BFCP packet */
160 #define BFCP_OFFSET_TRANSACTION_INITIATOR 0
161 #define BFCP_OFFSET_PRIMITIVE 1
162 #define BFCP_OFFSET_PAYLOAD_LENGTH 2
163 #define BFCP_OFFSET_CONFERENCE_ID 4
164 #define BFCP_OFFSET_TRANSACTION_ID 8
165 #define BFCP_OFFSET_USER_ID 10
166 #define BFCP_OFFSET_PAYLOAD 12
168 /* Set up an BFCP conversation using the info given */
169 void
170 bfcp_add_address( packet_info *pinfo, port_type ptype,
171 address *addr, int port,
172 const char *setup_method, uint32_t setup_frame_number)
174 address null_addr;
175 conversation_t* p_conv;
176 struct _bfcp_conversation_info *p_conv_data = NULL;
179 * If this isn't the first time this packet has been processed,
180 * we've already done this work, so we don't need to do it
181 * again.
183 if (PINFO_FD_VISITED(pinfo)) {
184 return;
187 clear_address(&null_addr);
190 * Check if the ip address and port combination is not
191 * already registered as a conversation.
193 p_conv = find_conversation( pinfo->num, addr, &null_addr, conversation_pt_to_conversation_type(ptype), port, 0,
194 NO_ADDR_B | NO_PORT_B);
197 * If not, create a new conversation.
199 if (!p_conv) {
200 p_conv = conversation_new( pinfo->num, addr, &null_addr, conversation_pt_to_conversation_type(ptype),
201 (uint32_t)port, 0,
202 NO_ADDR2 | NO_PORT2);
205 /* Set dissector */
206 conversation_set_dissector(p_conv, bfcp_handle);
209 * Check if the conversation has data associated with it.
211 p_conv_data = (struct _bfcp_conversation_info *)conversation_get_proto_data(p_conv, proto_bfcp);
214 * If not, add a new data item.
216 if (!p_conv_data) {
217 /* Create conversation data */
218 p_conv_data = wmem_new0(wmem_file_scope(), struct _bfcp_conversation_info);
219 conversation_add_proto_data(p_conv, proto_bfcp, p_conv_data);
223 * Update the conversation data.
225 p_conv_data->setup_method_set = true;
226 (void) g_strlcpy(p_conv_data->setup_method, setup_method, MAX_BFCP_SETUP_METHOD_SIZE);
227 p_conv_data->setup_frame_number = setup_frame_number;
230 /* Look for conversation info and display any setup info found */
231 static void
232 show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
234 /* Conversation and current data */
235 conversation_t *p_conv = NULL;
236 struct _bfcp_conversation_info *p_conv_data = NULL;
238 /* Use existing packet data if available */
239 p_conv_data = (struct _bfcp_conversation_info *)p_get_proto_data(wmem_file_scope(), pinfo, proto_bfcp, 0);
241 if (!p_conv_data) {
242 /* First time, get info from conversation */
243 p_conv = find_conversation(pinfo->num, &pinfo->net_dst, &pinfo->net_src,
244 conversation_pt_to_conversation_type(pinfo->ptype),
245 pinfo->destport, pinfo->srcport, 0);
247 if (p_conv) {
248 /* Look for data in conversation */
249 struct _bfcp_conversation_info *p_conv_packet_data;
250 p_conv_data = (struct _bfcp_conversation_info *)conversation_get_proto_data(p_conv, proto_bfcp);
252 if (p_conv_data) {
253 /* Save this conversation info into packet info */
254 p_conv_packet_data = (struct _bfcp_conversation_info *)wmem_memdup(wmem_file_scope(),
255 p_conv_data, sizeof(struct _bfcp_conversation_info));
257 p_add_proto_data(wmem_file_scope(), pinfo, proto_bfcp, 0, p_conv_packet_data);
262 /* Create setup info subtree with summary info. */
263 if (p_conv_data && p_conv_data->setup_method_set) {
264 proto_tree *bfcp_setup_tree;
265 proto_item *ti = proto_tree_add_string_format(tree, hf_bfcp_setup, tvb, 0, 0,
267 "Stream setup by %s (frame %u)",
268 p_conv_data->setup_method,
269 p_conv_data->setup_frame_number);
270 proto_item_set_generated(ti);
271 bfcp_setup_tree = proto_item_add_subtree(ti, ett_bfcp_setup);
272 if (bfcp_setup_tree) {
273 /* Add details into subtree */
274 proto_item* item = proto_tree_add_uint(bfcp_setup_tree, hf_bfcp_setup_frame,
275 tvb, 0, 0, p_conv_data->setup_frame_number);
276 proto_item_set_generated(item);
277 item = proto_tree_add_string(bfcp_setup_tree, hf_bfcp_setup_method,
278 tvb, 0, 0, p_conv_data->setup_method);
279 proto_item_set_generated(item);
284 static int
285 // NOLINTNEXTLINE(misc-no-recursion)
286 dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset, int bfcp_payload_length)
288 proto_item *ti, *item;
289 proto_tree *bfcp_attr_tree = NULL;
290 int attr_start_offset;
291 int length;
292 uint8_t attribute_type;
293 int read_attr = 0;
294 uint8_t first_byte, pad_len;
296 increment_dissection_depth(pinfo);
297 while ((tvb_reported_length_remaining(tvb, offset) >= 2) &&
298 ((bfcp_payload_length - read_attr) >= 2))
301 attr_start_offset = offset;
302 first_byte = tvb_get_uint8(tvb, offset);
304 /* Padding so continue to next attribute */
305 if (first_byte == 0){
306 read_attr++;
307 continue;
310 ti = proto_tree_add_item(tree, hf_bfcp_attribute_types, tvb, offset, 1, ENC_BIG_ENDIAN);
311 bfcp_attr_tree = proto_item_add_subtree(ti, ett_bfcp_attr);
312 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_attribute_types_m_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
314 attribute_type = (first_byte & 0xFE) >> 1;
315 offset++;
317 /* Length: This 8-bit field contains the length of the attribute in
318 * octets, excluding any padding defined for specific attributes. The
319 * length of attributes that are not grouped includes the Type, 'M' bit,
320 * and Length fields. The Length in grouped attributes is the length of
321 * the grouped attribute itself (including Type, 'M' bit, and Length
322 * fields) plus the total length (including padding) of all the included
323 * attributes.
326 item = proto_tree_add_item(bfcp_attr_tree, hf_bfcp_attribute_length, tvb, offset, 1, ENC_BIG_ENDIAN);
327 length = tvb_get_uint8(tvb, offset);
328 /* At least Type, M bit and Length fields */
329 if (length < 2){
330 expert_add_info_format(pinfo, item, &ei_bfcp_attribute_length_too_small,
331 "Attribute length is too small (%d bytes - minimum valid is 2)", length);
332 break;
334 offset++;
336 switch(attribute_type){
337 case 1: /* Beneficiary ID */
338 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_beneficiary_id, tvb, offset, 2, ENC_BIG_ENDIAN);
339 offset+=2;
340 break;
341 case 2: /* FLOOR-ID */
342 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
343 offset+=2;
344 break;
345 case 3: /* FLOOR-REQUEST-ID */
346 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_request_id, tvb, offset, 2, ENC_BIG_ENDIAN);
347 offset+=2;
348 break;
349 case 4: /* PRIORITY */
350 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_priority, tvb, offset, 2, ENC_BIG_ENDIAN);
351 offset+=2;
352 break;
353 case 5: /* REQUEST-STATUS */
354 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_request_status, tvb, offset,1, ENC_BIG_ENDIAN);
355 offset++;
356 /* Queue Position */
357 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_queue_pos, tvb, offset,1, ENC_BIG_ENDIAN);
358 offset++;
359 break;
360 case 6: /* ERROR-CODE */
361 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_code, tvb, offset, 1, ENC_BIG_ENDIAN);
362 offset++;
363 if(length>3){
364 /* We have Error Specific Details */
365 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_specific_details, tvb, offset, length-3, ENC_NA);
367 offset = offset + length-3;
368 pad_len = length & 0x03;
369 if(pad_len != 0){
370 pad_len = 4 - pad_len;
371 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
373 offset = offset + pad_len;
374 break;
375 case 7: /* ERROR-INFO */
376 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_info_text, tvb, offset, length-2, ENC_ASCII);
377 offset = offset + length-2;
378 pad_len = length & 0x03;
379 if(pad_len != 0){
380 pad_len = 4 - pad_len;
381 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
383 offset = offset + pad_len;
384 break;
385 case 8: /* PARTICIPANT-PROVIDED-INFO */
386 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_part_prov_info_text, tvb, offset, length-2, ENC_ASCII);
387 offset = offset + length-2;
388 pad_len = length & 0x03;
389 if(pad_len != 0){
390 pad_len = 4 - pad_len;
391 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
393 offset = offset + pad_len;
394 break;
395 case 9: /* STATUS-INFO */
396 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_status_info_text, tvb, offset, length-2, ENC_ASCII);
397 offset = offset + length-2;
398 pad_len = length & 0x03;
399 if(pad_len != 0){
400 pad_len = 4 - pad_len;
401 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
403 offset = offset + pad_len;
404 break;
405 case 10: /* SUPPORTED-ATTRIBUTES */
407 while(offset < (attr_start_offset+length)){
408 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_supp_attr, tvb, offset, 1, ENC_BIG_ENDIAN);
409 offset+=1;
411 pad_len = length & 0x03;
412 if(pad_len != 0){
413 pad_len = 4 - pad_len;
414 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
416 offset = offset + pad_len;
417 break;
418 case 11: /* SUPPORTED-PRIMITIVES */
420 while(offset < (attr_start_offset+length)){
421 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_supp_prim, tvb, offset, 1, ENC_BIG_ENDIAN);
422 offset+=1;
424 pad_len = length & 0x03;
425 if(pad_len != 0){
426 pad_len = 4 - pad_len;
427 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
429 offset = offset + pad_len;
430 break;
431 case 12: /* USER-DISPLAY-NAME */
432 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_disp_name, tvb, offset, length-2, ENC_ASCII);
433 offset = offset + length-2;
434 pad_len = length & 0x03;
435 if(pad_len != 0){
436 pad_len = 4 - pad_len;
437 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
439 offset = offset + pad_len;
440 break;
441 case 13: /* USER-URI */
442 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_uri, tvb, offset, length-2, ENC_ASCII);
443 offset = offset + length-2;
444 pad_len = length & 0x03;
445 if(pad_len != 0){
446 pad_len = 4 - pad_len;
447 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_padding, tvb, offset, pad_len, ENC_NA);
449 offset = offset + pad_len;
450 break;
451 case 14: /* BENEFICIARY-INFORMATION */
452 /* The BENEFICIARY-INFORMATION attribute is a grouped attribute that
453 * consists of a header, which is referred to as BENEFICIARY-
454 * INFORMATION-HEADER, followed by a sequence of attributes.
456 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_beneficiary_id, tvb, offset, 2, ENC_BIG_ENDIAN);
457 offset+=2;
458 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
459 break;
460 case 15: /* FLOOR-REQUEST-INFORMATION */
461 /* The FLOOR-REQUEST-INFORMATION attribute is a grouped attribute that
462 * consists of a header, which is referred to as FLOOR-REQUEST-
463 * INFORMATION-HEADER, followed by a sequence of attributes.
465 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_request_id, tvb, offset, 2, ENC_BIG_ENDIAN);
466 offset+=2;
467 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
468 break;
469 case 16: /* REQUESTED-BY-INFORMATION */
470 /* The REQUESTED-BY-INFORMATION attribute is a grouped attribute that
471 * consists of a header, which is referred to as FLOOR-REQUEST-STATUS-
472 * -HEADER, followed by a sequence of attributes.
474 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_req_by_id, tvb, offset, 2, ENC_BIG_ENDIAN);
475 offset+=2;
476 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
477 break;
478 case 17: /* FLOOR-REQUEST-STATUS */
479 /* The FLOOR-REQUEST-STATUS attribute is a grouped attribute that
480 * consists of a header, which is referred to as OVERALL-REQUEST-STATUS-
481 * -HEADER, followed by a sequence of attributes.
483 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_id, tvb, offset, 2, ENC_BIG_ENDIAN);
484 offset+=2;
485 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
486 break;
487 case 18: /* OVERALL-REQUEST-STATUS */
488 /* The OVERALL-REQUEST-STATUS attribute is a grouped attribute that
489 * consists of a header, which is referred to as FLOOR-REQUEST-
490 * INFORMATION-HEADER, followed by a sequence of attributes.
492 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_floor_request_id, tvb, offset, 2, ENC_BIG_ENDIAN);
493 offset+=2;
494 offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_attr_tree, offset, length -4);
495 break;
497 default:
498 proto_tree_add_item(bfcp_attr_tree, hf_bfcp_payload, tvb, offset, length-2, ENC_NA);
499 /* Advance by any length attributable to payload */
500 offset = offset + length - 2;
501 break;
503 read_attr = read_attr + length;
505 decrement_dissection_depth(pinfo);
507 return offset;
511 static bool
512 dissect_bfcp_heur_check(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_)
514 uint8_t primitive;
515 uint8_t first_byte;
516 const char *str;
519 /* Size of smallest BFCP packet: 12 octets */
520 if (tvb_captured_length(tvb) < BFCP_HDR_LEN)
521 return false;
523 /* Check version and reserved bits in first byte */
524 first_byte = tvb_get_uint8(tvb, 0);
526 /* If first_byte of bfcp_packet is a combination of the
527 * version, the R-bit and the F-bit. The value must be:
528 * 0x20 || 0x30 || 0x40 || 0x48 || 0x50 || 0x58
529 * if the bit is set, otherwise it is not BFCP.
531 if ((first_byte != 0x20) && (first_byte != 0x30) && (first_byte != 0x40) && (first_byte != 0x48) && (first_byte != 0x50) && (first_byte != 0x58))
532 return false;
534 primitive = tvb_get_uint8(tvb, 1);
536 if ((primitive < 1) || (primitive > 18))
537 return false;
539 str = try_val_to_str(primitive, map_bfcp_primitive);
540 if (NULL == str)
541 return false;
543 return true;
546 /* Code to actually dissect BFCP packets */
547 static int
548 dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
550 int offset = 0;
551 uint8_t primitive;
552 const char *str;
553 int bfcp_payload_length;
554 bool f_bit;
555 proto_tree *bfcp_tree;
556 proto_item *ti;
558 if (!dissect_bfcp_heur_check(tvb, pinfo, tree, data))
559 return 0;
561 primitive = tvb_get_uint8(tvb, 1);
562 str = try_val_to_str(primitive, map_bfcp_primitive);
564 /* Make entries in Protocol column and Info column on summary display*/
565 col_set_str(pinfo->cinfo, COL_PROTOCOL, "BFCP");
566 col_add_str(pinfo->cinfo, COL_INFO, str);
568 ti = proto_tree_add_item(tree, proto_bfcp, tvb, 0, -1, ENC_NA);
569 bfcp_tree = proto_item_add_subtree(ti, ett_bfcp);
570 show_setup_info(tvb, pinfo, bfcp_tree);
572 The following is the format of the common header.
574 0 1 2 3
575 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
576 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
577 | Ver |R|F| Res | Primitive | Payload Length |
578 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
579 | Conference ID |
580 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
581 | Transaction ID | User ID |
582 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
583 | Fragment Offset (if F is set) | Fragment Length (if F is set) |
584 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
588 /* Add items to BFCP tree */
589 proto_tree_add_item(bfcp_tree, hf_bfcp_version, tvb, offset, 1, ENC_BIG_ENDIAN);
590 proto_tree_add_item(bfcp_tree, hf_bfcp_hdr_r_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
591 proto_tree_add_item_ret_boolean(bfcp_tree, hf_bfcp_hdr_f_bit, tvb, offset, 1, ENC_BIG_ENDIAN, &f_bit);
592 /* Ver should be 1 over a reliable transport (TCP) and 2 over an
593 * unreliable transport (UDP). R and F should only be set on an
594 * unreliable transport. They should be ignored on a reliable
595 * transport.
597 * XXX: If it's version 1 and an unreliable transport, it may be
598 * a draft implementation.
599 * ( https://www.ietf.org/archive/id/draft-sandbakken-dispatch-bfcp-udp-03.html )
601 offset++;
602 proto_tree_add_item(bfcp_tree, hf_bfcp_primitive, tvb, offset, 1, ENC_BIG_ENDIAN);
603 offset++;
604 proto_tree_add_item(bfcp_tree, hf_bfcp_payload_length, tvb, offset, 2, ENC_BIG_ENDIAN);
605 offset+=2;
606 proto_tree_add_item(bfcp_tree, hf_bfcp_conference_id, tvb, offset, 4, ENC_BIG_ENDIAN);
607 offset+=4;
608 proto_tree_add_item(bfcp_tree, hf_bfcp_transaction_id, tvb, offset, 2, ENC_BIG_ENDIAN);
609 offset+=2;
610 proto_tree_add_item(bfcp_tree, hf_bfcp_user_id, tvb, offset, 2, ENC_BIG_ENDIAN);
611 offset+=2;
612 if (f_bit) {
613 proto_tree_add_item(bfcp_tree, hf_bfcp_fragment_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
614 offset+=2;
615 proto_tree_add_item(bfcp_tree, hf_bfcp_fragment_length, tvb, offset, 2, ENC_BIG_ENDIAN);
616 offset+=2;
619 bfcp_payload_length = tvb_get_ntohs(tvb,
620 BFCP_OFFSET_PAYLOAD_LENGTH) * 4;
622 /*offset = */dissect_bfcp_attributes(tvb, pinfo, bfcp_tree, offset, bfcp_payload_length);
624 return tvb_captured_length(tvb);
627 static bool
628 dissect_bfcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
630 if (!dissect_bfcp_heur_check(tvb, pinfo, tree, data))
631 return false;
633 dissect_bfcp(tvb, pinfo, tree, data);
634 return true;
637 void proto_register_bfcp(void)
639 module_t *bfcp_module;
640 expert_module_t* expert_bfcp;
642 static hf_register_info hf[] = {
644 &hf_bfcp_version,
645 { "Version(ver)", "bfcp.ver",
646 FT_UINT8, BASE_DEC, NULL, 0xe0,
647 NULL, HFILL }
650 &hf_bfcp_hdr_r_bit,
651 { "Transaction Responder (R)", "bfcp.hdr_r_bit",
652 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x10,
653 NULL, HFILL }
656 &hf_bfcp_hdr_f_bit,
657 { "Fragmentation (F)", "bfcp.hdr_f_bit",
658 FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x08,
659 NULL, HFILL }
662 &hf_bfcp_primitive,
663 { "Primitive", "bfcp.primitive",
664 FT_UINT8, BASE_DEC, VALS(map_bfcp_primitive), 0x0,
665 NULL, HFILL }
668 &hf_bfcp_payload_length,
669 { "Payload Length", "bfcp.payload_length",
670 FT_UINT16, BASE_DEC, NULL, 0x0,
671 "Length in 4-octet units, excluding the COMMON-HEADER", HFILL }
674 &hf_bfcp_conference_id,
675 { "Conference ID", "bfcp.conference_id",
676 FT_UINT32, BASE_DEC, NULL, 0x0,
677 NULL, HFILL }
680 &hf_bfcp_transaction_id,
681 { "Transaction ID", "bfcp.transaction_id",
682 FT_UINT16, BASE_DEC, NULL, 0x0,
683 NULL, HFILL }
686 &hf_bfcp_user_id,
687 { "User ID", "bfcp.user_id",
688 FT_UINT16, BASE_DEC, NULL, 0x0,
689 NULL, HFILL }
692 &hf_bfcp_fragment_offset,
693 { "Fragment Offset", "bfcp.fragment_offset",
694 FT_UINT16, BASE_DEC, NULL, 0x0,
695 "Number of 4-octet units contained in previous fragments, excluding the COMMON-HEADER", HFILL }
698 &hf_bfcp_fragment_length,
699 { "Fragment Length", "bfcp.fragment_length",
700 FT_UINT16, BASE_DEC, NULL, 0x0,
701 "Number of 4-octet units contained in this fragment, excluding the COMMON-HEADER", HFILL }
704 &hf_bfcp_payload,
705 { "Payload", "bfcp.payload",
706 FT_BYTES, BASE_NONE, NULL, 0x0, NULL,
707 HFILL }
710 &hf_bfcp_attribute_types,
711 { "Attribute Type", "bfcp.attribute_type",
712 FT_UINT8, BASE_DEC, VALS(map_bfcp_attribute_types), 0xFE,
713 NULL, HFILL }
716 &hf_bfcp_attribute_types_m_bit,
717 { "Mandatory bit(M)", "bfcp.attribute_types_m_bit",
718 FT_BOOLEAN, 8, NULL, 0x01,
719 NULL, HFILL }
722 &hf_bfcp_attribute_length,
723 { "Attribute Length", "bfcp.attribute_length",
724 FT_UINT16, BASE_DEC, NULL, 0x0,
725 NULL, HFILL }
728 &hf_bfcp_beneficiary_id,
729 { "BENEFICIARY-ID", "bfcp.beneficiary_id",
730 FT_UINT16, BASE_DEC, NULL, 0x0,
731 NULL, HFILL }
734 &hf_bfcp_floor_id,
735 { "FLOOR-ID", "bfcp.floor_id",
736 FT_UINT16, BASE_DEC, NULL, 0x0,
737 NULL, HFILL }
740 &hf_bfcp_floor_request_id,
741 { "FLOOR-REQUEST-ID", "bfcp.floorrequest_id",
742 FT_UINT16, BASE_DEC, NULL, 0x0,
743 NULL, HFILL }
746 &hf_bfcp_priority,
747 { "FLOOR-REQUEST-ID", "bfcp.priority",
748 FT_UINT16, BASE_DEC, NULL, 0xe000,
749 NULL, HFILL }
752 &hf_bfcp_request_status,
753 { "Request Status", "bfcp.request_status",
754 FT_UINT8, BASE_DEC, VALS(map_bfcp_request_status), 0x0,
755 NULL, HFILL }
758 &hf_bfcp_queue_pos,
759 { "Queue Position", "bfcp.queue_pos",
760 FT_UINT8, BASE_DEC, NULL, 0x0,
761 NULL, HFILL }
764 &hf_bfcp_error_code,
765 { "Error Code", "bfcp.error_code",
766 FT_UINT8, BASE_DEC, VALS(bfcp_error_code_valuse), 0x0,
767 NULL, HFILL }
770 &hf_bfcp_error_info_text,
771 { "Text", "bfcp.error_info_text",
772 FT_STRING, BASE_NONE, NULL, 0x0,
773 NULL, HFILL }
776 &hf_bfcp_part_prov_info_text,
777 { "Text", "bfcp.part_prov_info_text",
778 FT_STRING, BASE_NONE, NULL, 0x0,
779 NULL, HFILL }
782 &hf_bfcp_status_info_text,
783 { "Text", "bfcp.status_info_text",
784 FT_STRING, BASE_NONE, NULL, 0x0,
785 NULL, HFILL }
788 &hf_bfcp_supp_attr,
789 { "Supported Attribute", "bfcp.supp_attr",
790 FT_UINT8, BASE_DEC, VALS(map_bfcp_attribute_types), 0xFE,
791 NULL, HFILL }
794 &hf_bfcp_supp_prim,
795 { "Supported Primitive", "bfcp.supp_primitive",
796 FT_UINT8, BASE_DEC, VALS(map_bfcp_primitive), 0x0,
797 NULL, HFILL }
800 &hf_bfcp_user_disp_name,
801 { "Name", "bfcp.user_disp_name",
802 FT_STRING, BASE_NONE, NULL, 0x0,
803 NULL, HFILL }
806 &hf_bfcp_user_uri,
807 { "URI", "bfcp.user_uri",
808 FT_STRING, BASE_NONE, NULL, 0x0,
809 NULL, HFILL }
812 &hf_bfcp_req_by_id,
813 { "Requested-by ID", "bfcp.req_by_i",
814 FT_UINT16, BASE_DEC, NULL, 0x0,
815 NULL, HFILL }
818 &hf_bfcp_padding,
819 { "Padding", "bfcp.padding",
820 FT_BYTES, BASE_NONE, NULL, 0x0,
821 NULL, HFILL }
824 &hf_bfcp_error_specific_details,
825 { "Error Specific Details", "bfcp.error_specific_details",
826 FT_BYTES, BASE_NONE, NULL, 0x0,
827 NULL, HFILL }
829 { &hf_bfcp_setup,
830 { "Stream setup", "bfcp.setup",
831 FT_STRING, BASE_NONE, NULL, 0x0,
832 "Stream setup, method and frame number", HFILL}
834 { &hf_bfcp_setup_frame,
835 { "Setup frame", "bfcp.setup-frame",
836 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
837 "Frame that set up this stream", HFILL}
839 { &hf_bfcp_setup_method,
840 { "Setup Method", "bfcp.setup-method",
841 FT_STRING, BASE_NONE, NULL, 0x0,
842 "Method used to set up this stream", HFILL}
846 static int *ett[] = {
847 &ett_bfcp,
848 &ett_bfcp_setup,
849 &ett_bfcp_attr,
852 static ei_register_info ei[] = {
853 { &ei_bfcp_attribute_length_too_small, { "bfcp.attribute_length.too_small", PI_MALFORMED, PI_ERROR, "Attribute length is too small", EXPFILL }},
856 /* Register protocol name and description */
857 proto_bfcp = proto_register_protocol("Binary Floor Control Protocol", "BFCP", "bfcp");
859 bfcp_handle = register_dissector("bfcp", dissect_bfcp, proto_bfcp);
861 bfcp_module = prefs_register_protocol(proto_bfcp, NULL);
863 prefs_register_obsolete_preference(bfcp_module, "enable");
865 /* Register field and subtree array */
866 proto_register_field_array(proto_bfcp, hf, array_length(hf));
867 proto_register_subtree_array(ett, array_length(ett));
869 expert_bfcp = expert_register_protocol(proto_bfcp);
870 expert_register_field_array(expert_bfcp, ei, array_length(ei));
873 void proto_reg_handoff_bfcp(void)
875 /* "Decode As" is always available;
876 * Heuristic dissection in disabled by default since
877 * the heuristic is quite weak.
879 heur_dissector_add("tcp", dissect_bfcp_heur, "BFCP over TCP", "bfcp_tcp", proto_bfcp, HEURISTIC_DISABLE);
880 heur_dissector_add("udp", dissect_bfcp_heur, "BFCP over UDP", "bfcp_udp", proto_bfcp, HEURISTIC_DISABLE);
881 dissector_add_for_decode_as_with_preference("tcp.port", bfcp_handle);
882 dissector_add_for_decode_as_with_preference("udp.port", bfcp_handle);
886 * Editor modelines - https://www.wireshark.org/tools/modelines.html
888 * Local variables:
889 * c-basic-offset: 8
890 * tab-width: 8
891 * indent-tabs-mode: t
892 * End:
894 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
895 * :indentSize=8:tabSize=8:noTabs=false: