pidl-wireshark: SWITCH_TYPE is not always defined use switch_dt->{DATA}->{NAME} when not
authorMatthieu Patou <mat@matws.net>
Tue, 1 Oct 2013 19:10:18 +0000 (12:10 -0700)
committerStefan Metzmacher <metze@samba.org>
Mon, 4 Nov 2013 11:19:29 +0000 (12:19 +0100)
Signed-off-by: Matthieu Patou <mat@matws.net>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Wireshark/NDR.pm

index 9db6db29bdfefba0b90fd06bd40929b6534392d7..8740f154ebae759dfedd5111a49eb2aab59922a8 100644 (file)
@@ -451,7 +451,13 @@ sub Element($$$$$)
                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}";
+                       if (defined $e->{SWITCH_TYPE}) {
+                               $switch_type = "g$e->{SWITCH_TYPE}";
+                       } else {
+                               $switch_type = "g$switch_dt->{DATA}->{NAME}";
+                       }
+               } else {
+                               $switch_type = "guint32";
                }
                $moreparam = ", $switch_type *".$name;
                $param = $name;
@@ -668,7 +674,11 @@ sub Struct($$$$)
                        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}";
+                               if (defined $e->{SWITCH_TYPE}) {
+                                       $switch_type = "g$e->{SWITCH_TYPE}";
+                               } else {
+                                       $switch_type = "g$switch_dt->{DATA}->{NAME}";
+                               }
                        }
 
                        push @$vars, "$switch_type $v;";
@@ -760,8 +770,13 @@ sub Union($$$$)
                $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}";
+               if (defined $e->{SWITCH_TYPE}) {
+                       $switch_type = "g$e->{SWITCH_TYPE}";
+                       $switch_dissect = "dissect_ndr_$e->{SWITCH_TYPE}";
+               } else {
+                       $switch_type = "g$switch_dt->{DATA}->{NAME}";
+                       $switch_dissect = "dissect_ndr_$switch_dt->{DATA}->{NAME}";
+               }
        }
 
        $self->pidl_fn_start($dissectorname);