Fix bug #9585 - Samba 3.6.x not correctly signing any but the last response in a...
[Samba.git] / source4 / cluster / cluster.c
blob746c0048202841411d54b0b873e28bae1a5e8bf2
1 /*
2 Unix SMB/CIFS implementation.
4 core clustering code
6 Copyright (C) Andrew Tridgell 2006
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "cluster/cluster.h"
24 #include "cluster/cluster_private.h"
25 #include "librpc/gen_ndr/misc.h"
26 #include "librpc/gen_ndr/server_id4.h"
28 static struct cluster_ops *ops;
30 /* set cluster operations */
31 void cluster_set_ops(struct cluster_ops *new_ops)
33 ops = new_ops;
37 an ugly way of getting at the backend handle (eg. ctdb context) via the cluster API
39 void *cluster_backend_handle(void)
41 return ops->backend_handle(ops);
44 /* by default use the local ops */
45 static void cluster_init(void)
47 if (ops == NULL) cluster_local_init();
51 create a server_id for the local node
53 struct server_id cluster_id(uint64_t id, uint32_t id2)
55 cluster_init();
56 return ops->cluster_id(ops, id, id2);
61 return a server_id as a string
63 const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id)
65 cluster_init();
66 return ops->cluster_id_string(ops, mem_ctx, id);
71 open a temporary tdb in a cluster friendly manner
73 struct tdb_wrap *cluster_tdb_tmp_open(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, const char *dbname, int flags)
75 cluster_init();
76 return ops->cluster_tdb_tmp_open(ops, mem_ctx, lp_ctx, dbname, flags);
81 register a callback function for a messaging endpoint
83 NTSTATUS cluster_message_init(struct messaging_context *msg, struct server_id server,
84 cluster_message_fn_t handler)
86 cluster_init();
87 return ops->message_init(ops, msg, server, handler);
91 send a message to another node in the cluster
93 NTSTATUS cluster_message_send(struct server_id server, DATA_BLOB *data)
95 cluster_init();
96 return ops->message_send(ops, server, data);