15f8259e5148f6ea6ef8d42b8dba5e16cce7975c
[kai/samba.git] / source4 / lib / messaging / irpc.h
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Samba internal rpc code - header
5
6    Copyright (C) Andrew Tridgell 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef IRPC_H
23 #define IRPC_H
24
25 #include "lib/messaging/messaging.h"
26 #include "librpc/gen_ndr/irpc.h"
27
28 /*
29   an incoming irpc message
30 */
31 struct irpc_message {
32         struct server_id from;
33         void *private_data;
34         struct irpc_header header;
35         struct ndr_pull *ndr;
36         bool defer_reply;
37         bool no_reply;
38         struct imessaging_context *msg_ctx;
39         struct irpc_list *irpc;
40         void *data;
41         struct tevent_context *ev;
42 };
43
44 /* don't allow calls to take too long */
45 #define IRPC_CALL_TIMEOUT       10
46 /* wait for the calls as long as it takes */
47 #define IRPC_CALL_TIMEOUT_INF   0
48
49
50 /* the server function type */
51 typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r);
52
53 /* register a server function with the irpc messaging system */
54 #define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private_data) \
55    irpc_register(msg_ctx, &ndr_table_ ## pipename, \
56                           NDR_ ## funcname, \
57                           (irpc_function_t)function, private_data)
58
59 struct ndr_interface_table;
60
61 NTSTATUS irpc_register(struct imessaging_context *msg_ctx,
62                        const struct ndr_interface_table *table, 
63                        int call, irpc_function_t fn, void *private_data);
64
65 struct dcerpc_binding_handle *irpc_binding_handle(TALLOC_CTX *mem_ctx,
66                                         struct imessaging_context *msg_ctx,
67                                         struct server_id server_id,
68                                         const struct ndr_interface_table *table);
69 struct dcerpc_binding_handle *irpc_binding_handle_by_name(TALLOC_CTX *mem_ctx,
70                                         struct imessaging_context *msg_ctx,
71                                         const char *dest_task,
72                                         const struct ndr_interface_table *table);
73 void irpc_binding_handle_add_security_token(struct dcerpc_binding_handle *h,
74                                             struct security_token *token);
75
76 NTSTATUS irpc_add_name(struct imessaging_context *msg_ctx, const char *name);
77 struct server_id *irpc_servers_byname(struct imessaging_context *msg_ctx, TALLOC_CTX *mem_ctx, const char *name);
78 void irpc_remove_name(struct imessaging_context *msg_ctx, const char *name);
79 NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
80
81 #endif
82