summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-08 15:13:41 -0800
committerJeremy Allison <jra@samba.org>2007-11-08 15:13:41 -0800
commit976b0ec487720982e456f8c3634be3df64882dae (patch)
treef7a9883ae8988f42ef98aa612e433e0c9613a03b /source3
parente501c0cd44116ee6e42c14100fea526558c37cb2 (diff)
parent128fa582a62ad3e145c2bda93e4f939d5f62885f (diff)
downloadsamba-976b0ec487720982e456f8c3634be3df64882dae.tar.gz
samba-976b0ec487720982e456f8c3634be3df64882dae.tar.bz2
samba-976b0ec487720982e456f8c3634be3df64882dae.zip
Merge branch 'v3-2-test' of ssh://jra@git.samba.org/data/git/samba into v3-2-test
(This used to be commit d9335456d23271a4b15b97d24f1b263700a3b9df)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/interfaces.h1
-rw-r--r--source3/lib/replace/getaddrinfo.m42
-rw-r--r--source3/librpc/ndr/libndr.h18
-rw-r--r--source3/librpc/ndr/ndr.c203
-rw-r--r--source3/librpc/ndr/ndr_basic.c175
-rw-r--r--source3/librpc/ndr/ndr_string.c214
-rw-r--r--source3/libsmb/doserr.c6
-rw-r--r--source3/param/loadparm.c9
-rw-r--r--source3/script/mkproto.awk4
-rw-r--r--source3/smbd/oplock_irix.c4
-rw-r--r--source3/smbd/reply.c22
11 files changed, 422 insertions, 236 deletions
diff --git a/source3/include/interfaces.h b/source3/include/interfaces.h
index b9d900053d..84501cee41 100644
--- a/source3/include/interfaces.h
+++ b/source3/include/interfaces.h
@@ -25,6 +25,7 @@
#define _INTERFACES_H
#include "lib/replace/replace.h"
+#include "lib/replace/system/network.h"
#define MAX_INTERFACES 128
diff --git a/source3/lib/replace/getaddrinfo.m4 b/source3/lib/replace/getaddrinfo.m4
index 92620aa3d0..bc6e69ea56 100644
--- a/source3/lib/replace/getaddrinfo.m4
+++ b/source3/lib/replace/getaddrinfo.m4
@@ -1,6 +1,6 @@
dnl test for getaddrinfo/getnameinfo
AC_CACHE_CHECK([for getaddrinfo],libreplace_cv_HAVE_GETADDRINFO,[
-AC_TRY_COMPILE([
+AC_TRY_LINK([
#include <sys/types.h>
#if STDC_HEADERS
#include <stdlib.h>
diff --git a/source3/librpc/ndr/libndr.h b/source3/librpc/ndr/libndr.h
index f09693feb8..518b4a5a37 100644
--- a/source3/librpc/ndr/libndr.h
+++ b/source3/librpc/ndr/libndr.h
@@ -104,7 +104,7 @@ struct ndr_print {
uint32_t flags; /* LIBNDR_FLAG_* */
uint32_t depth;
struct ndr_token_list *switch_list;
- void (*print)(struct ndr_print *, const char *, ...);
+ void (*print)(struct ndr_print *, const char *, ...) PRINTF_ATTRIBUTE(2,3);
void *private_data;
};
@@ -244,7 +244,7 @@ enum ndr_compression_alg {
if (!(mem_ctx)) {\
return ndr_pull_error(ndr, NDR_ERR_ALLOC, "NDR_PULL_SET_MEM_CTX(NULL): %s\n", __location__); \
}\
- ndr->current_mem_ctx = CONST_DISCARD(TALLOC_CTX *, mem_ctx);\
+ ndr->current_mem_ctx = discard_const(mem_ctx);\
}\
} while(0)
@@ -271,7 +271,7 @@ enum ndr_compression_alg {
#define NDR_PUSH_ALLOC_SIZE(ndr, s, size) do { \
- (s) = talloc_array(ndr, uint8, size); \
+ (s) = talloc_array(ndr, uint8_t, size); \
if (!(s)) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %u failed: %s\n", (unsigned)size, __location__); \
} while (0)
@@ -290,12 +290,12 @@ extern const struct ndr_syntax_id ndr_transfer_syntax;
extern const struct ndr_syntax_id ndr64_transfer_syntax;
struct ndr_interface_call {
- const char *name;
- size_t struct_size;
- ndr_push_flags_fn_t ndr_push;
- ndr_pull_flags_fn_t ndr_pull;
- ndr_print_function_t ndr_print;
- bool async;
+ const char *name;
+ size_t struct_size;
+ ndr_push_flags_fn_t ndr_push;
+ ndr_pull_flags_fn_t ndr_pull;
+ ndr_print_function_t ndr_print;
+ bool async;
};
struct ndr_interface_string_array {
diff --git a/source3/librpc/ndr/ndr.c b/source3/librpc/ndr/ndr.c
index 1538891320..5e4997c4ab 100644
--- a/source3/librpc/ndr/ndr.c
+++ b/source3/librpc/ndr/ndr.c
@@ -44,7 +44,7 @@ const struct ndr_syntax_id ndr64_transfer_syntax = {
/*
work out the number of bytes needed to align on a n byte boundary
*/
-size_t ndr_align_size(uint32_t offset, size_t n)
+_PUBLIC_ size_t ndr_align_size(uint32_t offset, size_t n)
{
if ((offset & (n-1)) == 0) return 0;
return n - (offset & (n-1));
@@ -53,7 +53,7 @@ size_t ndr_align_size(uint32_t offset, size_t n)
/*
initialise a ndr parse structure from a data blob
*/
-struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
+_PUBLIC_ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
{
struct ndr_pull *ndr;
@@ -70,7 +70,7 @@ struct ndr_pull *ndr_pull_init_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx)
/*
advance by 'size' bytes
*/
-NTSTATUS ndr_pull_advance(struct ndr_pull *ndr, uint32_t size)
+_PUBLIC_ NTSTATUS ndr_pull_advance(struct ndr_pull *ndr, uint32_t size)
{
ndr->offset += size;
if (ndr->offset > ndr->data_size) {
@@ -96,14 +96,14 @@ static NTSTATUS ndr_pull_set_offset(struct ndr_pull *ndr, uint32_t ofs)
}
/* save the offset/size of the current ndr state */
-void ndr_pull_save(struct ndr_pull *ndr, struct ndr_pull_save *save)
+_PUBLIC_ void ndr_pull_save(struct ndr_pull *ndr, struct ndr_pull_save *save)
{
save->offset = ndr->offset;
save->data_size = ndr->data_size;
}
/* restore the size/offset of a ndr structure */
-void ndr_pull_restore(struct ndr_pull *ndr, struct ndr_pull_save *save)
+_PUBLIC_ void ndr_pull_restore(struct ndr_pull *ndr, struct ndr_pull_save *save)
{
ndr->offset = save->offset;
ndr->data_size = save->data_size;
@@ -111,7 +111,7 @@ void ndr_pull_restore(struct ndr_pull *ndr, struct ndr_pull_save *save)
/* create a ndr_push structure, ready for some marshalling */
-struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
+_PUBLIC_ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
{
struct ndr_push *ndr;
@@ -130,27 +130,11 @@ struct ndr_push *ndr_push_init_ctx(TALLOC_CTX *mem_ctx)
return ndr;
}
-
-/* create a ndr_push structure, ready for some marshalling */
-struct ndr_push *ndr_push_init(void)
-{
- return ndr_push_init_ctx(NULL);
-}
-
-/* free a ndr_push structure */
-void ndr_push_free(struct ndr_push *ndr)
-{
- talloc_free(ndr);
-}
-
-
/* return a DATA_BLOB structure for the current ndr_push marshalled data */
-DATA_BLOB ndr_push_blob(struct ndr_push *ndr)
+_PUBLIC_ DATA_BLOB ndr_push_blob(struct ndr_push *ndr)
{
DATA_BLOB blob;
- blob.data = ndr->data;
- blob.length = ndr->offset;
- blob.free = NULL;
+ blob = data_blob_const(ndr->data, ndr->offset);
if (ndr->alloc_size > ndr->offset) {
ndr->data[ndr->offset] = 0;
}
@@ -161,7 +145,7 @@ DATA_BLOB ndr_push_blob(struct ndr_push *ndr)
/*
expand the available space in the buffer to ndr->offset + extra_size
*/
-NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size)
+_PUBLIC_ NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size)
{
uint32_t size = extra_size + ndr->offset;
@@ -188,7 +172,7 @@ NTSTATUS ndr_push_expand(struct ndr_push *ndr, uint32_t extra_size)
return NT_STATUS_OK;
}
-void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
+_PUBLIC_ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
{
va_list ap;
char *s = NULL;
@@ -206,28 +190,28 @@ void ndr_print_debug_helper(struct ndr_print *ndr, const char *format, ...) _PRI
free(s);
}
-static void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
+_PUBLIC_ void ndr_print_string_helper(struct ndr_print *ndr, const char *format, ...) _PRINTF_ATTRIBUTE(2,3)
{
va_list ap;
int i;
for (i=0;i<ndr->depth;i++) {
- ndr->private_data = talloc_asprintf_append(
- (char *)ndr->private_data, " ");
+ ndr->private_data = talloc_asprintf_append_buffer(
+ (char *)ndr->private_data, " ");
}
va_start(ap, format);
- ndr->private_data = talloc_vasprintf_append(
- (char *)ndr->private_data, format, ap);
+ ndr->private_data = talloc_vasprintf_append_buffer((char *)ndr->private_data,
+ format, ap);
va_end(ap);
- ndr->private_data = talloc_asprintf_append(
- (char *)ndr->private_data, "\n");
+ ndr->private_data = talloc_asprintf_append_buffer((char *)ndr->private_data,
+ "\n");
}
/*
a useful helper function for printing idl structures via DEBUG()
*/
-void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr)
+_PUBLIC_ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr)
{
struct ndr_print *ndr;
@@ -243,7 +227,7 @@ void ndr_print_debug(ndr_print_fn_t fn, const char *name, void *ptr)
/*
a useful helper function for printing idl unions via DEBUG()
*/
-void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr)
+_PUBLIC_ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr)
{
struct ndr_print *ndr;
@@ -260,7 +244,7 @@ void ndr_print_union_debug(ndr_print_fn_t fn, const char *name, uint32_t level,
/*
a useful helper function for printing idl function calls via DEBUG()
*/
-void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr)
+_PUBLIC_ void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int flags, void *ptr)
{
struct ndr_print *ndr;
@@ -273,11 +257,59 @@ void ndr_print_function_debug(ndr_print_function_t fn, const char *name, int fla
talloc_free(ndr);
}
+/*
+ a useful helper function for printing idl structures to a string
+*/
+_PUBLIC_ char *ndr_print_struct_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, void *ptr)
+{
+ struct ndr_print *ndr;
+ char *ret = NULL;
+
+ ndr = talloc_zero(mem_ctx, struct ndr_print);
+ if (!ndr) return NULL;
+ ndr->private_data = talloc_strdup(ndr, "");
+ if (!ndr->private_data) {
+ goto failed;
+ }
+ ndr->print = ndr_print_string_helper;
+ ndr->depth = 1;
+ ndr->flags = 0;
+ fn(ndr, name, ptr);
+ ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
+failed:
+ talloc_free(ndr);
+ return ret;
+}
+
+/*
+ a useful helper function for printing idl unions to a string
+*/
+_PUBLIC_ char *ndr_print_union_string(TALLOC_CTX *mem_ctx, ndr_print_fn_t fn, const char *name, uint32_t level, void *ptr)
+{
+ struct ndr_print *ndr;
+ char *ret = NULL;
+
+ ndr = talloc_zero(mem_ctx, struct ndr_print);
+ if (!ndr) return NULL;
+ ndr->private_data = talloc_strdup(ndr, "");
+ if (!ndr->private_data) {
+ goto failed;
+ }
+ ndr->print = ndr_print_string_helper;
+ ndr->depth = 1;
+ ndr->flags = 0;
+ ndr_print_set_switch_value(ndr, ptr, level);
+ fn(ndr, name, ptr);
+ ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
+failed:
+ talloc_free(ndr);
+ return ret;
+}
/*
a useful helper function for printing idl function calls to a string
*/
-char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
+_PUBLIC_ char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
ndr_print_function_t fn, const char *name,
int flags, void *ptr)
{
@@ -286,20 +318,21 @@ char *ndr_print_function_string(TALLOC_CTX *mem_ctx,
ndr = talloc_zero(mem_ctx, struct ndr_print);
if (!ndr) return NULL;
- if (!(ndr->private_data = talloc_strdup(mem_ctx, ""))) {
- TALLOC_FREE(ndr);
- return NULL;
+ ndr->private_data = talloc_strdup(ndr, "");
+ if (!ndr->private_data) {
+ goto failed;
}
ndr->print = ndr_print_string_helper;
ndr->depth = 1;
ndr->flags = 0;
fn(ndr, name, flags, ptr);
- ret = (char *)ndr->private_data;
+ ret = talloc_steal(mem_ctx, (char *)ndr->private_data);
+failed:
talloc_free(ndr);
return ret;
}
-void ndr_set_flags(uint32_t *pflags, uint32_t new_flags)
+_PUBLIC_ void ndr_set_flags(uint32_t *pflags, uint32_t new_flags)
{
/* the big/little endian flags are inter-dependent */
if (new_flags & LIBNDR_FLAG_LITTLE_ENDIAN) {
@@ -343,7 +376,7 @@ static NTSTATUS ndr_map_error(enum ndr_err_code ndr_err)
/*
return and possibly log an NDR error
*/
-NTSTATUS ndr_pull_error(struct ndr_pull *ndr,
+_PUBLIC_ NTSTATUS ndr_pull_error(struct ndr_pull *ndr,
enum ndr_err_code ndr_err,
const char *format, ...) _PRINTF_ATTRIBUTE(3,4)
{
@@ -364,7 +397,7 @@ NTSTATUS ndr_pull_error(struct ndr_pull *ndr,
/*
return and possibly log an NDR error
*/
-NTSTATUS ndr_push_error(struct ndr_push *ndr,
+_PUBLIC_ NTSTATUS ndr_push_error(struct ndr_push *ndr,
enum ndr_err_code ndr_err,
const char *format, ...) _PRINTF_ATTRIBUTE(3,4)
{
@@ -386,7 +419,7 @@ NTSTATUS ndr_push_error(struct ndr_push *ndr,
handle subcontext buffers, which in midl land are user-marshalled, but
we use magic in pidl to make them easier to cope with
*/
-NTSTATUS ndr_pull_subcontext_start(struct ndr_pull *ndr,
+_PUBLIC_ NTSTATUS ndr_pull_subcontext_start(struct ndr_pull *ndr,
struct ndr_pull **_subndr,
size_t header_size,
ssize_t size_is)
@@ -445,7 +478,7 @@ NTSTATUS ndr_pull_subcontext_start(struct ndr_pull *ndr,
return NT_STATUS_OK;
}
-NTSTATUS ndr_pull_subcontext_end(struct ndr_pull *ndr,
+_PUBLIC_ NTSTATUS ndr_pull_subcontext_end(struct ndr_pull *ndr,
struct ndr_pull *subndr,
size_t header_size,
ssize_t size_is)
@@ -462,7 +495,7 @@ NTSTATUS ndr_pull_subcontext_end(struct ndr_pull *ndr,
return NT_STATUS_OK;
}
-NTSTATUS ndr_push_subcontext_start(struct ndr_push *ndr,
+_PUBLIC_ NTSTATUS ndr_push_subcontext_start(struct ndr_push *ndr,
struct ndr_push **_subndr,
size_t header_size,
ssize_t size_is)
@@ -480,7 +513,7 @@ NTSTATUS ndr_push_subcontext_start(struct ndr_push *ndr,
/*
push a subcontext header
*/
-NTSTATUS ndr_push_subcontext_end(struct ndr_push *ndr,
+_PUBLIC_ NTSTATUS ndr_push_subcontext_end(struct ndr_push *ndr,
struct ndr_push *subndr,
size_t header_size,
ssize_t size_is)
@@ -519,7 +552,7 @@ NTSTATUS ndr_push_subcontext_end(struct ndr_push *ndr,
/*
store a token in the ndr context, for later retrieval
*/
-NTSTATUS ndr_token_store(TALLOC_CTX *mem_ctx,
+_PUBLIC_ NTSTATUS ndr_token_store(TALLOC_CTX *mem_ctx,
struct ndr_token_list **list,
const void *key,
uint32_t value)
@@ -536,7 +569,7 @@ NTSTATUS ndr_token_store(TALLOC_CTX *mem_ctx,
/*
retrieve a token from a ndr context, using cmp_fn to match the tokens
*/
-NTSTATUS ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v,
+_PUBLIC_ NTSTATUS ndr_token_retrieve_cmp_fn(struct ndr_token_list **list, const void *key, uint32_t *v,
comparison_fn_t _cmp_fn, bool _remove_tok)
{
struct ndr_token_list *tok;
@@ -557,15 +590,15 @@ found:
/*
retrieve a token from a ndr context
*/
-NTSTATUS ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v)
+_PUBLIC_ NTSTATUS ndr_token_retrieve(struct ndr_token_list **list, const void *key, uint32_t *v)
{
- return ndr_token_retrieve_cmp_fn(list, key, v, NULL, True);
+ return ndr_token_retrieve_cmp_fn(list, key, v, NULL, true);
}
/*
peek at but don't removed a token from a ndr context
*/
-uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key)
+_PUBLIC_ uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key)
{
NTSTATUS status;
uint32_t v;
@@ -581,7 +614,7 @@ uint32_t ndr_token_peek(struct ndr_token_list **list, const void *key)
/*
pull an array size field and add it to the array_size_list token list
*/
-NTSTATUS ndr_pull_array_size(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_pull_array_size(struct ndr_pull *ndr, const void *p)
{
uint32_t size;
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &size));
@@ -591,7 +624,7 @@ NTSTATUS ndr_pull_array_size(struct ndr_pull *ndr, const void *p)
/*
get the stored array size field
*/
-uint32_t ndr_get_array_size(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ uint32_t ndr_get_array_size(struct ndr_pull *ndr, const void *p)
{
return ndr_token_peek(&ndr->array_size_list, p);
}
@@ -599,7 +632,7 @@ uint32_t ndr_get_array_size(struct ndr_pull *ndr, const void *p)
/*
check the stored array size field
*/
-NTSTATUS ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t size)
+_PUBLIC_ NTSTATUS ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t size)
{
uint32_t stored;
stored = ndr_token_peek(&ndr->array_size_list, p);
@@ -614,7 +647,7 @@ NTSTATUS ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t size)
/*
pull an array length field and add it to the array_length_list token list
*/
-NTSTATUS ndr_pull_array_length(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_pull_array_length(struct ndr_pull *ndr, const void *p)
{
uint32_t length, offset;
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &offset));
@@ -629,7 +662,7 @@ NTSTATUS ndr_pull_array_length(struct ndr_pull *ndr, const void *p)
/*
get the stored array length field
*/
-uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p)
{
return ndr_token_peek(&ndr->array_length_list, p);
}
@@ -637,7 +670,7 @@ uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p)
/*
check the stored array length field
*/
-NTSTATUS ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length)
+_PUBLIC_ NTSTATUS ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length)
{
uint32_t stored;
stored = ndr_token_peek(&ndr->array_length_list, p);
@@ -652,17 +685,17 @@ NTSTATUS ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length)
/*
store a switch value
*/
-NTSTATUS ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val)
+_PUBLIC_ NTSTATUS ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val)
{
return ndr_token_store(ndr, &ndr->switch_list, p, val);
}
-NTSTATUS ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val)
+_PUBLIC_ NTSTATUS ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val)
{
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)
+_PUBLIC_ 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);
}
@@ -670,17 +703,17 @@ NTSTATUS ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32
/*
retrieve a switch value
*/
-uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, const void *p)
+_PUBLIC_ uint32_t ndr_push_get_switch_value(struct ndr_push *ndr, const void *p)
{
return ndr_token_peek(&ndr->switch_list, p);
}
-uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ uint32_t ndr_pull_get_switch_value(struct ndr_pull *ndr, const void *p)
{
return ndr_token_peek(&ndr->switch_list, p);
}
-uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p)
+_PUBLIC_ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p)
{
return ndr_token_peek(&ndr->switch_list, p);
}
@@ -688,7 +721,7 @@ uint32_t ndr_print_get_switch_value(struct ndr_print *ndr, const void *p)
/*
pull a struct from a blob using NDR
*/
-NTSTATUS ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
+_PUBLIC_ NTSTATUS ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
@@ -701,7 +734,7 @@ NTSTATUS ndr_pull_struct_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *
/*
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,
+_PUBLIC_ 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;
@@ -719,7 +752,7 @@ NTSTATUS ndr_pull_struct_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, vo
/*
pull a union from a blob using NDR, given the union discriminator
*/
-NTSTATUS ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
+_PUBLIC_ NTSTATUS ndr_pull_union_blob(const DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
uint32_t level, ndr_pull_flags_fn_t fn)
{
struct ndr_pull *ndr;
@@ -753,7 +786,7 @@ _PUBLIC_ NTSTATUS ndr_pull_union_blob_all(const DATA_BLOB *blob, TALLOC_CTX *mem
/*
push a struct to a blob using NDR
*/
-NTSTATUS ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p,
+_PUBLIC_ NTSTATUS ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *p,
ndr_push_flags_fn_t fn)
{
struct ndr_push *ndr;
@@ -772,7 +805,7 @@ NTSTATUS ndr_push_struct_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, const void *
/*
push a union to a blob using NDR
*/
-NTSTATUS ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
+_PUBLIC_ NTSTATUS ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
uint32_t level, ndr_push_flags_fn_t fn)
{
struct ndr_push *ndr;
@@ -792,7 +825,7 @@ NTSTATUS ndr_push_union_blob(DATA_BLOB *blob, TALLOC_CTX *mem_ctx, void *p,
/*
generic ndr_size_*() handler for structures
*/
-size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push)
+_PUBLIC_ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push)
{
struct ndr_push *ndr;
NTSTATUS status;
@@ -804,7 +837,7 @@ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push)
ndr = ndr_push_init_ctx(NULL);
if (!ndr) return 0;
ndr->flags |= flags | LIBNDR_FLAG_NO_NDR_SIZE;
- status = push(ndr, NDR_SCALARS|NDR_BUFFERS, p);
+ status = push(ndr, NDR_SCALARS|NDR_BUFFERS, discard_const(p));
if (!NT_STATUS_IS_OK(status)) {
talloc_free(ndr);
return 0;
@@ -817,7 +850,7 @@ size_t ndr_size_struct(const void *p, int flags, ndr_push_flags_fn_t push)
/*
generic ndr_size_*() handler for unions
*/
-size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push)
+_PUBLIC_ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_fn_t push)
{
struct ndr_push *ndr;
NTSTATUS status;
@@ -848,7 +881,7 @@ size_t ndr_size_union(const void *p, int flags, uint32_t level, ndr_push_flags_f
/*
get the current base for relative pointers for the push
*/
-uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr)
+_PUBLIC_ uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr)
{
return ndr->relative_base_offset;
}
@@ -856,7 +889,7 @@ uint32_t ndr_push_get_relative_base_offset(struct ndr_push *ndr)
/*
restore the old base for relative pointers for the push
*/
-void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset)
+_PUBLIC_ void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset)
{
ndr->relative_base_offset = offset;
}
@@ -865,7 +898,7 @@ void ndr_push_restore_relative_base_offset(struct ndr_push *ndr, uint32_t offset
setup the current base for relative pointers for the push
called in the NDR_SCALAR stage
*/
-NTSTATUS ndr_push_setup_relative_base_offset1(struct ndr_push *ndr, const void *p, uint32_t offset)
+_PUBLIC_ NTSTATUS ndr_push_setup_relative_base_offset1(struct ndr_push *ndr, const void *p, uint32_t offset)
{
ndr->relative_base_offset = offset;
return ndr_token_store(ndr, &ndr->relative_base_list, p, offset);
@@ -875,7 +908,7 @@ NTSTATUS ndr_push_setup_relative_base_offset1(struct ndr_push *ndr, const void *
setup the current base for relative pointers for the push
called in the NDR_BUFFERS stage
*/
-NTSTATUS ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *p)
{
return ndr_token_retrieve(&ndr->relative_base_list, p, &ndr->relative_base_offset);
}
@@ -884,7 +917,7 @@ NTSTATUS ndr_push_setup_relative_base_offset2(struct ndr_push *ndr, const void *
push a relative object - stage1
this is called during SCALARS processing
*/
-NTSTATUS ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p)
{
if (p == NULL) {
NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, 0));
@@ -899,7 +932,7 @@ NTSTATUS ndr_push_relative_ptr1(struct ndr_push *ndr, const void *p)
push a relative object - stage2
this is called during buffers processing
*/
-NTSTATUS ndr_push_relative_ptr2(struct ndr_push *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_push_relative_ptr2(struct ndr_push *ndr, const void *p)
{
struct ndr_push_save save;
uint32_t ptr_offset = 0xFFFFFFFF;
@@ -927,7 +960,7 @@ NTSTATUS ndr_push_relative_ptr2(struct ndr_push *ndr, const void *p)
/*
get the current base for relative pointers for the pull
*/
-uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr)
+_PUBLIC_ uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr)
{
return ndr->relative_base_offset;
}
@@ -935,7 +968,7 @@ uint32_t ndr_pull_get_relative_base_offset(struct ndr_pull *ndr)
/*
restore the old base for relative pointers for the pull
*/
-void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset)
+_PUBLIC_ void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset)
{
ndr->relative_base_offset = offset;
}
@@ -944,7 +977,7 @@ void ndr_pull_restore_relative_base_offset(struct ndr_pull *ndr, uint32_t offset
setup the current base for relative pointers for the pull
called in the NDR_SCALAR stage
*/
-NTSTATUS ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *p, uint32_t offset)
+_PUBLIC_ NTSTATUS ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *p, uint32_t offset)
{
ndr->relative_base_offset = offset;
return ndr_token_store(ndr, &ndr->relative_base_list, p, offset);
@@ -954,7 +987,7 @@ NTSTATUS ndr_pull_setup_relative_base_offset1(struct ndr_pull *ndr, const void *
setup the current base for relative pointers for the pull
called in the NDR_BUFFERS stage
*/
-NTSTATUS ndr_pull_setup_relative_base_offset2(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_pull_setup_relative_base_offset2(struct ndr_pull *ndr, const void *p)
{
return ndr_token_retrieve(&ndr->relative_base_list, p, &ndr->relative_base_offset);
}
@@ -963,7 +996,7 @@ NTSTATUS ndr_pull_setup_relative_base_offset2(struct ndr_pull *ndr, const void *
pull a relative object - stage1
called during SCALARS processing
*/
-NTSTATUS ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset)
+_PUBLIC_ NTSTATUS ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset)
{
rel_offset += ndr->relative_base_offset;
if (rel_offset > ndr->data_size) {
@@ -978,7 +1011,7 @@ NTSTATUS ndr_pull_relative_ptr1(struct ndr_pull *ndr, const void *p, uint32_t re
pull a relative object - stage2
called during BUFFERS processing
*/
-NTSTATUS ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_pull_relative_ptr2(struct ndr_pull *ndr, const void *p)
{
uint32_t rel_offset;
NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, p, &rel_offset));
diff --git a/source3/librpc/ndr/ndr_basic.c b/source3/librpc/ndr/ndr_basic.c
index 5377ed3dd3..b406791a27 100644
--- a/source3/librpc/ndr/ndr_basic.c
+++ b/source3/librpc/ndr/ndr_basic.c
@@ -20,6 +20,8 @@
*/
#include "includes.h"
+#include "system/network.h"
+#include "librpc/ndr/libndr.h"
#define NDR_SVAL(ndr, ofs) (NDR_BE(ndr)?RSVAL(ndr->data,ofs):SVAL(ndr->data,ofs))
#define NDR_IVAL(ndr, ofs) (NDR_BE(ndr)?RIVAL(ndr->data,ofs):IVAL(ndr->data,ofs))
@@ -34,7 +36,7 @@
these could also indicate that real structure elements have been
mistaken for padding in the IDL
*/
-void ndr_check_padding(struct ndr_pull *ndr, size_t n)
+_PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n)
{
size_t ofs2 = (ndr->offset + (n-1)) & ~(n-1);
int i;
@@ -56,7 +58,7 @@ void ndr_check_padding(struct ndr_pull *ndr, size_t n)
/*
parse a int8_t
*/
-NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v)
{
NDR_PULL_NEED_BYTES(ndr, 1);
*v = (int8_t)CVAL(ndr->data, ndr->offset);
@@ -67,7 +69,7 @@ NTSTATUS ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v)
/*
parse a uint8_t
*/
-NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v)
{
NDR_PULL_NEED_BYTES(ndr, 1);
*v = CVAL(ndr->data, ndr->offset);
@@ -78,7 +80,7 @@ NTSTATUS ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v)
/*
parse a int16_t
*/
-NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v)
{
NDR_PULL_ALIGN(ndr, 2);
NDR_PULL_NEED_BYTES(ndr, 2);
@@ -90,7 +92,7 @@ NTSTATUS ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v)
/*
parse a uint16_t
*/
-NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
{
NDR_PULL_ALIGN(ndr, 2);
NDR_PULL_NEED_BYTES(ndr, 2);
@@ -102,7 +104,7 @@ NTSTATUS ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
/*
parse a int32_t
*/
-NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
{
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 4);
@@ -114,7 +116,7 @@ NTSTATUS ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
/*
parse a uint32_t
*/
-NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
{
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 4);
@@ -126,7 +128,7 @@ NTSTATUS ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
/*
parse a pointer referent identifier
*/
-NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v)
{
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v));
if (*v != 0) {
@@ -138,7 +140,7 @@ NTSTATUS ndr_pull_generic_ptr(struct ndr_pull *ndr, uint32_t *v)
/*
parse a ref pointer referent identifier
*/
-NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v)
{
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, v));
/* ref pointers always point to data */
@@ -149,7 +151,7 @@ NTSTATUS ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v)
/*
parse a udlong
*/
-NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
{
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 8);
@@ -162,7 +164,7 @@ NTSTATUS ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
/*
parse a udlongr
*/
-NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
{
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 8);
@@ -175,7 +177,7 @@ NTSTATUS ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
/*
parse a dlong
*/
-NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v)
{
return ndr_pull_udlong(ndr, ndr_flags, (uint64_t *)v);
}
@@ -183,7 +185,7 @@ NTSTATUS ndr_pull_dlong(struct ndr_pull *ndr, int ndr_flags, int64_t *v)
/*
parse a hyper
*/
-NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
+_PUBLIC_ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
{
NDR_PULL_ALIGN(ndr, 8);
return ndr_pull_udlong(ndr, ndr_flags, v);
@@ -192,7 +194,7 @@ NTSTATUS ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
/*
parse a pointer
*/
-NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
+_PUBLIC_ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
{
intptr_t h;
NDR_PULL_ALIGN(ndr, sizeof(h));
@@ -206,7 +208,7 @@ NTSTATUS ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
/*
pull a NTSTATUS
*/
-NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status)
+_PUBLIC_ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status)
{
uint32_t v;
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
@@ -217,12 +219,12 @@ NTSTATUS ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status
/*
push a NTSTATUS
*/
-NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status)
+_PUBLIC_ NTSTATUS ndr_push_NTSTATUS(struct ndr_push *ndr, int ndr_flags, NTSTATUS status)
{
return ndr_push_uint32(ndr, ndr_flags, NT_STATUS_V(status));
}
-void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r)
+_PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r)
{
ndr->print(ndr, "%-25s: %s", name, nt_errstr(r));
}
@@ -230,7 +232,7 @@ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTATUS r)
/*
pull a WERROR
*/
-NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status)
+_PUBLIC_ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status)
{
uint32_t v;
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
@@ -241,20 +243,20 @@ NTSTATUS ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status)
/*
push a WERROR
*/
-NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status)
+_PUBLIC_ NTSTATUS ndr_push_WERROR(struct ndr_push *ndr, int ndr_flags, WERROR status)
{
return ndr_push_uint32(ndr, NDR_SCALARS, W_ERROR_V(status));
}
-void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r)
+_PUBLIC_ void ndr_print_WERROR(struct ndr_print *ndr, const char *name, WERROR r)
{
- ndr->print(ndr, "%-25s: %s", name, dos_errstr(r));
+ ndr->print(ndr, "%-25s: %s", name, win_errstr(r));
}
/*
parse a set of bytes
*/
-NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n)
+_PUBLIC_ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n)
{
NDR_PULL_NEED_BYTES(ndr, n);
memcpy(data, ndr->data + ndr->offset, n);
@@ -265,7 +267,7 @@ NTSTATUS ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, uint32_t n)
/*
pull an array of uint8
*/
-NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n)
+_PUBLIC_ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n)
{
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
@@ -276,7 +278,7 @@ NTSTATUS ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data
/*
push a int8_t
*/
-NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v)
+_PUBLIC_ NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v)
{
NDR_PUSH_NEED_BYTES(ndr, 1);
SCVAL(ndr->data, ndr->offset, (uint8_t)v);
@@ -287,7 +289,7 @@ NTSTATUS ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v)
/*
push a uint8_t
*/
-NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v)
+_PUBLIC_ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v)
{
NDR_PUSH_NEED_BYTES(ndr, 1);
SCVAL(ndr->data, ndr->offset, v);
@@ -298,7 +300,7 @@ NTSTATUS ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v)
/*
push a int16_t
*/
-NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v)
+_PUBLIC_ NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v)
{
NDR_PUSH_ALIGN(ndr, 2);
NDR_PUSH_NEED_BYTES(ndr, 2);
@@ -310,7 +312,7 @@ NTSTATUS ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v)
/*
push a uint16_t
*/
-NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v)
+_PUBLIC_ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v)
{
NDR_PUSH_ALIGN(ndr, 2);
NDR_PUSH_NEED_BYTES(ndr, 2);
@@ -322,7 +324,7 @@ NTSTATUS ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v)
/*
push a int32_t
*/
-NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
+_PUBLIC_ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
{
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 4);
@@ -334,7 +336,7 @@ NTSTATUS ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
/*
push a uint32_t
*/
-NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
+_PUBLIC_ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
{
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 4);
@@ -346,7 +348,7 @@ NTSTATUS ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
/*
push a udlong
*/
-NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v)
+_PUBLIC_ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v)
{
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 8);
@@ -359,7 +361,7 @@ NTSTATUS ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v)
/*
push a udlongr
*/
-NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v)
+_PUBLIC_ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v)
{
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 8);
@@ -372,7 +374,7 @@ NTSTATUS ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v)
/*
push a dlong
*/
-NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v)
+_PUBLIC_ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v)
{
return ndr_push_udlong(ndr, NDR_SCALARS, (uint64_t)v);
}
@@ -380,7 +382,7 @@ NTSTATUS ndr_push_dlong(struct ndr_push *ndr, int ndr_flags, int64_t v)
/*
push a hyper
*/
-NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v)
+_PUBLIC_ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v)
{
NDR_PUSH_ALIGN(ndr, 8);
return ndr_push_udlong(ndr, NDR_SCALARS, v);
@@ -389,7 +391,7 @@ NTSTATUS ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, uint64_t v)
/*
push a pointer
*/
-NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
+_PUBLIC_ NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
{
intptr_t h = (intptr_t)v;
NDR_PUSH_ALIGN(ndr, sizeof(h));
@@ -399,13 +401,13 @@ NTSTATUS ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
return NT_STATUS_OK;
}
-NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size)
+_PUBLIC_ NTSTATUS ndr_push_align(struct ndr_push *ndr, size_t size)
{
NDR_PUSH_ALIGN(ndr, size);
return NT_STATUS_OK;
}
-NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size)
+_PUBLIC_ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size)
{
NDR_PULL_ALIGN(ndr, size);
return NT_STATUS_OK;
@@ -414,7 +416,7 @@ NTSTATUS ndr_pull_align(struct ndr_pull *ndr, size_t size)
/*
push some bytes
*/
-NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n)
+_PUBLIC_ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n)
{
NDR_PUSH_NEED_BYTES(ndr, n);
memcpy(ndr->data + ndr->offset, data, n);
@@ -425,7 +427,7 @@ NTSTATUS ndr_push_bytes(struct ndr_push *ndr, const uint8_t *data, uint32_t n)
/*
push some zero bytes
*/
-NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n)
+_PUBLIC_ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n)
{
NDR_PUSH_NEED_BYTES(ndr, n);
memset(ndr->data + ndr->offset, 0, n);
@@ -436,7 +438,7 @@ NTSTATUS ndr_push_zero(struct ndr_push *ndr, uint32_t n)
/*
push an array of uint8
*/
-NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n)
+_PUBLIC_ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n)
{
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
@@ -447,7 +449,7 @@ NTSTATUS ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t
/*
save the current position
*/
-void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save)
+_PUBLIC_ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save)
{
save->offset = ndr->offset;
}
@@ -455,7 +457,7 @@ void ndr_push_save(struct ndr_push *ndr, struct ndr_push_save *save)
/*
restore the position
*/
-void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save)
+_PUBLIC_ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save)
{
ndr->offset = save->offset;
}
@@ -463,7 +465,7 @@ void ndr_push_restore(struct ndr_push *ndr, struct ndr_push_save *save)
/*
push a unique non-zero value if a pointer is non-NULL, otherwise 0
*/
-NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p)
{
uint32_t ptr = 0;
if (p) {
@@ -477,7 +479,7 @@ NTSTATUS ndr_push_unique_ptr(struct ndr_push *ndr, const void *p)
/*
push a 'simple' full non-zero value if a pointer is non-NULL, otherwise 0
*/
-NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p)
+_PUBLIC_ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p)
{
uint32_t ptr = 0;
if (p) {
@@ -495,15 +497,16 @@ NTSTATUS ndr_push_full_ptr(struct ndr_push *ndr, const void *p)
/*
push always a 0, if a pointer is NULL it's a fatal error
*/
-NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr)
+_PUBLIC_ NTSTATUS ndr_push_ref_ptr(struct ndr_push *ndr)
{
return ndr_push_uint32(ndr, NDR_SCALARS, 0xAEF1AEF1);
}
+
/*
push a NTTIME
*/
-NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t)
+_PUBLIC_ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t)
{
NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t));
return NT_STATUS_OK;
@@ -512,7 +515,7 @@ NTSTATUS ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t)
/*
pull a NTTIME
*/
-NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
+_PUBLIC_ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
{
NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t));
return NT_STATUS_OK;
@@ -521,7 +524,7 @@ NTSTATUS ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
/*
push a NTTIME
*/
-NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t)
+_PUBLIC_ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t)
{
t /= 10000000;
NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t));
@@ -531,7 +534,7 @@ NTSTATUS ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t)
/*
pull a NTTIME_1sec
*/
-NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
+_PUBLIC_ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
{
NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t));
(*t) *= 10000000;
@@ -541,7 +544,7 @@ NTSTATUS ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
/*
pull a NTTIME_hyper
*/
-NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
+_PUBLIC_ NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
{
NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t));
return NT_STATUS_OK;
@@ -550,7 +553,7 @@ NTSTATUS ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
/*
push a NTTIME_hyper
*/
-NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t)
+_PUBLIC_ NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t)
{
NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t));
return NT_STATUS_OK;
@@ -559,7 +562,7 @@ NTSTATUS ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t)
/*
push a time_t
*/
-NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t)
+_PUBLIC_ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t)
{
return ndr_push_uint32(ndr, ndr_flags, t);
}
@@ -567,7 +570,7 @@ NTSTATUS ndr_push_time_t(struct ndr_push *ndr, int ndr_flags, time_t t)
/*
pull a time_t
*/
-NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t)
+_PUBLIC_ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t)
{
uint32_t tt;
NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &tt));
@@ -575,10 +578,11 @@ NTSTATUS ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags, time_t *t)
return NT_STATUS_OK;
}
+
/*
pull a ipv4address
*/
-NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address)
+_PUBLIC_ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **address)
{
struct in_addr in;
NDR_CHECK(ndr_pull_uint32(ndr, ndr_flags, &in.s_addr));
@@ -591,10 +595,10 @@ NTSTATUS ndr_pull_ipv4address(struct ndr_pull *ndr, int ndr_flags, const char **
/*
push a ipv4address
*/
-NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address)
+_PUBLIC_ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *address)
{
uint32_t addr;
- if (!is_ipaddress_v4(address)) {
+ if (!is_ipaddress(address)) {
return ndr_push_error(ndr, NDR_ERR_IPV4ADDRESS,
"Invalid IPv4 address: '%s'",
address);
@@ -607,18 +611,19 @@ NTSTATUS ndr_push_ipv4address(struct ndr_push *ndr, int ndr_flags, const char *a
/*
print a ipv4address
*/
-void ndr_print_ipv4address(struct ndr_print *ndr, const char *name,
+_PUBLIC_ void ndr_print_ipv4address(struct ndr_print *ndr, const char *name,
const char *address)
{
ndr->print(ndr, "%-25s: %s", name, address);
}
-void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type)
+
+_PUBLIC_ void ndr_print_struct(struct ndr_print *ndr, const char *name, const char *type)
{
ndr->print(ndr, "%s: struct %s", name, type);
}
-void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type,
+_PUBLIC_ void ndr_print_enum(struct ndr_print *ndr, const char *name, const char *type,
const char *val, uint32_t value)
{
if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) {
@@ -628,7 +633,7 @@ 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, uint32_t flag, uint32_t value)
+_PUBLIC_ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_name, uint32_t flag, uint32_t value)
{
/* this is an attempt to support multi-bit bitmap masks */
value &= flag;
@@ -644,62 +649,62 @@ void ndr_print_bitmap_flag(struct ndr_print *ndr, size_t size, const char *flag_
}
}
-void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v)
+_PUBLIC_ void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v)
{
ndr->print(ndr, "%-25s: %d", name, v);
}
-void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v)
+_PUBLIC_ void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v)
{
ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v);
}
-void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v)
+_PUBLIC_ void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v)
{
ndr->print(ndr, "%-25s: %d", name, v);
}
-void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v)
+_PUBLIC_ void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v)
{
ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v);
}
-void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v)
+_PUBLIC_ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v)
{
ndr->print(ndr, "%-25s: %d", name, v);
}
-void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v)
+_PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v)
{
ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v);
}
-void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v)
+_PUBLIC_ void ndr_print_udlong(struct ndr_print *ndr, const char *name, uint64_t v)
{
- ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, v, v);
+ ndr->print(ndr, "%-25s: 0x%016llx (%llu)", name, (unsigned long long)v, (unsigned long long)v);
}
-void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v)
+_PUBLIC_ void ndr_print_udlongr(struct ndr_print *ndr, const char *name, uint64_t v)
{
ndr_print_udlong(ndr, name, v);
}
-void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v)
+_PUBLIC_ void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v)
{
- ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, v, v);
+ ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, (unsigned long long)v, (long long)v);
}
-void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v)
+_PUBLIC_ void ndr_print_hyper(struct ndr_print *ndr, const char *name, uint64_t v)
{
ndr_print_dlong(ndr, name, v);
}
-void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v)
+_PUBLIC_ void ndr_print_pointer(struct ndr_print *ndr, const char *name, void *v)
{
ndr->print(ndr, "%-25s: %p", name, v);
}
-void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p)
+_PUBLIC_ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p)
{
if (p) {
ndr->print(ndr, "%-25s: *", name);
@@ -708,12 +713,12 @@ void ndr_print_ptr(struct ndr_print *ndr, const char *name, const void *p)
}
}
-void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t)
+_PUBLIC_ void ndr_print_NTTIME(struct ndr_print *ndr, const char *name, NTTIME t)
{
ndr->print(ndr, "%-25s: %s", name, nt_time_string(ndr, t));
}
-void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t)
+_PUBLIC_ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t)
{
/* this is a standard NTTIME here
* as it's already converted in the pull/push code
@@ -721,12 +726,12 @@ void ndr_print_NTTIME_1sec(struct ndr_print *ndr, const char *name, NTTIME t)
ndr_print_NTTIME(ndr, name, t);
}
-void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t)
+_PUBLIC_ void ndr_print_NTTIME_hyper(struct ndr_print *ndr, const char *name, NTTIME t)
{
ndr_print_NTTIME(ndr, name, t);
}
-void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t)
+_PUBLIC_ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t)
{
if (t == (time_t)-1 || t == 0) {
ndr->print(ndr, "%-25s: (time_t)%d", name, (int)t);
@@ -735,7 +740,7 @@ void ndr_print_time_t(struct ndr_print *ndr, const char *name, time_t t)
}
}
-void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type)
+_PUBLIC_ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const char *type)
{
if (ndr->flags & LIBNDR_PRINT_ARRAY_HEX) {
ndr->print(ndr, "%-25s: union %s(case 0x%X)", name, type, level);
@@ -744,12 +749,12 @@ void ndr_print_union(struct ndr_print *ndr, const char *name, int level, const c
}
}
-void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level)
+_PUBLIC_ void ndr_print_bad_level(struct ndr_print *ndr, const char *name, uint16_t level)
{
ndr->print(ndr, "UNKNOWN LEVEL %u", level);
}
-void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
+_PUBLIC_ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
const uint8_t *data, uint32_t count)
{
int i;
@@ -777,9 +782,9 @@ void ndr_print_array_uint8(struct ndr_print *ndr, const char *name,
ndr->depth--;
}
-void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r)
+_PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r)
{
- ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, r.length);
+ ndr->print(ndr, "%-25s: DATA_BLOB length=%u", name, (unsigned)r.length);
if (r.length) {
dump_data(10, r.data, r.length);
}
@@ -789,7 +794,7 @@ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_BLOB r)
/*
push a DATA_BLOB onto the wire.
*/
-NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob)
+_PUBLIC_ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob)
{
if (ndr->flags & LIBNDR_ALIGN_FLAGS) {
if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
@@ -811,7 +816,7 @@ NTSTATUS ndr_push_DATA_BLOB(struct ndr_push *ndr, int ndr_flags, DATA_BLOB blob)
/*
pull a DATA_BLOB from the wire.
*/
-NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob)
+_PUBLIC_ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob)
{
uint32_t length = 0;
@@ -837,7 +842,7 @@ NTSTATUS ndr_pull_DATA_BLOB(struct ndr_pull *ndr, int ndr_flags, DATA_BLOB *blob
return NT_STATUS_OK;
}
-uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags)
+_PUBLIC_ uint32_t ndr_size_DATA_BLOB(int ret, const DATA_BLOB *data, int flags)
{
if (!data) return ret;
return ret + data->length;
diff --git a/source3/librpc/ndr/ndr_string.c b/source3/librpc/ndr/ndr_string.c
index bc4582cca7..375cb00eb4 100644
--- a/source3/librpc/ndr/ndr_string.c
+++ b/source3/librpc/ndr/ndr_string.c
@@ -20,17 +20,18 @@
*/
#include "includes.h"
+#include "librpc/ndr/libndr.h"
/**
pull a general string from the wire
*/
-NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
+_PUBLIC_ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
{
char *as=NULL;
uint32_t len1, ofs, len2;
uint16_t len3;
int ret;
- charset_t chset = CH_UTF16LE;
+ int chset = CH_UTF16;
unsigned byte_mul = 2;
unsigned flags = ndr->flags;
unsigned c_len_term = 0;
@@ -84,7 +85,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
chset, CH_UNIX,
ndr->data+ndr->offset,
(len2 + c_len_term)*byte_mul,
- &as, True);
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -121,7 +122,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
- &as, False);
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -159,7 +160,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
chset, CH_UNIX,
ndr->data+ndr->offset,
(len1 + c_len_term)*byte_mul,
- &as, False);
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -193,7 +194,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
chset, CH_UNIX,
ndr->data+ndr->offset,
(len3 + c_len_term)*byte_mul,
- &as, False);
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -224,7 +225,8 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
- len3, &as, False);
+ len3,
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -243,7 +245,8 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
- len1, &as, False);
+ len1,
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -259,7 +262,8 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
ret = convert_string_talloc(ndr->current_mem_ctx,
chset, CH_UNIX,
ndr->data+ndr->offset,
- len1*byte_mul, &as, False);
+ len1*byte_mul,
+ (void **)&as, false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -268,6 +272,33 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
*s = as;
break;
+ case LIBNDR_FLAG_STR_NOTERM:
+ if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x (missing NDR_REMAINING)\n",
+ ndr->flags & LIBNDR_STRING_FLAGS);
+ }
+
+ len1 = ndr->data_size - ndr->offset;
+
+ NDR_PULL_NEED_BYTES(ndr, len1);
+ if (len1 == 0) {
+ as = talloc_strdup(ndr->current_mem_ctx, "");
+ } else {
+ ret = convert_string_talloc(ndr->current_mem_ctx,
+ chset, CH_UNIX,
+ ndr->data+ndr->offset,
+ len1,
+ (void **)&as, false);
+ if (ret == -1) {
+ return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
+ "Bad character conversion");
+ }
+ }
+ NDR_CHECK(ndr_pull_advance(ndr, len1));
+
+ *s = as;
+ break;
+
default:
return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n",
ndr->flags & LIBNDR_STRING_FLAGS);
@@ -280,10 +311,10 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
/**
push a general string onto the wire
*/
-NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
+_PUBLIC_ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
{
ssize_t s_len, c_len, d_len;
- charset_t chset = CH_UTF16LE;
+ int chset = CH_UTF16;
unsigned flags = ndr->flags;
unsigned byte_mul = 2;
uint8_t *dest = NULL;
@@ -318,8 +349,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
LIBNDR_FLAG_STR_FIXLEN32))) {
s_len++;
}
- d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, &dest,
- False);
+ d_len = convert_string_talloc(ndr, CH_UNIX, chset, s, s_len, (void **)&dest, false);
if (d_len == -1) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -379,6 +409,11 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
}
default:
+ if (ndr->flags & LIBNDR_FLAG_REMAINING) {
+ NDR_CHECK(ndr_push_bytes(ndr, dest, d_len));
+ break;
+ }
+
return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n",
ndr->flags & LIBNDR_STRING_FLAGS);
}
@@ -391,7 +426,7 @@ NTSTATUS ndr_push_string(struct ndr_push *ndr, int ndr_flags, const char *s)
/**
push a general string onto the wire
*/
-size_t ndr_string_array_size(struct ndr_push *ndr, const char *s)
+_PUBLIC_ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s)
{
size_t c_len;
unsigned flags = ndr->flags;
@@ -405,7 +440,7 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s)
return 15;
}
- c_len = s?strlen(s):0;
+ c_len = s?strlen_m(s):0;
if (flags & (LIBNDR_FLAG_STR_ASCII|LIBNDR_FLAG_STR_UTF8)) {
byte_mul = 1;
@@ -424,7 +459,7 @@ size_t ndr_string_array_size(struct ndr_push *ndr, const char *s)
return c_len;
}
-void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s)
+_PUBLIC_ void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s)
{
if (s) {
ndr->print(ndr, "%-25s: '%s'", name, s);
@@ -433,7 +468,7 @@ void ndr_print_string(struct ndr_print *ndr, const char *name, const char *s)
}
}
-uint32_t ndr_size_string(int ret, const char * const* string, int flags)
+_PUBLIC_ uint32_t ndr_size_string(int ret, const char * const* string, int flags)
{
/* FIXME: Is this correct for all strings ? */
if(!(*string)) return ret;
@@ -443,60 +478,142 @@ uint32_t ndr_size_string(int ret, const char * const* string, int flags)
/**
pull a general string array from the wire
*/
-NTSTATUS ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char ***_a)
+_PUBLIC_ NTSTATUS ndr_pull_string_array(struct ndr_pull *ndr, int ndr_flags, const char ***_a)
{
const char **a = *_a;
uint32_t count;
+ unsigned flags = ndr->flags;
+ unsigned saved_flags = ndr->flags;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
- for (count = 0;; count++) {
- TALLOC_CTX *tmp_ctx;
- const char *s = NULL;
- a = talloc_realloc(ndr->current_mem_ctx, a, const char *, count + 2);
- NT_STATUS_HAVE_NO_MEMORY(a);
- a[count] = NULL;
- a[count+1] = NULL;
-
- tmp_ctx = ndr->current_mem_ctx;
- ndr->current_mem_ctx = a;
- NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
- ndr->current_mem_ctx = tmp_ctx;
- if (strcmp("", s)==0) {
- a[count] = NULL;
- break;
- } else {
+ switch (flags & LIBNDR_STRING_FLAGS) {
+ case LIBNDR_FLAG_STR_NULLTERM:
+ /*
+ * here the strings are null terminated
+ * but also the array is null terminated
+ */
+ for (count = 0;; count++) {
+ TALLOC_CTX *tmp_ctx;
+ const char *s = NULL;
+ a = talloc_realloc(ndr->current_mem_ctx, a, const char *, count + 2);
+ NT_STATUS_HAVE_NO_MEMORY(a);
+ a[count] = NULL;
+ a[count+1] = NULL;
+
+ tmp_ctx = ndr->current_mem_ctx;
+ ndr->current_mem_ctx = a;
+ NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
+ ndr->current_mem_ctx = tmp_ctx;
+ if (strcmp("", s)==0) {
+ a[count] = NULL;
+ break;
+ } else {
+ a[count] = s;
+ }
+ }
+
+ *_a =a;
+ break;
+
+ case LIBNDR_FLAG_STR_NOTERM:
+ if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) {
+ return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x (missing NDR_REMAINING)\n",
+ ndr->flags & LIBNDR_STRING_FLAGS);
+ }
+ /*
+ * here the strings are not null terminated
+ * but serarated by a null terminator
+ *
+ * which means the same as:
+ * very string is null terminated exept the last
+ * string is terminated by the end of the buffer
+ *
+ * as LIBNDR_FLAG_STR_NULLTERM also end at the end
+ * of the buffer, we can pull each string with this flag
+ */
+ ndr->flags &= ~(LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING);
+ ndr->flags |= LIBNDR_FLAG_STR_NULLTERM;
+
+ for (count = 0; ((ndr->data_size - ndr->offset) > 0); count++) {
+ TALLOC_CTX *tmp_ctx;
+ const char *s = NULL;
+ a = talloc_realloc(ndr->current_mem_ctx, a, const char *, count + 2);
+ NT_STATUS_HAVE_NO_MEMORY(a);
+ a[count] = NULL;
+ a[count+1] = NULL;
+
+ tmp_ctx = ndr->current_mem_ctx;
+ ndr->current_mem_ctx = a;
+ NDR_CHECK(ndr_pull_string(ndr, ndr_flags, &s));
+ ndr->current_mem_ctx = tmp_ctx;
a[count] = s;
}
+
+ *_a =a;
+ break;
+
+ default:
+ return ndr_pull_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n",
+ ndr->flags & LIBNDR_STRING_FLAGS);
}
- *_a =a;
+ ndr->flags = saved_flags;
return NT_STATUS_OK;
}
/**
push a general string array onto the wire
*/
-NTSTATUS ndr_push_string_array(struct ndr_push *ndr, int ndr_flags, const char **a)
+_PUBLIC_ NTSTATUS ndr_push_string_array(struct ndr_push *ndr, int ndr_flags, const char **a)
{
uint32_t count;
+ unsigned flags = ndr->flags;
+ unsigned saved_flags = ndr->flags;
if (!(ndr_flags & NDR_SCALARS)) {
return NT_STATUS_OK;
}
- for (count = 0; a && a[count]; count++) {
- NDR_CHECK(ndr_push_string(ndr, ndr_flags, a[count]));
- }
+ switch (flags & LIBNDR_STRING_FLAGS) {
+ case LIBNDR_FLAG_STR_NULLTERM:
+ for (count = 0; a && a[count]; count++) {
+ NDR_CHECK(ndr_push_string(ndr, ndr_flags, a[count]));
+ }
- NDR_CHECK(ndr_push_string(ndr, ndr_flags, ""));
+ NDR_CHECK(ndr_push_string(ndr, ndr_flags, ""));
+ break;
+
+ case LIBNDR_FLAG_STR_NOTERM:
+ if (!(ndr->flags & LIBNDR_FLAG_REMAINING)) {
+ return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x (missing NDR_REMAINING)\n",
+ ndr->flags & LIBNDR_STRING_FLAGS);
+ }
+
+ for (count = 0; a && a[count]; count++) {
+ if (count > 0) {
+ ndr->flags &= ~(LIBNDR_FLAG_STR_NOTERM|LIBNDR_FLAG_REMAINING);
+ ndr->flags |= LIBNDR_FLAG_STR_NULLTERM;
+ NDR_CHECK(ndr_push_string(ndr, ndr_flags, ""));
+ ndr->flags = saved_flags;
+ }
+ NDR_CHECK(ndr_push_string(ndr, ndr_flags, a[count]));
+ }
+ break;
+
+ default:
+ return ndr_push_error(ndr, NDR_ERR_STRING, "Bad string flags 0x%x\n",
+ ndr->flags & LIBNDR_STRING_FLAGS);
+ }
+
+ ndr->flags = saved_flags;
return NT_STATUS_OK;
}
-void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a)
+_PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a)
{
uint32_t count;
uint32_t i;
@@ -519,7 +636,7 @@ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char
/**
* Return number of elements in a string including the last (zeroed) element
*/
-uint32_t ndr_string_length(const void *_var, uint32_t element_size)
+_PUBLIC_ uint32_t ndr_string_length(const void *_var, uint32_t element_size)
{
uint32_t i;
uint8_t zero[4] = {0,0,0,0};
@@ -530,7 +647,7 @@ uint32_t ndr_string_length(const void *_var, uint32_t element_size)
return i+1;
}
-NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size)
+_PUBLIC_ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint32_t element_size)
{
uint32_t i;
struct ndr_pull_save save_offset;
@@ -552,7 +669,7 @@ NTSTATUS ndr_check_string_terminator(struct ndr_pull *ndr, uint32_t count, uint3
return NT_STATUS_OK;
}
-NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset)
+_PUBLIC_ NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var, uint32_t length, uint8_t byte_mul, charset_t chset)
{
int ret;
if (length == 0) {
@@ -570,7 +687,7 @@ NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var,
chset, CH_UNIX,
ndr->data+ndr->offset,
length*byte_mul,
- var, False);
+ discard_const_p(void *, var), false);
if (ret == -1) {
return ndr_pull_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -580,8 +697,7 @@ NTSTATUS ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, const char **var,
return NT_STATUS_OK;
}
-NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var,
- uint32_t length, uint8_t byte_mul, charset_t chset)
+_PUBLIC_ NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset)
{
ssize_t ret, required;
@@ -594,7 +710,7 @@ NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var,
NDR_PUSH_NEED_BYTES(ndr, required);
ret = convert_string(CH_UNIX, chset,
var, strlen(var),
- ndr->data+ndr->offset, required, False);
+ ndr->data+ndr->offset, required, false);
if (ret == -1) {
return ndr_push_error(ndr, NDR_ERR_CHARCNV,
"Bad character conversion");
@@ -611,7 +727,7 @@ NTSTATUS ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var,
}
/* Return number of elements in a string in the specified charset */
-uint32_t ndr_charset_length(const void *var, int chset)
+_PUBLIC_ uint32_t ndr_charset_length(const void *var, charset_t chset)
{
/* FIXME: Treat special chars special here, taking chset into account */
/* Also include 0 byte */
diff --git a/source3/libsmb/doserr.c b/source3/libsmb/doserr.c
index 52afb0d022..b8cb8b4bc6 100644
--- a/source3/libsmb/doserr.c
+++ b/source3/libsmb/doserr.c
@@ -108,3 +108,9 @@ const char *dos_errstr(WERROR werror)
return msg;
}
+
+/* compat function for samba4 */
+const char *win_errstr(WERROR werror)
+{
+ return dos_errstr(werror);
+}
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 19af6aa3cf..07f8dc4144 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -2169,7 +2169,6 @@ FN_GLOBAL_INTEGER(lp_algorithmic_rid_base, &Globals.AlgorithmicRidBase)
FN_GLOBAL_INTEGER(lp_name_cache_timeout, &Globals.name_cache_timeout)
FN_GLOBAL_INTEGER(lp_client_signing, &Globals.client_signing)
FN_GLOBAL_INTEGER(lp_server_signing, &Globals.server_signing)
-FN_GLOBAL_INTEGER(lp_min_receive_file_size, &Globals.iminreceivefile);
FN_GLOBAL_INTEGER(lp_client_ldap_sasl_wrapping, &Globals.client_ldap_sasl_wrapping)
/* local prototypes */
@@ -6242,3 +6241,11 @@ void lp_set_posix_default_cifsx_readwrite_locktype(enum brl_flavour val)
posix_default_lock_was_set = True;
posix_cifsx_locktype = val;
}
+
+int lp_min_receive_file_size(void)
+{
+ if (Globals.iminreceivefile < 0) {
+ return 0;
+ }
+ return MIN(Globals.iminreceivefile, BUFFER_SIZE);
+}
diff --git a/source3/script/mkproto.awk b/source3/script/mkproto.awk
index a707378251..ff266321ff 100644
--- a/source3/script/mkproto.awk
+++ b/source3/script/mkproto.awk
@@ -113,7 +113,7 @@ END {
printf "int %s(void);\n", a[2]
}
-/^static|^extern/ || !/^[a-zA-Z]/ || /[;]/ {
+/^static|^extern/ || !/^[a-zA-Z\_]/ || /[;]/ {
next;
}
@@ -151,7 +151,7 @@ END {
gotstart = 1;
}
- if( $0 ~ /^NODE_STATUS_STRUCT|SMB_STRUCT_DIR|ELOG_TDB|codepoint_t/ ) {
+ if( $0 ~ /^NODE_STATUS_STRUCT|^SMB_STRUCT_DIR|^ELOG_TDB|^codepoint_t|^_PUBLIC_/ ) {
gotstart = 1;
}
diff --git a/source3/smbd/oplock_irix.c b/source3/smbd/oplock_irix.c
index b8d49f03a1..a4ea63bc0a 100644
--- a/source3/smbd/oplock_irix.c
+++ b/source3/smbd/oplock_irix.c
@@ -121,7 +121,7 @@ static files_struct *irix_oplock_receive_message(fd_set *fds)
DEBUG(0,("irix_oplock_receive_message: read of kernel "
"notification failed. Error was %s.\n",
strerror(errno) ));
- set_smb_read_error(SMB_READ_ERROR);
+ set_smb_read_error(get_srv_read_error(), SMB_READ_ERROR);
return NULL;
}
@@ -141,7 +141,7 @@ static files_struct *irix_oplock_receive_message(fd_set *fds)
*/
return NULL;
}
- set_smb_read_error(SMB_READ_ERROR);
+ set_smb_read_error(get_srv_read_error(), SMB_READ_ERROR);
return NULL;
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 1b36fb1e44..45081808e1 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -3856,16 +3856,24 @@ bool is_valid_writeX_buffer(const char *inbuf)
unsigned int doff = 0;
size_t len = smb_len_large(inbuf);
- if (CVAL(inbuf,smb_com) != SMBwriteX ||
- CVAL(inbuf,smb_vwv0) != 0xFF ||
+ if (CVAL(inbuf,smb_com) != SMBwriteX) {
+ return false;
+ }
+
+ if (CVAL(inbuf,smb_vwv0) != 0xFF ||
CVAL(inbuf,smb_wct) != 14) {
+ DEBUG(10,("is_valid_writeX_buffer: chained or "
+ "invalid word length.\n"));
return false;
}
+
conn = conn_find(SVAL(inbuf, smb_tid));
if (conn == NULL) {
+ DEBUG(10,("is_valid_writeX_buffer: bad tid\n"));
return false;
}
if (IS_IPC(conn)) {
+ DEBUG(10,("is_valid_writeX_buffer: IPC$ tid\n"));
return false;
}
doff = SVAL(inbuf,smb_vwv11);
@@ -3877,12 +3885,16 @@ bool is_valid_writeX_buffer(const char *inbuf)
}
if (numtowrite == 0) {
+ DEBUG(10,("is_valid_writeX_buffer: zero write\n"));
return false;
}
/* Ensure the sizes match up. */
if (doff < STANDARD_WRITE_AND_X_HEADER_SIZE) {
/* no pad byte...old smbclient :-( */
+ DEBUG(10,("is_valid_writeX_buffer: small doff %u (min %u)\n",
+ (unsigned int)doff,
+ (unsigned int)STANDARD_WRITE_AND_X_HEADER_SIZE));
return false;
}
@@ -3939,6 +3951,12 @@ void reply_write_and_X(connection_struct *conn, struct smb_request *req)
}
if (req->unread_bytes) {
+ /* Can't do a recvfile write on IPC$ */
+ if (IS_IPC(conn)) {
+ reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ END_PROFILE(SMBwriteX);
+ return;
+ }
if (numtowrite != req->unread_bytes) {
reply_doserror(req, ERRDOS, ERRbadmem);
END_PROFILE(SMBwriteX);