From e0040ff537f080a77ceb041915f6d04ac138955c Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 3 Oct 2005 23:54:44 +0000 Subject: r10698: Fix support of enums in switch_type() in the ethereal parser generator (This used to be commit 9fac8dfeb393212e16be7156de466077bc90232d) --- source4/pidl/lib/Parse/Pidl/Ethereal/NDR.pm | 17 +++++++++++++---- 1 file 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"; -- cgit