summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-05 07:16:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:16 -0500
commitb613386a7f045ba3f29e6c41709fff6ca1394e48 (patch)
tree0f420a6a7d1f463b4e1b92389a90f319fe694c89 /source4
parent2d9d6c46897ab87c0a331900cade73e72c257ea9 (diff)
downloadsamba-b613386a7f045ba3f29e6c41709fff6ca1394e48.tar.gz
samba-b613386a7f045ba3f29e6c41709fff6ca1394e48.tar.bz2
samba-b613386a7f045ba3f29e6c41709fff6ca1394e48.zip
r9104: Finish ethereal parser generator. Still a couple of minor issues
remaining to get it to generate completely compilable code. (This used to be commit d8727b8de75be7e44bd889c9650d5d68d486a95a)
Diffstat (limited to 'source4')
-rw-r--r--source4/build/pidl/Parse/Pidl/Ethereal/NDR.pm42
-rwxr-xr-xsource4/build/pidl/pidl2
2 files changed, 30 insertions, 14 deletions
diff --git a/source4/build/pidl/Parse/Pidl/Ethereal/NDR.pm b/source4/build/pidl/Parse/Pidl/Ethereal/NDR.pm
index 18a6a4aa8e..4c9ac81d1e 100644
--- a/source4/build/pidl/Parse/Pidl/Ethereal/NDR.pm
+++ b/source4/build/pidl/Parse/Pidl/Ethereal/NDR.pm
@@ -6,7 +6,7 @@
# Portions based on idl2eth.c by Ronnie Sahlberg
# released under the GNU GPL
-package Parse::Pidl::Ethereal::NDR::Parser;
+package Parse::Pidl::Ethereal::NDR;
use strict;
use Parse::Pidl::Typelist;
@@ -20,6 +20,14 @@ my %ptrtype_mappings = (
"ptr" => "NDR_POINTER_PTR"
);
+my %dissectors = (
+ "uint16" => "dissect_ndr_uint16",
+ "uint8" => "dissect_ndr_uint8",
+ "uint32" => "dissect_ndr_uint32",
+ "time_t" => "dissect_ndr_time_t",
+ "GUID" => "dissect_ndr_uuid_t"
+);
+
sub type2ft($)
{
my($t) = shift;
@@ -29,9 +37,7 @@ sub type2ft($)
return "FT_UINT64", if $t eq "HYPER_T" or $t eq "NTTIME"
or $t eq "NTTIME_1sec" or $t eq "NTTIME_hyper" or $t eq "hyper";
- # Type is an enum
-
- return "FT_UINT16";
+ return "FT_NONE";
}
# Determine the display base for an element
@@ -144,7 +150,7 @@ sub Enum($$$)
pidl_code "return offset;";
pidl_code "}\n";
- register_type($name, $dissectorname, enum_ft($e), "BASE_DEC", "0", "VALS($valsstring)", enum_size($e));
+ register_hf_field($name, $dissectorname, enum_ft($e), "BASE_DEC", "0", "VALS($valsstring)", enum_size($e));
}
sub Bitmap($$$)
@@ -215,7 +221,13 @@ sub ElementLevel($$$$)
my ($e,$l,$hf,$myname) = @_;
if ($l->{TYPE} eq "POINTER") {
- pidl_code "offset=dissect_ndr_pointer(tvb,offset,pinfo,tree,drep,$myname\_,$ptrtype_mappings{$l->{POINTER_TYPE}},\"\",$hf);";
+ my $type;
+ if ($l->{LEVEL} eq "TOP") {
+ $type = "toplevel";
+ } elsif ($l->{LEVEL} eq "EMBEDDED") {
+ $type = "embedded";
+ }
+ pidl_code "offset=dissect_ndr_$type\_pointer(tvb,offset,pinfo,tree,drep,$myname\_,$ptrtype_mappings{$l->{POINTER_TYPE}},\"\",$hf);";
} elsif ($l->{TYPE} eq "ARRAY") {
my $af = "";
@@ -225,8 +237,9 @@ sub ElementLevel($$$$)
pidl_code "offset=dissect_ndr_$af(tvb,offset,pinfo,tree,drep,$myname\_);";
} elsif ($l->{TYPE} eq "DATA") {
-# pidl_code "guint32 param=" . FindDissectorParam($dissectorname).";";
-# pidl_code "offset=$type->{DISSECTOR}(tvb, offset, pinfo, tree, drep, $hf, param);";
+ pidl_code "guint32 param=" . FindDissectorParam($myname).";";
+ defined($dissectors{$l->{DATA_TYPE}}) or warn("Unknown data type $l->{DATA_TYPE}");
+ pidl_code "offset=".$dissectors{$l->{DATA_TYPE}}."(tvb, offset, pinfo, tree, drep, $hf, param);";
} elsif ($_->{TYPE} eq "SUBCONTEXT") {
die("subcontext() not supported")
}
@@ -240,8 +253,7 @@ sub Element($$$)
return if (EmitProhibited($dissectorname));
- my $hf = "";
- #FIXME my $hf = register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", $e->{NAME}, "$ifname.$pn.$e->{NAME}", $type->{FT_TYPE}, $type->{BASE_TYPE}, $type->{VALS}, $type->{MASK}, "");
+ my $hf = register_hf_field("hf_$ifname\_$pn\_$e->{NAME}", $e->{NAME}, "$ifname.$pn.$e->{NAME}", type2ft($e->{TYPE}), "BASE_HEX", "NULL", 0, "");
my $add = "";
foreach (@{$e->{LEVELS}}) {
@@ -312,7 +324,7 @@ sub Struct($$$)
register_ett("ett_$ifname\_$name");
my $res = "";
- ($res.=Element($_, $name, $ifname)."\n") foreach (@{$e->{ELEMENTS}});
+ ($res.="\t".Element($_, $name, $ifname)."\n") foreach (@{$e->{ELEMENTS}});
pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_);";
@@ -337,7 +349,7 @@ sub Struct($$$)
deindent;
pidl_code "}";
- pidl_code "$res";
+ pidl_code "\n$res";
pidl_code "";
@@ -351,7 +363,7 @@ sub Union($$$)
{
my ($e,$name,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect_union_$name";
+ my $dissectorname = "$ifname\_dissect_$name";
register_ett("ett_$ifname\_$name");
@@ -466,6 +478,10 @@ sub ProcessInterface($)
{
my $x = shift;
+ foreach (@{$x->{TYPEDEFS}}) {
+ $dissectors{$_->{NAME}} = "$x->{NAME}_dissect_$_->{NAME}";
+ }
+
if (defined($x->{UUID})) {
my $if_uuid = $x->{UUID};
diff --git a/source4/build/pidl/pidl b/source4/build/pidl/pidl
index c24a0a0007..eb5e635b7f 100755
--- a/source4/build/pidl/pidl
+++ b/source4/build/pidl/pidl
@@ -319,7 +319,7 @@ $dcom
my $eheader = $eparser;
$eheader =~ s/\.c$/\.h/;
- my ($dp, $dh) = Parse::Pidl::Ethereal::NDR::Parser::Parse($ndr, $basename, $eparser);
+ my ($dp, $dh) = Parse::Pidl::Ethereal::NDR::Parse($ndr, $eheader, $eparser);
FileSave($eparser, $dp);
FileSave($eheader, $dh);
}