pidl: Introduce new dirrective: relative_short
authorMatthieu Patou <mat@matws.net>
Thu, 10 Dec 2009 07:04:48 +0000 (10:04 +0300)
committerStefan Metzmacher <metze@samba.org>
Sat, 12 Dec 2009 09:26:05 +0000 (10:26 +0100)
relative_short is like relative but instead of having the offset coded on 4 bytes
it's coded on 2 bytes. Such things happen in GET_DFS_REFERAL messages.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
pidl/lib/Parse/Pidl/Compat.pm
pidl/lib/Parse/Pidl/NDR.pm
pidl/lib/Parse/Pidl/Samba4/NDR/Parser.pm

index 1b49c439c43bd3fdc4b679c0838d4bd832000949..c248677747d7be7a34bdbbb4caffa05cab7848ed 100644 (file)
@@ -125,6 +125,10 @@ sub CheckElement($)
                warning($e, "relative() pointer property not supported");
        }
 
                warning($e, "relative() pointer property not supported");
        }
 
+       if (has_property($e, "relative_short")) {
+               warning($e, "relative_short() pointer property not supported");
+       }
+
        if (has_property($e, "flag")) {
                warning($e, "ignoring flag() property");
        }
        if (has_property($e, "flag")) {
                warning($e, "ignoring flag() property");
        }
index 4e680b336f1bdf4646c31ca46f6883bdec4919a7..d326f6704097944daacdefe300b74df6292f90d6 100644 (file)
@@ -351,6 +351,7 @@ sub pointer_type($)
        return "sptr" if (has_property($e, "sptr"));
        return "unique" if (has_property($e, "unique"));
        return "relative" if (has_property($e, "relative"));
        return "sptr" if (has_property($e, "sptr"));
        return "unique" if (has_property($e, "unique"));
        return "relative" if (has_property($e, "relative"));
+       return "relative_short" if (has_property($e, "relative_short"));
        return "ignore" if (has_property($e, "ignore"));
 
        return undef;
        return "ignore" if (has_property($e, "ignore"));
 
        return undef;
@@ -902,6 +903,7 @@ my %property_list = (
        "unique"                => ["ELEMENT"],
        "ignore"                => ["ELEMENT"],
        "relative"              => ["ELEMENT"],
        "unique"                => ["ELEMENT"],
        "ignore"                => ["ELEMENT"],
        "relative"              => ["ELEMENT"],
+       "relative_short"        => ["ELEMENT"],
        "null_is_ffffffff" => ["ELEMENT"],
        "relative_base"         => ["TYPEDEF", "STRUCT", "UNION"],
 
        "null_is_ffffffff" => ["ELEMENT"],
        "relative_base"         => ["TYPEDEF", "STRUCT", "UNION"],
 
@@ -1059,6 +1061,7 @@ sub ValidElement($)
                has_property($e, "ptr") or
                has_property($e, "unique") or
                has_property($e, "relative") or
                has_property($e, "ptr") or
                has_property($e, "unique") or
                has_property($e, "relative") or
+               has_property($e, "relative_short") or
                has_property($e, "ref"))) {
                fatal($e, el_name($e) . " : pointer properties on non-pointer element\n");      
        }
                has_property($e, "ref"))) {
                fatal($e, el_name($e) . " : pointer properties on non-pointer element\n");      
        }
index af28bda1082e0a44bb902b904c42968811a32984..bd6909361b4dfb13adf81fe537a69e921a389cab 100644 (file)
@@ -573,6 +573,9 @@ sub ParseElementPushLevel
                        if ($l->{POINTER_TYPE} eq "relative") {
                                $self->pidl("NDR_CHECK(ndr_push_relative_ptr2($ndr, $var_name));");
                        }
                        if ($l->{POINTER_TYPE} eq "relative") {
                                $self->pidl("NDR_CHECK(ndr_push_relative_ptr2($ndr, $var_name));");
                        }
+                       if ($l->{POINTER_TYPE} eq "relative_short") {
+                               $self->pidl("NDR_CHECK(ndr_push_short_relative_ptr2($ndr, $var_name));");
+                       }
                }
                $var_name = get_value_of($var_name);
                $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 1);
                }
                $var_name = get_value_of($var_name);
                $self->ParseElementPushLevel($e, GetNextLevel($e, $l), $ndr, $var_name, $env, 1, 1);
@@ -670,6 +673,8 @@ sub ParsePtrPush($$$$$)
                }
        } elsif ($l->{POINTER_TYPE} eq "relative") {
                $self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));");
                }
        } elsif ($l->{POINTER_TYPE} eq "relative") {
                $self->pidl("NDR_CHECK(ndr_push_relative_ptr1($ndr, $var_name));");
+       } elsif ($l->{POINTER_TYPE} eq "relative_short") {
+               $self->pidl("NDR_CHECK(ndr_push_short_relative_ptr1($ndr, $var_name));");
        } elsif ($l->{POINTER_TYPE} eq "unique") {
                $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));");
        } elsif ($l->{POINTER_TYPE} eq "full") {
        } elsif ($l->{POINTER_TYPE} eq "unique") {
                $self->pidl("NDR_CHECK(ndr_push_unique_ptr($ndr, $var_name));");
        } elsif ($l->{POINTER_TYPE} eq "full") {
@@ -1038,7 +1043,7 @@ sub ParseElementPullLevel
                        $self->pidl("if ($var_name) {");
                        $self->indent;
 
                        $self->pidl("if ($var_name) {");
                        $self->indent;
 
-                       if ($l->{POINTER_TYPE} eq "relative") {
+                       if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
                                $self->pidl("uint32_t _relative_save_offset;");
                                $self->pidl("_relative_save_offset = $ndr->offset;");
                                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2($ndr, $var_name));");
                                $self->pidl("uint32_t _relative_save_offset;");
                                $self->pidl("_relative_save_offset = $ndr->offset;");
                                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr2($ndr, $var_name));");
@@ -1170,6 +1175,8 @@ sub ParsePtrPull($$$$$)
                 ($l->{POINTER_TYPE} eq "relative") or
                 ($l->{POINTER_TYPE} eq "full")) {
                $self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));");
                 ($l->{POINTER_TYPE} eq "relative") or
                 ($l->{POINTER_TYPE} eq "full")) {
                $self->pidl("NDR_CHECK(ndr_pull_generic_ptr($ndr, &_ptr_$e->{NAME}));");
+       } elsif ($l->{POINTER_TYPE} eq "relative_short") {
+               $self->pidl("NDR_CHECK(ndr_pull_relative_ptr_short($ndr, &_ptr_$e->{NAME}));");
        } else {
                die("Unhandled pointer type $l->{POINTER_TYPE}");
        }
        } else {
                die("Unhandled pointer type $l->{POINTER_TYPE}");
        }
@@ -1190,7 +1197,7 @@ sub ParsePtrPull($$$$$)
        }
 
        #$self->pidl("memset($var_name, 0, sizeof($var_name));");
        }
 
        #$self->pidl("memset($var_name, 0, sizeof($var_name));");
-       if ($l->{POINTER_TYPE} eq "relative") {
+       if ($l->{POINTER_TYPE} eq "relative" or $l->{POINTER_TYPE} eq "relative_short") {
                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr1($ndr, $var_name, _ptr_$e->{NAME}));");
        }
        $self->deindent;
                $self->pidl("NDR_CHECK(ndr_pull_relative_ptr1($ndr, $var_name, _ptr_$e->{NAME}));");
        }
        $self->deindent;
@@ -1471,9 +1478,13 @@ sub DeclarePtrVariables($$)
 {
        my ($self,$e) = @_;
        foreach my $l (@{$e->{LEVELS}}) {
 {
        my ($self,$e) = @_;
        foreach my $l (@{$e->{LEVELS}}) {
+               my $size = 32;
                if ($l->{TYPE} eq "POINTER" and 
                        not ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP")) {
                if ($l->{TYPE} eq "POINTER" and 
                        not ($l->{POINTER_TYPE} eq "ref" and $l->{LEVEL} eq "TOP")) {
-                       $self->pidl("uint32_t _ptr_$e->{NAME};");
+                       if ($l->{POINTER_TYPE} eq "relative_short") {
+                               $size = 16;
+                       }
+                       $self->pidl("uint${size}_t _ptr_$e->{NAME};");
                        last;
                }
        }
                        last;
                }
        }