diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-10-03 23:54:44 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:39:20 -0500 |
commit | e0040ff537f080a77ceb041915f6d04ac138955c (patch) | |
tree | 6beaeef30700049e9699540833dd59736fef1957 | |
parent | 099c3d532736d5836d0d5d3236cd1e502897076c (diff) | |
download | samba-e0040ff537f080a77ceb041915f6d04ac138955c.tar.gz samba-e0040ff537f080a77ceb041915f6d04ac138955c.tar.bz2 samba-e0040ff537f080a77ceb041915f6d04ac138955c.zip |
r10698: Fix support of enums in switch_type() in the ethereal parser generator
(This used to be commit 9fac8dfeb393212e16be7156de466077bc90232d)
-rw-r--r-- | source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm index b497f87403..e7a6b80b7b 100644 --- a/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm +++ b/source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm @@ -9,7 +9,7 @@ package Parse::Pidl::Ethereal::NDR; use strict; -use Parse::Pidl::Typelist; +use Parse::Pidl::Typelist qw(getType); use Parse::Pidl::Util qw(has_property ParseExpr property_matches make_str); use Parse::Pidl::NDR; use Parse::Pidl::Dump qw(DumpTypedef DumpFunction); @@ -485,7 +485,16 @@ sub Union($$$) $res.="\t\tbreak;\n"; } - my $switch_type = $e->{SWITCH_TYPE}; + my $switch_type; + my $switch_dissect; + my $switch_dt = getType($e->{SWITCH_TYPE}); + if ($switch_dt->{DATA}->{TYPE} eq "ENUM") { + $switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt); + $switch_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($switch_dt); + } elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") { + $switch_type = "g$e->{SWITCH_TYPE}"; + $switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}"; + } pidl_code "static int"; pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_)"; @@ -494,7 +503,7 @@ sub Union($$$) pidl_code "proto_item *item = NULL;"; pidl_code "proto_tree *tree = NULL;"; pidl_code "int old_offset;"; - pidl_code "g$switch_type level;"; + pidl_code "$switch_type level;"; pidl_code ""; if ($e->{ALIGN} > 1) { @@ -513,7 +522,7 @@ sub Union($$$) pidl_code ""; - pidl_code "offset = dissect_ndr_$switch_type(tvb, offset, pinfo, tree, drep, hf_index, &level);"; + pidl_code "offset = $switch_dissect(tvb, offset, pinfo, tree, drep, hf_index, &level);"; pidl_code "switch(level) {$res\t}"; pidl_code "proto_item_set_len(item, offset-old_offset);\n"; |