messaging3: Directly refer to messaging_dgm in messages.c
[Samba.git] / source3 / include / messages.h
blob328161021fdcd722235a379759ccef4da8a22219
1 /*
2 Unix SMB/CIFS implementation.
3 messages.c header
4 Copyright (C) Andrew Tridgell 2000
5 Copyright (C) 2001, 2002 by Martin Pool
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef _MESSAGES_H_
22 #define _MESSAGES_H_
24 /* change the message version with any incompatible changes in the protocol */
25 #define MESSAGE_VERSION 2
28 * Special flags passed to message_send. Allocated from the top, lets see when
29 * it collides with the message types in the lower 16 bits :-)
33 * Under high load, this message can be dropped. Use for notify-style
34 * messages that are not critical for correct operation.
36 #define MSG_FLAG_LOWPRIORITY 0x80000000
39 /* Flags to classify messages - used in message_send_all() */
40 /* Sender will filter by flag. */
42 #define FLAG_MSG_GENERAL 0x0001
43 #define FLAG_MSG_SMBD 0x0002
44 #define FLAG_MSG_NMBD 0x0004
45 #define FLAG_MSG_WINBIND 0x0008
46 #define FLAG_MSG_PRINT_GENERAL 0x0010
47 /* dbwrap messages 4001-4999 */
48 #define FLAG_MSG_DBWRAP 0x0020
51 * ctdb gives us 64-bit server ids for messaging_send. This is done to avoid
52 * pid clashes and to be able to register for special messages like "all
53 * smbds".
55 * Normal individual server id's have the upper 32 bits to 0, I picked "1" for
56 * Samba, other subsystems might use something else.
59 #define MSG_SRVID_SAMBA 0x0000000100000000LL
61 #include "librpc/gen_ndr/server_id.h"
63 #define MSG_BROADCAST_PID_STR "0:0"
65 struct messaging_context;
66 struct messaging_rec;
68 struct messaging_backend {
69 int (*send_fn)(struct server_id src,
70 struct server_id pid, int msg_type,
71 const struct iovec *iov, int iovlen,
72 struct messaging_backend *backend);
73 void *private_data;
76 struct messaging_dgm_context;
77 int messaging_dgm_init(TALLOC_CTX *mem_ctx,
78 struct tevent_context *ev,
79 struct server_id pid,
80 void (*recv_cb)(int msg_type,
81 struct server_id src,
82 struct server_id dst,
83 const uint8_t *msg,
84 size_t msg_len,
85 void *private_data),
86 void *recv_cb_private_data,
87 struct messaging_dgm_context **pctx);
88 int messaging_dgm_send(struct messaging_dgm_context *ctx,
89 struct server_id src, struct server_id pid,
90 int msg_type, const struct iovec *iov, int iovlen);
91 int messaging_dgm_cleanup(struct messaging_dgm_context *ctx, pid_t pid);
92 int messaging_dgm_wipe(struct messaging_dgm_context *ctx);
93 void *messaging_dgm_register_tevent_context(TALLOC_CTX *mem_ctx,
94 struct messaging_dgm_context *ctx,
95 struct tevent_context *ev);
97 NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
98 TALLOC_CTX *mem_ctx,
99 struct messaging_backend **presult);
100 struct ctdbd_connection *messaging_ctdbd_connection(void);
102 bool message_send_all(struct messaging_context *msg_ctx,
103 int msg_type,
104 const void *buf, size_t len,
105 int *n_sent);
106 struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
107 struct tevent_context *ev);
109 struct server_id messaging_server_id(const struct messaging_context *msg_ctx);
110 struct tevent_context *messaging_tevent_context(
111 struct messaging_context *msg_ctx);
114 * re-init after a fork
116 NTSTATUS messaging_reinit(struct messaging_context *msg_ctx);
118 NTSTATUS messaging_register(struct messaging_context *msg_ctx,
119 void *private_data,
120 uint32_t msg_type,
121 void (*fn)(struct messaging_context *msg,
122 void *private_data,
123 uint32_t msg_type,
124 struct server_id server_id,
125 DATA_BLOB *data));
126 void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type,
127 void *private_data);
128 NTSTATUS messaging_send(struct messaging_context *msg_ctx,
129 struct server_id server,
130 uint32_t msg_type, const DATA_BLOB *data);
132 NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
133 struct server_id server, uint32_t msg_type,
134 const uint8_t *buf, size_t len);
135 NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
136 struct server_id server, uint32_t msg_type,
137 const struct iovec *iov, int iovlen);
138 void messaging_dispatch_rec(struct messaging_context *msg_ctx,
139 struct messaging_rec *rec);
141 struct tevent_req *messaging_filtered_read_send(
142 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
143 struct messaging_context *msg_ctx,
144 bool (*filter)(struct messaging_rec *rec, void *private_data),
145 void *private_data);
146 int messaging_filtered_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
147 struct messaging_rec **presult);
149 struct tevent_req *messaging_read_send(TALLOC_CTX *mem_ctx,
150 struct tevent_context *ev,
151 struct messaging_context *msg,
152 uint32_t msg_type);
153 int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
154 struct messaging_rec **presult);
156 int messaging_cleanup(struct messaging_context *msg_ctx, pid_t pid);
158 bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg);
160 #include "librpc/gen_ndr/ndr_messaging.h"
162 #endif