diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-09-16 23:57:32 -0700 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-09-16 23:59:53 -0700 |
commit | 9407ab573e492c8ab01c2694d3e6f31924bbb0f8 (patch) | |
tree | d388c12ed31c2eec373cc76029455835131b3def /librpc/ndr | |
parent | 99c3fc19587431efda1ae6161453d84673b32071 (diff) | |
download | samba-9407ab573e492c8ab01c2694d3e6f31924bbb0f8.tar.gz samba-9407ab573e492c8ab01c2694d3e6f31924bbb0f8.tar.bz2 samba-9407ab573e492c8ab01c2694d3e6f31924bbb0f8.zip |
ndr: added --ndr64 flag to ndrdump
This only does pull, but it is useful for w2k8-r2 <-> w2k8-r2 ndrdump
usage, which is always 64bit.
Diffstat (limited to 'librpc/ndr')
-rw-r--r-- | librpc/ndr/libndr.h | 3 | ||||
-rw-r--r-- | librpc/ndr/ndr.c | 6 | ||||
-rw-r--r-- | librpc/ndr/ndr_basic.c | 24 |
3 files changed, 28 insertions, 5 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index d01b68ef51..1868af6104 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -141,6 +141,8 @@ struct ndr_print { /* used to check if alignment padding is zero */ #define LIBNDR_FLAG_PAD_CHECK (1<<28) +#define LIBNDR_FLAG_NDR64 (1<<29) + /* set if an object uuid will be present */ #define LIBNDR_FLAG_OBJECT_PRESENT (1<<30) @@ -465,6 +467,7 @@ NDR_SCALAR_PROTO(int8, int8_t) NDR_SCALAR_PROTO(uint16, uint16_t) NDR_SCALAR_PROTO(int16, int16_t) NDR_SCALAR_PROTO(uint32, uint32_t) +NDR_SCALAR_PROTO(uint3264, uint32_t) NDR_SCALAR_PROTO(int32, int32_t) NDR_SCALAR_PROTO(udlong, uint64_t) NDR_SCALAR_PROTO(udlongr, uint64_t) diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c index 2b3493b2e3..ef318d64d2 100644 --- a/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -736,7 +736,7 @@ _PUBLIC_ uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key) _PUBLIC_ enum ndr_err_code ndr_pull_array_size(struct ndr_pull *ndr, const void *p) { uint32_t size; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &size)); + NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &size)); return ndr_token_store(ndr, &ndr->array_size_list, p, size); } @@ -769,12 +769,12 @@ _PUBLIC_ enum ndr_err_code ndr_check_array_size(struct ndr_pull *ndr, void *p, u _PUBLIC_ enum ndr_err_code ndr_pull_array_length(struct ndr_pull *ndr, const void *p) { uint32_t length, offset; - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &offset)); + NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &offset)); if (offset != 0) { return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, "non-zero array offset %u\n", offset); } - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &length)); + NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, &length)); return ndr_token_store(ndr, &ndr->array_length_list, p, length); } diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c index d46590f0cb..fad66687f7 100644 --- a/librpc/ndr/ndr_basic.c +++ b/librpc/ndr/ndr_basic.c @@ -118,6 +118,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, i */ _PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) { + uint32_t v2; NDR_PULL_ALIGN(ndr, 4); NDR_PULL_NEED_BYTES(ndr, 4); *v = NDR_IVAL(ndr, ndr->offset); @@ -126,6 +127,25 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, } /* + parse a arch dependent uint32/uint64 +*/ +_PUBLIC_ enum ndr_err_code ndr_pull_uint3264(struct ndr_pull *ndr, int ndr_flags, uint32_t *v) +{ + uint64_t v64; + enum ndr_err_code err; + if (!(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) { + DEBUG(0,(__location__ ": non-zero upper 32 bits 0x%016llx\n", + (unsigned long long)v64)); + } + return err; +} + +/* parse a double */ _PUBLIC_ enum ndr_err_code ndr_pull_double(struct ndr_pull *ndr, int ndr_flags, double *v) @@ -142,7 +162,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_double(struct ndr_pull *ndr, int ndr_flags, */ _PUBLIC_ enum ndr_err_code ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); + NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, v)); if (*v != 0) { ndr->ptr_count++; } @@ -154,7 +174,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t * */ _PUBLIC_ enum ndr_err_code ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v) { - NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v)); + NDR_CHECK(ndr_pull_uint3264(ndr, NDR_SCALARS, v)); /* ref pointers always point to data */ *v = 1; return NDR_ERR_SUCCESS; |