1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

pidl/ws: Remove pinfo->private_data from DCERPC dissectors.

Sort of re-apply Wireshark commit 79cd356 which was never sync with
samba. It was reverted then reintroduced in the WS repo (yes this is
quite convulted).

Original commit message:

Author: Michael Mann <mmann78@netscape.net>
Date:   Wed Nov 6 12:36:09 2013 +0000

    Remove pinfo->private_data from DCERPC dissectors.  Bug 9387 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9387)

    This is the PIDL input file changes necessary to support removing pinfo->private_data from the DCERPC dissectors in favor of passing it through function parameters.  I didn't regenerate the dissector source, so this is just a "good faith" effort to mimic the manual changes.

    svn path=/trunk/; revision=53098

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
This commit is contained in:
Aurelien Aptel 2016-02-09 17:30:09 +01:00 committed by Stefan Metzmacher
parent 498189087b
commit 57bc1ced67

View File

@ -151,7 +151,7 @@ sub Enum($$$$)
} }
$self->pidl_hdr("extern const value_string $valsstring\[];"); $self->pidl_hdr("extern const value_string $valsstring\[];");
$self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_);"); $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_);");
$self->pidl_def("const value_string ".$valsstring."[] = {"); $self->pidl_def("const value_string ".$valsstring."[] = {");
foreach (@{$e->{ELEMENTS}}) { foreach (@{$e->{ELEMENTS}}) {
@ -164,7 +164,7 @@ sub Enum($$$$)
$self->pidl_fn_start($dissectorname); $self->pidl_fn_start($dissectorname);
$self->pidl_code("int"); $self->pidl_code("int");
$self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_)"); $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, g$e->{BASE_TYPE} *param _U_)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
$self->pidl_code("g$e->{BASE_TYPE} parameter=0;"); $self->pidl_code("g$e->{BASE_TYPE} parameter=0;");
@ -173,7 +173,7 @@ sub Enum($$$$)
$self->pidl_code("parameter = *param;"); $self->pidl_code("parameter = *param;");
$self->deindent; $self->deindent;
$self->pidl_code("}"); $self->pidl_code("}");
$self->pidl_code("offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, drep, hf_index, &parameter);"); $self->pidl_code("offset = dissect_ndr_$e->{BASE_TYPE}(tvb, offset, pinfo, tree, di, drep, hf_index, &parameter);");
$self->pidl_code("if (param) {"); $self->pidl_code("if (param) {");
$self->indent; $self->indent;
$self->pidl_code("*param = parameter;"); $self->pidl_code("*param = parameter;");
@ -186,7 +186,7 @@ sub Enum($$$$)
my $enum_size = $e->{BASE_TYPE}; my $enum_size = $e->{BASE_TYPE};
$enum_size =~ s/uint//g; $enum_size =~ s/uint//g;
$self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$enum_size", "BASE_DEC", "0", "VALS($valsstring)", $enum_size / 8); $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);", "FT_UINT$enum_size", "BASE_DEC", "0", "VALS($valsstring)", $enum_size / 8);
} }
sub Pipe($$$$) sub Pipe($$$$)
@ -203,11 +203,11 @@ sub Bitmap($$$$)
$self->register_ett("ett_$ifname\_$name"); $self->register_ett("ett_$ifname\_$name");
$self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);"); $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);");
$self->pidl_fn_start($dissectorname); $self->pidl_fn_start($dissectorname);
$self->pidl_code("int"); $self->pidl_code("int");
$self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)"); $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
$self->pidl_code("proto_item *item = NULL;"); $self->pidl_code("proto_item *item = NULL;");
@ -275,7 +275,7 @@ sub Bitmap($$$$)
my $size = $e->{BASE_TYPE}; my $size = $e->{BASE_TYPE};
$size =~ s/uint//g; $size =~ s/uint//g;
$self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$size", "BASE_HEX", "0", "NULL", $size/8); $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);", "FT_UINT$size", "BASE_HEX", "0", "NULL", $size/8);
} }
sub ElementLevel($$$$$$$$) sub ElementLevel($$$$$$$$)
@ -293,26 +293,26 @@ sub ElementLevel($$$$$$$$)
} elsif ($l->{LEVEL} eq "EMBEDDED") { } elsif ($l->{LEVEL} eq "EMBEDDED") {
$type = "embedded"; $type = "embedded";
} }
$self->pidl_code("offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes})) . " ($e->{TYPE})\",$hf);"); $self->pidl_code("offset = dissect_ndr_$type\_pointer(tvb, offset, pinfo, tree, di, drep, $myname\_, $ptrtype_mappings{$l->{POINTER_TYPE}}, \"Pointer to ".field2name(StripPrefixes($e->{NAME}, $self->{conformance}->{strip_prefixes})) . " ($e->{TYPE})\",$hf);");
} elsif ($l->{TYPE} eq "ARRAY") { } elsif ($l->{TYPE} eq "ARRAY") {
if ($l->{IS_INLINE}) { if ($l->{IS_INLINE}) {
error($e->{ORIGINAL}, "Inline arrays not supported"); error($e->{ORIGINAL}, "Inline arrays not supported");
} elsif ($l->{IS_FIXED}) { } elsif ($l->{IS_FIXED}) {
$self->pidl_code("int i;"); $self->pidl_code("int i;");
$self->pidl_code("for (i = 0; i < $l->{SIZE_IS}; i++)"); $self->pidl_code("for (i = 0; i < $l->{SIZE_IS}; i++)");
$self->pidl_code("\toffset = $myname\_(tvb, offset, pinfo, tree, drep);"); $self->pidl_code("\toffset = $myname\_(tvb, offset, pinfo, tree, di, drep);");
} else { } else {
my $type = ""; my $type = "";
$type .= "c" if ($l->{IS_CONFORMANT}); $type .= "c" if ($l->{IS_CONFORMANT});
$type .= "v" if ($l->{IS_VARYING}); $type .= "v" if ($l->{IS_VARYING});
unless ($l->{IS_ZERO_TERMINATED}) { unless ($l->{IS_ZERO_TERMINATED}) {
$self->pidl_code("offset = dissect_ndr_u" . $type . "array(tvb, offset, pinfo, tree, drep, $myname\_);"); $self->pidl_code("offset = dissect_ndr_u" . $type . "array(tvb, offset, pinfo, tree, di, drep, $myname\_);");
} else { } else {
my $nl = GetNextLevel($e,$l); my $nl = GetNextLevel($e,$l);
$self->pidl_code("char *data;"); $self->pidl_code("char *data;");
$self->pidl_code(""); $self->pidl_code("");
$self->pidl_code("offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, drep, sizeof(g$nl->{DATA_TYPE}), $hf, FALSE, &data);"); $self->pidl_code("offset = dissect_ndr_$type" . "string(tvb, offset, pinfo, tree, di, drep, sizeof(g$nl->{DATA_TYPE}), $hf, FALSE, &data);");
$self->pidl_code("proto_item_append_text(tree, \": %s\", data);"); $self->pidl_code("proto_item_append_text(tree, \": %s\", data);");
} }
} }
@ -325,10 +325,10 @@ sub ElementLevel($$$$$$$$)
if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*") and property_matches($e, "flag", ".*LIBNDR_FLAG_STR_LEN4.*")) { if (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*") and property_matches($e, "flag", ".*LIBNDR_FLAG_STR_LEN4.*")) {
$self->pidl_code("char *data;\n"); $self->pidl_code("char *data;\n");
$self->pidl_code("offset = dissect_ndr_cvstring(tvb, offset, pinfo, tree, drep, $bs, $hf, FALSE, &data);"); $self->pidl_code("offset = dissect_ndr_cvstring(tvb, offset, pinfo, tree, di, drep, $bs, $hf, FALSE, &data);");
$self->pidl_code("proto_item_append_text(tree, \": %s\", data);"); $self->pidl_code("proto_item_append_text(tree, \": %s\", data);");
} elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*")) { } elsif (property_matches($e, "flag", ".*LIBNDR_FLAG_STR_SIZE4.*")) {
$self->pidl_code("offset = dissect_ndr_vstring(tvb, offset, pinfo, tree, drep, $bs, $hf, FALSE, NULL);"); $self->pidl_code("offset = dissect_ndr_vstring(tvb, offset, pinfo, tree, di, drep, $bs, $hf, FALSE, NULL);");
} elsif (property_matches($e, "flag", ".*STR_NULLTERM.*")) { } elsif (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
if ($bs == 2) { if ($bs == 2) {
$self->pidl_code("offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, $hf , 0);") $self->pidl_code("offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, $hf , 0);")
@ -341,7 +341,7 @@ sub ElementLevel($$$$$$$$)
} elsif ($l->{DATA_TYPE} eq "DATA_BLOB") { } elsif ($l->{DATA_TYPE} eq "DATA_BLOB") {
my $remain = 0; my $remain = 0;
$remain = 1 if (property_matches($e->{ORIGINAL}, "flag", ".*LIBNDR_FLAG_REMAINING.*")); $remain = 1 if (property_matches($e->{ORIGINAL}, "flag", ".*LIBNDR_FLAG_REMAINING.*"));
$self->pidl_code("offset = dissect_ndr_datablob(tvb, offset, pinfo, tree, drep, $hf, $remain);"); $self->pidl_code("offset = dissect_ndr_datablob(tvb, offset, pinfo, tree, di, drep, $hf, $remain);");
} else { } else {
my $call; my $call;
@ -364,7 +364,7 @@ sub ElementLevel($$$$$$$$)
$t = $l->{DATA_TYPE}; $t = $l->{DATA_TYPE};
} }
$self->pidl_code("offset = $ifname\_dissect_struct_" . $t . "(tvb,offset,pinfo,tree,drep,$hf,$param);"); $self->pidl_code("offset = $ifname\_dissect_struct_" . $t . "(tvb,offset,pinfo,tree,di,drep,$hf,$param);");
return; return;
} }
@ -382,7 +382,6 @@ sub ElementLevel($$$$$$$$)
my $hf2 = $self->register_hf_field($hf."_", "Subcontext length", "$ifname.$pn.$_->{NAME}subcontext", "FT_UINT$num_bits", "BASE_HEX", "NULL", 0, ""); my $hf2 = $self->register_hf_field($hf."_", "Subcontext length", "$ifname.$pn.$_->{NAME}subcontext", "FT_UINT$num_bits", "BASE_HEX", "NULL", 0, "");
$num_bits = 3264 if ($num_bits == 32); $num_bits = 3264 if ($num_bits == 32);
$self->{hf_used}->{$hf2} = 1; $self->{hf_used}->{$hf2} = 1;
$self->pidl_code("dcerpc_info *di = (dcerpc_info*)pinfo->private_data;");
$self->pidl_code("guint$num_bits size;"); $self->pidl_code("guint$num_bits size;");
$self->pidl_code("int conformant = di->conformant_run;"); $self->pidl_code("int conformant = di->conformant_run;");
$self->pidl_code("tvbuff_t *subtvb;"); $self->pidl_code("tvbuff_t *subtvb;");
@ -392,19 +391,19 @@ sub ElementLevel($$$$$$$$)
$self->pidl_code("if (!conformant) {"); $self->pidl_code("if (!conformant) {");
$self->indent; $self->indent;
$self->pidl_code("guint32 saved_flags = di->call_data->flags;"); $self->pidl_code("guint32 saved_flags = di->call_data->flags;");
$self->pidl_code("offset = dissect_ndr_uint$num_bits(tvb, offset, pinfo, tree, drep, $hf2, &size);"); $self->pidl_code("offset = dissect_ndr_uint$num_bits(tvb, offset, pinfo, tree, di, drep, $hf2, &size);");
# This is a subcontext, there is normally no such thing as # This is a subcontext, there is normally no such thing as
# 64 bit NDR is subcontext so we clear the flag so that we can # 64 bit NDR is subcontext so we clear the flag so that we can
# continue to dissect handmarshalled stuff with pidl # continue to dissect handmarshalled stuff with pidl
$self->pidl_code("di->call_data->flags &= ~DCERPC_IS_NDR64;"); $self->pidl_code("di->call_data->flags &= ~DCERPC_IS_NDR64;");
$self->pidl_code("subtvb = tvb_new_subset(tvb, offset, size, -1);"); $self->pidl_code("subtvb = tvb_new_subset(tvb, offset, (const gint)size, -1);");
if ($param ne 0) { if ($param ne 0) {
$self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, drep, $param);"); $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, di, drep, $param);");
} else { } else {
$self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, drep);"); $self->pidl_code("$myname\_(subtvb, 0, pinfo, tree, di, drep);");
} }
$self->pidl_code("offset += size;"); $self->pidl_code("offset += (int)size;");
$self->pidl_code("di->call_data->flags = saved_flags;"); $self->pidl_code("di->call_data->flags = saved_flags;");
$self->deindent; $self->deindent;
$self->pidl_code("}"); $self->pidl_code("}");
@ -458,10 +457,9 @@ sub Element($$$$$)
$moreparam = ", $switch_type *".$name; $moreparam = ", $switch_type *".$name;
$param = $name; $param = $name;
$call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep, &$name);";
} else { } else {
$moreparam = ""; $moreparam = "";
$call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep);"; $call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep);";
} }
@ -510,10 +508,10 @@ sub Element($$$$$)
} }
next if ($_->{TYPE} eq "SWITCH"); next if ($_->{TYPE} eq "SWITCH");
next if (defined($self->{conformance}->{noemit}->{"$dissectorname$add"})); next if (defined($self->{conformance}->{noemit}->{"$dissectorname$add"}));
$self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_$moreparam);"); $self->pidl_def("static int $dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_$moreparam);");
$self->pidl_fn_start("$dissectorname$add"); $self->pidl_fn_start("$dissectorname$add");
$self->pidl_code("static int"); $self->pidl_code("static int");
$self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_$moreparam)"); $self->pidl_code("$dissectorname$add(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_$moreparam)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
@ -550,7 +548,7 @@ sub Function($$$)
$self->PrintIdl(DumpFunction($fn->{ORIGINAL})); $self->PrintIdl(DumpFunction($fn->{ORIGINAL}));
$self->pidl_fn_start("$ifname\_dissect\_$fn_name\_response"); $self->pidl_fn_start("$ifname\_dissect\_$fn_name\_response");
$self->pidl_code("static int"); $self->pidl_code("static int");
$self->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_)"); $self->pidl_code("$ifname\_dissect\_${fn_name}_response(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
if ( not defined($fn->{RETURN_TYPE})) { if ( not defined($fn->{RETURN_TYPE})) {
@ -569,23 +567,23 @@ sub Function($$$)
error($fn, "unknown return type `$fn->{RETURN_TYPE}'"); error($fn, "unknown return type `$fn->{RETURN_TYPE}'");
} }
$self->pidl_code("pinfo->dcerpc_procedure_name=\"${fn_name}\";"); $self->pidl_code("di->dcerpc_procedure_name=\"${fn_name}\";");
foreach (@{$fn->{ELEMENTS}}) { foreach (@{$fn->{ELEMENTS}}) {
if (grep(/out/,@{$_->{DIRECTION}})) { if (grep(/out/,@{$_->{DIRECTION}})) {
$self->pidl_code("$dissectornames{$_->{NAME}}"); $self->pidl_code("$dissectornames{$_->{NAME}}");
$self->pidl_code("offset = dissect_deferred_pointers(pinfo, tvb, offset, drep);"); $self->pidl_code("offset = dissect_deferred_pointers(pinfo, tvb, offset, di, drep);");
$self->pidl_code(""); $self->pidl_code("");
} }
} }
if (not defined($fn->{RETURN_TYPE})) { if (not defined($fn->{RETURN_TYPE})) {
} elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") { } elsif ($fn->{RETURN_TYPE} eq "NTSTATUS") {
$self->pidl_code("offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep, hf\_$ifname\_status, &status);\n"); $self->pidl_code("offset = dissect_ntstatus(tvb, offset, pinfo, tree, di, drep, hf\_$ifname\_status, &status);\n");
$self->pidl_code("if (status != 0)"); $self->pidl_code("if (status != 0)");
$self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, NT_errors, \"Unknown NT status 0x%08x\"));\n"); $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, NT_errors, \"Unknown NT status 0x%08x\"));\n");
$return_types{$ifname}->{"status"} = ["NTSTATUS", "NT Error"]; $return_types{$ifname}->{"status"} = ["NTSTATUS", "NT Error"];
} elsif ($fn->{RETURN_TYPE} eq "WERROR") { } elsif ($fn->{RETURN_TYPE} eq "WERROR") {
$self->pidl_code("offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, drep, hf\_$ifname\_werror, &status);\n"); $self->pidl_code("offset = dissect_ndr_uint32(tvb, offset, pinfo, tree, di, drep, hf\_$ifname\_werror, &status);\n");
$self->pidl_code("if (status != 0)"); $self->pidl_code("if (status != 0)");
$self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, WERR_errors, \"Unknown DOS error 0x%08x\"));\n"); $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Error: %s\", val_to_str(status, WERR_errors, \"Unknown DOS error 0x%08x\"));\n");
@ -595,12 +593,12 @@ sub Function($$$)
my $return_type = "g".Parse::Pidl::Typelist::enum_type_fn($type->{DATA}); my $return_type = "g".Parse::Pidl::Typelist::enum_type_fn($type->{DATA});
my $return_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($type->{DATA}); my $return_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($type->{DATA});
$self->pidl_code("offset = $return_dissect(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);"); $self->pidl_code("offset = $return_dissect(tvb, offset, pinfo, tree, di, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);");
$self->pidl_code("if (status != 0)"); $self->pidl_code("if (status != 0)");
$self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %s\", val_to_str(status, $ifname\_$fn->{RETURN_TYPE}\_vals, \"Unknown " . $fn->{RETURN_TYPE} . " error 0x%08x\"));\n"); $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %s\", val_to_str(status, $ifname\_$fn->{RETURN_TYPE}\_vals, \"Unknown " . $fn->{RETURN_TYPE} . " error 0x%08x\"));\n");
$return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}]; $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
} elsif ($type->{DATA}->{TYPE} eq "SCALAR") { } elsif ($type->{DATA}->{TYPE} eq "SCALAR") {
$self->pidl_code("offset = dissect_ndr_$fn->{RETURN_TYPE}(tvb, offset, pinfo, tree, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);"); $self->pidl_code("offset = dissect_ndr_$fn->{RETURN_TYPE}(tvb, offset, pinfo, tree, di, drep, hf\_$ifname\_$fn->{RETURN_TYPE}_status, &status);");
$self->pidl_code("if (status != 0)"); $self->pidl_code("if (status != 0)");
$self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %d\", status);\n"); $self->pidl_code("\tcol_append_fstr(pinfo->cinfo, COL_INFO, \", Status: %d\", status);\n");
$return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}]; $return_types{$ifname}->{$fn->{RETURN_TYPE}."_status"} = [$fn->{RETURN_TYPE}, $fn->{RETURN_TYPE}];
@ -614,14 +612,14 @@ sub Function($$$)
$self->pidl_fn_start("$ifname\_dissect\_$fn_name\_request"); $self->pidl_fn_start("$ifname\_dissect\_$fn_name\_request");
$self->pidl_code("static int"); $self->pidl_code("static int");
$self->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_)"); $self->pidl_code("$ifname\_dissect\_${fn_name}_request(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, dcerpc_info* di _U_, guint8 *drep _U_)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
$self->pidl_code("pinfo->dcerpc_procedure_name=\"${fn_name}\";"); $self->pidl_code("di->dcerpc_procedure_name=\"${fn_name}\";");
foreach (@{$fn->{ELEMENTS}}) { foreach (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$_->{DIRECTION}})) { if (grep(/in/,@{$_->{DIRECTION}})) {
$self->pidl_code("$dissectornames{$_->{NAME}}"); $self->pidl_code("$dissectornames{$_->{NAME}}");
$self->pidl_code("offset = dissect_deferred_pointers(pinfo, tvb, offset, drep);"); $self->pidl_code("offset = dissect_deferred_pointers(pinfo, tvb, offset, di, drep);");
} }
} }
@ -682,11 +680,11 @@ sub Struct($$$$)
$doalign = 0; $doalign = 0;
} }
$self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);"); $self->pidl_hdr("int $dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_);");
$self->pidl_fn_start($dissectorname); $self->pidl_fn_start($dissectorname);
$self->pidl_code("int"); $self->pidl_code("int");
$self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)"); $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
$self->pidl_code($_) foreach (@$vars); $self->pidl_code($_) foreach (@$vars);
@ -748,7 +746,7 @@ sub Struct($$$$)
$self->pidl_code("}\n"); $self->pidl_code("}\n");
$self->pidl_fn_end($dissectorname); $self->pidl_fn_end($dissectorname);
$self->register_type($name, "offset = $dissectorname(tvb,offset,pinfo,tree,drep,\@HF\@,\@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0); $self->register_type($name, "offset = $dissectorname(tvb,offset,pinfo,tree,di,drep,\@HF\@,\@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
} }
sub Union($$$$) sub Union($$$$)
@ -780,7 +778,7 @@ sub Union($$$$)
$self->pidl_fn_start($dissectorname); $self->pidl_fn_start($dissectorname);
$self->pidl_code("static int"); $self->pidl_code("static int");
$self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)"); $self->pidl_code("$dissectorname(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, dcerpc_info* di _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)");
$self->pidl_code("{"); $self->pidl_code("{");
$self->indent; $self->indent;
$self->pidl_code("proto_item *item = NULL;"); $self->pidl_code("proto_item *item = NULL;");
@ -796,15 +794,14 @@ sub Union($$$$)
$self->pidl_code("old_offset = offset;"); $self->pidl_code("old_offset = offset;");
$self->pidl_code("if (parent_tree) {"); $self->pidl_code("if (parent_tree) {");
$self->indent; $self->indent;
$self->pidl_code("item = proto_tree_add_text(parent_tree, tvb, offset, -1, \"$name\");"); $self->pidl_code("tree = proto_tree_add_subtree(parent_tree, tvb, offset, -1, ett_$ifname\_$name, &item, \"$name\");");
$self->pidl_code("tree = proto_item_add_subtree(item, ett_$ifname\_$name);");
$self->deindent; $self->deindent;
$self->pidl_code("}"); $self->pidl_code("}");
$self->pidl_code(""); $self->pidl_code("");
if (defined $switch_type) { if (defined $switch_type) {
$self->pidl_code("offset = $switch_dissect(tvb, offset, pinfo, tree, drep, hf_index, &level);"); $self->pidl_code("offset = $switch_dissect(tvb, offset, pinfo, tree, di, drep, hf_index, &level);");
if ($e->{ALIGN} > 1) { if ($e->{ALIGN} > 1) {
$self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;"); $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
@ -822,7 +819,7 @@ sub Union($$$$)
$self->pidl_code("}"); $self->pidl_code("}");
$self->pidl_fn_end($dissectorname); $self->pidl_fn_end($dissectorname);
$self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0); $self->register_type($name, "offset = $dissectorname(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);", "FT_NONE", "BASE_NONE", 0, "NULL", 0);
} }
sub Const($$$) sub Const($$$)
@ -1047,40 +1044,37 @@ sub Initialize($$)
foreach my $bytes (qw(1 2 4 8)) { foreach my $bytes (qw(1 2 4 8)) {
my $bits = $bytes * 8; my $bits = $bytes * 8;
$self->register_type("uint$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_UINT$bits", "BASE_DEC", 0, "NULL", $bytes); $self->register_type("uint$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);", "FT_UINT$bits", "BASE_DEC", 0, "NULL", $bytes);
$self->register_type("int$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);", "FT_INT$bits", "BASE_DEC", 0, "NULL", $bytes); $self->register_type("int$bits", "offset = PIDL_dissect_uint$bits(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);", "FT_INT$bits", "BASE_DEC", 0, "NULL", $bytes);
} }
$self->register_type("uint3264", "offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT32", "BASE_DEC", 0, "NULL", 8); $self->register_type("uint3264", "offset = dissect_ndr_uint3264(tvb, offset, pinfo, tree, di, drep, \@HF\@, NULL);", "FT_UINT32", "BASE_DEC", 0, "NULL", 8);
$self->register_type("hyper", "offset = dissect_ndr_uint64(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 8); $self->register_type("hyper", "offset = dissect_ndr_uint64(tvb, offset, pinfo, tree, di, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 8);
$self->register_type("udlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 4); $self->register_type("udlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, di, drep, \@HF\@, NULL);", "FT_UINT64", "BASE_DEC", 0, "NULL", 4);
$self->register_type("bool8", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1); $self->register_type("bool8", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1);
$self->register_type("char", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1); $self->register_type("char", "offset = PIDL_dissect_uint8(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1);
$self->register_type("long", "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_INT32", "BASE_DEC", 0, "NULL", 4); $self->register_type("long", "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);","FT_INT32", "BASE_DEC", 0, "NULL", 4);
$self->register_type("dlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);","FT_INT64", "BASE_DEC", 0, "NULL", 8); $self->register_type("dlong", "offset = dissect_ndr_duint32(tvb, offset, pinfo, tree, di, drep, \@HF\@, NULL);","FT_INT64", "BASE_DEC", 0, "NULL", 8);
$self->register_type("GUID", "offset = dissect_ndr_uuid_t(tvb, offset, pinfo, tree, drep, \@HF\@, NULL);","FT_GUID", "BASE_NONE", 0, "NULL", 4); $self->register_type("GUID", "offset = dissect_ndr_uuid_t(tvb, offset, pinfo, tree, di, drep, \@HF\@, NULL);","FT_GUID", "BASE_NONE", 0, "NULL", 4);
$self->register_type("policy_handle", "offset = PIDL_dissect_policy_hnd(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_BYTES", "BASE_NONE", 0, "NULL", 4); $self->register_type("policy_handle", "offset = PIDL_dissect_policy_hnd(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);","FT_BYTES", "BASE_NONE", 0, "NULL", 4);
$self->register_type("NTTIME", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4); $self->register_type("NTTIME", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, di, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
$self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4); $self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, di, drep, \@HF\@);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
$self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4); $self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, di, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
$self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4); $self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, di, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "ABSOLUTE_TIME_LOCAL", 0, "NULL", 4);
$self->register_type("dom_sid28", "{ $self->register_type("dom_sid28", "
dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
di->hf_index = \@HF\@; di->hf_index = \@HF\@;
offset = dissect_ndr_nt_SID28(tvb, offset, pinfo, tree, drep); offset = dissect_ndr_nt_SID28(tvb, offset, pinfo, tree, di, drep);
}", "FT_STRING", "BASE_NONE", 0, "NULL", 4); ", "FT_STRING", "BASE_NONE", 0, "NULL", 4);
$self->register_type("SID", "{ $self->register_type("SID", "
dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
di->hf_index = \@HF\@; di->hf_index = \@HF\@;
offset = dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, drep, param); offset = dissect_ndr_nt_SID_with_options(tvb, offset, pinfo, tree, di, drep, param);
}", "FT_STRING", "BASE_NONE", 0, "NULL", 4); ","FT_STRING", "BASE_NONE", 0, "NULL", 4);
$self->register_type("WERROR", $self->register_type("WERROR",
"offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(WERR_errors)", 4); "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(WERR_errors)", 4);
$self->register_type("NTSTATUS", $self->register_type("NTSTATUS",
"offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(NT_errors)", 4); "offset = PIDL_dissect_uint32(tvb, offset, pinfo, tree, di, drep, \@HF\@, \@PARAM\@);","FT_UINT32", "BASE_DEC", 0, "VALS(NT_errors)", 4);
$self->register_type("ipv6address", "proto_tree_add_item(tree, \@HF\@, tvb, offset, 16, ENC_NA); offset += 16;", "FT_IPv6", "BASE_NONE", 0, "NULL", 16); $self->register_type("ipv6address", "proto_tree_add_item(tree, \@HF\@, tvb, offset, 16, ENC_NA); offset += 16;", "FT_IPv6", "BASE_NONE", 0, "NULL", 16);
$self->register_type("ipv4address", "proto_tree_add_item(tree, \@HF\@, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;", "FT_IPv4", "BASE_NONE", 0, "NULL", 4); $self->register_type("ipv4address", "proto_tree_add_item(tree, \@HF\@, tvb, offset, 4, ENC_BIG_ENDIAN); offset += 4;", "FT_IPv4", "BASE_NONE", 0, "NULL", 4);