my %dissectornames;
+ my $paramsrefs = {};
+ # will contain the switch var declaration;
+ my $vars = [];
+ my %paramshash;
foreach (@{$fn->{ELEMENTS}}) {
- $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname, undef, undef) if not defined($dissectornames{$_->{NAME}});
+ my $paramvar = undef;
+
+ if (has_property($_, "switch_is")) {
+ $paramvar = $_->{PROPERTIES}->{switch_is};
+ }
+
+ if ($_->{LEVELS}[0]{IS_INLINE}) {
+ $paramvar = $_->{LEVELS}[0]{SIZE_IS};
+ }
+
+ if (defined($paramvar)) {
+ $paramsrefs->{$paramvar} = [];
+ $paramshash{$paramvar} = $paramvar;
+ }
+ }
+
+ foreach (@{$fn->{ELEMENTS}}) {
+ my $paraminfo = undef;
+
+ my $v = $_->{NAME};
+ if (scalar(grep {/^$v$/} keys(%$paramsrefs)) == 1) {
+ # This element is one of the switch attribute
+ my $switch_raw_type = SwitchType($_, $_->{TYPE}, "uint32");
+ if (not defined($switch_raw_type)) {
+ die("Unknown type[$_->{TYPE}]\n");
+ }
+ my $switch_type = "g${switch_raw_type}";
+
+ if ($switch_type ne "") {
+ push @$vars, "$switch_type $v = 0;";
+ }
+ $paraminfo = [ $_->{TYPE}, $v ];
+ $paramsrefs->{$v} = $paraminfo;
+ }
+
+ my $paramvar = undef;
+ if (has_property($_, "switch_is")) {
+ $paramvar = $_->{PROPERTIES}->{switch_is};
+ }
+
+ if ($_->{LEVELS}[0]{IS_INLINE}) {
+ $paramvar = $_->{LEVELS}[0]{SIZE_IS};
+ }
+
+ if (defined($paramvar)) {
+ $paraminfo = $paramsrefs->{$paramvar};
+ }
+
+ $dissectornames{$_->{NAME}} = $self->Element($_, $fn->{NAME}, $ifname, $paraminfo, %paramshash) if not defined($dissectornames{$_->{NAME}});
}
my $fn_name = $_->{NAME};
$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->indent;
+ $self->pidl_code($_) foreach (@$vars);
if ( not defined($fn->{RETURN_TYPE})) {
} elsif ($fn->{RETURN_TYPE} eq "NTSTATUS" or $fn->{RETURN_TYPE} eq "WERROR" or $fn->{RETURN_TYPE} eq "HRESULT")
{
$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->indent;
+ $self->pidl_code($_) foreach (@$vars);
$self->pidl_code("di->dcerpc_procedure_name=\"${fn_name}\";");
foreach (@{$fn->{ELEMENTS}}) {
if (grep(/in/,@{$_->{DIRECTION}})) {