From f6274959ba381b6b5d025cb0cee78665107a72a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 10 Jan 2007 11:16:11 +0000 Subject: r20647: add cluster code (This used to be commit 5870830b99a8d76bda1ff5af3fcf8dda9aba50ec) --- source4/cluster/cluster.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ source4/cluster/cluster.h | 35 +++++++++++++++++++++++++++++++++++ source4/cluster/config.mk | 4 ++++ 3 files changed, 84 insertions(+) create mode 100644 source4/cluster/cluster.c create mode 100644 source4/cluster/cluster.h create mode 100644 source4/cluster/config.mk (limited to 'source4/cluster') diff --git a/source4/cluster/cluster.c b/source4/cluster/cluster.c new file mode 100644 index 0000000000..fef5bce0d1 --- /dev/null +++ b/source4/cluster/cluster.c @@ -0,0 +1,45 @@ +/* + Unix SMB/CIFS implementation. + + core clustering code + + Copyright (C) Andrew Tridgell 2006 + + 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. +*/ + +#include "includes.h" +#include "cluster/cluster.h" + +/* + server a server_id for the local node +*/ +struct server_id cluster_id(uint32_t id) +{ + struct server_id server_id; + ZERO_STRUCT(server_id); + server_id.id = id; + return server_id; +} + + +/* + return a server_id as a string +*/ +const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id) +{ + return talloc_asprintf(mem_ctx, "%u.%u", id.node, id.id); +} + diff --git a/source4/cluster/cluster.h b/source4/cluster/cluster.h new file mode 100644 index 0000000000..3c7f83960e --- /dev/null +++ b/source4/cluster/cluster.h @@ -0,0 +1,35 @@ +/* + Unix SMB/CIFS implementation. + + structures for clustering + + Copyright (C) Andrew Tridgell 2006 + + 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. +*/ + +#ifndef __CLUSTER_H__ +#define __CLUSTER_H__ + +/* + test for same cluster id +*/ +#define cluster_id_equal(id1, id2) ((id1)->id == (id2)->id && (id1)->node == (id2)->node) + +/* prototypes */ +struct server_id cluster_id(uint32_t id); +const char *cluster_id_string(TALLOC_CTX *mem_ctx, struct server_id id); + +#endif diff --git a/source4/cluster/config.mk b/source4/cluster/config.mk new file mode 100644 index 0000000000..934bc55252 --- /dev/null +++ b/source4/cluster/config.mk @@ -0,0 +1,4 @@ + +#################### +[SUBSYSTEM::CLUSTER] +OBJ_FILES = cluster.o -- cgit