#define MSG_FLAG_LOWPRIORITY 0x80000000
-/* Flags to classify messages - used in message_send_all() */
-/* Sender will filter by flag. */
-
-#define FLAG_MSG_GENERAL 0x0001
-#define FLAG_MSG_SMBD 0x0002
-#define FLAG_MSG_NMBD 0x0004
-#define FLAG_MSG_WINBIND 0x0008
-#define FLAG_MSG_PRINT_GENERAL 0x0010
-/* dbwrap messages 4001-4999 */
-#define FLAG_MSG_DBWRAP 0x0020
-
/*
* 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
struct messaging_backend *backend);
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);
struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx,
struct tevent_context *ev);
#include "lib/dbwrap/dbwrap.h"
#include "librpc/gen_ndr/server_id.h"
+/* Flags to classify messages - used in message_send_all() */
+/* Sender will filter by flag. */
+
+#define FLAG_MSG_GENERAL 0x0001
+#define FLAG_MSG_SMBD 0x0002
+#define FLAG_MSG_NMBD 0x0004
+#define FLAG_MSG_WINBIND 0x0008
+#define FLAG_MSG_PRINT_GENERAL 0x0010
+/* dbwrap messages 4001-4999 */
+#define FLAG_MSG_DBWRAP 0x0020
+
/*
* Register a server with its unique id
*/
*/
bool serverid_parent_init(TALLOC_CTX *mem_ctx);
+struct messaging_context;
+
+bool message_send_all(struct messaging_context *msg_ctx,
+ int msg_type,
+ const void *buf, size_t len,
+ int *n_sent);
+
#endif
messaging_send(msg_ctx, src, MSG_PONG, data);
}
-/****************************************************************************
- Register/replace a dispatch function for a particular message type.
- JRA changed Dec 13 2006. Only one message handler now permitted per type.
- *NOTE*: Dispatch functions must be able to cope with incoming
- messages on an *odd* byte boundary.
-****************************************************************************/
-
-struct msg_all {
- struct messaging_context *msg_ctx;
- int msg_type;
- uint32_t msg_flag;
- const void *buf;
- size_t len;
- int n_sent;
-};
-
-/****************************************************************************
- Send one of the messages for the broadcast.
-****************************************************************************/
-
-static int traverse_fn(struct db_record *rec, const struct server_id *id,
- uint32_t msg_flags, void *state)
-{
- struct msg_all *msg_all = (struct msg_all *)state;
- NTSTATUS status;
-
- /* Don't send if the receiver hasn't registered an interest. */
-
- if((msg_flags & msg_all->msg_flag) == 0) {
- return 0;
- }
-
- /* If the msg send fails because the pid was not found (i.e. smbd died),
- * the msg has already been deleted from the messages.tdb.*/
-
- status = messaging_send_buf(msg_all->msg_ctx, *id, msg_all->msg_type,
- (const uint8_t *)msg_all->buf, msg_all->len);
-
- if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
- struct server_id_buf idbuf;
-
- /*
- * If the pid was not found delete the entry from
- * serverid.tdb
- */
-
- DEBUG(2, ("pid %s doesn't exist\n",
- server_id_str_buf(*id, &idbuf)));
-
- dbwrap_record_delete(rec);
- }
- msg_all->n_sent++;
- return 0;
-}
-
-/**
- * Send a message to all smbd processes.
- *
- * It isn't very efficient, but should be OK for the sorts of
- * applications that use it. When we need efficient broadcast we can add
- * it.
- *
- * @param n_sent Set to the number of messages sent. This should be
- * equal to the number of processes, but be careful for races.
- *
- * @retval True for success.
- **/
-bool message_send_all(struct messaging_context *msg_ctx,
- int msg_type,
- const void *buf, size_t len,
- int *n_sent)
-{
- struct msg_all msg_all;
-
- msg_all.msg_type = msg_type;
- if (msg_type < 0x100) {
- msg_all.msg_flag = FLAG_MSG_GENERAL;
- } else if (msg_type > 0x100 && msg_type < 0x200) {
- msg_all.msg_flag = FLAG_MSG_NMBD;
- } else if (msg_type > 0x200 && msg_type < 0x300) {
- msg_all.msg_flag = FLAG_MSG_PRINT_GENERAL;
- } else if (msg_type > 0x300 && msg_type < 0x400) {
- msg_all.msg_flag = FLAG_MSG_SMBD;
- } else if (msg_type > 0x400 && msg_type < 0x600) {
- msg_all.msg_flag = FLAG_MSG_WINBIND;
- } else if (msg_type > 4000 && msg_type < 5000) {
- msg_all.msg_flag = FLAG_MSG_DBWRAP;
- } else {
- return false;
- }
-
- msg_all.buf = buf;
- msg_all.len = len;
- msg_all.n_sent = 0;
- msg_all.msg_ctx = msg_ctx;
-
- serverid_traverse(traverse_fn, &msg_all);
- if (n_sent)
- *n_sent = msg_all.n_sent;
- return true;
-}
-
static void messaging_recv_cb(const uint8_t *msg, size_t msg_len,
int *fds, size_t num_fds,
void *private_data)
status = dbwrap_traverse(db, serverid_traverse_fn, &state, NULL);
return NT_STATUS_IS_OK(status);
}
+
+struct msg_all {
+ struct messaging_context *msg_ctx;
+ int msg_type;
+ uint32_t msg_flag;
+ const void *buf;
+ size_t len;
+ int n_sent;
+};
+
+/****************************************************************************
+ Send one of the messages for the broadcast.
+****************************************************************************/
+
+static int traverse_fn(struct db_record *rec, const struct server_id *id,
+ uint32_t msg_flags, void *state)
+{
+ struct msg_all *msg_all = (struct msg_all *)state;
+ NTSTATUS status;
+
+ /* Don't send if the receiver hasn't registered an interest. */
+
+ if((msg_flags & msg_all->msg_flag) == 0) {
+ return 0;
+ }
+
+ /* If the msg send fails because the pid was not found (i.e. smbd died),
+ * the msg has already been deleted from the messages.tdb.*/
+
+ status = messaging_send_buf(msg_all->msg_ctx, *id, msg_all->msg_type,
+ (const uint8_t *)msg_all->buf, msg_all->len);
+
+ if (NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) {
+ struct server_id_buf idbuf;
+
+ /*
+ * If the pid was not found delete the entry from
+ * serverid.tdb
+ */
+
+ DEBUG(2, ("pid %s doesn't exist\n",
+ server_id_str_buf(*id, &idbuf)));
+
+ dbwrap_record_delete(rec);
+ }
+ msg_all->n_sent++;
+ return 0;
+}
+
+/**
+ * Send a message to all smbd processes.
+ *
+ * It isn't very efficient, but should be OK for the sorts of
+ * applications that use it. When we need efficient broadcast we can add
+ * it.
+ *
+ * @param n_sent Set to the number of messages sent. This should be
+ * equal to the number of processes, but be careful for races.
+ *
+ * @retval True for success.
+ **/
+bool message_send_all(struct messaging_context *msg_ctx,
+ int msg_type,
+ const void *buf, size_t len,
+ int *n_sent)
+{
+ struct msg_all msg_all;
+
+ msg_all.msg_type = msg_type;
+ if (msg_type < 0x100) {
+ msg_all.msg_flag = FLAG_MSG_GENERAL;
+ } else if (msg_type > 0x100 && msg_type < 0x200) {
+ msg_all.msg_flag = FLAG_MSG_NMBD;
+ } else if (msg_type > 0x200 && msg_type < 0x300) {
+ msg_all.msg_flag = FLAG_MSG_PRINT_GENERAL;
+ } else if (msg_type > 0x300 && msg_type < 0x400) {
+ msg_all.msg_flag = FLAG_MSG_SMBD;
+ } else if (msg_type > 0x400 && msg_type < 0x600) {
+ msg_all.msg_flag = FLAG_MSG_WINBIND;
+ } else if (msg_type > 4000 && msg_type < 5000) {
+ msg_all.msg_flag = FLAG_MSG_DBWRAP;
+ } else {
+ return false;
+ }
+
+ msg_all.buf = buf;
+ msg_all.len = len;
+ msg_all.n_sent = 0;
+ msg_all.msg_ctx = msg_ctx;
+
+ serverid_traverse(traverse_fn, &msg_all);
+ if (n_sent)
+ *n_sent = msg_all.n_sent;
+ return true;
+}
#include "passdb.h"
#include "secrets.h"
#include "messages.h"
+#include "serverid.h"
#include "../librpc/gen_ndr/samr.h"
#include "../librpc/gen_ndr/drsblobs.h"
#include "../librpc/gen_ndr/ndr_drsblobs.h"
#include "includes.h"
#include "ntdomain.h"
#include "include/messages.h"
+#include "serverid.h"
#include "include/auth.h"
#include "../libcli/security/security.h"
#include "../libcli/util/hresult.h"
#include "smbd/globals.h"
#include "auth.h"
#include "messages.h"
+#include "serverid.h"
#include "lib/conn_tdb.h"
extern const struct generic_mapping file_generic_mapping;
#include "../lib/util/memcache.h"
#include "smbd/smbd.h"
#include "messages.h"
+#include "serverid.h"
#include "smbprofile.h"
#include <tdb.h>