s4/net_drs: 'net drs' utility initial creation
[Samba/nascimento.git] / source4 / lib / messaging / irpc.h
blobc82ad398ff41225c62f40f826f12ba0a53d2f2a5
1 /*
2 Unix SMB/CIFS implementation.
4 Samba internal rpc code - header
6 Copyright (C) Andrew Tridgell 2005
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.
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.
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/>.
22 #ifndef IRPC_H
23 #define IRPC_H
25 #include "lib/messaging/messaging.h"
26 #include "librpc/gen_ndr/irpc.h"
27 #include "librpc/gen_ndr/server_id.h"
30 an incoming irpc message
32 struct irpc_message {
33 struct server_id from;
34 void *private_data;
35 struct irpc_header header;
36 struct ndr_pull *ndr;
37 bool defer_reply;
38 struct messaging_context *msg_ctx;
39 struct irpc_list *irpc;
40 void *data;
41 struct tevent_context *ev;
44 /* don't allow calls to take too long */
45 #define IRPC_CALL_TIMEOUT 10
48 /* the server function type */
49 typedef NTSTATUS (*irpc_function_t)(struct irpc_message *, void *r);
51 /* register a server function with the irpc messaging system */
52 #define IRPC_REGISTER(msg_ctx, pipename, funcname, function, private_data) \
53 irpc_register(msg_ctx, &ndr_table_ ## pipename, \
54 NDR_ ## funcname, \
55 (irpc_function_t)function, private_data)
57 /* make a irpc call */
58 #define IRPC_CALL(msg_ctx, server_id, pipename, funcname, ptr, ctx) \
59 irpc_call(msg_ctx, server_id, &ndr_table_ ## pipename, NDR_ ## funcname, ptr, ctx)
61 #define IRPC_CALL_SEND(msg_ctx, server_id, pipename, funcname, ptr, ctx) \
62 irpc_call_send(msg_ctx, server_id, &ndr_table_ ## pipename, NDR_ ## funcname, ptr, ctx)
66 a pending irpc call
68 struct irpc_request {
69 struct messaging_context *msg_ctx;
70 const struct ndr_interface_table *table;
71 int callnum;
72 int callid;
73 void *r;
74 NTSTATUS status;
75 bool done;
76 bool reject_free;
77 TALLOC_CTX *mem_ctx;
78 struct {
79 void (*fn)(struct irpc_request *);
80 void *private_data;
81 } async;
84 struct loadparm_context;
86 typedef void (*msg_callback_t)(struct messaging_context *msg, void *private_data,
87 uint32_t msg_type,
88 struct server_id server_id, DATA_BLOB *data);
90 NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server,
91 uint32_t msg_type, DATA_BLOB *data);
92 NTSTATUS messaging_register(struct messaging_context *msg, void *private_data,
93 uint32_t msg_type,
94 msg_callback_t fn);
95 NTSTATUS messaging_register_tmp(struct messaging_context *msg, void *private_data,
96 msg_callback_t fn, uint32_t *msg_type);
97 struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
98 const char *dir,
99 struct server_id server_id,
100 struct smb_iconv_convenience *iconv_convenience,
101 struct tevent_context *ev);
102 struct messaging_context *messaging_client_init(TALLOC_CTX *mem_ctx,
103 const char *dir,
104 struct smb_iconv_convenience *iconv_convenience,
105 struct tevent_context *ev);
106 NTSTATUS messaging_send_ptr(struct messaging_context *msg, struct server_id server,
107 uint32_t msg_type, void *ptr);
108 void messaging_deregister(struct messaging_context *msg, uint32_t msg_type, void *private_data);
113 NTSTATUS irpc_register(struct messaging_context *msg_ctx,
114 const struct ndr_interface_table *table,
115 int call, irpc_function_t fn, void *private_data);
116 struct irpc_request *irpc_call_send(struct messaging_context *msg_ctx,
117 struct server_id server_id,
118 const struct ndr_interface_table *table,
119 int callnum, void *r, TALLOC_CTX *ctx);
120 NTSTATUS irpc_call_recv(struct irpc_request *irpc);
121 NTSTATUS irpc_call(struct messaging_context *msg_ctx,
122 struct server_id server_id,
123 const struct ndr_interface_table *table,
124 int callnum, void *r, TALLOC_CTX *ctx);
126 NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
127 struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, const char *name);
128 void irpc_remove_name(struct messaging_context *msg_ctx, const char *name);
129 NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
130 struct server_id messaging_get_server_id(struct messaging_context *msg_ctx);
132 #endif