summaryrefslogtreecommitdiff
path: root/pidl/lib/Parse
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2013-10-01 12:10:18 -0700
committerStefan Metzmacher <metze@samba.org>2014-10-24 01:39:16 +0200
commit4b09df897803e78265fd19f6ff19be6e3d8a3944 (patch)
treef415c4ca49a6787e5815888315e7422f83818b26 /pidl/lib/Parse
parent93f262ee6d162bf007b79d2daf9de6c49c6163d1 (diff)
downloadsamba-4b09df897803e78265fd19f6ff19be6e3d8a3944.tar.gz
pidl-wireshark: SWITCH_TYPE is not always defined, SwitchType() will try to find a fallback
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Matthieu Patou <mat@matws.net> Signed-off-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Oct 24 01:39:16 CEST 2014 on sn-devel-104
Diffstat (limited to 'pidl/lib/Parse')
-rw-r--r--pidl/lib/Parse/Pidl/Wireshark/NDR.pm59
1 files changed, 38 insertions, 21 deletions
diff --git a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
index 7a81f5ca5a9..89cbf84cd90 100644
--- a/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
+++ b/pidl/lib/Parse/Pidl/Wireshark/NDR.pm
@@ -414,6 +414,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) = @_;
@@ -426,13 +449,12 @@ sub Element($$$$$)
my $type = $isoruseswitch->[0];
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$e->{SWITCH_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}";
+
$moreparam = ", $switch_type *".$name;
$param = $name;
$call_code = "offset = $dissectorname(tvb, offset, pinfo, tree, drep, &$name);";
@@ -632,13 +654,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$e->{SWITCH_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}";
push @$vars, "$switch_type $v;";
$switch_info = [ $_->{TYPE}, $v ];
@@ -741,15 +761,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);