r21074: Preparation for the import of samba4 notify: Add the file notify.idl and the
authorVolker Lendecke <vlendec@samba.org>
Wed, 31 Jan 2007 11:48:14 +0000 (11:48 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:17:33 +0000 (12:17 -0500)
resulting marshalling/unmarshalling routines in gen_ndr/

Volker

source/Makefile.in
source/include/includes.h
source/include/messages.h
source/include/smb.h
source/librpc/gen_ndr/ndr_notify.c [new file with mode: 0644]
source/librpc/gen_ndr/ndr_notify.h [new file with mode: 0644]
source/librpc/gen_ndr/notify.h [new file with mode: 0644]
source/librpc/idl/notify.idl [new file with mode: 0644]
source/librpc/ndr/ndr_misc.c

index ed884bd3eaf6007d9f5fcf59496352d28b4b04b4..4b590119e99e9daaa8bff10fe8f8b8d5fbd9bc78 100644 (file)
@@ -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)" \
index 84bd90cc27f7eef83cf9af3a879273b52a160f6b..f7edb68c16bead37b274a1448aed0be5643c4e4a 100644 (file)
@@ -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"
index 223eca859b5b8ca717c8202fcdaa64e56a555b17..ead5fb08c29ee93214b28de6af0e509979aa5b78 100644 (file)
@@ -96,4 +96,12 @@ struct process_id {
        pid_t pid;
 };
 
+/*
+ * Samba4 API compatibility layer
+ */
+
+struct server_id {
+       struct process_id id;
+};
+
 #endif
index 21643c64a1f9d9ec5f56057ca06d3f6855fa4339..48d0e0cf6fa08cabe679c63b06befeb216091e9d 100644 (file)
@@ -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/source/librpc/gen_ndr/ndr_notify.c b/source/librpc/gen_ndr/ndr_notify.c
new file mode 100644 (file)
index 0000000..c387355
--- /dev/null
@@ -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/source/librpc/gen_ndr/ndr_notify.h b/source/librpc/gen_ndr/ndr_notify.h
new file mode 100644 (file)
index 0000000..793ffa5
--- /dev/null
@@ -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/source/librpc/gen_ndr/notify.h b/source/librpc/gen_ndr/notify.h
new file mode 100644 (file)
index 0000000..f85b9b1
--- /dev/null
@@ -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/source/librpc/idl/notify.idl b/source/librpc/idl/notify.idl
new file mode 100644 (file)
index 0000000..c4e633c
--- /dev/null
@@ -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;
+
+}
index 0be13eec3348fdcd7bcfd66eecfc43232f2f8351..54face8d7a03d3e38fb64b7272f74f4c7cc34d92 100644 (file)
@@ -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--;
+}