selftest: Turn on auth event notification and so allow tests to pass
[Samba.git] / source3 / include / messages.h
blobea89383e02d4db64e9c499b94706b7aa9e36aff4
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
40 * ctdb gives us 64-bit server ids for messaging_send. This is done to avoid
41 * pid clashes and to be able to register for special messages like "all
42 * smbds".
44 * Normal individual server id's have the upper 32 bits to 0, I picked "1" for
45 * Samba, other subsystems might use something else.
48 #define MSG_SRVID_SAMBA 0x0000000100000000LL
50 #include "librpc/gen_ndr/server_id.h"
51 #include "lib/util/data_blob.h"
52 #include "system/network.h"
54 #define MSG_BROADCAST_PID_STR "0:0"
56 struct messaging_context;
57 struct messaging_rec;
59 struct messaging_backend {
60 int (*send_fn)(struct server_id src,
61 struct server_id pid, int msg_type,
62 const struct iovec *iov, int iovlen,
63 const int *fds, size_t num_fds,
64 struct messaging_backend *backend);
65 void *private_data;
68 int messaging_ctdbd_init(struct messaging_context *msg_ctx,
69 TALLOC_CTX *mem_ctx,
70 struct messaging_backend **presult);
71 int messaging_ctdbd_reinit(struct messaging_context *msg_ctx,
72 TALLOC_CTX *mem_ctx,
73 struct messaging_backend *backend);
74 struct ctdbd_connection *messaging_ctdbd_connection(void);
76 struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
77 struct tevent_context *ev);
78 NTSTATUS messaging_init_client(TALLOC_CTX *mem_ctx,
79 struct tevent_context *ev,
80 struct messaging_context **pmsg_ctx);
82 struct server_id messaging_server_id(const struct messaging_context *msg_ctx);
83 struct tevent_context *messaging_tevent_context(
84 struct messaging_context *msg_ctx);
85 struct server_id_db *messaging_names_db(struct messaging_context *msg_ctx);
88 * re-init after a fork
90 NTSTATUS messaging_reinit(struct messaging_context *msg_ctx);
92 NTSTATUS messaging_register(struct messaging_context *msg_ctx,
93 void *private_data,
94 uint32_t msg_type,
95 void (*fn)(struct messaging_context *msg,
96 void *private_data,
97 uint32_t msg_type,
98 struct server_id server_id,
99 DATA_BLOB *data));
100 void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type,
101 void *private_data);
104 * CAVEAT:
106 * While the messaging_send*() functions are synchronuous by API,
107 * they trigger a tevent-based loop upon sending bigger messages.
109 * Hence callers should not use these in purely synchonous code,
110 * but run a tevent_loop instead.
112 NTSTATUS messaging_send(struct messaging_context *msg_ctx,
113 struct server_id server,
114 uint32_t msg_type, const DATA_BLOB *data);
116 NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
117 struct server_id server, uint32_t msg_type,
118 const uint8_t *buf, size_t len);
119 int messaging_send_iov_from(struct messaging_context *msg_ctx,
120 struct server_id src, struct server_id dst,
121 uint32_t msg_type,
122 const struct iovec *iov, int iovlen,
123 const int *fds, size_t num_fds);
124 NTSTATUS messaging_send_iov(struct messaging_context *msg_ctx,
125 struct server_id server, uint32_t msg_type,
126 const struct iovec *iov, int iovlen,
127 const int *fds, size_t num_fds);
129 struct tevent_req *messaging_filtered_read_send(
130 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
131 struct messaging_context *msg_ctx,
132 bool (*filter)(struct messaging_rec *rec, void *private_data),
133 void *private_data);
134 int messaging_filtered_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
135 struct messaging_rec **presult);
137 struct tevent_req *messaging_read_send(TALLOC_CTX *mem_ctx,
138 struct tevent_context *ev,
139 struct messaging_context *msg,
140 uint32_t msg_type);
141 int messaging_read_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
142 struct messaging_rec **presult);
144 struct tevent_req *messaging_handler_send(
145 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
146 struct messaging_context *msg_ctx, uint32_t msg_type,
147 bool (*handler)(struct messaging_context *msg_ctx,
148 struct messaging_rec **rec, void *private_data),
149 void *private_data);
150 int messaging_handler_recv(struct tevent_req *req);
152 int messaging_cleanup(struct messaging_context *msg_ctx, pid_t pid);
154 bool messaging_parent_dgm_cleanup_init(struct messaging_context *msg);
156 #include "librpc/gen_ndr/ndr_messaging.h"
158 #endif