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

jelmer at samba.org jelmer at samba.org
Fri Oct 14 19:57:42 GMT 2005


Author: jelmer
Date: 2005-10-14 19:57:41 +0000 (Fri, 14 Oct 2005)
New Revision: 11067

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

Log:
Support for [string] in the Ethereal parser generator

Modified:
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm
   branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/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-14 18:54:12 UTC (rev 11066)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/Ethereal/NDR.pm	2005-10-14 19:57:41 UTC (rev 11067)
@@ -19,13 +19,19 @@
 use strict;
 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::NDR qw(ContainsString GetNextLevel);
 use Parse::Pidl::Dump qw(DumpTypedef DumpFunction);
 use Parse::Pidl::Ethereal::Conformance qw(ReadConformance);
 
 use vars qw($VERSION);
 $VERSION = '0.01';
 
+sub error($$)
+{
+	my ($e,$t) = @_;
+	print "$e->{FILE}:$e->{LINE}: $t\n";
+}
+
 my @ett;
 
 my %hf_used = ();
@@ -243,21 +249,26 @@
 		}
 		pidl_code "offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME})) . " ($e->{TYPE})\",$hf);";
 	} elsif ($l->{TYPE} eq "ARRAY") {
-		
 		if ($l->{IS_INLINE}) {
-			warn ("Inline arrays not supported");
-			pidl_code "/* FIXME: Handle inline array */";
+			error($e->{ORIGINAL}, "Inline arrays not supported");
 		} elsif ($l->{IS_FIXED}) {
 			pidl_code "int i;";
 			pidl_code "for (i = 0; i < $l->{SIZE_IS}; i++)";
 			pidl_code "\toffset = $myname\_(tvb, offset, pinfo, tree, drep);";
 		} else {
-			my $af = "";
-			($af = "ucarray") if ($l->{IS_CONFORMANT});
-			($af = "uvarray") if ($l->{IS_VARYING});
-			($af = "ucvarray") if ($l->{IS_CONFORMANT} and $l->{IS_VARYING});
+			my $type = "";
+			$type .= "c" if ($l->{IS_CONFORMANT});
+			$type .= "v" if ($l->{IS_VARYING});
 
-			pidl_code "offset = dissect_ndr_$af(tvb, offset, pinfo, tree, drep, $myname\_);";
+			unless ($l->{IS_ZERO_TERMINATED}) {
+				pidl_code "offset = dissect_ndr_u" . $type . "array(tvb, offset, pinfo, tree, drep, $myname\_);";
+			} else {
+				my $nl = GetNextLevel($e,$l);
+				pidl_code "char *data;";
+				pidl_code "";
+				pidl_code "offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, drep, sizeof(g$nl->{DATA_TYPE}), $hf, FALSE, &data);";
+				pidl_code "proto_item_append_text(tree, \": %s\", data);";
+			}
 		}
 	} elsif ($l->{TYPE} eq "DATA") {
 		if ($l->{DATA_TYPE} eq "string") {
@@ -332,6 +343,15 @@
 		};
 	}
 
+	if (ContainsString($e)) {
+		$type = {
+			MASK => 0,
+			VALSSTRING => "NULL",
+			FT_TYPE => "FT_STRING",
+			BASE_TYPE => "BASE_DEC"
+		};
+	}
+
 	my $hf = register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", field2name($e->{NAME}), "$ifname.$pn.$e->{NAME}", $type->{FT_TYPE}, $type->{BASE_TYPE}, $type->{VALSSTRING}, $type->{MASK}, "");
 	$hf_used{$hf} = 1;
 
@@ -357,6 +377,7 @@
 		deindent;
 		pidl_code "}\n";
 		$add.="_";
+		last if ($_->{TYPE} eq "ARRAY" and $_->{IS_ZERO_TERMINATED});
 	}
 
 	return $call_code;

Modified: branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm
===================================================================
--- branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm	2005-10-14 18:54:12 UTC (rev 11066)
+++ branches/SAMBA_4_0/source/pidl/lib/Parse/Pidl/NDR.pm	2005-10-14 19:57:41 UTC (rev 11067)
@@ -31,7 +31,7 @@
 use vars qw($VERSION);
 $VERSION = '0.01';
 @ISA = qw(Exporter);
- at EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred);
+ at EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
 
 use strict;
 use Parse::Pidl::Typelist qw(hasType getType);
@@ -654,6 +654,17 @@
 	return undef;
 }
 
+sub ContainsString($)
+{
+	my ($e) = @_;
+
+	foreach my $l (@{$e->{LEVELS}}) {
+		return 1 if ($l->{TYPE} eq "ARRAY" and $l->{IS_ZERO_TERMINATED});
+	}
+
+	return 0;
+}
+
 sub ContainsDeferred($$)
 {
 	my ($e,$l) = @_;



More information about the samba-cvs mailing list