aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pidl
diff options
context:
space:
mode:
authorJörg Mayer <jmayer@loplof.de>2006-07-04 18:23:36 +0000
committerJörg Mayer <jmayer@loplof.de>2006-07-04 18:23:36 +0000
commita9924ae949751c93c119e509144ca2b6601a2a24 (patch)
tree28b694f76164c97b1a60601268805505db87adfe /tools/pidl
parentb1215a0a85a000ef7456f7f7cc8783ac1eaa1c8a (diff)
Update to current samba branch (sorry, lost the samba changelog)
while maintaining the Ethereal -> Wireshark changes. svn path=/trunk/; revision=18655
Diffstat (limited to 'tools/pidl')
-rw-r--r--tools/pidl/MANIFEST8
-rw-r--r--tools/pidl/README2
-rw-r--r--tools/pidl/TODO10
-rw-r--r--tools/pidl/lib/Parse/Pidl/Dump.pm11
-rw-r--r--tools/pidl/lib/Parse/Pidl/NDR.pm32
-rw-r--r--tools/pidl/lib/Parse/Pidl/Samba3/Parser.pm2
-rw-r--r--tools/pidl/lib/Parse/Pidl/Samba4/Header.pm6
-rw-r--r--tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm73
-rw-r--r--tools/pidl/lib/Parse/Pidl/Typelist.pm66
-rw-r--r--tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm25
-rw-r--r--tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm39
-rwxr-xr-xtools/pidl/pidl14
12 files changed, 184 insertions, 104 deletions
diff --git a/tools/pidl/MANIFEST b/tools/pidl/MANIFEST
index 8dc1096cbb..0a4df7ba89 100644
--- a/tools/pidl/MANIFEST
+++ b/tools/pidl/MANIFEST
@@ -7,6 +7,13 @@ tests/ndr_simple.pl
tests/ndr_align.pl
tests/ndr_alloc.pl
tests/ndr_array.pl
+lib/Parse/Pidl/Samba3/Client.pm
+lib/Parse/Pidl/Samba3/ClientNDR.pm
+lib/Parse/Pidl/Samba3/Header.pm
+lib/Parse/Pidl/Samba3/Parser.pm
+lib/Parse/Pidl/Samba3/Server.pm
+lib/Parse/Pidl/Samba3/Template.pm
+lib/Parse/Pidl/Samba3/Types.pm
lib/Parse/Pidl/Samba4/NDR/Server.pm
lib/Parse/Pidl/Samba4/NDR/Parser.pm
lib/Parse/Pidl/Samba4/NDR/Client.pm
@@ -18,6 +25,7 @@ lib/Parse/Pidl/Samba4/SWIG.pm
lib/Parse/Pidl/Samba4/TDR.pm
lib/Parse/Pidl/Samba4/Template.pm
lib/Parse/Pidl/Samba4/EJS.pm
+lib/Parse/Pidl/Samba4.pm
lib/Parse/Pidl/Wireshark/Conformance.pm
lib/Parse/Pidl/Wireshark/NDR.pm
lib/Parse/Pidl/Typelist.pm
diff --git a/tools/pidl/README b/tools/pidl/README
index 17d91c54c5..f29e274192 100644
--- a/tools/pidl/README
+++ b/tools/pidl/README
@@ -47,7 +47,7 @@ Parse::Pidl::Samba4::COM::Stub - Generates stub call handler for DCOM (server-si
Parse::Pidl::Samba4::COM::Header - Generates headers for COM
-- Wireshark --
-Parse::Pidl::Wireshark::NDR - Generates a parser for the wireshark network sniffer
+Parse::Pidl::Wireshark::NDR - Generates a parser for the Wireshark network sniffer
Parse::Pidl::Wireshark::Conformance - Reads conformance files containing additional data for generating Wireshark parsers
-- Utility modules --
diff --git a/tools/pidl/TODO b/tools/pidl/TODO
index 3098a44a8f..bfbf5afc54 100644
--- a/tools/pidl/TODO
+++ b/tools/pidl/TODO
@@ -3,18 +3,16 @@
- compatibility mode for generating MIDL-readable data:
- strip out pidl-specific properties
-- don't be so strict on array boundaries.. arrays can and will be empty when
- a (regular) remote error occurs
-
- support nested elements
- generate names for anonymous tagged types
+ - support typedefs properly
-- auto-alloc [ref] pointers for Samba4 during pull if they were NULL
-
-- improve represent_as()
+- improve represent_as(): allow it to be used for arrays and other complex types
- --explain-ndr option that dumps out parse tree ?
- seperate tables for NDR and DCE/RPC
- allow data structures outside of interfaces
+
+- mem_ctx in the interface rather than as struct ndr member.
diff --git a/tools/pidl/lib/Parse/Pidl/Dump.pm b/tools/pidl/lib/Parse/Pidl/Dump.pm
index 3a1cec1b59..88f18de322 100644
--- a/tools/pidl/lib/Parse/Pidl/Dump.pm
+++ b/tools/pidl/lib/Parse/Pidl/Dump.pm
@@ -36,7 +36,7 @@ my($res);
sub DumpProperties($)
{
my($props) = shift;
- my($res);
+ my $res = "";
foreach my $d ($props) {
foreach my $k (keys %{$d}) {
@@ -63,7 +63,7 @@ sub DumpProperties($)
sub DumpElement($)
{
my($element) = shift;
- my($res);
+ my $res = "";
(defined $element->{PROPERTIES}) &&
($res .= DumpProperties($element->{PROPERTIES}));
@@ -89,10 +89,9 @@ sub DumpStruct($)
$res .= "struct {\n";
if (defined $struct->{ELEMENTS}) {
- foreach my $e (@{$struct->{ELEMENTS}}) {
- $res .= "\t" . DumpElement($e);
- $res .= ";\n";
- }
+ foreach (@{$struct->{ELEMENTS}}) {
+ $res .= "\t" . DumpElement($_) . ";\n";
+ }
}
$res .= "}";
diff --git a/tools/pidl/lib/Parse/Pidl/NDR.pm b/tools/pidl/lib/Parse/Pidl/NDR.pm
index 3cbf416488..21875a1297 100644
--- a/tools/pidl/lib/Parse/Pidl/NDR.pm
+++ b/tools/pidl/lib/Parse/Pidl/NDR.pm
@@ -37,7 +37,7 @@ $VERSION = '0.01';
@EXPORT = qw(GetPrevLevel GetNextLevel ContainsDeferred ContainsString);
use strict;
-use Parse::Pidl::Typelist qw(hasType getType);
+use Parse::Pidl::Typelist qw(hasType getType expandAlias);
use Parse::Pidl::Util qw(has_property property_matches);
# Alignment of the built-in scalar types
@@ -364,6 +364,8 @@ sub ParseElement($)
{
my $e = shift;
+ $e->{TYPE} = expandAlias($e->{TYPE});
+
return {
NAME => $e->{NAME},
TYPE => $e->{TYPE},
@@ -549,7 +551,7 @@ sub ParseFunction($$$)
}
if ($d->{RETURN_TYPE} ne "void") {
- $rettype = $d->{RETURN_TYPE};
+ $rettype = expandAlias($d->{RETURN_TYPE});
}
my $async = 0;
@@ -569,8 +571,7 @@ sub ParseFunction($$$)
sub CheckPointerTypes($$)
{
- my $s = shift;
- my $default = shift;
+ my ($s,$default) = @_;
foreach my $e (@{$s->{ELEMENTS}}) {
if ($e->{POINTERS} and not defined(pointer_type($e))) {
@@ -579,6 +580,23 @@ sub CheckPointerTypes($$)
}
}
+#FIXME: Remove when ref handling in Samba4 is fixed
+sub AddKeepRef($)
+{
+ my $d = shift;
+
+ if ($d->{TYPE} eq "FUNCTION") {
+ foreach (@{$d->{ELEMENTS}}) {
+ $_->{PROPERTIES}->{keepref} = 1;
+ }
+ } elsif ($d->{TYPE} eq "TYPEDEF" and ($d->{DATA}->{TYPE} eq "STRUCT"
+ or $d->{DATA}->{TYPE} eq "UNION")) {
+ foreach (@{$d->{DATA}->{ELEMENTS}}) {
+ $_->{PROPERTIES}->{keepref} = 1;
+ }
+ }
+}
+
sub ParseInterface($)
{
my $idl = shift;
@@ -604,10 +622,12 @@ sub ParseInterface($)
if ($d->{TYPE} eq "DECLARE") {
push (@declares, $d);
} elsif ($d->{TYPE} eq "FUNCTION") {
+ AddKeepRef($d) if (has_property($idl, "keepref"));
push (@functions, ParseFunction($idl, $d, \$opnum));
} elsif ($d->{TYPE} eq "CONST") {
push (@consts, ParseConst($idl, $d));
} else {
+ AddKeepRef($d) if (has_property($idl, "keepref"));
push (@types, ParseType($idl, $d));
}
}
@@ -829,6 +849,10 @@ my %property_list = (
"noheader" => ["ELEMENT"],
"charset" => ["ELEMENT"],
"length_is" => ["ELEMENT"],
+
+ # temporary (should be removed once we've migrated away from
+ # relying on ref pointers being there in Samba4's code)
+ "keepref" => ["ELEMENT","INTERFACE"],
);
#####################################################################
diff --git a/tools/pidl/lib/Parse/Pidl/Samba3/Parser.pm b/tools/pidl/lib/Parse/Pidl/Samba3/Parser.pm
index a6b4b38cdf..57fa3867f7 100644
--- a/tools/pidl/lib/Parse/Pidl/Samba3/Parser.pm
+++ b/tools/pidl/lib/Parse/Pidl/Samba3/Parser.pm
@@ -35,7 +35,7 @@ sub Align($$)
{
my ($a,$b) = @_;
- # Only align if previous element was smaller then current one
+ # Only align if previous element was smaller than current one
if ($$a < $b) {
pidl "if (!prs_align_custom(ps, $b))";
pidl "\treturn False;";
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/Header.pm b/tools/pidl/lib/Parse/Pidl/Samba4/Header.pm
index 6fb3ee2eec..c9487115f5 100644
--- a/tools/pidl/lib/Parse/Pidl/Samba4/Header.pm
+++ b/tools/pidl/lib/Parse/Pidl/Samba4/Header.pm
@@ -60,7 +60,11 @@ sub HeaderElement($)
} else {
HeaderType($element, $element->{TYPE}, "");
pidl " ";
- my $numstar = $element->{POINTERS};
+ my $numstar = 0;
+ if (!has_property($element, "ref") or
+ has_property($element, "keepref")) {
+ $numstar += $element->{POINTERS};
+ }
if ($numstar >= 1) {
$numstar-- if Parse::Pidl::Typelist::scalar_is_reference($element->{TYPE});
}
diff --git a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index b7ae526e68..912c4b74f9 100644
--- a/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/tools/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -103,7 +103,7 @@ sub get_value_of($)
}
my $res;
-my $deferred = "";
+my $deferred = [];
my $tabs = "";
####################################
@@ -128,14 +128,16 @@ sub pidl_hdr ($) { my $d = shift; $res_hdr .= "$d\n"; }
# output buffer at the end of the structure/union/function
# This is needed to cope with code that must be pushed back
# to the end of a block of elements
+my $defer_tabs = "";
+sub defer_indent() { $defer_tabs.="\t"; }
+sub defer_deindent() { $defer_tabs=substr($defer_tabs, 0, -1); }
+
sub defer($)
{
my $d = shift;
if ($d) {
- $deferred .= $tabs;
- $deferred .= $d;
+ push(@$deferred, $defer_tabs.$d);
}
- $deferred .="\n";
}
########################################
@@ -143,8 +145,9 @@ sub defer($)
# output
sub add_deferred()
{
- $res .= $deferred;
- $deferred = "";
+ pidl $_ foreach (@$deferred);
+ $deferred = [];
+ $defer_tabs = "";
}
sub indent()
@@ -370,16 +373,20 @@ sub ParseArrayPullHeader($$$$$)
if ($l->{IS_CONFORMANT} and not $l->{IS_ZERO_TERMINATED}) {
my $size = ParseExpr($l->{SIZE_IS}, $env);
defer "if ($var_name) {";
+ defer_indent;
check_null_pointer_deferred($size);
defer "NDR_CHECK(ndr_check_array_size(ndr, (void*)" . get_pointer_to($var_name) . ", $size));";
+ defer_deindent;
defer "}";
}
if ($l->{IS_VARYING} and not $l->{IS_ZERO_TERMINATED}) {
my $length = ParseExpr($l->{LENGTH_IS}, $env);
defer "if ($var_name) {";
+ defer_indent;
check_null_pointer_deferred($length);
defer "NDR_CHECK(ndr_check_array_length(ndr, (void*)" . get_pointer_to($var_name) . ", $length));";
+ defer_deindent;
defer "}"
}
@@ -582,7 +589,9 @@ sub ParseElementPushLevel
pidl "NDR_CHECK(ndr_push_relative_ptr2(ndr, $var_name));";
}
}
- $var_name = get_value_of($var_name);
+ if ($l->{POINTER_TYPE} ne "ref" or has_property($e, "keepref")) {
+ $var_name = get_value_of($var_name);
+ }
ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 1);
if ($l->{POINTER_TYPE} ne "ref") {
@@ -662,11 +671,12 @@ sub ParsePtrPush($$$)
my ($e,$l,$var_name) = @_;
if ($l->{POINTER_TYPE} eq "ref") {
- if ($l->{LEVEL} eq "EMBEDDED") {
- pidl "NDR_CHECK(ndr_push_ref_ptr(ndr, $var_name));";
- } else {
+ if (has_property($e, "keepref")) {
check_null_pointer(get_value_of($var_name));
}
+ if ($l->{LEVEL} eq "EMBEDDED") {
+ pidl "NDR_CHECK(ndr_push_ref_ptr(ndr));";
+ }
} elsif ($l->{POINTER_TYPE} eq "relative") {
pidl "NDR_CHECK(ndr_push_relative_ptr1(ndr, $var_name));";
} elsif ($l->{POINTER_TYPE} eq "unique") {
@@ -699,13 +709,15 @@ sub ParseElementPrint($$$)
foreach my $l (@{$e->{LEVELS}}) {
if ($l->{TYPE} eq "POINTER") {
+ if ($l->{POINTER_TYPE} ne "ref" or has_property($e, "keepref")) {
pidl "ndr_print_ptr(ndr, \"$e->{NAME}\", $var_name);";
pidl "ndr->depth++;";
- if ($l->{POINTER_TYPE} ne "ref") {
- pidl "if ($var_name) {";
- indent;
+ if ($l->{POINTER_TYPE} ne "ref") {
+ pidl "if ($var_name) {";
+ indent;
+ }
+ $var_name = get_value_of($var_name);
}
- $var_name = get_value_of($var_name);
} elsif ($l->{TYPE} eq "ARRAY") {
my $length;
@@ -754,11 +766,13 @@ sub ParseElementPrint($$$)
foreach my $l (reverse @{$e->{LEVELS}}) {
if ($l->{TYPE} eq "POINTER") {
- if ($l->{POINTER_TYPE} ne "ref") {
- deindent;
- pidl "}";
+ if ($l->{POINTER_TYPE} ne "ref" or has_property($e, "keepref")) {
+ if ($l->{POINTER_TYPE} ne "ref") {
+ deindent;
+ pidl "}";
+ }
+ pidl "ndr->depth--;";
}
- pidl "ndr->depth--;";
} elsif (($l->{TYPE} eq "ARRAY")
and not is_charset_array($e,$l)
and not has_fast_array($e,$l)) {
@@ -822,7 +836,7 @@ sub ParseDataPush($$$$$)
{
my ($e,$l,$ndr,$var_name,$ndr_flags) = @_;
- # strings are passed by value rather then reference
+ # strings are passed by value rather than reference
if (not Parse::Pidl::Typelist::is_scalar($l->{DATA_TYPE}) or Parse::Pidl::Typelist::scalar_is_reference($l->{DATA_TYPE})) {
$var_name = get_pointer_to($var_name);
}
@@ -872,7 +886,7 @@ sub ParseMemCtxPullStart($$$)
my $next_is_array = ($nl->{TYPE} eq "ARRAY");
my $next_is_string = (($nl->{TYPE} eq "DATA") and
($nl->{DATA_TYPE} eq "string"));
- if ($next_is_array or $next_is_string) {
+ if ($next_is_array or $next_is_string or not has_property($e, "keepref")) {
return;
} else {
$mem_c_flags = "LIBNDR_FLAG_REF_ALLOC";
@@ -898,7 +912,7 @@ sub ParseMemCtxPullEnd($$)
my $next_is_array = ($nl->{TYPE} eq "ARRAY");
my $next_is_string = (($nl->{TYPE} eq "DATA") and
($nl->{DATA_TYPE} eq "string"));
- if ($next_is_array or $next_is_string) {
+ if ($next_is_array or $next_is_string or not has_property($e, "keepref")) {
return;
} else {
$mem_r_flags = "LIBNDR_FLAG_REF_ALLOC";
@@ -975,7 +989,9 @@ sub ParseElementPullLevel
ParseMemCtxPullStart($e,$l, $var_name);
- $var_name = get_value_of($var_name);
+ if ($l->{POINTER_TYPE} ne "ref" or has_property($e, "keepref")) {
+ $var_name = get_value_of($var_name);
+ }
ParseElementPullLevel($e,GetNextLevel($e,$l), $ndr, $var_name, $env, 1, 1);
ParseMemCtxPullEnd($e,$l);
@@ -1075,11 +1091,12 @@ sub ParsePtrPull($$$$)
($nl->{DATA_TYPE} eq "string"));
if ($l->{POINTER_TYPE} eq "ref") {
- unless ($l->{LEVEL} eq "TOP") {
+ if ($l->{LEVEL} eq "EMBEDDED") {
pidl "NDR_CHECK(ndr_pull_ref_ptr($ndr, &_ptr_$e->{NAME}));";
}
- unless ($next_is_array or $next_is_string) {
+ if (!$next_is_array and !$next_is_string and
+ has_property($e, "keepref")) {
pidl "if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {";
pidl "\tNDR_PULL_ALLOC($ndr, $var_name);";
pidl "}";
@@ -1413,8 +1430,7 @@ sub DeclareArrayVariables($)
sub need_decl_mem_ctx($$)
{
- my $e = shift;
- my $l = shift;
+ my ($e,$l) = @_;
return 0 if has_fast_array($e,$l);
return 0 if is_charset_array($e,$l);
@@ -1425,7 +1441,7 @@ sub need_decl_mem_ctx($$)
my $next_is_array = ($nl->{TYPE} eq "ARRAY");
my $next_is_string = (($nl->{TYPE} eq "DATA") and
($nl->{DATA_TYPE} eq "string"));
- return 0 if ($next_is_array or $next_is_string);
+ return 0 if ($next_is_array or $next_is_string or not has_property($e, "keepref"));
}
return 1 if ($l->{TYPE} eq "POINTER");
@@ -2085,12 +2101,13 @@ sub ParseFunctionPull($)
}
# allocate the "simple" out ref variables. FIXME: Shouldn't this have it's
- # own flag rather then be in NDR_IN ?
+ # own flag rather than be in NDR_IN ?
foreach my $e (@{$fn->{ELEMENTS}}) {
next unless (grep(/out/, @{$e->{DIRECTION}}));
next unless ($e->{LEVELS}[0]->{TYPE} eq "POINTER" and
$e->{LEVELS}[0]->{POINTER_TYPE} eq "ref");
+ next unless has_property($e, "keepref");
next if (($e->{LEVELS}[1]->{TYPE} eq "DATA") and
($e->{LEVELS}[1]->{DATA_TYPE} eq "string"));
next if (($e->{LEVELS}[1]->{TYPE} eq "ARRAY")
diff --git a/tools/pidl/lib/Parse/Pidl/Typelist.pm b/tools/pidl/lib/Parse/Pidl/Typelist.pm
index ff8f18ee48..66d5e59e7c 100644
--- a/tools/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/tools/pidl/lib/Parse/Pidl/Typelist.pm
@@ -7,7 +7,7 @@ package Parse::Pidl::Typelist;
require Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(hasType getType mapType scalar_is_reference);
+@EXPORT_OK = qw(hasType getType mapType scalar_is_reference expandAlias);
use vars qw($VERSION);
$VERSION = '0.01';
@@ -23,55 +23,57 @@ my @reference_scalars = (
# a list of known scalar types
my %scalars = (
- # 0 byte types
"void" => "void",
-
- # 1 byte types
"char" => "char",
"int8" => "int8_t",
"uint8" => "uint8_t",
-
- # 2 byte types
"int16" => "int16_t",
"uint16" => "uint16_t",
-
- # 4 byte types
"int32" => "int32_t",
"uint32" => "uint32_t",
-
- # 8 byte types
"hyper" => "uint64_t",
"dlong" => "int64_t",
"udlong" => "uint64_t",
"udlongr" => "uint64_t",
-
- # assume its a 8 byte type, but cope with either
"pointer" => "void*",
-
- # DATA_BLOB types
"DATA_BLOB" => "DATA_BLOB",
-
- # string types
"string" => "const char *",
"string_array" => "const char **",
-
- # time types
"time_t" => "time_t",
"NTTIME" => "NTTIME",
"NTTIME_1sec" => "NTTIME",
"NTTIME_hyper" => "NTTIME",
-
- # error code types
"WERROR" => "WERROR",
"NTSTATUS" => "NTSTATUS",
"COMRESULT" => "COMRESULT",
-
- # special types
"nbt_string" => "const char *",
"wrepl_nbt_name"=> "struct nbt_name *",
"ipv4address" => "const char *",
);
+my %aliases = (
+ "error_status_t" => "uint32",
+ "boolean8" => "uint8",
+ "boolean32" => "uint32",
+ "DWORD" => "uint32",
+ "int" => "int32",
+ "WORD" => "uint16",
+ "char" => "uint8",
+ "long" => "int32",
+ "short" => "int16",
+ "HYPER_T" => "hyper",
+ "HRESULT" => "COMRESULT",
+);
+
+sub expandAlias($)
+{
+ my $name = shift;
+
+ return $aliases{$name} if defined($aliases{$name});
+
+ return $name;
+}
+
# map from a IDL type to a C header type
sub mapScalarType($)
{
@@ -148,24 +150,6 @@ sub RegisterScalars()
}
}
-my %aliases = (
- "DWORD" => "uint32",
- "int" => "int32",
- "WORD" => "uint16",
- "char" => "uint8",
- "long" => "int32",
- "short" => "int16",
- "HYPER_T" => "hyper",
- "HRESULT" => "COMRESULT",
-);
-
-sub RegisterAliases()
-{
- foreach (keys %aliases) {
- $typedefs{$_} = $typedefs{$aliases{$_}};
- }
-}
-
sub enum_type_fn($)
{
my $enum = shift;
@@ -196,6 +180,7 @@ sub mapType($)
my $t = shift;
return "void" unless defined($t);
my $dt;
+ $t = expandAlias($t);
unless ($dt or ($dt = getType($t))) {
# Best guess
@@ -237,6 +222,5 @@ sub LoadIdl($)
}
RegisterScalars();
-RegisterAliases();
1;
diff --git a/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
index e7a93eb0d8..93927f8f54 100644
--- a/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
+++ b/tools/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
@@ -1,5 +1,5 @@
###################################################
-# parse an wireshark conformance file
+# parse an Wireshark conformance file
# Copyright jelmer@samba.org 2005
# released under the GNU GPL
@@ -15,7 +15,7 @@ This module supports parsing Wireshark conformance files (*.cnf).
=head1 FILE FORMAT
-Pidl needs additional data for wireshark output. This data is read from
+Pidl needs additional data for Wireshark output. This data is read from
so-called conformance files. This section describes the format of these
files.
@@ -49,7 +49,7 @@ Generate a custom header field with specified properties.
Force the use of new_hf_name when the parser generator was going to
use old_hf_name.
-This can be used in conjunction with HF_FIELD in order to make more then
+This can be used in conjunction with HF_FIELD in order to make more than
one element use the same filter name.
=item I<STRIP_PREFIX> prefix
@@ -74,6 +74,13 @@ Code to insert when generating the specified dissector. @HF@ and
Override the text shown when a bitmap boolean value is enabled or disabled.
+=item I<MANUAL> fn_name
+
+Force pidl to not generate a particular function but allow the user
+to write a function manually. This can be used to remove the function
+for only one level for a particular element rather than all the functions and
+ett/hf variables for a particular element as the NOEMIT command does.
+
=back
=head1 EXAMPLE
@@ -232,9 +239,7 @@ sub handle_strip_prefix($$$)
sub handle_noemit($$$)
{
- my $pos = shift;
- my $data = shift;
- my $type = shift;
+ my ($pos,$data,$type) = @_;
if (defined($type)) {
$data->{noemit}->{$type} = 1;
@@ -243,6 +248,13 @@ sub handle_noemit($$$)
}
}
+sub handle_manual($$$)
+{
+ my ($pos,$data,$fn) = @_;
+
+ $data->{manual}->{$fn} = 1;
+}
+
sub handle_protocol($$$$$$)
{
my ($pos, $data, $name, $longname, $shortname, $filtername) = @_;
@@ -287,6 +299,7 @@ sub handle_import
my %field_handlers = (
TYPE => \&handle_type,
NOEMIT => \&handle_noemit,
+ MANUAL => \&handle_manual,
PARAM_VALUE => \&handle_param_value,
HF_FIELD => \&handle_hf_field,
HF_RENAME => \&handle_hf_rename,
diff --git a/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index f42d73a832..872a149274 100644
--- a/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/tools/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -3,7 +3,7 @@
# Copyright tridge@samba.org 2000-2003
# Copyright tpot@samba.org 2001,2005
# Copyright jelmer@samba.org 2004-2005
-# Portions based on idl2wrs.c by Ronnie Sahlberg
+# Portions based on idl2eth.c by Ronnie Sahlberg
# released under the GNU GPL
=pod
@@ -72,9 +72,24 @@ sub field2name($)
my %res = ();
my $tabs = "";
+my $cur_fn = undef;
+sub pidl_fn_start($)
+{
+ my $fn = shift;
+ $cur_fn = $fn;
+}
+sub pidl_fn_end($)
+{
+ my $fn = shift;
+ die("Inconsistent state: $fn != $cur_fn") if ($fn ne $cur_fn);
+ $cur_fn = undef;
+}
+
sub pidl_code($)
{
my $d = shift;
+ return if (defined($cur_fn) and defined($conformance->{manual}->{$cur_fn}));
+
if ($d) {
$res{code} .= $tabs;
$res{code} .= $d;
@@ -124,7 +139,7 @@ sub Enum($$$)
return if (defined($conformance->{noemit}->{StripPrefixes($name)}));
- foreach (@{$e->{ELEMENTS}}) {
+ foreach (@{$e->{ELEMENTS}}) {
if (/([^=]*)=(.*)/) {
pidl_hdr "#define $1 ($2)";
}
@@ -142,6 +157,7 @@ sub Enum($$$)
pidl_def "{ 0, NULL }";
pidl_def "};";
+ pidl_fn_start $dissectorname;
pidl_code "int";
pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param _U_)";
pidl_code "{";
@@ -150,6 +166,7 @@ sub Enum($$$)
pidl_code "return offset;";
deindent;
pidl_code "}\n";
+ pidl_fn_end $dissectorname;
my $enum_size = $e->{BASE_TYPE};
$enum_size =~ s/uint//g;
@@ -165,6 +182,7 @@ sub Bitmap($$$)
pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep, int hf_index, guint32 param);";
+ pidl_fn_start $dissectorname;
pidl_code "int";
pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_)";
pidl_code "{";
@@ -230,6 +248,7 @@ sub Bitmap($$$)
pidl_code "return offset;";
deindent;
pidl_code "}\n";
+ pidl_fn_end $dissectorname;
my $size = $e->{BASE_TYPE};
$size =~ s/uint//g;
@@ -376,6 +395,7 @@ sub Element($$$)
foreach (@{$e->{LEVELS}}) {
next if ($_->{TYPE} eq "SWITCH");
pidl_def "static int $dissectorname$add(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep);";
+ pidl_fn_start "$dissectorname$add";
pidl_code "static int";
pidl_code "$dissectorname$add(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep)";
pidl_code "{";
@@ -387,6 +407,7 @@ sub Element($$$)
pidl_code "return offset;";
deindent;
pidl_code "}\n";
+ pidl_fn_end "$dissectorname$add";
$add.="_";
last if ($_->{TYPE} eq "ARRAY" and $_->{IS_ZERO_TERMINATED});
}
@@ -408,6 +429,7 @@ sub Function($$$)
$fn_name =~ s/^${ifname}_//;
PrintIdl DumpFunction($fn->{ORIGINAL});
+ pidl_fn_start "$ifname\_dissect\_$fn_name\_response";
pidl_code "static int";
pidl_code "$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)";
pidl_code "{";
@@ -441,7 +463,9 @@ sub Function($$$)
pidl_code "return offset;";
deindent;
pidl_code "}\n";
+ pidl_fn_end "$ifname\_dissect\_$fn_name\_response";
+ pidl_fn_start "$ifname\_dissect\_$fn_name\_request";
pidl_code "static int";
pidl_code "$ifname\_dissect\_${fn_name}_request(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_)";
pidl_code "{";
@@ -457,6 +481,7 @@ sub Function($$$)
pidl_code "return offset;";
deindent;
pidl_code "}\n";
+ pidl_fn_end "$ifname\_dissect\_$fn_name\_request";
}
sub Struct($$$)
@@ -473,6 +498,7 @@ sub Struct($$$)
pidl_hdr "int $dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_);";
+ pidl_fn_start $dissectorname;
pidl_code "int";
pidl_code "$dissectorname(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *parent_tree, guint8 *drep, int hf_index, guint32 param _U_)";
pidl_code "{";
@@ -502,6 +528,7 @@ sub Struct($$$)
pidl_code "return offset;";
deindent;
pidl_code "}\n";
+ pidl_fn_end $dissectorname;
register_type($name, "offset = $dissectorname(tvb,offset,pinfo,tree,drep,\@HF\@,\@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
}
@@ -536,6 +563,7 @@ sub Union($$$)
$switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
}
+ pidl_fn_start $dissectorname;
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_)";
pidl_code "{";
@@ -569,6 +597,7 @@ sub Union($$$)
pidl_code "return offset;";
deindent;
pidl_code "}";
+ pidl_fn_end $dissectorname;
register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
}
@@ -602,6 +631,7 @@ sub RegisterInterface($)
{
my ($x) = @_;
+ pidl_fn_start "proto_register_dcerpc_$x->{NAME}";
pidl_code "void proto_register_dcerpc_$x->{NAME}(void)";
pidl_code "{";
indent;
@@ -639,6 +669,7 @@ sub RegisterInterface($)
deindent;
pidl_code "}\n";
+ pidl_fn_end "proto_register_dcerpc_$x->{NAME}";
}
sub RegisterInterfaceHandoff($)
@@ -646,6 +677,7 @@ sub RegisterInterfaceHandoff($)
my $x = shift;
if (defined($x->{UUID})) {
+ pidl_fn_start "proto_reg_handoff_dcerpc_$x->{NAME}";
pidl_code "void proto_reg_handoff_dcerpc_$x->{NAME}(void)";
pidl_code "{";
indent;
@@ -654,6 +686,7 @@ sub RegisterInterfaceHandoff($)
pidl_code "\t$x->{NAME}_dissectors, hf_$x->{NAME}_opnum);";
deindent;
pidl_code "}";
+ pidl_fn_end "proto_reg_handoff_dcerpc_$x->{NAME}";
$hf_used{"hf_$x->{NAME}_opnum"} = 1;
}
@@ -789,7 +822,7 @@ sub Initialize($)
}
#####################################################################
-# Generate wireshark parser and header code
+# Generate Wireshark parser and header code
sub Parse($$$$)
{
my($ndr,$idl_file,$h_filename,$cnf_file) = @_;
diff --git a/tools/pidl/pidl b/tools/pidl/pidl
index f702c31086..4d23060f6e 100755
--- a/tools/pidl/pidl
+++ b/tools/pidl/pidl
@@ -26,13 +26,13 @@ compatible with the midl compiler. IDL is short for
"Interface Definition Language".
pidl can generate stubs for DCE/RPC server code, DCE/RPC
-client code and wireshark dissectors for DCE/RPC traffic.
+client code and Wireshark dissectors for DCE/RPC traffic.
IDL compilers like pidl take a description
of an interface as their input and use it to generate C
(though support for other languages may be added later) code that
can use these interfaces, pretty print data sent
-using these interfaces, or even generate wireshark
+using these interfaces, or even generate Wireshark
dissectors that can parse data sent over the
wire by these interfaces.
@@ -61,7 +61,7 @@ directory.
=item I<--parse-idl-tree>
Read internal tree structure from input files rather
-then assuming they contain IDL.
+than assuming they contain IDL.
=item I<--dump-idl>
@@ -99,9 +99,9 @@ Generate an Wireshark dissector (in C) and header file. The dissector filename
defaults to packet-dcerpc-OUTNAME.c while the header filename defaults to
packet-dcerpc-OUTNAME.h.
-Pidl will read additional data from an wireshark conformance file if present.
+Pidl will read additional data from an Wireshark conformance file if present.
Such a file should have the same location as the IDL file but with the
-extension I<cnf> rather then I<idl>. See L<Parse::Pidl::Wireshark::Conformance>
+extension I<cnf> rather than I<idl>. See L<Parse::Pidl::Wireshark::Conformance>
for details on the format of this file.
=item I<--diff>
@@ -369,7 +369,7 @@ usesgetlasterror, vararg, vi_progid, wire_marshal.
=head1 EXAMPLES
- # Generating an wireshark parser
+ # Generating an Wireshark parser
$ ./pidl --ws-parser -- atsvc.idl
# Generating a TDR parser and header
@@ -534,7 +534,7 @@ Samba 3 output:
using Samba4's NDR code [cli_BASENAME.c]
Wireshark parsers:
- --ws-parser[=OUTFILE] create wireshark parser and header
+ --ws-parser[=OUTFILE] create Wireshark parser and header
\n";
exit(0);
}