summaryrefslogtreecommitdiff
path: root/librpc/ndr/ndr_basic.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2009-09-17 09:08:47 -0700
committerAndrew Tridgell <tridge@samba.org>2009-09-17 15:19:27 -0700
commit056cbf7f816a6d01bc0ef3105eca43b4aeee9116 (patch)
tree92e7c1aeabe92d2bb5e53ae13c00c3eca3625c85 /librpc/ndr/ndr_basic.c
parent7326b8f63ebe55bdf662c6f7798cbeeb026b033a (diff)
downloadsamba-056cbf7f816a6d01bc0ef3105eca43b4aeee9116.tar.gz
samba-056cbf7f816a6d01bc0ef3105eca43b4aeee9116.tar.bz2
samba-056cbf7f816a6d01bc0ef3105eca43b4aeee9116.zip
ndr: added support for NDR64
This adds NDR64 support for the push functions in libndr
Diffstat (limited to 'librpc/ndr/ndr_basic.c')
-rw-r--r--librpc/ndr/ndr_basic.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index 6781ccda2e..efadb1e95e 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -132,14 +132,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint3264(struct ndr_pull *ndr, int ndr_flags
{
uint64_t v64;
enum ndr_err_code err;
- if (!(ndr->flags & LIBNDR_FLAG_NDR64)) {
+ if (likely(!(ndr->flags & LIBNDR_FLAG_NDR64))) {
return ndr_pull_uint32(ndr, ndr_flags, v);
}
err = ndr_pull_hyper(ndr, ndr_flags, &v64);
*v = (uint32_t)v64;
- if (v64 != *v) {
+ if (unlikely(v64 != *v)) {
DEBUG(0,(__location__ ": non-zero upper 32 bits 0x%016llx\n",
(unsigned long long)v64));
+ return NDR_ERR_NDR64;
}
return err;
}
@@ -377,6 +378,21 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags,
}
/*
+ push a uint3264
+*/
+_PUBLIC_ enum ndr_err_code ndr_push_uint3264(struct ndr_push *ndr, int ndr_flags, uint32_t v)
+{
+ if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) {
+ return ndr_push_hyper(ndr, ndr_flags, v);
+ }
+ NDR_PUSH_ALIGN(ndr, 4);
+ NDR_PUSH_NEED_BYTES(ndr, 4);
+ NDR_SIVAL(ndr, ndr->offset, v);
+ ndr->offset += 4;
+ return NDR_ERR_SUCCESS;
+}
+
+/*
push a udlong
*/
_PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v)
@@ -446,12 +462,28 @@ _PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags,
_PUBLIC_ enum ndr_err_code ndr_push_align(struct ndr_push *ndr, size_t size)
{
+ /* this is a nasty hack to make pidl work with NDR64 */
+ if (size == 5) {
+ if (ndr->flags & LIBNDR_FLAG_NDR64) {
+ size = 8;
+ } else {
+ size = 4;
+ }
+ }
NDR_PUSH_ALIGN(ndr, size);
return NDR_ERR_SUCCESS;
}
_PUBLIC_ enum ndr_err_code ndr_pull_align(struct ndr_pull *ndr, size_t size)
{
+ /* this is a nasty hack to make pidl work with NDR64 */
+ if (size == 5) {
+ if (ndr->flags & LIBNDR_FLAG_NDR64) {
+ size = 8;
+ } else {
+ size = 4;
+ }
+ }
NDR_PULL_ALIGN(ndr, size);
return NDR_ERR_SUCCESS;
}
@@ -500,7 +532,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_unique_ptr(struct ndr_push *ndr, const void
ptr |= 0x00020000;
ndr->ptr_count++;
}
- return ndr_push_uint32(ndr, NDR_SCALARS, ptr);
+ return ndr_push_uint3264(ndr, NDR_SCALARS, ptr);
}
/*
@@ -518,7 +550,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p
ndr_token_store(ndr, &ndr->full_ptr_list, p, ptr);
}
}
- return ndr_push_uint32(ndr, NDR_SCALARS, ptr);
+ return ndr_push_uint3264(ndr, NDR_SCALARS, ptr);
}
/*
@@ -526,7 +558,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_full_ptr(struct ndr_push *ndr, const void *p
*/
_PUBLIC_ enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr)
{
- return ndr_push_uint32(ndr, NDR_SCALARS, 0xAEF1AEF1);
+ return ndr_push_uint3264(ndr, NDR_SCALARS, 0xAEF1AEF1);
}