summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse/Pidl
diff options
context:
space:
mode:
Diffstat (limited to 'pidl/lib/Parse/Pidl')
-rw-r--r--pidl/lib/Parse/Pidl/NDR.pm23
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm12
-rw-r--r--pidl/lib/Parse/Pidl/Samba4/TDR.pm6
-rw-r--r--pidl/lib/Parse/Pidl/Typelist.pm6
-rw-r--r--pidl/lib/Parse/Pidl/Wireshark/Conformance.pm12
-rw-r--r--pidl/lib/Parse/Pidl/Wireshark/NDR.pm18
6 files changed, 67 insertions, 10 deletions
diff --git a/pidl/lib/Parse/Pidl/NDR.pm b/pidl/lib/Parse/Pidl/NDR.pm
index 7aebed0fe2..4e680b336f 100644
--- a/pidl/lib/Parse/Pidl/NDR.pm
+++ b/pidl/lib/Parse/Pidl/NDR.pm
@@ -39,7 +39,7 @@ $VERSION = '0.01';
use strict;
use Parse::Pidl qw(warning fatal);
-use Parse::Pidl::Typelist qw(hasType getType expandAlias);
+use Parse::Pidl::Typelist qw(hasType getType expandAlias mapScalarType);
use Parse::Pidl::Util qw(has_property property_matches);
# Alignment of the built-in scalar types
@@ -50,8 +50,12 @@ my $scalar_alignment = {
'uint8' => 1,
'int16' => 2,
'uint16' => 2,
+ 'int1632' => 3,
+ 'uint1632' => 3,
'int32' => 4,
'uint32' => 4,
+ 'int3264' => 5,
+ 'uint3264' => 5,
'hyper' => 8,
'double' => 8,
'pointer' => 8,
@@ -404,6 +408,8 @@ sub align_type($)
if ($dt->{TYPE} eq "TYPEDEF") {
return align_type($dt->{DATA});
+ } elsif ($dt->{TYPE} eq "CONFORMANCE") {
+ return $dt->{DATA}->{ALIGN};
} elsif ($dt->{TYPE} eq "ENUM") {
return align_type(Parse::Pidl::Typelist::enum_type_fn($dt));
} elsif ($dt->{TYPE} eq "BITMAP") {
@@ -509,7 +515,8 @@ sub ParseUnion($$)
ELEMENTS => undef,
PROPERTIES => $e->{PROPERTIES},
HAS_DEFAULT => $hasdefault,
- ORIGINAL => $e
+ ORIGINAL => $e,
+ ALIGN => undef
} unless defined($e->{ELEMENTS});
CheckPointerTypes($e, $pointer_default);
@@ -533,6 +540,11 @@ sub ParseUnion($$)
push @elements, $t;
}
+ my $align = undef;
+ if ($e->{NAME}) {
+ $align = align_type($e->{NAME});
+ }
+
return {
TYPE => "UNION",
NAME => $e->{NAME},
@@ -540,7 +552,8 @@ sub ParseUnion($$)
ELEMENTS => \@elements,
PROPERTIES => $e->{PROPERTIES},
HAS_DEFAULT => $hasdefault,
- ORIGINAL => $e
+ ORIGINAL => $e,
+ ALIGN => $align
};
}
@@ -997,13 +1010,13 @@ sub ValidElement($)
my $discriminator_type = has_property($type->{DATA}, "switch_type");
$discriminator_type = "uint32" unless defined ($discriminator_type);
- my $t1 = mapToScalar($discriminator_type);
+ my $t1 = mapScalarType(mapToScalar($discriminator_type));
if (not defined($t1)) {
fatal($e, el_name($e) . ": unable to map discriminator type '$discriminator_type' to scalar");
}
- my $t2 = mapToScalar($e2->{TYPE});
+ my $t2 = mapScalarType(mapToScalar($e2->{TYPE}));
if (not defined($t2)) {
fatal($e, el_name($e) . ": unable to map variable used for switch_is() to scalar");
}
diff --git a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
index 62e38bf7e9..11a43b4509 100644
--- a/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm
@@ -1235,6 +1235,8 @@ sub ParseStructPushPrimitives($$$$$)
}
$self->ParseElementPush($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
+
+ $self->pidl("NDR_CHECK(ndr_push_trailer_align($ndr, $struct->{ALIGN}));");
}
sub ParseStructPushDeferred($$$$)
@@ -1533,6 +1535,8 @@ sub ParseStructPullPrimitives($$$$$)
$self->ParseElementPull($_, $ndr, $env, 1, 0) foreach (@{$struct->{ELEMENTS}});
$self->add_deferred();
+
+ $self->pidl("NDR_CHECK(ndr_pull_trailer_align($ndr, $struct->{ALIGN}));");
}
sub ParseStructPullDeferred($$$$$)
@@ -1644,6 +1648,10 @@ sub ParseUnionPushPrimitives($$$$)
$self->pidl("NDR_CHECK(ndr_push_$e->{SWITCH_TYPE}($ndr, NDR_SCALARS, level));");
}
+ if (defined($e->{ALIGN})) {
+ $self->pidl("NDR_CHECK(ndr_push_union_align($ndr, $e->{ALIGN}));");
+ }
+
$self->pidl("switch (level) {");
$self->indent;
foreach my $el (@{$e->{ELEMENTS}}) {
@@ -1788,6 +1796,10 @@ sub ParseUnionPullPrimitives($$$$$)
$self->pidl("}");
}
+ if (defined($e->{ALIGN})) {
+ $self->pidl("NDR_CHECK(ndr_pull_union_align($ndr, $e->{ALIGN}));");
+ }
+
$self->pidl("switch (level) {");
$self->indent;
foreach my $el (@{$e->{ELEMENTS}}) {
diff --git a/pidl/lib/Parse/Pidl/Samba4/TDR.pm b/pidl/lib/Parse/Pidl/Samba4/TDR.pm
index a6b74a0ba4..c0749304ef 100644
--- a/pidl/lib/Parse/Pidl/Samba4/TDR.pm
+++ b/pidl/lib/Parse/Pidl/Samba4/TDR.pm
@@ -7,6 +7,7 @@ package Parse::Pidl::Samba4::TDR;
use Parse::Pidl qw(fatal);
use Parse::Pidl::Util qw(has_property ParseExpr is_constant);
use Parse::Pidl::Samba4 qw(is_intree choose_header);
+use Parse::Pidl::Typelist qw(mapTypeName);
use Exporter;
@ISA = qw(Exporter);
@@ -195,15 +196,16 @@ sub ParserEnum($$$$)
{
my ($self,$e,$t,$p) = @_;
my $bt = Parse::Pidl::Typelist::enum_type_fn($e);
+ my $mt = mapTypeName($bt);
$self->fn_declare($p, "NTSTATUS tdr_$t\_$e->{NAME} (struct tdr_$t *tdr".typearg($t).", enum $e->{NAME} *v)");
$self->pidl("{");
if ($t eq "pull") {
- $self->pidl("\t$bt\_t r;");
+ $self->pidl("\t$mt r;");
$self->pidl("\tTDR_CHECK(tdr_$t\_$bt(tdr, mem_ctx, \&r));");
$self->pidl("\t*v = r;");
} elsif ($t eq "push") {
- $self->pidl("\tTDR_CHECK(tdr_$t\_$bt(tdr, ($bt\_t *)v));");
+ $self->pidl("\tTDR_CHECK(tdr_$t\_$bt(tdr, ($mt *)v));");
} elsif ($t eq "print") {
$self->pidl("\t/* FIXME */");
}
diff --git a/pidl/lib/Parse/Pidl/Typelist.pm b/pidl/lib/Parse/Pidl/Typelist.pm
index 12ffa92bf6..1d82dee833 100644
--- a/pidl/lib/Parse/Pidl/Typelist.pm
+++ b/pidl/lib/Parse/Pidl/Typelist.pm
@@ -32,8 +32,12 @@ my %scalars = (
"uint8" => "uint8_t",
"int16" => "int16_t",
"uint16" => "uint16_t",
+ "int1632" => "int16_t",
+ "uint1632" => "uint16_t",
"int32" => "int32_t",
"uint32" => "uint32_t",
+ "int3264" => "int32_t",
+ "uint3264" => "uint32_t",
"hyper" => "uint64_t",
"dlong" => "int64_t",
"udlong" => "uint64_t",
@@ -220,7 +224,7 @@ sub enum_type_fn($)
} elsif (has_property($enum->{PARENT}, "v1_enum")) {
return "uint32";
}
- return "uint16";
+ return "uint1632";
}
sub bitmap_type_fn($)
diff --git a/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm b/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
index 5c37b4a0c4..1dec647d87 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/Conformance.pm
@@ -110,6 +110,7 @@ use strict;
use Parse::Pidl qw(fatal warning error);
use Parse::Pidl::Util qw(has_property);
+use Parse::Pidl::Typelist qw(addType);
sub handle_type($$$$$$$$$$)
{
@@ -149,6 +150,17 @@ sub handle_type($$$$$$$$$$)
VALSSTRING => $valsstring,
ALIGNMENT => $alignment
};
+
+ addType({
+ NAME => $name,
+ TYPE => "CONFORMANCE",
+ BASEFILE => "conformance file",
+ DATA => {
+ NAME => $name,
+ TYPE => "CONFORMANCE",
+ ALIGN => $alignment
+ }
+ });
}
sub handle_tfs($$$$$)
diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index a9ad555cca..b8adf2dc4e 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -1,5 +1,5 @@
##################################################
-# Samba4 NDR parser generator for IDL structures
+# Wireshark NDR parser generator for IDL structures
# Copyright tridge@samba.org 2000-2003
# Copyright tpot@samba.org 2001,2005
# Copyright jelmer@samba.org 2004-2007
@@ -545,6 +545,9 @@ sub Struct($$$$)
$self->indent;
$self->pidl_code("proto_item *item = NULL;");
$self->pidl_code("proto_tree *tree = NULL;");
+ if ($e->{ALIGN} > 1) {
+ $self->pidl_code("dcerpc_info *di = pinfo->private_data;");
+ }
$self->pidl_code("int old_offset;");
$self->pidl_code("");
@@ -565,6 +568,15 @@ sub Struct($$$$)
$self->pidl_code("\n$res");
$self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
+ if ($e->{ALIGN} > 1) {
+ $self->pidl_code("");
+ $self->pidl_code("if (di->call_data->flags & DCERPC_IS_NDR64) {");
+ $self->indent;
+ $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
+ $self->deindent;
+ $self->pidl_code("}");
+ }
+ $self->pidl_code("");
$self->pidl_code("return offset;");
$self->deindent;
$self->pidl_code("}\n");
@@ -634,6 +646,8 @@ sub Union($$$$)
$self->pidl_code("switch(level) {$res\t}");
$self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
+ $self->pidl_code("");
+
$self->pidl_code("return offset;");
$self->deindent;
$self->pidl_code("}");
@@ -895,7 +909,7 @@ sub Initialize($$)
sub Parse($$$$$)
{
my($self,$ndr,$idl_file,$h_filename,$cnf_file) = @_;
-
+
$self->Initialize($cnf_file);
return (undef, undef) if defined($self->{conformance}->{noemit_dissector});