summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr/ndr_basic.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/librpc/ndr/ndr_basic.c')
-rw-r--r--source4/librpc/ndr/ndr_basic.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c
index 2276b76e95..3cb9e38749 100644
--- a/source4/librpc/ndr/ndr_basic.c
+++ b/source4/librpc/ndr/ndr_basic.c
@@ -117,6 +117,39 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, char *data, uint32 n)
/*
+ pull an array of uint16
+*/
+NTSTATUS ndr_pull_array_uint16(struct ndr_pull *ndr, uint16 *data, uint32 n)
+{
+ uint32 len, i;
+ NDR_CHECK(ndr_pull_uint32(ndr, &len));
+ if (len != n) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ for (i=0;i<n;i++) {
+ NDR_CHECK(ndr_pull_uint16(ndr, &data[i]));
+ }
+ return NT_STATUS_OK;
+}
+
+/*
+ pull an array of uint32
+*/
+NTSTATUS ndr_pull_array_uint32(struct ndr_pull *ndr, uint32 *data, uint32 n)
+{
+ uint32 len, i;
+ NDR_CHECK(ndr_pull_uint32(ndr, &len));
+ if (len != n) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+ for (i=0;i<n;i++) {
+ NDR_CHECK(ndr_pull_uint32(ndr, &data[i]));
+ }
+ return NT_STATUS_OK;
+}
+
+
+/*
parse a GUID
*/
NTSTATUS ndr_pull_guid(struct ndr_pull *ndr, GUID *guid)
@@ -428,3 +461,21 @@ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16 level)
{
ndr->print(ndr, "UNKNOWN LEVEL %u", level);
}
+
+void ndr_print_array_uint32(struct ndr_print *ndr, const char *name,
+ uint32 *data, uint32 count)
+{
+ int i;
+
+ ndr->print(ndr, "%s: ARRAY(%d)", name, count);
+ ndr->depth++;
+ for (i=0;i<count;i++) {
+ char *idx=NULL;
+ asprintf(&idx, "[%d]", i);
+ if (idx) {
+ ndr_print_uint32(ndr, idx, data[i]);
+ free(idx);
+ }
+ }
+ ndr->depth--;
+}