{
struct ndr_print *ndr;
- ndr = talloc(NULL, struct ndr_print);
+ ndr = talloc_zero(NULL, struct ndr_print);
if (!ndr) return;
ndr->print = ndr_print_debug_helper;
ndr->depth = 1;
ndr->flags = 0;
- ndr->switch_list = talloc(ndr, struct ndr_token_list);
- if (!ndr->switch_list)
- goto fail;
fn(ndr, name, ptr);
-fail:
talloc_free(ndr);
}
{
struct ndr_print *ndr;
- ndr = talloc(NULL, struct ndr_print);
+ ndr = talloc_zero(NULL, struct ndr_print);
if (!ndr) return;
ndr->print = ndr_print_debug_helper;
ndr->depth = 1;
return ndr_token_store(ndr, &ndr->switch_list, p, val);
}
+NTSTATUS ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val)
+{
+ return ndr_token_store(ndr, &ndr->switch_list, p, val);
+}
+
/*
retrieve a switch value
*/
return ndr_token_peek(&ndr->switch_list, p);
}
-NTSTATUS ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val)
-{
- return ndr_token_store(ndr, &ndr->switch_list, p, val);
-}
-
-/*
- retrieve a switch value
- */
uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p)
{
return ndr_token_peek(&ndr->switch_list, p);
return fn(ndr, NDR_SCALARS|NDR_BUFFERS, p);
}
+/*
+ pull a struct from a blob using NDR - failing if all bytes are not consumed
+*/
+NTSTATUS ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
+ ndr_pull_flags_fn_t fn)
+{
+ struct ndr_pull *ndr;
+ NTSTATUS status;
+
+ ndr = ndr_pull_init_blob(blob, mem_ctx);
+ if (!ndr) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ status = fn(ndr, NDR_SCALARS|NDR_BUFFERS, p);
+ if (!NT_STATUS_IS_OK(status)) return status;
+ if (ndr->offset != ndr->data_size) {
+ return NT_STATUS_BUFFER_TOO_SMALL;
+ }
+ return status;
+}
+
/*
push a struct to a blob using NDR
*/