summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-06-10 17:02:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:14 -0500
commitde565785f5e1f097bd75f57331425c4185185f80 (patch)
treeaf24bb44388f9ffa2077435cc3fea134557c186b /source3/include
parentb05c7b97830f6029c264fc44831c2f5eae4f0c83 (diff)
downloadsamba-de565785f5e1f097bd75f57331425c4185185f80.tar.gz
samba-de565785f5e1f097bd75f57331425c4185185f80.tar.bz2
samba-de565785f5e1f097bd75f57331425c4185185f80.zip
r23410: Merge the core of the cluster code.
I'm 100% certain I've forgotten to merge something, but the main code should be in. It's mainly in dbwrap_ctdb.c, ctdbd_conn.c and messages_ctdbd.c. There should be no changes to the non-cluster case, it does survive make test on my laptop. It survives some very basic tests with ctdbd enables, I did not do the full test suite for clusters yet. Phew... Volker (This used to be commit 15553d6327a3aecdd2b0b94a3656d04bf4106323)
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/ctdbd_conn.h65
-rw-r--r--source3/include/includes.h2
-rw-r--r--source3/include/messages.h36
-rw-r--r--source3/include/packet.h84
-rw-r--r--source3/include/smb.h4
5 files changed, 191 insertions, 0 deletions
diff --git a/source3/include/ctdbd_conn.h b/source3/include/ctdbd_conn.h
new file mode 100644
index 0000000000..79d8abe59d
--- /dev/null
+++ b/source3/include/ctdbd_conn.h
@@ -0,0 +1,65 @@
+/*
+ Unix SMB/CIFS implementation.
+ Samba3 ctdb connection handling
+ Copyright (C) Volker Lendecke 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+struct ctdbd_connection;
+
+NTSTATUS ctdbd_init_connection(TALLOC_CTX *mem_ctx,
+ struct ctdbd_connection **pconn);
+NTSTATUS ctdbd_messaging_connection(TALLOC_CTX *mem_ctx,
+ struct ctdbd_connection **pconn);
+
+uint32 ctdbd_vnn(const struct ctdbd_connection *conn);
+
+NTSTATUS ctdbd_register_msg_ctx(struct ctdbd_connection *conn,
+ struct messaging_context *msg_ctx);
+
+NTSTATUS ctdbd_messaging_send(struct ctdbd_connection *conn,
+ uint32 dst_vnn, uint64 dst_srvid,
+ struct messaging_rec *msg);
+
+BOOL ctdbd_process_exists(struct ctdbd_connection *conn, uint32 vnn,
+ pid_t pid);
+
+char *ctdbd_dbpath(struct ctdbd_connection *conn,
+ TALLOC_CTX *mem_ctx, uint32_t db_id);
+
+NTSTATUS ctdbd_db_attach(struct ctdbd_connection *conn, const char *name,
+ uint32_t *db_id, int tdb_flags);
+
+NTSTATUS ctdbd_migrate(struct ctdbd_connection *conn, uint32 db_id,
+ TDB_DATA key);
+
+NTSTATUS ctdbd_fetch(struct ctdbd_connection *conn, uint32 db_id,
+ TDB_DATA key, TALLOC_CTX *mem_ctx, TDB_DATA *data);
+
+NTSTATUS ctdbd_traverse(uint32 db_id,
+ void (*fn)(TDB_DATA key, TDB_DATA data,
+ void *private_data),
+ void *private_data);
+
+NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
+ const struct sockaddr_in *server,
+ const struct sockaddr_in *client,
+ void (*release_ip_handler)(const char *ip_addr,
+ void *private_data),
+ void *private_data);
+
+NTSTATUS ctdbd_register_reconfigure(struct ctdbd_connection *conn);
+
diff --git a/source3/include/includes.h b/source3/include/includes.h
index 9c7b3d1c1f..20a693d64b 100644
--- a/source3/include/includes.h
+++ b/source3/include/includes.h
@@ -702,6 +702,8 @@ typedef int BOOL;
#include "rpc_client.h"
#include "event.h"
#include "dbwrap.h"
+#include "packet.h"
+#include "ctdbd_conn.h"
/*
* Type for wide character dirent structure.
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 5ba2f45bd2..bf5f49b872 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -119,10 +119,35 @@
#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;
@@ -139,6 +164,7 @@ struct messaging_context {
struct messaging_callback *callbacks;
struct messaging_backend *local;
+ struct messaging_backend *remote;
};
struct messaging_backend {
@@ -154,6 +180,10 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_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,
@@ -163,6 +193,12 @@ 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,
diff --git a/source3/include/packet.h b/source3/include/packet.h
new file mode 100644
index 0000000000..9f36482705
--- /dev/null
+++ b/source3/include/packet.h
@@ -0,0 +1,84 @@
+/*
+ Unix SMB/CIFS implementation.
+ Packet handling
+ Copyright (C) Volker Lendecke 2007
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/*
+ * A packet context is a wrapper around a bidirectional file descriptor,
+ * hiding the handling of individual requests.
+ */
+
+struct packet_context;
+
+/*
+ * Initialize a packet context. The fd is given to the packet context, meaning
+ * that it is automatically closed when the packet context is freed.
+ */
+struct packet_context *packet_init(TALLOC_CTX *mem_ctx, int fd);
+
+/*
+ * Pull data from the fd
+ */
+NTSTATUS packet_fd_read(struct packet_context *ctx);
+
+/*
+ * Sync read, wait for the next chunk
+ */
+NTSTATUS packet_fd_read_sync(struct packet_context *ctx);
+
+/*
+ * Handle an incoming packet:
+ * Return False if none is available
+ * Otherwise return True and store the callback result in *status
+ */
+BOOL packet_handler(struct packet_context *ctx,
+ BOOL (*full_req)(const struct data_blob *data,
+ size_t *length,
+ void *private_data),
+ NTSTATUS (*callback)(const struct data_blob *data,
+ void *private_data),
+ void *private_data,
+ NTSTATUS *status);
+
+/*
+ * How many bytes of outgoing data do we have pending?
+ */
+size_t packet_outgoing_bytes(struct packet_context *ctx);
+
+/*
+ * Push data to the fd
+ */
+NTSTATUS packet_fd_write(struct packet_context *ctx);
+
+/*
+ * Sync flush all outgoing bytes
+ */
+NTSTATUS packet_flush(struct packet_context *ctx);
+
+/*
+ * Send a list of DATA_BLOBs
+ *
+ * Example: packet_send(ctx, 2, data_blob_const(&size, sizeof(size)),
+ * data_blob_const(buf, size));
+ */
+NTSTATUS packet_send(struct packet_context *ctx, int num_blobs, ...);
+
+/*
+ * Get the packet context's file descriptor
+ */
+int packet_get_fd(struct packet_context *ctx);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 6f10eb67c8..9c7b32f58a 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -785,7 +785,11 @@ Offset Data length.
54
*/
+#ifdef CLUSTER_SUPPORT
+#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 58
+#else
#define MSG_SMB_SHARE_MODE_ENTRY_SIZE 54
+#endif
struct share_mode_lock {
const char *servicepath; /* canonicalized. */