auth: Move auth_session_info into IDL
[sfrench/samba-autobuild/.git] / librpc / ndr / ndr.c
index 14f9e063379b90c0fe06df7dabb0138b0048503a..56d1fab05e4b2b778f558eb84d8eff204dfeacc5 100644 (file)
@@ -829,6 +829,40 @@ _PUBLIC_ enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p,
        return NDR_ERR_SUCCESS;
 }
 
+_PUBLIC_ enum ndr_err_code ndr_push_pipe_chunk_trailer(struct ndr_push *ndr, int ndr_flags, uint32_t count)
+{
+       if (ndr->flags & LIBNDR_FLAG_NDR64) {
+               int64_t tmp = 0 - (int64_t)count;
+               uint64_t ncount = tmp;
+
+               NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, ncount));
+       }
+
+       return NDR_ERR_SUCCESS;
+}
+
+_PUBLIC_ enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_flags, uint32_t count)
+{
+       if (ndr->flags & LIBNDR_FLAG_NDR64) {
+               int64_t tmp = 0 - (int64_t)count;
+               uint64_t ncount1 = tmp;
+               uint64_t ncount2;
+
+               NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &ncount2));
+               if (ncount1 == ncount2) {
+                       return NDR_ERR_SUCCESS;
+               }
+
+               return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE,
+                       "Bad pipe trailer[%lld should be %lld] size was %lu\"",
+                       (unsigned long long)ncount2,
+                       (unsigned long long)ncount1,
+                       (unsigned long)count);
+       }
+
+       return NDR_ERR_SUCCESS;
+}
+
 /*
   store a switch value
  */
@@ -1181,8 +1215,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, co
        if (!(ndr->flags & LIBNDR_FLAG_RELATIVE_REVERSE)) {
                uint32_t relative_offset;
                size_t pad;
-               /* TODO: remove this hack and let the idl use FLAG_ALIGN2 explicit */
-               size_t align = 2;
+               size_t align = 1;
 
                if (ndr->offset < ndr->relative_base_offset) {
                        return ndr_push_error(ndr, NDR_ERR_BUFSIZE,
@@ -1192,7 +1225,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_start(struct ndr_push *ndr, co
 
                relative_offset = ndr->offset - ndr->relative_base_offset;
 
-               if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
+               if (ndr->flags & LIBNDR_FLAG_NOALIGN) {
+                       align = 1;
+               } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                        align = 2;
                } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
                        align = 4;
@@ -1271,10 +1306,9 @@ _PUBLIC_ enum ndr_err_code ndr_push_relative_ptr2_end(struct ndr_push *ndr, cons
        /* the reversed offset is at the end of the main buffer */
        correct_offset = ndr->relative_end_offset - len;
 
-       /* TODO: remove this hack and let the idl use FLAG_ALIGN2 explicit */
-       align = 2;
-
-       if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
+       if (ndr->flags & LIBNDR_FLAG_NOALIGN) {
+               align = 1;
+       } else if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
                align = 2;
        } else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
                align = 4;