Remove proto_tree_add_text from idl2wrs generation.
authorMichael Mann <mmann78@netscape.net>
Thu, 7 May 2015 02:32:29 +0000 (22:32 -0400)
committerAnders Broman <a.broman58@gmail.com>
Thu, 7 May 2015 06:05:50 +0000 (06:05 +0000)
Change-Id: Iab9df3e68d2a3878c3081c6352c45f7c329b983e
Reviewed-on: https://code.wireshark.org/review/8323
Reviewed-by: Anders Broman <a.broman58@gmail.com>
epan/dissectors/packet-gias.c
epan/dissectors/packet-parlay.c
tools/wireshark_gen.py

index 9085cbdaca0712d71567a596b2b7500d32df21e1..90210b8242c7900291a1d3574e70887572ce2406 100644 (file)
@@ -5713,8 +5713,8 @@ decode_UCO_CompressedImage_st(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_t
             u_octet4_loop_UCO_CompressedImage_data);
         text_seq_UCO_CompressedImage_data = make_printable_string(binary_seq_UCO_CompressedImage_data,
             u_octet4_loop_UCO_CompressedImage_data);
-        proto_tree_add_text(tree, tvb, *offset - u_octet4_loop_UCO_CompressedImage_data,
-            u_octet4_loop_UCO_CompressedImage_data, "UCO_CompressedImage_data: %s", text_seq_UCO_CompressedImage_data);
+        proto_tree_add_bytes_format_value(tree, hf_UCO_CompressedImage_data, tvb, *offset - u_octet4_loop_UCO_CompressedImage_data,
+            u_octet4_loop_UCO_CompressedImage_data, binary_seq_UCO_CompressedImage_data, "%s", text_seq_UCO_CompressedImage_data);
     }
 
 }
@@ -6518,8 +6518,8 @@ decode_UCO_Buffer_un(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree
                 u_octet4_loop_UCO_Buffer_octet_buffer);
             text_seq_UCO_Buffer_octet_buffer = make_printable_string(binary_seq_UCO_Buffer_octet_buffer,
                 u_octet4_loop_UCO_Buffer_octet_buffer);
-            proto_tree_add_text(tree, tvb, *offset - u_octet4_loop_UCO_Buffer_octet_buffer,
-                u_octet4_loop_UCO_Buffer_octet_buffer, "UCO_Buffer_octet_buffer: %s", text_seq_UCO_Buffer_octet_buffer);
+            proto_tree_add_bytes_format_value(tree, hf_UCO_Buffer_octet_buffer, tvb, *offset - u_octet4_loop_UCO_Buffer_octet_buffer,
+                u_octet4_loop_UCO_Buffer_octet_buffer, binary_seq_UCO_Buffer_octet_buffer, "%s", text_seq_UCO_Buffer_octet_buffer);
         }
 
         return;     /* End Compare for this discriminant type */
@@ -6868,8 +6868,8 @@ decode_GIAS_Domain_un(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tre
                 u_octet4_loop_GIAS_Domain_bd);
             text_seq_GIAS_Domain_bd = make_printable_string(binary_seq_GIAS_Domain_bd,
                 u_octet4_loop_GIAS_Domain_bd);
-            proto_tree_add_text(tree, tvb, *offset - u_octet4_loop_GIAS_Domain_bd,
-                u_octet4_loop_GIAS_Domain_bd, "GIAS_Domain_bd: %s", text_seq_GIAS_Domain_bd);
+            proto_tree_add_bytes_format_value(tree, hf_GIAS_Domain_bd, tvb, *offset - u_octet4_loop_GIAS_Domain_bd,
+                u_octet4_loop_GIAS_Domain_bd, binary_seq_GIAS_Domain_bd, "%s", text_seq_GIAS_Domain_bd);
         }
 
         return;     /* End Compare for this discriminant type */
@@ -7986,7 +7986,7 @@ void proto_register_giop_gias(void)
         {&hf_UCO_CompressedImage_height, {"CompressedImage_height","giop-gias.CompressedImage.height",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
         {&hf_UCO_CompressedImage_compression_form, {"CompressedImage_compression_form","giop-gias.CompressedImage.compression_form",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_UCO_CompressedImage_data_loop, {"Seq length of CompressedImage_data","giop-gias.CompressedImage.data.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
-        {&hf_UCO_CompressedImage_data, {"CompressedImage_data","giop-gias.CompressedImage.data",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL}},
+        {&hf_UCO_CompressedImage_data, {"CompressedImage_data","giop-gias.CompressedImage.data",FT_BYTES,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_UCO_Status_completion_state, {"Status_completion_state","giop-gias.Status.completion_state",FT_UINT32,BASE_DEC,VALS(UCO_State),0x0,NULL,HFILL}},
         {&hf_UCO_Status_warning, {"Status_warning","giop-gias.Status.warning",FT_BOOLEAN,8,NULL,0x01,NULL,HFILL}},
         {&hf_UCO_Status_status_message, {"Status_status_message","giop-gias.Status.status_message",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
@@ -8086,7 +8086,7 @@ void proto_register_giop_gias(void)
         /* Union filters */
         {&hf_UCO_Buffer_Buffer, {"Buffer","giop-gias.UCO.Buffer",FT_UINT32,BASE_DEC,VALS(UCO_BufferType),0x0,NULL,HFILL}},
         {&hf_UCO_Buffer_octet_buffer_loop, {"Seq length of Buffer_octet_buffer","giop-gias.UCO.Buffer.octet_buffer.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
-        {&hf_UCO_Buffer_octet_buffer, {"Buffer_octet_buffer","giop-gias.UCO.Buffer.octet_buffer",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL}},
+        {&hf_UCO_Buffer_octet_buffer, {"Buffer_octet_buffer","giop-gias.UCO.Buffer.octet_buffer",FT_BYTES,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_UCO_Buffer_char_buffer_loop, {"Seq length of Buffer_char_buffer","giop-gias.UCO.Buffer.char_buffer.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
         {&hf_UCO_Buffer_char_buffer, {"Buffer_char_buffer","giop-gias.UCO.Buffer.char_buffer",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL}},
         {&hf_UCO_Buffer_ushort_buffer_loop, {"Seq length of Buffer_ushort_buffer","giop-gias.UCO.Buffer.ushort_buffer.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
@@ -8113,7 +8113,7 @@ void proto_register_giop_gias(void)
         {&hf_GIAS_Domain_ol, {"Domain_ol","giop-gias.GIAS.Domain.ol",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_GIAS_Domain_gs_loop, {"Seq length of Domain_gs","giop-gias.GIAS.Domain.gs.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
         {&hf_GIAS_Domain_bd_loop, {"Seq length of Domain_bd","giop-gias.GIAS.Domain.bd.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
-        {&hf_GIAS_Domain_bd, {"Domain_bd","giop-gias.GIAS.Domain.bd",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL}},
+        {&hf_GIAS_Domain_bd, {"Domain_bd","giop-gias.GIAS.Domain.bd",FT_BYTES,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_GIAS_Domain_bv, {"Domain_bv","giop-gias.GIAS.Domain.bv",FT_BOOLEAN,8,NULL,0x01,NULL,HFILL}},
         {&hf_GIAS_LifeEvent_LifeEvent, {"LifeEvent","giop-gias.GIAS.LifeEvent",FT_UINT32,BASE_DEC,VALS(GIAS_LifeEventType),0x0,NULL,HFILL}},
         {&hf_GIAS_LifeEvent_ev, {"LifeEvent_ev","giop-gias.GIAS.LifeEvent.ev",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
index 906ce17ffe8accf2336d28c7b8bc675334380f72..3b2adecccfeede3933ca616331b6fe2b968c33ce 100644 (file)
@@ -2761,6 +2761,7 @@ static int hf_org_csapi_TpSimpleAttributeValue_TpSimpleAttributeValue = -1;
 static int hf_org_csapi_TpSimpleAttributeValue_BooleanValue = -1;
 static int hf_org_csapi_TpSimpleAttributeValue_OctetValue = -1;
 static int hf_org_csapi_TpSimpleAttributeValue_CharValue = -1;
+static int hf_org_csapi_TpSimpleAttributeValue_WCharValue_len = -1;
 static int hf_org_csapi_TpSimpleAttributeValue_WCharValue = -1;
 static int hf_org_csapi_TpSimpleAttributeValue_StringValue = -1;
 static int hf_org_csapi_TpSimpleAttributeValue_WStringValue = -1;
@@ -53164,13 +53165,13 @@ decode_org_csapi_TpSimpleAttributeValue_un(tvbuff_t *tvb _U_, packet_info *pinfo
         s_octet1 = get_CDR_wchar(tvb, &seq, offset, header);
         if (tree) {
             if (s_octet1 > 0)
-                proto_tree_add_text(tree,tvb,*offset-1-s_octet1,1,"length = %u",s_octet1);
+                proto_tree_add_uint(tree, hf_org_csapi_TpSimpleAttributeValue_WCharValue_len, tvb, *offset-1-s_octet1, 1, s_octet1);
 
             if (s_octet1 < 0)
                 s_octet1 = -s_octet1;
 
             if (s_octet1 > 0)
-                proto_tree_add_text(tree,tvb,*offset-s_octet1,s_octet1,"org_csapi_TpSimpleAttributeValue_WCharValue = %s",seq);
+                proto_tree_add_string(tree, hf_org_csapi_TpSimpleAttributeValue_WCharValue, tvb, *offset-s_octet1, s_octet1, seq);
         }
 
         return;     /* End Compare for this discriminant type */
@@ -53186,8 +53187,7 @@ decode_org_csapi_TpSimpleAttributeValue_un(tvbuff_t *tvb _U_, packet_info *pinfo
     if (disc_s_TpSimpleAttributeValue == 5 ) {
 
         u_octet4 = get_CDR_wstring(tvb, &seq, offset, stream_is_big_endian, boundary, header);
-        proto_tree_add_text(tree,tvb,*offset-u_octet4,u_octet4,"org_csapi_TpSimpleAttributeValue_WStringValue (%u) = %s",
-              u_octet4, (u_octet4 > 0) ? seq : "");
+        proto_tree_add_string(tree, hf_org_csapi_TpSimpleAttributeValue_WStringValue, tvb, *offset-u_octet4, u_octet4, (u_octet4 > 0) ? seq : "");
 
         return;     /* End Compare for this discriminant type */
     }
@@ -67044,7 +67044,8 @@ void proto_register_giop_parlay(void)
         {&hf_org_csapi_TpSimpleAttributeValue_BooleanValue, {"TpSimpleAttributeValue_BooleanValue","giop-parlay.org.csapi.TpSimpleAttributeValue.BooleanValue",FT_BOOLEAN,8,NULL,0x01,NULL,HFILL}},
         {&hf_org_csapi_TpSimpleAttributeValue_OctetValue, {"TpSimpleAttributeValue_OctetValue","giop-parlay.org.csapi.TpSimpleAttributeValue.OctetValue",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL}},
         {&hf_org_csapi_TpSimpleAttributeValue_CharValue, {"TpSimpleAttributeValue_CharValue","giop-parlay.org.csapi.TpSimpleAttributeValue.CharValue",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL}},
-        {&hf_org_csapi_TpSimpleAttributeValue_WCharValue, {"TpSimpleAttributeValue_WCharValue","giop-parlay.org.csapi.TpSimpleAttributeValue.WCharValue",FT_UINT16,BASE_DEC,NULL,0x0,NULL,HFILL}},
+        {&hf_org_csapi_TpSimpleAttributeValue_WCharValue_len, {"TpSimpleAttributeValue_WCharValue Length","giop-parlay.org.csapi.TpSimpleAttributeValue.WCharValue.len",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL}},
+        {&hf_org_csapi_TpSimpleAttributeValue_WCharValue, {"TpSimpleAttributeValue_WCharValue","giop-parlay.org.csapi.TpSimpleAttributeValue.WCharValue",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_org_csapi_TpSimpleAttributeValue_StringValue, {"TpSimpleAttributeValue_StringValue","giop-parlay.org.csapi.TpSimpleAttributeValue.StringValue",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_org_csapi_TpSimpleAttributeValue_WStringValue, {"TpSimpleAttributeValue_WStringValue","giop-parlay.org.csapi.TpSimpleAttributeValue.WStringValue",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},
         {&hf_org_csapi_TpSimpleAttributeValue_Int16Value, {"TpSimpleAttributeValue_Int16Value","giop-parlay.org.csapi.TpSimpleAttributeValue.Int16Value",FT_INT16,BASE_DEC,NULL,0x0,NULL,HFILL}},
index a920aa0ef29424cedf0a2d1c949cce60d652c5cf..8286b9ba6d4f96f37e37f4930f5af3aedd604787 100755 (executable)
@@ -335,6 +335,8 @@ class wireshark_gen_C:
                   (p.paramType().unalias().kind() != idltype.tk_struct) and \
                   (p.paramType().unalias().kind() != idltype.tk_objref) and \
                   (p.paramType().unalias().kind() != idltype.tk_union)):
+                if (p.paramType().unalias().kind() == idltype.tk_wchar):
+                    self.st.out(self.template_hf, name=sname + "_" + p.identifier() + "_len")
                 self.st.out(self.template_hf, name=sname + "_" + p.identifier())
 
     #
@@ -378,6 +380,8 @@ class wireshark_gen_C:
                         if (self.isSeqNativeType(m.memberType().unalias().seqType())):
                             self.st.out(self.template_hf, name=sname + "_" + decl.identifier())
                     else:
+                        if (m.memberType().unalias().kind() == idltype.tk_wchar):
+                            self.st.out(self.template_hf, name=sname + "_" + decl.identifier() + "_len")
                         self.st.out(self.template_hf, name=sname + "_" + decl.identifier())
 
     #
@@ -425,6 +429,8 @@ class wireshark_gen_C:
                     if (self.isSeqNativeType(uc.caseType().unalias().seqType())):
                         self.st.out(self.template_hf, name=sname + "_" + uc.declarator().identifier())
                 elif (self.isSeqNativeType(uc.caseType())):
+                    if (uc.caseType().unalias().kind() == idltype.tk_wchar):
+                        self.st.out(self.template_hf, name=sname + "_" + uc.declarator().identifier() + "_len")
                     self.st.out(self.template_hf, name=sname + "_" + uc.declarator().identifier())
 
     #
@@ -1277,7 +1283,7 @@ class wireshark_gen_C:
         string_scale  = '%i ' % type.scale()  # convert int to string
         string_length  = '%i ' % self.dig_to_len(type.digits())  # how many octets to hilight for a number of digits
 
-        self.st.out(self.template_get_CDR_fixed, varname=pn, digits=string_digits, scale=string_scale, length=string_length )
+        self.st.out(self.template_get_CDR_fixed, hfname=pn, digits=string_digits, scale=string_scale, length=string_length )
         self.addvar(self.c_seq)
 
 
@@ -1300,12 +1306,12 @@ class wireshark_gen_C:
         self.st.out(self.template_get_CDR_string, hfname=pn)
 
     def get_CDR_wstring(self,pn):
-        self.st.out(self.template_get_CDR_wstring, varname=pn)
+        self.st.out(self.template_get_CDR_wstring, hfname=pn)
         self.addvar(self.c_u_octet4)
         self.addvar(self.c_seq)
 
     def get_CDR_wchar(self,pn):
-        self.st.out(self.template_get_CDR_wchar, varname=pn)
+        self.st.out(self.template_get_CDR_wchar, hfname=pn)
         self.addvar(self.c_s_octet1)
         self.addvar(self.c_seq)
 
@@ -1376,7 +1382,7 @@ class wireshark_gen_C:
         elif pt ==  idltype.tk_double:
             self.get_CDR_double_hf(pn, desc, filter, self.dissname)
         elif pt == idltype.tk_fixed:
-            pt = pt   # no hf_ variables needed
+            self.get_CDR_fixed_hf(pn, desc, filter, self.dissname)
         elif pt ==  idltype.tk_boolean:
             self.get_CDR_boolean_hf(pn, desc, filter, self.dissname)
         elif pt ==  idltype.tk_char:
@@ -1439,6 +1445,9 @@ class wireshark_gen_C:
     def get_CDR_double_hf(self,pn,desc,filter,diss):
         self.st.out(self.template_get_CDR_double_hf, hfname=pn, dissector_name=diss, descname=desc, filtername=filter)
 
+    def get_CDR_fixed_hf(self,pn,desc,filter,diss):
+        self.st.out(self.template_get_CDR_fixed_hf, hfname=pn, dissector_name=diss, descname=desc, filtername=filter)
+
     def get_CDR_longlong_hf(self,pn,desc,filter,diss):
         self.st.out(self.template_get_CDR_longlong_hf, hfname=pn, dissector_name=diss, descname=desc, filtername=filter)
 
@@ -1783,6 +1792,8 @@ class wireshark_gen_C:
 
 
     def get_CDR_sequence(self,type,pn):
+        if self.DEBUG:
+            print "XXX get_CDR_sequence"
         self.st.out(self.template_get_CDR_sequence_length, seqname=pn )
         self.st.out(self.template_get_CDR_sequence_loop_start, seqname=pn )
         self.addvar(self.c_i_lim + pn + ";" )
@@ -2347,7 +2358,7 @@ get_CDR_any(tvb, pinfo, tree, item, offset, stream_is_big_endian, boundary, head
 """
     template_get_CDR_fixed = """\
 get_CDR_fixed(tvb, pinfo, item, &seq, offset, @digits@, @scale@);
-proto_tree_add_text(tree,tvb,*offset-@length@, @length@, "@varname@ < @digits@, @scale@> = %s",seq);
+proto_tree_add_string_format_value(tree, hf_@hfname@, tvb, *offset-@length@, @length@, seq, "< @digits@, @scale@> = %s", seq);
 """
     template_get_CDR_enum_symbolic = """\
 u_octet4 = get_CDR_enum(tvb,offset,stream_is_big_endian, boundary);
@@ -2359,20 +2370,19 @@ giop_add_CDR_string(tree, tvb, offset, stream_is_big_endian, boundary, hf_@hfnam
 """
     template_get_CDR_wstring = """\
 u_octet4 = get_CDR_wstring(tvb, &seq, offset, stream_is_big_endian, boundary, header);
-proto_tree_add_text(tree,tvb,*offset-u_octet4,u_octet4,"@varname@ (%u) = %s",
-      u_octet4, (u_octet4 > 0) ? seq : \"\");
+proto_tree_add_string(tree, hf_@hfname@, tvb, *offset-u_octet4, u_octet4, (u_octet4 > 0) ? seq : \"\");
 """
     template_get_CDR_wchar = """\
 s_octet1 = get_CDR_wchar(tvb, &seq, offset, header);
 if (tree) {
     if (s_octet1 > 0)
-        proto_tree_add_text(tree,tvb,*offset-1-s_octet1,1,"length = %u",s_octet1);
+        proto_tree_add_uint(tree, hf_@hfname@_len, tvb, *offset-1-s_octet1, 1, s_octet1);
 
     if (s_octet1 < 0)
         s_octet1 = -s_octet1;
 
     if (s_octet1 > 0)
-        proto_tree_add_text(tree,tvb,*offset-s_octet1,s_octet1,"@varname@ = %s",seq);
+        proto_tree_add_string(tree, hf_@hfname@, tvb, *offset-s_octet1, s_octet1, seq);
 }
 """
     template_get_CDR_TypeCode = """\
@@ -2401,8 +2411,8 @@ if (u_octet4_loop_@seqname@ > 0 && tree) {
         u_octet4_loop_@seqname@);
     text_seq_@seqname@ = make_printable_string(binary_seq_@seqname@,
         u_octet4_loop_@seqname@);
-    proto_tree_add_text(tree, tvb, *offset - u_octet4_loop_@seqname@,
-        u_octet4_loop_@seqname@, \"@seqname@: %s\", text_seq_@seqname@);
+    proto_tree_add_bytes_format_value(tree, hf_@seqname@, tvb, *offset - u_octet4_loop_@seqname@,
+        u_octet4_loop_@seqname@, binary_seq_@seqname@, \"%s\", text_seq_@seqname@);
 }
 """
     template_get_CDR_array_start = """\
@@ -2448,6 +2458,9 @@ for (i_@aname@=0; i_@aname@ < @aval@; i_@aname@++) {
     template_get_CDR_double_hf = """\
         {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_DOUBLE,BASE_NONE,NULL,0x0,NULL,HFILL}},"""
 
+    template_get_CDR_fixed_hf = """\
+        {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},"""
+
     template_get_CDR_longlong_hf = """\
         {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_INT64,BASE_DEC,NULL,0x0,NULL,HFILL}},"""
 
@@ -2473,7 +2486,8 @@ for (i_@aname@=0; i_@aname@ < @aval@; i_@aname@++) {
         {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},"""
 
     template_get_CDR_wchar_hf = """\
-        {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_UINT16,BASE_DEC,NULL,0x0,NULL,HFILL}},"""
+        {&hf_@hfname@_len, {"@descname@ Length","giop-@dissector_name@.@filtername@.len",FT_UINT8,BASE_DEC,NULL,0x0,NULL,HFILL}},
+        {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_STRING,BASE_NONE,NULL,0x0,NULL,HFILL}},"""
 
     template_get_CDR_TypeCode_hf = """\
         {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},"""
@@ -2483,7 +2497,7 @@ for (i_@aname@=0; i_@aname@ < @aval@; i_@aname@++) {
 
     template_get_CDR_sequence_octet_hf = """\
         {&hf_@hfname@_loop, {"Seq length of @descname@","giop-@dissector_name@.@filtername@.size",FT_UINT32,BASE_DEC,NULL,0x0,NULL,HFILL}},
-        {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_UINT8,BASE_HEX,NULL,0x0,NULL,HFILL}},"""
+        {&hf_@hfname@, {"@descname@","giop-@dissector_name@.@filtername@",FT_BYTES,BASE_NONE,NULL,0x0,NULL,HFILL}},"""
 
 #
 # Program Header Template