pidl: handle hyper attribute for wireshark
[kai/samba-autobuild/.git] / pidl / lib / Parse / Pidl / Wireshark / NDR.pm
index e13e14465cae3a9c28a5f9e868a9fb1fd23f19f2..4ff5f41e11e70c895d4b843b820e66368ce54390 100644 (file)
@@ -323,9 +323,19 @@ sub ElementLevel($$$$$$$)
                                $self->pidl_code("proto_item_append_text(tree, \": %s\", data);");
                        } 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);");
+                       } elsif (property_matches($e, "flag", ".*STR_NULLTERM.*")) {
+                               if ($bs == 2) {
+                                       $self->pidl_code("offset = dissect_null_term_wstring(tvb, offset, pinfo, tree, drep, $hf , 0);")
+                               } else {
+                                       $self->pidl_code("offset = dissect_null_term_string(tvb, offset, pinfo, tree, drep, $hf , 0);")
+                               }
                        } else {
                                warn("Unable to handle string with flags $e->{PROPERTIES}->{flag}");
                        }
+               } elsif ($l->{DATA_TYPE} eq "DATA_BLOB") {
+                       my $remain = 0;
+                       $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);");
                } else {
                        my $call;
 
@@ -545,6 +555,9 @@ sub Struct($$$$)
        $self->indent;
        $self->pidl_code("proto_item *item = NULL;");
        $self->pidl_code("proto_tree *tree = NULL;");
+       if ($e->{ALIGN} > 1) {
+               $self->pidl_code("dcerpc_info *di = pinfo->private_data;");
+       }
        $self->pidl_code("int old_offset;");
        $self->pidl_code("");
 
@@ -565,6 +578,15 @@ sub Struct($$$$)
        $self->pidl_code("\n$res");
 
        $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
+       if ($e->{ALIGN} > 1) {
+               $self->pidl_code("");
+               $self->pidl_code("if (di->call_data->flags & DCERPC_IS_NDR64) {");
+               $self->indent;
+               $self->pidl_code("ALIGN_TO_$e->{ALIGN}_BYTES;");
+               $self->deindent;
+               $self->pidl_code("}");
+       }
+       $self->pidl_code("");
        $self->pidl_code("return offset;");
        $self->deindent;
        $self->pidl_code("}\n");
@@ -634,6 +656,8 @@ sub Union($$$$)
 
        $self->pidl_code("switch(level) {$res\t}");
        $self->pidl_code("proto_item_set_len(item, offset-old_offset);\n");
+       $self->pidl_code("");
+
        $self->pidl_code("return offset;");
        $self->deindent;
        $self->pidl_code("}");
@@ -756,8 +780,8 @@ sub ProcessImport
        my @imports = @_;
        foreach (@imports) {
                next if($_ eq "security");
-               s/\.idl\"$//;
                s/^\"//;
+               s/\.idl"?$//;
                $self->pidl_hdr("#include \"packet-dcerpc-$_\.h\"");
        }
        $self->pidl_hdr("");
@@ -799,7 +823,7 @@ sub ProcessInterface($$)
        
            my $maj = $x->{VERSION};
            $maj =~ s/\.(.*)$//g;
-           $self->pidl_def("static guint16 ver_dcerpc_$x->{NAME} = $maj;");
+           $self->pidl_def("static guint32 ver_dcerpc_$x->{NAME} = $maj;");
            $self->pidl_def("");
        }
 
@@ -865,6 +889,7 @@ sub Initialize($$)
                $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("hyper", "offset = dissect_ndr_uint64(tvb, offset, pinfo, tree, 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("bool8", "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, drep, \@HF\@, \@PARAM\@);","FT_INT8", "BASE_DEC", 0, "NULL", 1);
@@ -872,10 +897,10 @@ sub Initialize($$)
        $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("GUID", "offset = dissect_ndr_uuid_t(tvb, offset, pinfo, tree, 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("NTTIME", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
-       $self->register_type("NTTIME_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
-       $self->register_type("time_t", "offset = dissect_ndr_time_t(tvb, offset, pinfo,tree, drep, \@HF\@, NULL);","FT_ABSOLUTE_TIME", "BASE_NONE", 0, "NULL", 4);
-       $self->register_type("NTTIME_1sec", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, drep, \@HF\@);", "FT_ABSOLUTE_TIME", "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_hyper", "offset = dissect_ndr_nt_NTTIME(tvb, offset, pinfo, tree, 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("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("SID", "
                dcerpc_info *di = (dcerpc_info *)pinfo->private_data;