From 38104c7cff8a42b82886e49fba11b10418db2d26 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 4 Oct 2009 13:45:56 +1100 Subject: [PATCH] add trailer alignment to STRUCT and UNION for the wireshark backend --- pidl/lib/Parse/Pidl/Wireshark/NDR.pm | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+), 0 deletions(-) diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm index a9ad555..f0aab80 100644 --- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm +++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm @@ -545,6 +545,7 @@ sub Struct($$$$) $self->indent; $self->pidl_code("proto_item *item = NULL;"); $self->pidl_code("proto_tree *tree = NULL;"); + $self->pidl_code("dcerpc_info *di = pinfo->private_data;"); $self->pidl_code("int old_offset;"); $self->pidl_code(""); @@ -565,6 +566,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"); @@ -610,6 +620,7 @@ sub Union($$$$) $self->indent; $self->pidl_code("proto_item *item = NULL;"); $self->pidl_code("proto_tree *tree = NULL;"); + $self->pidl_code("dcerpc_info *di = pinfo->private_data;"); $self->pidl_code("int old_offset;"); $self->pidl_code("$switch_type level;"); $self->pidl_code(""); @@ -634,6 +645,17 @@ sub Union($$$$) $self->pidl_code("switch(level) {$res\t}"); $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("}"); -- 1.5.4.3