/* [<][>][^][v][top][bottom][index][help] */
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 "librpc/gen_ndr/irpc.h"
26 #include "librpc/gen_ndr/server_id.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 struct messaging_context *msg_ctx;
38 struct irpc_list *irpc;
39 void *data;
40 struct tevent_context *ev;
41 };
42
43 /* don't allow calls to take too long */
44 #define IRPC_CALL_TIMEOUT 10
45
46
47 /* the server function type */
48 typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r);
49
50 /* register a server function with the irpc messaging system */
51 #define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private_data) \
52 irpc_register(msg_ctx, &ndr_table_ ## pipename, \
53 NDR_ ## funcname, \
54 (irpc_function_t)function, private_data)
55
56 /* make a irpc call */
57 #define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr, ctx) \
58 irpc_call(msg_ctx, server_id, &ndr_table_ ## pipename, NDR_ ## funcname, ptr, ctx)
59
60 #define IRPC_CALL_SEND(msg_ctx, server_id, pipename, funcname, ptr, ctx) \
61 irpc_call_send(msg_ctx, server_id, &ndr_table_ ## pipename, NDR_ ## funcname, ptr, ctx)
62
63
64 /*
65 a pending irpc call
66 */
67 struct irpc_request {
68 struct messaging_context *msg_ctx;
69 const struct ndr_interface_table *table;
70 int callnum;
71 int callid;
72 void *r;
73 NTSTATUS status;
74 bool done;
75 bool reject_free;
76 TALLOC_CTX *mem_ctx;
77 struct {
78 void (*fn)(struct irpc_request *);
79 void *private_data;
80 } async;
81 };
82
83 struct loadparm_context;
84
85 typedef void (*msg_callback_t)(struct messaging_context *msg, void *private_data,
86 uint32_t msg_type,
87 struct server_id server_id, DATA_BLOB *data);
88
89 NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
90 uint32_t msg_type, DATA_BLOB *data);
91 NTSTATUS messaging_register(struct messaging_context *msg, void *private_data,
92 uint32_t msg_type,
93 msg_callback_t fn);
94 NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data,
95 msg_callback_t fn, uint32_t *msg_type);
96 struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
97 const char *dir,
98 struct server_id server_id,
99 struct smb_iconv_convenience *iconv_convenience,
100 struct tevent_context *ev);
101 struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
102 const char *dir,
103 struct smb_iconv_convenience *iconv_convenience,
104 struct tevent_context *ev);
105 NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server,
106 uint32_t msg_type, void *ptr);
107 void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data);
108
109
110
111
112 NTSTATUS irpc_register(struct messaging_context *msg_ctx,
113 const struct ndr_interface_table *table,
114 int call, irpc_function_t fn, void *private_data);
115 struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx,
116 struct server_id server_id,
117 const struct ndr_interface_table *table,
118 int callnum, void *r, TALLOC_CTX *ctx);
119 NTSTATUS irpc_call_recv(struct irpc_request *irpc);
120 NTSTATUS irpc_call(struct messaging_context *msg_ctx,
121 struct server_id server_id,
122 const struct ndr_interface_table *table,
123 int callnum, void *r, TALLOC_CTX *ctx);
124
125 NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
126 struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, const char *name);
127 void irpc_remove_name(struct messaging_context *msg_ctx, const char *name);
128 NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
129 struct server_id messaging_get_server_id(struct messaging_context *msg_ctx);
130
131 #endif
132