diff options
author | Volker Lendecke <vlendec@samba.org> | 2007-01-31 11:48:14 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:17:33 -0500 |
commit | 8bfa9351614115ceb8bfaa6f76355ddc14ec248b (patch) | |
tree | d74dcfe5ed206d06f2c036d81a45f094013619b2 | |
parent | 05f298b47e4493ccf04b8a1698c0593c8a0deaac (diff) | |
download | samba-8bfa9351614115ceb8bfaa6f76355ddc14ec248b.tar.gz samba-8bfa9351614115ceb8bfaa6f76355ddc14ec248b.tar.bz2 samba-8bfa9351614115ceb8bfaa6f76355ddc14ec248b.zip |
r21074: Preparation for the import of samba4 notify: Add the file notify.idl and the
resulting marshalling/unmarshalling routines in gen_ndr/
Volker
(This used to be commit a2ea54c23456925a8ed317edb1adf82d074041fc)
-rw-r--r-- | source3/Makefile.in | 5 | ||||
-rw-r--r-- | source3/include/includes.h | 1 | ||||
-rw-r--r-- | source3/include/messages.h | 8 | ||||
-rw-r--r-- | source3/include/smb.h | 1 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_notify.c | 242 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/ndr_notify.h | 20 | ||||
-rw-r--r-- | source3/librpc/gen_ndr/notify.h | 33 | ||||
-rw-r--r-- | source3/librpc/idl/notify.idl | 56 | ||||
-rw-r--r-- | source3/librpc/ndr/ndr_misc.c | 33 |
9 files changed, 397 insertions, 2 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index ed884bd3ea..4b590119e9 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -221,7 +221,8 @@ LIBNDR_GEN_OBJ = librpc/gen_ndr/ndr_unixinfo.o librpc/gen_ndr/ndr_lsa.o \ librpc/gen_ndr/ndr_dfs.o librpc/gen_ndr/ndr_echo.o \ librpc/gen_ndr/ndr_winreg.o librpc/gen_ndr/ndr_initshutdown.o \ librpc/gen_ndr/ndr_srvsvc.o librpc/gen_ndr/ndr_svcctl.o \ - librpc/gen_ndr/ndr_eventlog.o librpc/gen_ndr/ndr_wkssvc.o + librpc/gen_ndr/ndr_eventlog.o librpc/gen_ndr/ndr_wkssvc.o \ + librpc/gen_ndr/ndr_notify.o RPC_PARSE_OBJ0 = rpc_parse/parse_prs.o rpc_parse/parse_misc.o @@ -919,7 +920,7 @@ cac: SHOWFLAGS $(LIBMSRPC) ##################################################################### ## Perl IDL Compiler IDL_FILES = unixinfo.idl lsa.idl dfs.idl echo.idl winreg.idl initshutdown.idl \ - srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl + srvsvc.idl svcctl.idl eventlog.idl wkssvc.idl netlogon.idl notify.idl idl: @IDL_FILES="$(IDL_FILES)" CPP="$(CPP)" PERL="$(PERL)" \ diff --git a/source3/include/includes.h b/source3/include/includes.h index 84bd90cc27..f7edb68c16 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -681,6 +681,7 @@ typedef int BOOL; #include "rpc_perfcount_defs.h" #include "librpc/gen_ndr/srvsvc.h" #include "librpc/gen_ndr/echo.h" +#include "librpc/gen_ndr/notify.h" #include "nt_printing.h" #include "idmap.h" #include "client.h" diff --git a/source3/include/messages.h b/source3/include/messages.h index 223eca859b..ead5fb08c2 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -96,4 +96,12 @@ struct process_id { pid_t pid; }; +/* + * Samba4 API compatibility layer + */ + +struct server_id { + struct process_id id; +}; + #endif diff --git a/source3/include/smb.h b/source3/include/smb.h index 21643c64a1..48d0e0cf6f 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -421,6 +421,7 @@ struct fd_handle { unsigned long file_id; }; +struct messaging_context; struct event_context; struct fd_event; struct timed_event; diff --git a/source3/librpc/gen_ndr/ndr_notify.c b/source3/librpc/gen_ndr/ndr_notify.c new file mode 100644 index 0000000000..c3873550bb --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_notify.c @@ -0,0 +1,242 @@ +/* parser auto-generated by pidl */ + +#include "includes.h" +#include "librpc/gen_ndr/ndr_notify.h" + +_PUBLIC_ NTSTATUS ndr_push_notify_entry(struct ndr_push *ndr, int ndr_flags, const struct notify_entry *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_server_id(ndr, NDR_SCALARS, &r->server)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->filter)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->subdir_filter)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->path)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->path_len)); + NDR_CHECK(ndr_push_pointer(ndr, NDR_SCALARS, r->private_data)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_push_server_id(ndr, NDR_BUFFERS, &r->server)); + } + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ndr_pull_notify_entry(struct ndr_pull *ndr, int ndr_flags, struct notify_entry *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_server_id(ndr, NDR_SCALARS, &r->server)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->filter)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->subdir_filter)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->path)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->path_len)); + NDR_CHECK(ndr_pull_pointer(ndr, NDR_SCALARS, &r->private_data)); + } + if (ndr_flags & NDR_BUFFERS) { + NDR_CHECK(ndr_pull_server_id(ndr, NDR_BUFFERS, &r->server)); + } + return NT_STATUS_OK; +} + +_PUBLIC_ void ndr_print_notify_entry(struct ndr_print *ndr, const char *name, const struct notify_entry *r) +{ + ndr_print_struct(ndr, name, "notify_entry"); + ndr->depth++; + ndr_print_server_id(ndr, "server", &r->server); + ndr_print_uint32(ndr, "filter", r->filter); + ndr_print_uint32(ndr, "subdir_filter", r->subdir_filter); + ndr_print_string(ndr, "path", r->path); + ndr_print_uint32(ndr, "path_len", r->path_len); + ndr_print_pointer(ndr, "private_data", r->private_data); + ndr->depth--; +} + +NTSTATUS ndr_push_notify_depth(struct ndr_push *ndr, int ndr_flags, const struct notify_depth *r) +{ + uint32_t cntr_entries_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->max_mask)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->max_mask_subdir)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_entries)); + for (cntr_entries_0 = 0; cntr_entries_0 < r->num_entries; cntr_entries_0++) { + NDR_CHECK(ndr_push_notify_entry(ndr, NDR_SCALARS, &r->entries[cntr_entries_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_entries_0 = 0; cntr_entries_0 < r->num_entries; cntr_entries_0++) { + NDR_CHECK(ndr_push_notify_entry(ndr, NDR_BUFFERS, &r->entries[cntr_entries_0])); + } + } + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_notify_depth(struct ndr_pull *ndr, int ndr_flags, struct notify_depth *r) +{ + uint32_t cntr_entries_0; + TALLOC_CTX *_mem_save_entries_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->max_mask)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->max_mask_subdir)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_entries)); + NDR_PULL_ALLOC_N(ndr, r->entries, r->num_entries); + _mem_save_entries_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->entries, 0); + for (cntr_entries_0 = 0; cntr_entries_0 < r->num_entries; cntr_entries_0++) { + NDR_CHECK(ndr_pull_notify_entry(ndr, NDR_SCALARS, &r->entries[cntr_entries_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entries_0, 0); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_entries_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->entries, 0); + for (cntr_entries_0 = 0; cntr_entries_0 < r->num_entries; cntr_entries_0++) { + NDR_CHECK(ndr_pull_notify_entry(ndr, NDR_BUFFERS, &r->entries[cntr_entries_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_entries_0, 0); + } + return NT_STATUS_OK; +} + +_PUBLIC_ void ndr_print_notify_depth(struct ndr_print *ndr, const char *name, const struct notify_depth *r) +{ + uint32_t cntr_entries_0; + ndr_print_struct(ndr, name, "notify_depth"); + ndr->depth++; + ndr_print_uint32(ndr, "max_mask", r->max_mask); + ndr_print_uint32(ndr, "max_mask_subdir", r->max_mask_subdir); + ndr_print_uint32(ndr, "num_entries", r->num_entries); + ndr->print(ndr, "%s: ARRAY(%d)", "entries", r->num_entries); + ndr->depth++; + for (cntr_entries_0=0;cntr_entries_0<r->num_entries;cntr_entries_0++) { + char *idx_0=NULL; + asprintf(&idx_0, "[%d]", cntr_entries_0); + if (idx_0) { + ndr_print_notify_entry(ndr, "entries", &r->entries[cntr_entries_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ NTSTATUS ndr_push_notify_array(struct ndr_push *ndr, int ndr_flags, const struct notify_array *r) +{ + uint32_t cntr_depth_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->num_depths)); + for (cntr_depth_0 = 0; cntr_depth_0 < r->num_depths; cntr_depth_0++) { + NDR_CHECK(ndr_push_notify_depth(ndr, NDR_SCALARS, &r->depth[cntr_depth_0])); + } + } + if (ndr_flags & NDR_BUFFERS) { + for (cntr_depth_0 = 0; cntr_depth_0 < r->num_depths; cntr_depth_0++) { + NDR_CHECK(ndr_push_notify_depth(ndr, NDR_BUFFERS, &r->depth[cntr_depth_0])); + } + } + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ndr_pull_notify_array(struct ndr_pull *ndr, int ndr_flags, struct notify_array *r) +{ + uint32_t cntr_depth_0; + TALLOC_CTX *_mem_save_depth_0; + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->num_depths)); + NDR_PULL_ALLOC_N(ndr, r->depth, r->num_depths); + _mem_save_depth_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->depth, 0); + for (cntr_depth_0 = 0; cntr_depth_0 < r->num_depths; cntr_depth_0++) { + NDR_CHECK(ndr_pull_notify_depth(ndr, NDR_SCALARS, &r->depth[cntr_depth_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_depth_0, 0); + } + if (ndr_flags & NDR_BUFFERS) { + _mem_save_depth_0 = NDR_PULL_GET_MEM_CTX(ndr); + NDR_PULL_SET_MEM_CTX(ndr, r->depth, 0); + for (cntr_depth_0 = 0; cntr_depth_0 < r->num_depths; cntr_depth_0++) { + NDR_CHECK(ndr_pull_notify_depth(ndr, NDR_BUFFERS, &r->depth[cntr_depth_0])); + } + NDR_PULL_SET_MEM_CTX(ndr, _mem_save_depth_0, 0); + } + return NT_STATUS_OK; +} + +_PUBLIC_ void ndr_print_notify_array(struct ndr_print *ndr, const char *name, const struct notify_array *r) +{ + uint32_t cntr_depth_0; + ndr_print_struct(ndr, name, "notify_array"); + ndr->depth++; + ndr_print_uint32(ndr, "num_depths", r->num_depths); + ndr->print(ndr, "%s: ARRAY(%d)", "depth", r->num_depths); + ndr->depth++; + for (cntr_depth_0=0;cntr_depth_0<r->num_depths;cntr_depth_0++) { + char *idx_0=NULL; + asprintf(&idx_0, "[%d]", cntr_depth_0); + if (idx_0) { + ndr_print_notify_depth(ndr, "depth", &r->depth[cntr_depth_0]); + free(idx_0); + } + } + ndr->depth--; + ndr->depth--; +} + +_PUBLIC_ NTSTATUS ndr_push_notify_event(struct ndr_push *ndr, int ndr_flags, const struct notify_event *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 8)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, r->action)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_push_string(ndr, NDR_SCALARS, r->path)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_push_pointer(ndr, NDR_SCALARS, r->private_data)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NT_STATUS_OK; +} + +_PUBLIC_ NTSTATUS ndr_pull_notify_event(struct ndr_pull *ndr, int ndr_flags, struct notify_event *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_pull_align(ndr, 8)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &r->action)); + { + uint32_t _flags_save_string = ndr->flags; + ndr_set_flags(&ndr->flags, LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM); + NDR_CHECK(ndr_pull_string(ndr, NDR_SCALARS, &r->path)); + ndr->flags = _flags_save_string; + } + NDR_CHECK(ndr_pull_pointer(ndr, NDR_SCALARS, &r->private_data)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NT_STATUS_OK; +} + +_PUBLIC_ void ndr_print_notify_event(struct ndr_print *ndr, const char *name, const struct notify_event *r) +{ + ndr_print_struct(ndr, name, "notify_event"); + ndr->depth++; + ndr_print_uint32(ndr, "action", r->action); + ndr_print_string(ndr, "path", r->path); + ndr_print_pointer(ndr, "private_data", r->private_data); + ndr->depth--; +} + diff --git a/source3/librpc/gen_ndr/ndr_notify.h b/source3/librpc/gen_ndr/ndr_notify.h new file mode 100644 index 0000000000..793ffa51ca --- /dev/null +++ b/source3/librpc/gen_ndr/ndr_notify.h @@ -0,0 +1,20 @@ +/* header auto-generated by pidl */ + +#include "librpc/gen_ndr/notify.h" + +#ifndef _HEADER_NDR_notify +#define _HEADER_NDR_notify + +#include "librpc/ndr/libndr.h" +#define DCERPC_NOTIFY_CALL_COUNT (0) +NTSTATUS ndr_push_notify_entry(struct ndr_push *ndr, int ndr_flags, const struct notify_entry *r); +NTSTATUS ndr_pull_notify_entry(struct ndr_pull *ndr, int ndr_flags, struct notify_entry *r); +void ndr_print_notify_entry(struct ndr_print *ndr, const char *name, const struct notify_entry *r); +void ndr_print_notify_depth(struct ndr_print *ndr, const char *name, const struct notify_depth *r); +NTSTATUS ndr_push_notify_array(struct ndr_push *ndr, int ndr_flags, const struct notify_array *r); +NTSTATUS ndr_pull_notify_array(struct ndr_pull *ndr, int ndr_flags, struct notify_array *r); +void ndr_print_notify_array(struct ndr_print *ndr, const char *name, const struct notify_array *r); +NTSTATUS ndr_push_notify_event(struct ndr_push *ndr, int ndr_flags, const struct notify_event *r); +NTSTATUS ndr_pull_notify_event(struct ndr_pull *ndr, int ndr_flags, struct notify_event *r); +void ndr_print_notify_event(struct ndr_print *ndr, const char *name, const struct notify_event *r); +#endif /* _HEADER_NDR_notify */ diff --git a/source3/librpc/gen_ndr/notify.h b/source3/librpc/gen_ndr/notify.h new file mode 100644 index 0000000000..f85b9b1bac --- /dev/null +++ b/source3/librpc/gen_ndr/notify.h @@ -0,0 +1,33 @@ +/* header auto-generated by pidl */ + +#ifndef _HEADER_notify +#define _HEADER_notify + +struct notify_entry { + struct server_id server; + uint32_t filter; + uint32_t subdir_filter; + const char * path;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ + uint32_t path_len; + void* private_data; +}/* [public] */; + +struct notify_depth { + uint32_t max_mask; + uint32_t max_mask_subdir; + uint32_t num_entries; + struct notify_entry *entries; +}; + +struct notify_array { + uint32_t num_depths; + struct notify_depth *depth; +}/* [public] */; + +struct notify_event { + uint32_t action; + const char * path;/* [flag(LIBNDR_FLAG_STR_UTF8|LIBNDR_FLAG_STR_NULLTERM)] */ + void* private_data; +}/* [public] */; + +#endif /* _HEADER_notify */ diff --git a/source3/librpc/idl/notify.idl b/source3/librpc/idl/notify.idl new file mode 100644 index 0000000000..c4e633c254 --- /dev/null +++ b/source3/librpc/idl/notify.idl @@ -0,0 +1,56 @@ +#include "idl_types.h" + +/* + IDL structures for notify change code + + this defines the structures used in the notify database code, and + the change notify buffers +*/ + +[ + pointer_default(unique) +] +interface notify +{ + + /* structure used in the notify database */ + typedef [public] struct { + server_id server; + uint32 filter; /* filter to apply in this directory */ + uint32 subdir_filter; /* filter to apply in child directories */ + utf8string path; + uint32 path_len; /* saves some computation on search */ + pointer private_data; + } notify_entry; + + /* + to allow for efficient search for matching entries, we + divide them by the directory depth, with a separate array + per depth. The entries within each depth are sorted by path, + allowing for a bisection search. + + The max_mask and max_mask_subdir at each depth is the + bitwise or of the filters and subdir filters for all entries + at that depth. This allows a depth to be quickly skipped if + no entries will match the target filter + */ + typedef struct { + uint32 max_mask; + uint32 max_mask_subdir; + uint32 num_entries; + notify_entry entries[num_entries]; + } notify_depth; + + typedef [public] struct { + uint32 num_depths; + notify_depth depth[num_depths]; + } notify_array; + + /* structure sent between servers in notify messages */ + typedef [public] struct { + uint32 action; + utf8string path; + pointer private_data; + } notify_event; + +} diff --git a/source3/librpc/ndr/ndr_misc.c b/source3/librpc/ndr/ndr_misc.c index 0be13eec33..54face8d7a 100644 --- a/source3/librpc/ndr/ndr_misc.c +++ b/source3/librpc/ndr/ndr_misc.c @@ -237,3 +237,36 @@ void ndr_print_policy_handle(struct ndr_print *ndr, const char *name, const stru ndr_print_GUID(ndr, "uuid", &r->uuid); ndr->depth--; } + +NTSTATUS ndr_push_server_id(struct ndr_push *ndr, int ndr_flags, const struct server_id *r) +{ + if (ndr_flags & NDR_SCALARS) { + NDR_CHECK(ndr_push_align(ndr, 4)); + NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, + (uint32_t)r->id.pid)); + } + if (ndr_flags & NDR_BUFFERS) { + } + return NT_STATUS_OK; +} + +NTSTATUS ndr_pull_server_id(struct ndr_pull *ndr, int ndr_flags, struct server_id *r) +{ + if (ndr_flags & NDR_SCALARS) { + uint32_t pid; + NDR_CHECK(ndr_pull_align(ndr, 4)); + NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &pid)); + r->id.pid = (pid_t)pid; + } + if (ndr_flags & NDR_BUFFERS) { + } + return NT_STATUS_OK; +} + +void ndr_print_server_id(struct ndr_print *ndr, const char *name, const struct server_id *r) +{ + ndr_print_struct(ndr, name, "server_id"); + ndr->depth++; + ndr_print_uint32(ndr, "id", (uint32_t)r->id.pid); + ndr->depth--; +} |