diff options
Diffstat (limited to 'source4/librpc/ndr/ndr_basic.c')
-rw-r--r-- | source4/librpc/ndr/ndr_basic.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 0cb4456399..49cff11480 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -338,6 +338,22 @@ NTSTATUS ndr_push_unistr(struct ndr_push *ndr, const char *s) } /* + push a comformant, variable ascii string onto the wire from a C string + TODO: need to look at what charset this should be in +*/ +NTSTATUS ndr_push_ascstr(struct ndr_push *ndr, const char *s) +{ + ssize_t len = s?strlen(s):0; + NDR_CHECK(ndr_push_uint32(ndr, len)); + NDR_CHECK(ndr_push_uint32(ndr, 0)); + NDR_CHECK(ndr_push_uint32(ndr, len?len+1:0)); + if (s) { + NDR_CHECK(ndr_push_bytes(ndr, s, len)); + } + return NT_STATUS_OK; +} + +/* push a comformant, variable ucs2 string onto the wire from a C string don't send the null */ @@ -383,6 +399,29 @@ NTSTATUS ndr_pull_unistr(struct ndr_pull *ndr, const char **s) } /* + pull a comformant, variable ascii string from the wire into a C string + TODO: check what charset this is in +*/ +NTSTATUS ndr_pull_ascstr(struct ndr_pull *ndr, const char **s) +{ + uint32 len1, ofs, len2; + char *as; + + NDR_CHECK(ndr_pull_uint32(ndr, &len1)); + NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); + NDR_CHECK(ndr_pull_uint32(ndr, &len2)); + if (len2 > len1) { + return NT_STATUS_INVALID_PARAMETER; + } + NDR_ALLOC_N(ndr, as, (len1+1)); + NDR_CHECK(ndr_pull_bytes(ndr, as, len2)); + as[len2] = 0; + as[len1] = 0; + (*s) = as; + return NT_STATUS_OK; +} + +/* pull a comformant, variable ucs2 string from the wire into a C string */ NTSTATUS ndr_pull_unistr_noterm(struct ndr_pull *ndr, const char **s) @@ -498,6 +537,11 @@ void ndr_print_unistr_noterm(struct ndr_print *ndr, const char *name, const char ndr_print_unistr(ndr, name, s); } +void ndr_print_ascstr(struct ndr_print *ndr, const char *name, const char *s) +{ + ndr_print_unistr(ndr, name, s); +} + void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t) { ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr->mem_ctx, &t)); @@ -705,27 +749,6 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, DATA_BLOB *blob) } -/* - parse a policy handle -*/ -NTSTATUS ndr_pull_policy_handle(struct ndr_pull *ndr, - struct policy_handle *r) -{ - NDR_CHECK(ndr_pull_bytes(ndr, r->data, 20)); - return NT_STATUS_OK; -} - -/* - push a policy handle -*/ -NTSTATUS ndr_push_policy_handle(struct ndr_push *ndr, - struct policy_handle *r) -{ - NDR_CHECK(ndr_push_bytes(ndr, r->data, 20)); - return NT_STATUS_OK; -} - - void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, struct policy_handle *r) { ndr->print(ndr, "%-25s: policy_handle %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", |