diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-05-21 22:17:13 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:22:17 -0500 |
commit | ac3f08ddbe0b484375624db0e35999a8584b57f4 (patch) | |
tree | 477347104c60dc6ae205257d654b1d89c7903f35 /source3/librpc | |
parent | f96242d9331a5fcdc65445d0d0ea7177c7ddc6e0 (diff) | |
download | samba-ac3f08ddbe0b484375624db0e35999a8584b57f4.tar.gz samba-ac3f08ddbe0b484375624db0e35999a8584b57f4.tar.bz2 samba-ac3f08ddbe0b484375624db0e35999a8584b57f4.zip |
r23055: Rewrite messages.c to use auto-generated marshalling in the tdb. I'm
doing this because for the clustering the marshalling is needed in more
than one place, so I wanted a decent routine to marshall a message_rec
struct which was not there before.
Tridge, this seems about the same speed as it used to be before, the
librpc/ndr overhead in my tests was under the noise.
Volker
(This used to be commit eaefd00563173dfabb7716c5695ac0a2f7139bb6)
Diffstat (limited to 'source3/librpc')
-rw-r--r-- | source3/librpc/gen_ndr/messaging.h | 21 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_messaging.c | 115 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_messaging.h | 16 | ||||
-rw-r--r-- | source3/librpc/idl/messaging.idl | 26 |
4 files changed, 178 insertions, 0 deletions
diff --git a/source3/librpc/gen_ndr/messaging.h b/source3/librpc/gen_ndr/messaging.h new file mode 100644 index 0000000000..71340c0987 --- /dev/null +++ b/source3/librpc/gen_ndr/messaging.h @@ -0,0 +1,21 @@ +/* header auto-generated by pidl */ + +#include <stdint.h> + +#ifndef _HEADER_messaging +#define _HEADER_messaging + +struct messaging_rec { + uint32_t msg_version; + uint32_t msg_type; + struct server_id dest; + struct server_id src; + DATA_BLOB buf; +}/* [public] */; + +struct messaging_array { + uint32_t num_messages; + struct messaging_rec *messages; +}/* [public] */; + +#endif /* _HEADER_messaging */ diff --git a/source3/librpc/gen_ndr/ndr_messaging.c b/source3/librpc/gen_ndr/ndr_messaging.c new file mode 100644 index 0000000000..21aec98a98 --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_messaging.c @@ -0,0 +1,115 @@ +/* parser auto-generated by pidl */ + +#include "includes.h" +#include "librpc/gen_ndr/ndr_messaging.h" + +_PUBLIC_ NTSTATUS ndr_push_messaging_rec(struct ndr_push *ndr, int ndr_flags, const struct messaging_rec *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->msg_version)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->msg_type)); + NDR_CHECK(ndr_push_server_id(ndr, NDR_SCALARS, &r->dest)); + NDR_CHECK(ndr_push_server_id(ndr, NDR_SCALARS, &r->src)); + NDR_CHECK(ndr_push_DATA_BLOB(ndr, NDR_SCALARS, r->buf)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_server_id(ndr, NDR_BUFFERS, &r->dest)); + NDR_CHECK(ndr_push_server_id(ndr, NDR_BUFFERS, &r->src)); + } + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ndr_pull_messaging_rec(struct ndr_pull *ndr, int ndr_flags, struct messaging_rec *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->msg_version)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->msg_type)); + NDR_CHECK(ndr_pull_server_id(ndr, NDR_SCALARS, &r->dest)); + NDR_CHECK(ndr_pull_server_id(ndr, NDR_SCALARS, &r->src)); + NDR_CHECK(ndr_pull_DATA_BLOB(ndr, NDR_SCALARS, &r->buf)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_server_id(ndr, NDR_BUFFERS, &r->dest)); + NDR_CHECK(ndr_pull_server_id(ndr, NDR_BUFFERS, &r->src)); + } + return NT_STATUS_OK; +} + +_PUBLIC_ void ndr_print_messaging_rec(struct ndr_print *ndr, const char *name, const struct messaging_rec *r) +{ + ndr_print_struct(ndr, name, "messaging_rec"); + ndr->depth++; + ndr_print_uint32(ndr, "msg_version", r->msg_version); + ndr_print_uint32(ndr, "msg_type", r->msg_type); + ndr_print_server_id(ndr, "dest", &r->dest); + ndr_print_server_id(ndr, "src", &r->src); + ndr_print_DATA_BLOB(ndr, "buf", r->buf); + ndr->depth--; +} + +_PUBLIC_ NTSTATUS ndr_push_messaging_array(struct ndr_push *ndr, int ndr_flags, const struct messaging_array *r) +{ + uint32_t cntr_messages_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_messages)); + for (cntr_messages_0 = 0; cntr_messages_0 < r->num_messages; cntr_messages_0++) { + NDR_CHECK(ndr_push_messaging_rec(ndr, NDR_SCALARS, &r->messages[cntr_messages_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_messages_0 = 0; cntr_messages_0 < r->num_messages; cntr_messages_0++) { + NDR_CHECK(ndr_push_messaging_rec(ndr, NDR_BUFFERS, &r->messages[cntr_messages_0])); + } + } + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ndr_pull_messaging_array(struct ndr_pull *ndr, int ndr_flags, struct messaging_array *r) +{ + uint32_t cntr_messages_0; + TALLOC_CTX *_mem_save_messages_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_messages)); + NDR_PULL_ALLOC_N(ndr, r->messages, r->num_messages); + _mem_save_messages_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->messages, 0); + for (cntr_messages_0 = 0; cntr_messages_0 < r->num_messages; cntr_messages_0++) { + NDR_CHECK(ndr_pull_messaging_rec(ndr, NDR_SCALARS, &r->messages[cntr_messages_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_messages_0, 0); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_messages_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->messages, 0); + for (cntr_messages_0 = 0; cntr_messages_0 < r->num_messages; cntr_messages_0++) { + NDR_CHECK(ndr_pull_messaging_rec(ndr, NDR_BUFFERS, &r->messages[cntr_messages_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_messages_0, 0); + } + return NT_STATUS_OK; +} + +_PUBLIC_ void ndr_print_messaging_array(struct ndr_print *ndr, const char *name, const struct messaging_array *r) +{ + uint32_t cntr_messages_0; + ndr_print_struct(ndr, name, "messaging_array"); + ndr->depth++; + ndr_print_uint32(ndr, "num_messages", r->num_messages); + ndr->print(ndr, "%s: ARRAY(%d)", "messages", r->num_messages); + ndr->depth++; + for (cntr_messages_0=0;cntr_messages_0<r->num_messages;cntr_messages_0++) { + char *idx_0=NULL; + asprintf(&idx_0, "[%d]", cntr_messages_0); + if (idx_0) { + ndr_print_messaging_rec(ndr, "messages", &r->messages[cntr_messages_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + diff --git a/source3/librpc/gen_ndr/ndr_messaging.h b/source3/librpc/gen_ndr/ndr_messaging.h new file mode 100644 index 0000000000..c1093c76fe --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_messaging.h @@ -0,0 +1,16 @@ +/* header auto-generated by pidl */ + +#include "librpc/gen_ndr/messaging.h" + +#ifndef _HEADER_NDR_messaging +#define _HEADER_NDR_messaging + +#include "librpc/ndr/libndr.h" +#define DCERPC_MESSAGING_CALL_COUNT (0) +NTSTATUS ndr_push_messaging_rec(struct ndr_push *ndr, int ndr_flags, const struct messaging_rec *r); +NTSTATUS ndr_pull_messaging_rec(struct ndr_pull *ndr, int ndr_flags, struct messaging_rec *r); +void ndr_print_messaging_rec(struct ndr_print *ndr, const char *name, const struct messaging_rec *r); +NTSTATUS ndr_push_messaging_array(struct ndr_push *ndr, int ndr_flags, const struct messaging_array *r); +NTSTATUS ndr_pull_messaging_array(struct ndr_pull *ndr, int ndr_flags, struct messaging_array *r); +void ndr_print_messaging_array(struct ndr_print *ndr, const char *name, const struct messaging_array *r); +#endif /* _HEADER_NDR_messaging */ diff --git a/source3/librpc/idl/messaging.idl b/source3/librpc/idl/messaging.idl new file mode 100644 index 0000000000..b1158ca189 --- /dev/null +++ b/source3/librpc/idl/messaging.idl @@ -0,0 +1,26 @@ +#include "idl_types.h" + +/* + IDL structures for messaging code +*/ + +[ + pointer_default(unique) +] +interface messaging +{ + /* messaging struct sent across the sockets and stored in the tdb */ + + typedef [public] struct { + uint32 msg_version; + uint32 msg_type; + server_id dest; + server_id src; + DATA_BLOB buf; + } messaging_rec; + + typedef [public] struct { + uint32 num_messages; + messaging_rec messages[num_messages]; + } messaging_array; +} |