summaryrefslogtreecommitdiff
path: root/source4/pidl
diff options
context:
space:
mode:
Diffstat (limited to 'source4/pidl')
-rw-r--r--source4/pidl/TODO2
-rw-r--r--source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm28
-rwxr-xr-xsource4/pidl/tests/wireshark-ndr.pl8
3 files changed, 22 insertions, 16 deletions
diff --git a/source4/pidl/TODO b/source4/pidl/TODO
index 47cd956c4f..859b3d5317 100644
--- a/source4/pidl/TODO
+++ b/source4/pidl/TODO
@@ -1,3 +1,5 @@
+- allow [public] on typedefs only
+
- EJS output backend shouldn't use the NDR levels stuff but instead
as the "C levels" and NDR levels don't necessarily match.
diff --git a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index 72d353aa14..914d54d985 100644
--- a/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/source4/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -18,7 +18,7 @@ package Parse::Pidl::Wireshark::NDR;
use Exporter;
@ISA = qw(Exporter);
-@EXPORT_OK = qw(field2name @ett %res PrintIdl);
+@EXPORT_OK = qw(field2name @ett %res PrintIdl StripPrefixes);
use strict;
use Parse::Pidl qw(error warning);
@@ -46,11 +46,11 @@ my %ptrtype_mappings = (
"ptr" => "NDR_POINTER_PTR"
);
-sub StripPrefixes($)
+sub StripPrefixes($$)
{
- my ($s) = @_;
+ my ($s, $prefixes) = @_;
- foreach (@{$conformance->{strip_prefixes}}) {
+ foreach (@$prefixes) {
$s =~ s/^$_\_//g;
}
@@ -135,9 +135,9 @@ sub Enum($$$)
{
my ($e,$name,$ifname) = @_;
my $valsstring = "$ifname\_$name\_vals";
- my $dissectorname = "$ifname\_dissect\_enum\_".StripPrefixes($name);
+ my $dissectorname = "$ifname\_dissect\_enum\_".StripPrefixes($name, $conformance->{strip_prefixes});
- return if (defined($conformance->{noemit}->{StripPrefixes($name)}));
+ return if (defined($conformance->{noemit}->{StripPrefixes($name, $conformance->{strip_prefixes})}));
foreach (@{$e->{ELEMENTS}}) {
if (/([^=]*)=(.*)/) {
@@ -176,7 +176,7 @@ sub Enum($$$)
sub Bitmap($$$)
{
my ($e,$name,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect\_bitmap\_".StripPrefixes($name);
+ my $dissectorname = "$ifname\_dissect\_bitmap\_".StripPrefixes($name, $conformance->{strip_prefixes});
register_ett("ett_$ifname\_$name");
@@ -272,7 +272,7 @@ sub ElementLevel($$$$$$)
} 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}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME})) . " ($e->{TYPE})\",$hf);";
+ pidl_code "offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME}, $conformance->{strip_prefixes})) . " ($e->{TYPE})\",$hf);";
} elsif ($l->{TYPE} eq "ARRAY") {
if ($l->{IS_INLINE}) {
error($e->{ORIGINAL}, "Inline arrays not supported");
@@ -353,7 +353,7 @@ sub Element($$$)
{
my ($e,$pn,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect\_element\_".StripPrefixes($pn)."\_".StripPrefixes($e->{NAME});
+ my $dissectorname = "$ifname\_dissect\_element\_".StripPrefixes($pn, $conformance->{strip_prefixes})."\_".StripPrefixes($e->{NAME}, $conformance->{strip_prefixes});
my $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep);";
@@ -381,7 +381,7 @@ sub Element($$$)
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;
- my $eltname = StripPrefixes($pn) . ".$e->{NAME}";
+ my $eltname = StripPrefixes($pn, $conformance->{strip_prefixes}) . ".$e->{NAME}";
if (defined($conformance->{noemit}->{$eltname})) {
return $call_code;
}
@@ -513,9 +513,9 @@ sub Function($$$)
sub Struct($$$)
{
my ($e,$name,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect\_struct\_".StripPrefixes($name);
+ my $dissectorname = "$ifname\_dissect\_struct\_".StripPrefixes($name, $conformance->{strip_prefixes});
- return if (defined($conformance->{noemit}->{StripPrefixes($name)}));
+ return if (defined($conformance->{noemit}->{StripPrefixes($name, $conformance->{strip_prefixes})}));
register_ett("ett_$ifname\_$name");
@@ -563,9 +563,9 @@ sub Union($$$)
{
my ($e,$name,$ifname) = @_;
- my $dissectorname = "$ifname\_dissect_".StripPrefixes($name);
+ my $dissectorname = "$ifname\_dissect_".StripPrefixes($name, $conformance->{strip_prefixes});
- return if (defined($conformance->{noemit}->{StripPrefixes($name)}));
+ return if (defined($conformance->{noemit}->{StripPrefixes($name, $conformance->{strip_prefixes})}));
register_ett("ett_$ifname\_$name");
diff --git a/source4/pidl/tests/wireshark-ndr.pl b/source4/pidl/tests/wireshark-ndr.pl
index 574060f8ea..f5229560bd 100755
--- a/source4/pidl/tests/wireshark-ndr.pl
+++ b/source4/pidl/tests/wireshark-ndr.pl
@@ -5,12 +5,12 @@
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 6;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
use Parse::Pidl::Util qw(MyDumper);
-use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl);
+use Parse::Pidl::Wireshark::NDR qw(field2name %res PrintIdl StripPrefixes);
is("Access Mask", field2name("access_mask"));
is("Accessmask", field2name("AccessMask"));
@@ -21,3 +21,7 @@ is("/* IDL: foo */
/* IDL: bar */
", $res{code});
+
+is("bla_foo", StripPrefixes("bla_foo", []));
+is("foo", StripPrefixes("bla_foo", ["bla"]));
+is("foo_bla", StripPrefixes("foo_bla", ["bla"]));