From ea923fb4a26f88664a1db36e1a93a2c96239a7a4 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 21 Jan 2005 06:54:10 +0000 Subject: r4885: added a new NBT client library. Features include: - structures defined using IDL in nbt.idl - build around our events structure, and talloc - fully async - supports all NBT packet fields as per rfc1002 - easy interfaces for name query and status For the moment there are just a couple of test functions in namequery.c, test_name_query() and test_name_status(). These will be removed when we hook the new library into libcli/ fully The new library will also be a fairly good basis for a nbt server. Although it can't be a server as-is, I wrote it with the needs of a server in mind (for example, extremely scalable idtree based packet handling) (This used to be commit ae7e625bfa4b4a3ee32c64566064b6a4c84ee4b9) --- source4/librpc/ndr/ndr_basic.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) (limited to 'source4/librpc/ndr/ndr_basic.c') diff --git a/source4/librpc/ndr/ndr_basic.c b/source4/librpc/ndr/ndr_basic.c index 29a3009af6..6476f58764 100644 --- a/source4/librpc/ndr/ndr_basic.c +++ b/source4/librpc/ndr/ndr_basic.c @@ -718,8 +718,9 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = as; break; + case LIBNDR_FLAG_STR_FIXLEN15: case LIBNDR_FLAG_STR_FIXLEN32: - len1 = 32; + len1 = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; NDR_PULL_NEED_BYTES(ndr, len1*byte_mul); ret = convert_string_talloc(ndr, chset, CH_UNIX, ndr->data+ndr->offset, @@ -733,7 +734,6 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) *s = as; break; - default: return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n", ndr->flags & LIBNDR_STRING_FLAGS); @@ -748,7 +748,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s) */ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) { - ssize_t s_len, c_len; + ssize_t s_len, c_len, d_len; int ret; int chset = CH_UTF16; unsigned flags = ndr->flags; @@ -882,16 +882,18 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s) ndr->offset += c_len*byte_mul; break; + case LIBNDR_FLAG_STR_FIXLEN15: case LIBNDR_FLAG_STR_FIXLEN32: - NDR_PUSH_NEED_BYTES(ndr, byte_mul*32); + d_len = (flags & LIBNDR_FLAG_STR_FIXLEN32)?32:15; + NDR_PUSH_NEED_BYTES(ndr, byte_mul*d_len); ret = convert_string(CH_UNIX, chset, s, s_len + 1, - ndr->data+ndr->offset, byte_mul*32); + ndr->data+ndr->offset, byte_mul*d_len); if (ret == -1) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } - ndr->offset += byte_mul*32; + ndr->offset += byte_mul*d_len; break; default: @@ -915,6 +917,9 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s) if (flags & LIBNDR_FLAG_STR_FIXLEN32) { return 32; } + if (flags & LIBNDR_FLAG_STR_FIXLEN15) { + return 15; + } c_len = s?strlen_m(s):0; @@ -1029,11 +1034,18 @@ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type, void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint_t flag, uint_t value) { - /* size can be later used to print something like: - * ...1.... .........: FLAG1_NAME - * .....0.. .........: FLAG2_NAME - */ - ndr->print(ndr, "%s: %-25s", (flag & value)?"1":"0", flag_name); + /* this is an attempt to support multi-bit bitmap masks */ + value &= flag; + + while (!(flag & 1)) { + flag >>= 1; + value >>= 1; + } + if (flag == 1) { + ndr->print(ndr, " %d: %-25s", value, flag_name); + } else { + ndr->print(ndr, "0x%02x: %-25s (%d)", value, flag_name, value); + } } void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v) -- cgit