svn commit: samba r10698 - in branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal: .

jelmer at samba.org jelmer at samba.org
Mon Oct 3 23:54:45 GMT 2005


Author: jelmer
Date: 2005-10-03 23:54:44 +0000 (Mon, 03 Oct 2005)
New Revision: 10698

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=10698

Log:
Fix support of enums in switch_type() in the ethereal parser generator

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm


Changeset:
Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm	2005-10-03 23:46:21 UTC (rev 10697)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm	2005-10-03 23:54:44 UTC (rev 10698)
@@ -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 @@
 		$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 @@
 	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 @@
 
 	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";



More information about the samba-cvs mailing list