#ifndef _MESSAGES_H_
#define _MESSAGES_H_
+/* change the message version with any incompatible changes in the protocol */
+#define MESSAGE_VERSION 2
+
+
#define MSG_TYPE_MASK 0xFFFF
/* general messages */
* Samba4 compatibility
*/
#define MSG_PVFS_NOTIFY 0x0310
+/*
+ * cluster reconfigure events
+ */
+#define MSG_SMB_BRL_VALIDATE 0x0311
+#define MSG_SMB_RELEASE_IP 0x0312
/* winbind messages */
#define MSG_WINBIND_FINISHED 0x0401
#define MSG_WINBIND_TRY_TO_GO_ONLINE 0x0406
#define MSG_WINBIND_FAILED_TO_GO_ONLINE 0x0407
+/* event messages */
+#define MSG_DUMP_EVENT_LIST 0x0500
+
/*
* Special flags passed to message_send. Allocated from the top, lets see when
* it collides with the message types in the lower 16 bits :-)
#define FLAG_MSG_PRINT_NOTIFY 0x0008
#define FLAG_MSG_PRINT_GENERAL 0x0010
+
+/*
+ * Virtual Node Numbers are identifying a node within a cluster. Ctdbd sets
+ * this, we retrieve our vnn from it.
+ */
+
+#define NONCLUSTER_VNN (0xFFFFFFFF)
+
+/*
+ * ctdb gives us 64-bit server ids for messaging_send. This is done to avoid
+ * pid clashes and to be able to register for special messages like "all
+ * smbds".
+ *
+ * Normal individual server id's have the upper 32 bits to 0, I picked "1" for
+ * Samba, other subsystems might use something else.
+ */
+
+#define MSG_SRVID_SAMBA 0x0000000100000000LL
+
+
struct server_id {
pid_t pid;
+#ifdef CLUSTER_SUPPORT
+ uint32 vnn;
+#endif
};
+
+
struct messaging_context;
+struct messaging_rec;
struct data_blob;
+/*
+ * struct messaging_context belongs to messages.c, but because we still have
+ * messaging_dispatch, we need it here. Once we get rid of signals for
+ * notifying processes, this will go.
+ */
+
+struct messaging_context {
+ struct server_id id;
+ struct event_context *event_ctx;
+ struct messaging_callback *callbacks;
+
+ struct messaging_backend *local;
+ struct messaging_backend *remote;
+};
+
+struct messaging_backend {
+ NTSTATUS (*send_fn)(struct messaging_context *msg_ctx,
+ struct server_id pid, int msg_type,
+ const struct data_blob *data,
+ struct messaging_backend *backend);
+ void *private_data;
+};
+
+NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend **presult);
void message_dispatch(struct messaging_context *msg_ctx);
+
+NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx,
+ TALLOC_CTX *mem_ctx,
+ struct messaging_backend **presult);
+struct ctdbd_connection *messaging_ctdbd_connection(void);
+
BOOL message_send_all(struct messaging_context *msg_ctx,
int msg_type,
const void *buf, size_t len,
int *n_sent);
-void message_block(void);
-void message_unblock(void);
struct event_context *messaging_event_context(struct messaging_context *msg_ctx);
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
struct server_id server_id,
struct event_context *ev);
+
+/*
+ * re-init after a fork
+ */
+NTSTATUS messaging_reinit(struct messaging_context *msg_ctx);
+
NTSTATUS messaging_register(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
struct server_id server, uint32_t msg_type,
const uint8 *buf, size_t len);
+void messaging_dispatch_rec(struct messaging_context *msg_ctx,
+ struct messaging_rec *rec);
#endif