summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_pipe_register.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-07-19 13:48:31 -0400
committerSimo Sorce <idra@samba.org>2010-07-19 13:48:31 -0400
commitf9f3358348229b14d368316e327cfd2a4cb48c7c (patch)
tree9fb61c2ed61dd1ff93a64fc4498a4ec8d3a0607d /source3/rpc_server/srv_pipe_register.c
parent7e4de49bfceed18c81abf93703a61d0a22617a24 (diff)
parent630a2eb68af0d523a1bb4451bbaa75d2ba47d252 (diff)
downloadsamba-f9f3358348229b14d368316e327cfd2a4cb48c7c.tar.gz
samba-f9f3358348229b14d368316e327cfd2a4cb48c7c.tar.bz2
samba-f9f3358348229b14d368316e327cfd2a4cb48c7c.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3/rpc_server/srv_pipe_register.c')
-rw-r--r--source3/rpc_server/srv_pipe_register.c55
1 files changed, 48 insertions, 7 deletions
diff --git a/source3/rpc_server/srv_pipe_register.c b/source3/rpc_server/srv_pipe_register.c
index 757e4fbe72..3753596a2b 100644
--- a/source3/rpc_server/srv_pipe_register.c
+++ b/source3/rpc_server/srv_pipe_register.c
@@ -31,11 +31,26 @@ struct rpc_table {
struct ndr_syntax_id rpc_interface;
const struct api_struct *cmds;
uint32_t n_cmds;
+ bool (*shutdown_fn)(void *private_data);
+ void *shutdown_data;
};
static struct rpc_table *rpc_lookup;
static uint32_t rpc_lookup_size;
+static struct rpc_table *rpc_srv_get_pipe_by_id(const struct ndr_syntax_id *id)
+{
+ uint32_t i;
+
+ for (i = 0; i < rpc_lookup_size; i++) {
+ if (ndr_syntax_id_equal(&rpc_lookup[i].rpc_interface, id)) {
+ return &rpc_lookup[i];
+ }
+ }
+
+ return NULL;
+}
+
bool rpc_srv_pipe_exists_by_id(const struct ndr_syntax_id *id)
{
uint32_t i;
@@ -150,7 +165,8 @@ bool rpc_srv_get_pipe_interface_by_cli_name(const char *cli_name,
NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
const struct ndr_interface_table *iface,
- const struct api_struct *cmds, int size)
+ const struct api_struct *cmds, int size,
+ const struct rpc_srv_callbacks *rpc_srv_cb)
{
struct rpc_table *rpc_entry;
@@ -166,12 +182,10 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
return NT_STATUS_OBJECT_TYPE_MISMATCH;
}
- /* TODO:
- *
- * we still need to make sure that don't register the same commands twice!!!
- *
- * --metze
- */
+ /* Don't register the same command twice */
+ if (rpc_srv_pipe_exists_by_id(&iface->syntax_id)) {
+ return NT_STATUS_OK;
+ }
/*
* We use a temporary variable because this call can fail and
@@ -196,5 +210,32 @@ NTSTATUS rpc_srv_register(int version, const char *clnt, const char *srv,
rpc_entry->cmds = cmds;
rpc_entry->n_cmds = size;
+ if (rpc_srv_cb != NULL) {
+ rpc_entry->shutdown_fn = rpc_srv_cb->shutdown;
+ rpc_entry->shutdown_data = rpc_srv_cb->private_data;
+
+ if (rpc_srv_cb->init != NULL &&
+ !rpc_srv_cb->init(rpc_srv_cb->private_data)) {
+ DEBUG(0, ("rpc_srv_register: Failed to call the %s "
+ "init function!\n", srv));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+
+ return NT_STATUS_OK;
+}
+
+NTSTATUS rpc_srv_unregister(const struct ndr_interface_table *iface)
+{
+ struct rpc_table *rpc_entry = rpc_srv_get_pipe_by_id(&iface->syntax_id);
+
+ if (rpc_entry != NULL && rpc_entry->shutdown_fn != NULL) {
+ if (!rpc_entry->shutdown_fn(rpc_entry->shutdown_data)) {
+ DEBUG(0, ("rpc_srv_unregister: Failed to call the %s "
+ "init function!\n", rpc_entry->pipe.srv));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+ }
+
return NT_STATUS_OK;
}