aboutsummaryrefslogtreecommitdiffstats
path: root/tools/wireshark_gen.py
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-05-06 22:32:29 -0400
committerAnders Broman <a.broman58@gmail.com>2015-05-07 06:05:50 +0000
commit718e900824bc50624ab9e0e9b83f5e05f7049619 (patch)
tree612076794207183e4766a4228697fb5dfe84272d /tools/wireshark_gen.py
parent12e0f0fa4f4874c35998ae105cec084c7a07b8a5 (diff)
Remove proto_tree_add_text from idl2wrs generation.
Change-Id: Iab9df3e68d2a3878c3081c6352c45f7c329b983e Reviewed-on: https://code.wireshark.org/review/8323 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'tools/wireshark_gen.py')
-rwxr-xr-xtools/wireshark_gen.py40
1 files changed, 27 insertions, 13 deletions
diff --git a/tools/wireshark_gen.py b/tools/wireshark_gen.py
index a920aa0ef2..8286b9ba6d 100755
--- a/tools/wireshark_gen.py
+++ b/tools/wireshark_gen.py
@@ -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