Remove all $Id$ from top of file
[metze/wireshark/wip.git] / epan / dissectors / packet-bfcp.c
index 7899b1f4d097212c430be6ea7ab6a7283d71c4d1..129909ad5c847d72466ee7031959eef4202c4220 100644 (file)
@@ -5,8 +5,6 @@
  * Updated with attribute dissection
  * Copyright 2012, Anders Broman <anders.broman@ericsson.com>
  *
- * $Id$
- *
  * Wireshark - Network traffic analyzer
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 1998 Gerald Combs
@@ -75,6 +73,10 @@ static int hf_bfcp_req_by_id = -1;
 static gint ett_bfcp = -1;
 static gint ett_bfcp_attr = -1;
 
+static expert_field ei_bfcp_attribute_length_too_small = EI_INIT;
+
+static dissector_handle_t bfcp_handle;
+
 /* Initialize BFCP primitives */
 static const value_string map_bfcp_primitive[] = {
        { 0,  "<Invalid Primitive>"},
@@ -172,7 +174,7 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
        gint        length;
        guint8      attribute_type;
        gint        read_attr = 0;
-    guint8      first_byte, pad_len;
+       guint8      first_byte, pad_len;
 
        while ((tvb_reported_length_remaining(tvb, offset) >= 2) &&
                        ((bfcp_payload_length - read_attr) >= 2))
@@ -247,7 +249,7 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
                        offset = offset + pad_len;
                        break;
                case 7: /* ERROR-INFO */
-                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_info_text, tvb, offset, length-3, ENC_BIG_ENDIAN);
+                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_error_info_text, tvb, offset, length-3, ENC_ASCII|ENC_NA);
                        offset = offset + length-3;
                        pad_len = length & 0x03;
                        if(pad_len != 0){
@@ -257,7 +259,7 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
                        offset = offset + pad_len;
                        break;
                case 8: /* PARTICIPANT-PROVIDED-INFO */
-                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_part_prov_info_text, tvb, offset, length-3, ENC_BIG_ENDIAN);
+                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_part_prov_info_text, tvb, offset, length-3, ENC_ASCII|ENC_NA);
                        offset = offset + length-3;
                        pad_len = length & 0x03;
                        if(pad_len != 0){
@@ -267,7 +269,7 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
                        offset = offset + pad_len;
                        break;
                case 9: /* STATUS-INFO */
-                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_status_info_text, tvb, offset, length-3, ENC_BIG_ENDIAN);
+                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_status_info_text, tvb, offset, length-3, ENC_ASCII|ENC_NA);
                        offset = offset + length-3;
                        pad_len = length & 0x03;
                        if(pad_len != 0){
@@ -303,7 +305,7 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
                        offset = offset + pad_len;
                        break;
                case 12: /* USER-DISPLAY-NAME */
-                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_disp_name, tvb, offset, length-3, ENC_BIG_ENDIAN);
+                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_disp_name, tvb, offset, length-3, ENC_ASCII|ENC_NA);
                        offset = offset + length-3;
                        pad_len = length & 0x03;
                        if(pad_len != 0){
@@ -313,7 +315,7 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
                        offset = offset + pad_len;
                        break;
                case 13: /* USER-URI */
-                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_uri, tvb, offset, length-3, ENC_BIG_ENDIAN);
+                       proto_tree_add_item(bfcp_attr_tree, hf_bfcp_user_uri, tvb, offset, length-3, ENC_ASCII|ENC_NA);
                        offset = offset + length-3;
                        pad_len = length & 0x03;
                        if(pad_len != 0){
@@ -370,11 +372,11 @@ dissect_bfcp_attributes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
 
                default:
                        proto_tree_add_item(bfcp_attr_tree, hf_bfcp_payload, tvb, offset, length-2, ENC_NA);
-                       offset = offset + length - 2; 
+                       offset = offset + length - 2;
                        break;
                }
                if (length < (offset - attr_start_offset)){
-                       expert_add_info_format(pinfo, item, PI_MALFORMED, PI_ERROR,
+                       expert_add_info_format(pinfo, item, &ei_bfcp_attribute_length_too_small,
                                                        "Attribute length is too small (%d bytes)", length);
                        break;
                }
@@ -442,16 +444,16 @@ dissect_bfcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                bfcp_payload_length = tvb_get_ntohs(tvb,
                                                        BFCP_OFFSET_PAYLOAD_LENGTH) * 4;
 
-               offset = dissect_bfcp_attributes(tvb, pinfo, bfcp_tree, offset, bfcp_payload_length);
+               /*offset = */dissect_bfcp_attributes(tvb, pinfo, bfcp_tree, offset, bfcp_payload_length);
 
        } /* if(tree) */
 }
 
-static gboolean 
+static gboolean
 dissect_bfcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
 {
        guint8       primitive;
-    guint8      first_byte;
+       guint8      first_byte;
        const gchar *str;
 
 
@@ -485,6 +487,7 @@ dissect_bfcp_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
 void proto_register_bfcp(void)
 {
        module_t *bfcp_module;
+       expert_module_t* expert_bfcp;
 
        static hf_register_info hf[] = {
                {
@@ -656,11 +659,15 @@ void proto_register_bfcp(void)
                &ett_bfcp_attr,
        };
 
+       static ei_register_info ei[] = {
+               { &ei_bfcp_attribute_length_too_small, { "bfcp.attribute_length.too_small", PI_MALFORMED, PI_ERROR, "Attribute length is too small", EXPFILL }},
+       };
+
        /* Register protocol name and description */
        proto_bfcp = proto_register_protocol("Binary Floor Control Protocol",
                                "BFCP", "bfcp");
 
-       register_dissector("bfcp", dissect_bfcp, proto_bfcp);
+       bfcp_handle = register_dissector("bfcp", dissect_bfcp, proto_bfcp);
 
        bfcp_module = prefs_register_protocol(proto_bfcp,
                                proto_reg_handoff_bfcp);
@@ -673,6 +680,9 @@ void proto_register_bfcp(void)
        /* Register field and subtree array */
        proto_register_field_array(proto_bfcp, hf, array_length(hf));
        proto_register_subtree_array(ett, array_length(ett));
+
+       expert_bfcp = expert_register_protocol(proto_bfcp);
+       expert_register_field_array(expert_bfcp, ei, array_length(ei));
 }
 
 void proto_reg_handoff_bfcp(void)
@@ -685,11 +695,8 @@ void proto_reg_handoff_bfcp(void)
         */
        if (!prefs_initialized)
        {
-               dissector_handle_t bfcp_handle;
-
                heur_dissector_add("tcp", dissect_bfcp_heur, proto_bfcp);
                heur_dissector_add("udp", dissect_bfcp_heur, proto_bfcp);
-               bfcp_handle = create_dissector_handle(dissect_bfcp, proto_bfcp);
                dissector_add_handle("tcp.port", bfcp_handle);
                dissector_add_handle("udp.port", bfcp_handle);
                prefs_initialized = TRUE;