SWITCH_TYPE is not always defined, SwitchType() will try to find a fallback
Pick up change from Samba: commit 4b09df897803e78265fd19f6ff19be6e3d8a3944 Author: Matthieu Patou <mat@matws.net> Date: Tue Oct 1 12:10:18 2013 -0700 pidl-wireshark: SWITCH_TYPE is not always defined, SwitchType() will try to find a fallback Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Change-Id: I1f41ece23e8fec30f9cd89a2203ad63ee6e21e36 Reviewed-on: https://code.wireshark.org/review/5105 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
5025bc258c
commit
e41f08858b
|
@ -412,6 +412,29 @@ sub ElementLevel($$$$$$$$)
|
|||
}
|
||||
}
|
||||
|
||||
sub SwitchType($$;$)
|
||||
{
|
||||
my ($e, $type, $nodiscriminant) = @_;
|
||||
|
||||
my $switch_dt = getType($type);
|
||||
my $switch_type = undef;
|
||||
if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
|
||||
$switch_type = Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
|
||||
} elsif ($switch_dt->{DATA}->{TYPE} eq "BITMAP") {
|
||||
$switch_type = Parse::Pidl::Typelist::bitmap_type_fn($switch_dt->{DATA});
|
||||
} elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
|
||||
if (defined $e->{SWITCH_TYPE}) {
|
||||
$switch_type = "$e->{SWITCH_TYPE}";
|
||||
} else {
|
||||
$switch_type = "$switch_dt->{DATA}->{NAME}";
|
||||
}
|
||||
} elsif (not defined $e->{SWITCH_TYPE}) {
|
||||
$switch_type = $nodiscriminant;
|
||||
}
|
||||
|
||||
return $switch_type
|
||||
}
|
||||
|
||||
sub Element($$$$$$)
|
||||
{
|
||||
my ($self,$e,$pn,$ifname,$isoruseswitch,%switchvars) = @_;
|
||||
|
@ -425,27 +448,23 @@ sub Element($$$$$$)
|
|||
my $name = $isoruseswitch->[1];
|
||||
|
||||
my $switch_dt = getType($type);
|
||||
my $switch_type;
|
||||
if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
|
||||
$switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
|
||||
} elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
|
||||
$switch_type = "g$type";
|
||||
my $switch_raw_type = SwitchType($e, $type, "uint32");
|
||||
if (not defined($switch_raw_type)) {
|
||||
die("Unknown type[$type]\n");
|
||||
}
|
||||
|
||||
if ($switch_type ne "") {
|
||||
$moreparam = ", $switch_type *".$name;
|
||||
my $switch_type = "g${switch_raw_type}";
|
||||
|
||||
if (($e->{PROPERTIES}->{switch_is} eq "") && ($switchvars{$name}) &&
|
||||
#not a "native" type
|
||||
(!($type =~ /^uint(8|16|1632|32|3264|64)/))) {
|
||||
$param = $name;
|
||||
} elsif ( $switch_dt->{DATA}->{TYPE} eq "ENUM") {
|
||||
$param = $name;
|
||||
} else {
|
||||
$param = "*".$name;
|
||||
}
|
||||
$moreparam = ", $switch_type *".$name;
|
||||
|
||||
if (($e->{PROPERTIES}->{switch_is} eq "") && ($switchvars{$name}) &&
|
||||
#not a "native" type
|
||||
(!($type =~ /^uint(8|16|1632|32|3264|64)/))) {
|
||||
$param = $name;
|
||||
} elsif ( $switch_dt->{DATA}->{TYPE} eq "ENUM") {
|
||||
$param = $name;
|
||||
} else {
|
||||
$moreparam = "";
|
||||
$param = "*".$name;
|
||||
}
|
||||
|
||||
if ($name ne "") {
|
||||
|
@ -654,13 +673,11 @@ sub Struct($$$$)
|
|||
my $v = $_->{NAME};
|
||||
if (scalar(grep {/^$v$/} keys(%$varswitchs)) == 1) {
|
||||
# This element is one of the switch attribute
|
||||
my $switch_dt = getType($_->{TYPE});
|
||||
my $switch_type;
|
||||
if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
|
||||
$switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
|
||||
} elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
|
||||
$switch_type = "g$_->{TYPE}";
|
||||
my $switch_raw_type = SwitchType($e, $_->{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;";
|
||||
|
@ -771,15 +788,12 @@ sub Union($$$$)
|
|||
$res.="\t\tbreak;\n";
|
||||
}
|
||||
|
||||
my $switch_type;
|
||||
my $switch_dissect;
|
||||
my $switch_dt = getType($e->{SWITCH_TYPE});
|
||||
if ($switch_dt->{DATA}->{TYPE} eq "ENUM") {
|
||||
$switch_type = "g".Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
|
||||
$switch_dissect = "dissect_ndr_" .Parse::Pidl::Typelist::enum_type_fn($switch_dt->{DATA});
|
||||
} elsif ($switch_dt->{DATA}->{TYPE} eq "SCALAR") {
|
||||
$switch_type = "g$e->{SWITCH_TYPE}";
|
||||
$switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
|
||||
my $switch_type = undef;
|
||||
my $switch_dissect = undef;
|
||||
my $switch_raw_type = SwitchType($e, $e->{SWITCH_TYPE});
|
||||
if (defined($switch_raw_type)) {
|
||||
$switch_type = "g${switch_raw_type}";
|
||||
$switch_dissect = "dissect_ndr_${switch_raw_type}";
|
||||
}
|
||||
|
||||
$self->pidl_fn_start($dissectorname);
|
||||
|
|
Loading…
Reference in New Issue