summaryrefslogtreecommitdiff
path: root/source4/lib/messaging/irpc.h
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-06-05 06:53:07 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:17:37 -0500
commitbf1ffa283caef6a3c98b5cc7f5bc8205c2818b06 (patch)
tree11b434e632aaee2472c906b7ddb9d14fdfd48e38 /source4/lib/messaging/irpc.h
parent03840652354598db203a3596077ecc55726880c8 (diff)
downloadsamba-bf1ffa283caef6a3c98b5cc7f5bc8205c2818b06.tar.gz
samba-bf1ffa283caef6a3c98b5cc7f5bc8205c2818b06.tar.bz2
samba-bf1ffa283caef6a3c98b5cc7f5bc8205c2818b06.zip
r7294: implemented the irpc messaging system. This is the core of the
management system I proposed on samba-technical a couple of days ago. Essentially it is a very lightweight way for any code in Samba to make IDL based rpc calls to anywhere else in the code, without the client or server having to go to the trouble of setting up a full rpc service. It can be used with any of our existing IDL, but I expect it will mostly be used for a new set of Samba specific management calls. The LOCAL-IRPC torture test demonstrates how it can be used by calling the echo_AddOne() call over this transport. (This used to be commit 3d589a09954eb8b318f567e1150b0c27412fb942)
Diffstat (limited to 'source4/lib/messaging/irpc.h')
-rw-r--r--source4/lib/messaging/irpc.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/source4/lib/messaging/irpc.h b/source4/lib/messaging/irpc.h
new file mode 100644
index 0000000000..a483c78c70
--- /dev/null
+++ b/source4/lib/messaging/irpc.h
@@ -0,0 +1,94 @@
+/*
+ Unix SMB/CIFS implementation.
+
+ Samba internal rpc code - header
+
+ Copyright (C) Andrew Tridgell 2005
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+ an incoming irpc message
+*/
+struct irpc_message {
+ uint32_t from;
+};
+
+/* don't allow calls to take too long */
+#define IRPC_CALL_TIMEOUT 10
+
+
+/* the server function type */
+typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r);
+
+/* register a server function with the irpc messaging system */
+#define IRPC_REGISTER(msg_ctx, pipename, funcname, function) \
+ irpc_register(msg_ctx, &dcerpc_table_ ## pipename, \
+ DCERPC_ ## funcname, \
+ (irpc_function_t)function)
+
+/* make a irpc call */
+#define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr) \
+ irpc_call(msg_ctx, server_id, &dcerpc_table_ ## pipename, DCERPC_ ## funcname, ptr)
+
+
+/*
+ a pending irpc call
+*/
+struct irpc_request {
+ struct messaging_context *msg_ctx;
+ const struct dcerpc_interface_table *table;
+ int callnum;
+ int callid;
+ void *r;
+ NTSTATUS status;
+ BOOL done;
+ struct {
+ void (*fn)(struct irpc_request *);
+ void *private;
+ } async;
+};
+
+
+struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, uint32_t server_id,
+ struct event_context *ev);
+NTSTATUS messaging_send(struct messaging_context *msg, uint32_t server,
+ uint32_t msg_type, DATA_BLOB *data);
+void messaging_register(struct messaging_context *msg, void *private,
+ uint32_t msg_type,
+ void (*fn)(struct messaging_context *, void *, uint32_t, uint32_t, DATA_BLOB *));
+struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, uint32_t server_id,
+ struct event_context *ev);
+NTSTATUS messaging_send_ptr(struct messaging_context *msg, uint32_t server,
+ uint32_t msg_type, void *ptr);
+void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private);
+
+
+
+
+NTSTATUS irpc_register(struct messaging_context *msg_ctx,
+ const struct dcerpc_interface_table *table,
+ int call, irpc_function_t fn);
+struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx,
+ uint32_t server_id,
+ const struct dcerpc_interface_table *table,
+ int callnum, void *r);
+NTSTATUS irpc_call_recv(struct irpc_request *irpc);
+NTSTATUS irpc_call(struct messaging_context *msg_ctx,
+ uint32_t server_id,
+ const struct dcerpc_interface_table *table,
+ int callnum, void *r);
+