cluster: master - cman: Remove old code

Christine Caulfield chrissie@fedoraproject.org
Thu Jan 8 08:58:00 GMT 2009


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=cfe170aac9abd399f73f17eea1536cd03bdae834
Commit:        cfe170aac9abd399f73f17eea1536cd03bdae834
Parent:        d93b636fded43196b9da257ae6bbfa67c42ea162
Author:        Christine Caulfield <ccaulfie@redhat.com>
AuthorDate:    Thu Jan 8 08:55:43 2009 +0000
Committer:     Christine Caulfield <ccaulfie@redhat.com>
CommitterDate: Thu Jan 8 08:55:43 2009 +0000

cman: Remove old code

It is with some (but not much) regret that I record the passing away of the
'old' cman code.

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
---
 cman/daemon/Makefile         |   41 -
 cman/daemon/ais.c            |  343 -------
 cman/daemon/ais.h            |   13 -
 cman/daemon/barrier.c        |  468 ---------
 cman/daemon/barrier.h        |    6 -
 cman/daemon/cman-preconfig.c | 1172 ----------------------
 cman/daemon/cman.h           |   15 -
 cman/daemon/cmanconfig.c     |  297 ------
 cman/daemon/cmanconfig.h     |    3 -
 cman/daemon/cnxman-private.h |  183 ----
 cman/daemon/cnxman-socket.h  |  275 ------
 cman/daemon/commands.c       | 2232 ------------------------------------------
 cman/daemon/commands.h       |   37 -
 cman/daemon/daemon.c         |  539 ----------
 cman/daemon/daemon.h         |   12 -
 cman/daemon/list.h           |   97 --
 cman/daemon/logging.c        |   25 -
 cman/daemon/logging.h        |   17 -
 cman/daemon/nodelist.h       |   93 --
 cman/lib/Makefile            |   12 -
 cman/lib/libcman.c           | 1108 ---------------------
 cman/lib/libcman.h           |  423 --------
 configure                    |    4 +-
 23 files changed, 2 insertions(+), 7413 deletions(-)

diff --git a/cman/daemon/Makefile b/cman/daemon/Makefile
deleted file mode 100644
index f97c56f..0000000
--- a/cman/daemon/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-TARGET1= service_cman.lcrso
-TARGET2= config_cmanpre.lcrso
-
-LCRSOT=$(TARGET1) $(TARGET2)
-
-all: depends ${TARGET1} ${TARGET2}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${openaisincdir} -I${corosyncincdir}
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L${libdir}
-
-OBJS1=	daemon.o \
-	logging.o \
-	ais.o \
-	commands.o \
-	barrier.o \
-	cmanconfig.o
-
-OBJS2=	cman-preconfig.o
-
-${TARGET1}: ${OBJS1}
-	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-${TARGET2}: ${OBJS2}
-	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-depends:
-	$(MAKE) -C ../lib all
-
-clean: generalclean 
-
--include $(OBJS1:.o=.d)
--include $(OBJS2:.o=.d)
diff --git a/cman/daemon/ais.c b/cman/daemon/ais.c
deleted file mode 100644
index 1ebac82..0000000
--- a/cman/daemon/ais.c
+++ /dev/null
@@ -1,343 +0,0 @@
-#include <sys/poll.h>
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/socket.h>
-#include <sys/utsname.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-
-/* corosync headers */
-#include <corosync/corotypes.h>
-#include <corosync/ipc_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include <corosync/engine/quorum.h>
-#include <corosync/lcr/lcr_comp.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "commands.h"
-#include "logging.h"
-
-#include "ais.h"
-#include "cman.h"
-#define OBJDB_API struct corosync_api_v1
-#include "nodelist.h"
-#include "cmanconfig.h"
-#include "daemon.h"
-
-extern int our_nodeid();
-extern char cluster_name[MAX_CLUSTER_NAME_LEN+1];
-extern unsigned int quorumdev_poll;
-extern unsigned int ccsd_poll_interval;
-extern unsigned int shutdown_timeout;
-extern int init_config(struct corosync_api_v1 *api);
-
-struct totem_ip_address mcast_addr[MAX_INTERFACES];
-struct totem_ip_address ifaddrs[MAX_INTERFACES];
-int num_interfaces;
-uint64_t incarnation;
-int num_ais_nodes;
-quorum_set_quorate_fn_t corosync_set_quorum;
-struct memb_ring_id cman_ring_id;
-extern unsigned int config_version;
-static unsigned int cluster_parent_handle;
-
-static int startup_pipe;
-static unsigned int debug_mask;
-static int first_trans = 1;
-struct corosync_api_v1 *corosync;
-
-static cs_tpg_handle group_handle;
-static struct corosync_tpg_group cman_group[1] = {
-        { .group          = "CMAN", .group_len      = 4},
-};
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME, LOG_INFO);
-
-/* This structure is tacked onto the start of a cluster message packet for our
- * own nefarious purposes. */
-struct cl_protheader {
-	unsigned char  tgtport; /* Target port number */
-	unsigned char  srcport; /* Source (originating) port number */
-	unsigned short pad;
-	unsigned int   flags;
-	int            srcid;	/* Node ID of the sender */
-	int            tgtid;	/* Node ID of the target */
-};
-
-/* Plugin-specific code */
-/* Need some better way of determining these.... */
-#define CMAN_SERVICE 9
-
-static int cman_exit_fn(void *conn_info);
-static int cman_exec_init_fn(struct corosync_api_v1 *api);
-static void cman_confchg_fn(enum totem_configuration_type configuration_type,
-			    unsigned int *member_list, int member_list_entries,
-			    unsigned int *left_list, int left_list_entries,
-			    unsigned int *joined_list, int joined_list_entries,
-			    struct memb_ring_id *ring_id);
-static void cman_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_len,
-			    int endian_conversion_required);
-static void cman_quorum_init(struct corosync_api_v1 *api, quorum_set_quorate_fn_t report);
-
-/*
- * Exports the interface for the service
- */
-static struct corosync_service_engine cman_service_handler = {
-	.name		    		= (char *)"corosync CMAN membership service 2.90",
-	.id			        = CMAN_SERVICE,
-	.flow_control			= COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED,
-	.lib_exit_fn		       	= cman_exit_fn,
-	.exec_init_fn		       	= cman_exec_init_fn,
-	.config_init_fn                 = NULL,
-};
-
-static struct corosync_service_engine *cman_get_handler_ver0(void)
-{
-	return (&cman_service_handler);
-}
-
-static struct corosync_service_engine_iface_ver0 cman_service_handler_iface = {
-	.corosync_get_service_engine_ver0 = cman_get_handler_ver0
-};
-static struct quorum_services_api_ver1 cman_quorum_iface_ver0 = {
-	.init				= cman_quorum_init
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
-	{
-		.name		        = "corosync_cman",
-		.version	        = 0,
-		.versions_replace     	= 0,
-		.versions_replace_count = 0,
-		.dependencies	      	= 0,
-		.dependency_count      	= 0,
-		.constructor	       	= NULL,
-		.destructor		= NULL,
-		.interfaces		= NULL,
-	},
-	{
-		.name			= "quorum_cman",
-		.version		= 0,
-		.versions_replace	= 0,
-		.versions_replace_count	= 0,
-		.dependencies		= 0,
-		.dependency_count	= 0,
-		.constructor		= NULL,
-		.destructor		= NULL,
-		.interfaces		= (void **)(void *)&cman_quorum_iface_ver0,
-	},
-};
-
-static struct lcr_comp cman_comp_ver0 = {
-	.iface_count				= 2,
-	.ifaces					= ifaces_ver0,
-};
-
-
-__attribute__ ((constructor)) static void cman_comp_register(void) {
-	lcr_interfaces_set(&ifaces_ver0[0], &cman_service_handler_iface);
-	lcr_interfaces_set(&ifaces_ver0[1], &cman_quorum_iface_ver0);
-	lcr_component_register(&cman_comp_ver0);
-}
-
-/* ------------------------------- */
-
-static void cman_quorum_init(struct corosync_api_v1 *api, quorum_set_quorate_fn_t report)
-{
-	corosync = api;
-	corosync_set_quorum = report;
-}
-
-static int cman_exec_init_fn(struct corosync_api_v1 *api)
-{
-	unsigned int object_handle;
-	unsigned int find_handle;
-	char pipe_msg[256];
-
-	corosync = api;
-
-	if (getenv("CMAN_PIPE"))
-                startup_pipe = atoi(getenv("CMAN_PIPE"));
-
-        /* Get our config variables */
-	corosync->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
-	corosync->object_find_next(find_handle, &cluster_parent_handle);
-	corosync->object_find_destroy(find_handle);
-
-	corosync->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-	if (corosync->object_find_next(find_handle, &object_handle) == 0)
-	{
-		objdb_get_int(api, object_handle, "quorum_dev_poll", &quorumdev_poll, DEFAULT_QUORUMDEV_POLL);
-		objdb_get_int(api, object_handle, "shutdown_timeout", &shutdown_timeout, DEFAULT_SHUTDOWN_TIMEOUT);
-		objdb_get_int(api, object_handle, "ccsd_poll", &ccsd_poll_interval, DEFAULT_CCSD_POLL);
-		objdb_get_int(api, object_handle, "debug_mask", &debug_mask, 0);
-
-		/* All other debugging options should already have been set in preconfig */
-		set_debuglog(debug_mask);
-	}
-	corosync->object_find_destroy(find_handle);
-	P_DAEMON(CMAN_NAME " starting");
-
-	/* Open local sockets and initialise I/O queues */
-	if (read_cman_config(api, &config_version)) {
-		/* An error message will have been written to cman_pipe */
-		exit(9);
-	}
-	cman_init();
-
-	/* Let cman_tool know we are running and our PID */
-	sprintf(pipe_msg,"SUCCESS: %d", getpid());
-	write_cman_pipe(pipe_msg);
-	close(startup_pipe);
-	startup_pipe = 0;
-
-	/* Start totem */
-	api->tpg_init(&group_handle, cman_deliver_fn, cman_confchg_fn);
-	api->tpg_join(group_handle, cman_group, 1);
-
-	return 0;
-}
-
-
-int cman_exit_fn(void *conn_info)
-{
-	cman_finish();
-	return 0;
-}
-
-/* END Plugin-specific code */
-
-int comms_send_message(void *buf, int len,
-		       unsigned char toport, unsigned char fromport,
-		       int nodeid,
-		       unsigned int flags)
-{
-	struct iovec iov[2];
-	struct cl_protheader header;
-	int totem_flags = TOTEM_AGREED;
-
-	P_AIS("comms send message %p len = %d\n", buf,len);
-	header.tgtport = toport;
-	header.srcport = fromport;
-	header.flags   = flags;
-	header.srcid   = our_nodeid();
-	header.tgtid   = nodeid;
-
-	iov[0].iov_base = &header;
-	iov[0].iov_len  = sizeof(header);
-	iov[1].iov_base = buf;
-	iov[1].iov_len  = len;
-
-	if (flags & MSG_TOTEM_SAFE)
-		totem_flags = TOTEM_SAFE;
-
-	return corosync->tpg_joined_mcast(group_handle, iov, 2, totem_flags);
-}
-
-// This assumes the iovec has only one element ... is it true ??
-static void cman_deliver_fn(unsigned int nodeid, struct iovec *iovec, int iov_len,
-			    int endian_conversion_required)
-{
-	struct cl_protheader *header = iovec->iov_base;
-	char *buf = iovec->iov_base;
-
-	P_AIS("deliver_fn source nodeid = %d, len=%d, endian_conv=%d\n",
-	      nodeid, (int)iovec->iov_len, endian_conversion_required);
-
-	if (endian_conversion_required) {
-		header->srcid = swab32(header->srcid);
-		header->tgtid = swab32(header->tgtid);
-		header->flags = swab32(header->flags);
-	}
-
-	/* Only pass on messages for us or everyone */
-	if (header->tgtid == our_nodeid() ||
-	    header->tgtid == 0) {
-		send_to_userport(header->srcport, header->tgtport,
-				 header->srcid, header->tgtid,
-				 buf + sizeof(struct cl_protheader), iovec->iov_len - sizeof(struct cl_protheader),
-				 endian_conversion_required);
-	}
-}
-
-static void cman_confchg_fn(enum totem_configuration_type configuration_type,
-			    unsigned int *member_list, int member_list_entries,
-			    unsigned int *left_list, int left_list_entries,
-			    unsigned int *joined_list, int joined_list_entries,
-			    struct memb_ring_id *ring_id)
-{
-	int i;
-	static int last_memb_count = 0;
-	static int saved_left_list_entries;
-	static int saved_left_list_size;
-	static unsigned int *saved_left_list = NULL;
-
-	P_AIS("confchg_fn called type = %d, seq=%lld\n", configuration_type, ring_id->seq);
-
-	memcpy(&cman_ring_id, ring_id, sizeof(*ring_id));
-	incarnation = ring_id->seq;
-	num_ais_nodes = member_list_entries;
-
-	/* Tell the cman membership layer */
-	for (i=0; i<left_list_entries; i++)
-		del_ais_node(left_list[i]);
-
-	/* Joining nodes are only added after a valid TRANSITION message
-	 * is received.
-	 */
-
-	/* Save the left list for later so we can do a consolidated confchg message */
-	if (configuration_type == TOTEM_CONFIGURATION_TRANSITIONAL) {
-		if (saved_left_list == NULL) {
-			saved_left_list_size = left_list_entries*2;
-			saved_left_list = malloc(sizeof(int) * saved_left_list_size);
-			if (!saved_left_list) {
-				log_printf(LOG_LEVEL_CRIT, "cannot allocate memory for confchg message");
-				exit(3);
-			}
-		}
-		if (saved_left_list_size < left_list_entries) {
-			saved_left_list_size = left_list_entries*2;
-			saved_left_list = realloc(saved_left_list, sizeof(int) * saved_left_list_size);
-			if (!saved_left_list) {
-				log_printf(LOG_LEVEL_CRIT, "cannot reallocate memory for confchg message");
-				exit(3);
-			}
-		}
-		saved_left_list_entries = left_list_entries;
-		memcpy(saved_left_list, left_list, left_list_entries * sizeof(int));
-	}
-
-	if (configuration_type == TOTEM_CONFIGURATION_REGULAR) {
-		P_AIS("last memb_count = %d, current = %d\n", last_memb_count, member_list_entries);
-		send_transition_msg(last_memb_count, first_trans);
-		last_memb_count = member_list_entries;
-		if (member_list_entries > 1)
-			first_trans = 0;
-
-		cman_send_confchg(member_list,  member_list_entries,
-				  saved_left_list, saved_left_list_entries,
-				  joined_list, joined_list_entries);
-	}
-}
-
-/* Write an error message down the CMAN startup pipe so
-   that cman_tool can display it */
-int write_cman_pipe(char *message)
-{
-	if (startup_pipe)
-		return write(startup_pipe, message, strlen(message)+1);
-
-	return 0;
-}
diff --git a/cman/daemon/ais.h b/cman/daemon/ais.h
deleted file mode 100644
index 8ee2285..0000000
--- a/cman/daemon/ais.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <corosync/engine/quorum.h>
-/* DLM Currently maxes out at 3 ! */
-#define MAX_INTERFACES 8
-
-extern int ais_add_ifaddr(char *mcast, char *ifaddr, int portnum);
-extern int comms_send_message(void *buf, int len,
-			      unsigned char toport, unsigned char fromport,
-			      int nodeid,
-			      unsigned int flags);
-extern uint64_t incarnation;
-extern int num_ais_nodes;
-extern quorum_set_quorate_fn_t corosync_set_quorum;
-extern struct memb_ring_id cman_ring_id;
diff --git a/cman/daemon/barrier.c b/cman/daemon/barrier.c
deleted file mode 100644
index 54df19a..0000000
--- a/cman/daemon/barrier.c
+++ /dev/null
@@ -1,468 +0,0 @@
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/errno.h>
-
-#include <corosync/ipc_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "daemon.h"
-#include "commands.h"
-#include "logging.h"
-#include "barrier.h"
-#include "cman.h"
-#include "ais.h"
-
-extern int we_are_a_cluster_member;
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME, LOG_INFO);
-
-/* A barrier */
-struct cl_barrier {
-	struct list list;
-
-	char name[MAX_BARRIER_NAME_LEN];
-	unsigned int flags;
-	enum { BARRIER_STATE_WAITING, BARRIER_STATE_INACTIVE,
-	       BARRIER_STATE_COMPLETE } state;
-	unsigned int expected_nodes;
-	unsigned int got_nodes;
-	unsigned int waitsent;
-	unsigned int phase;	/* Completion phase */
-	unsigned int endreason;	/* Reason we were woken, usually 0 */
-	unsigned int client_complete;
-	unsigned long timeout;	/* In seconds */
-
-	struct connection *con;
-	corosync_timer_handle_t timer;
-};
-extern struct corosync_api_v1 *corosync;
-
-/* A list of all current barriers */
-static struct list barrier_list;
-
-static void send_barrier_complete_msg(struct cl_barrier *barrier)
-{
-	if (barrier->timeout) {
-		corosync->timer_delete(barrier->timer);
-		barrier->timeout = 0;
-	}
-
-	if (!barrier->client_complete) {
-		if (barrier->con)
-			send_status_return(barrier->con, CMAN_CMD_BARRIER, barrier->endreason);
-		barrier->client_complete = 1;
-	}
-}
-
-static struct cl_barrier *find_barrier(char *name)
-{
-	struct list *blist;
-	struct cl_barrier *bar;
-
-	list_iterate(blist, &barrier_list) {
-		bar = list_item(blist, struct cl_barrier);
-
-		if (strcmp(name, bar->name) == 0)
-			return bar;
-	}
-	return NULL;
-}
-
-/* Do the stuff we need to do when the barrier has completed phase 1 */
-static void check_barrier_complete_phase1(struct cl_barrier *barrier)
-{
-	if (barrier->got_nodes == ((barrier->expected_nodes != 0)
-				   ? barrier->expected_nodes :
-				   cluster_members)) {
-
-		struct cl_barriermsg bmsg;
-
-		barrier->phase = 2;	/* Wait for complete phase II */
-
-		bmsg.cmd = CLUSTER_MSG_BARRIER;
-		bmsg.subcmd = BARRIER_COMPLETE;
-		strcpy(bmsg.name, barrier->name);
-
-		P_BARRIER("Sending COMPLETE for %s\n", barrier->name);
-		comms_send_message((char *) &bmsg, sizeof (bmsg),
-				   0, 0,
-				   0,
-				   MSG_TOTEM_SAFE);
-	}
-}
-
-/* Do the stuff we need to do when the barrier has been reached */
-/* Return 1 if we deleted the barrier */
-static int barrier_complete_phase2(struct cl_barrier *barrier, int status)
-{
-	P_BARRIER("complete_phase2 for %s\n", barrier->name);
-
-	barrier->endreason = status;
-
-	/* Wake up listener */
-	if (barrier->state == BARRIER_STATE_WAITING) {
-		send_barrier_complete_msg(barrier);
-	}
-	barrier->state = BARRIER_STATE_COMPLETE;
-
-	/* Delete barrier if autodelete */
-	if (barrier->flags & BARRIER_ATTR_AUTODELETE) {
-		list_del(&barrier->list);
-		free(barrier);
-		return 1;
-	}
-
-	return 0;
-}
-
-/* Called if a barrier timeout happens */
-static void barrier_timer_fn(void *arg)
-{
-	struct cl_barrier *barrier = arg;
-
-	P_BARRIER("Barrier timer_fn called for %s\n", barrier->name);
-
-	/* Ignore any futher messages, they are too late. */
-	barrier->phase = 0;
-
-	/* and cause it to timeout */
-	barrier_complete_phase2(barrier, -ETIMEDOUT);
-}
-
-static struct cl_barrier *alloc_barrier(char *name, int nodes)
-{
-	struct cl_barrier *barrier;
-
-	/* Build a new struct and add it to the list */
-	barrier = malloc(sizeof (struct cl_barrier));
-	if (barrier == NULL) {
-		return NULL;
-	}
-	memset(barrier, 0, sizeof (*barrier));
-
-	strcpy(barrier->name, name);
-	barrier->flags = 0;
-	barrier->expected_nodes = nodes;
-	barrier->got_nodes = 0;
-	barrier->endreason = 0;
-	barrier->state = BARRIER_STATE_INACTIVE;
-
-	list_add(&barrier_list, &barrier->list);
-	return barrier;
-}
-
-/* Process BARRIER messages from other nodes */
-void process_barrier_msg(struct cl_barriermsg *msg,
-			 struct cluster_node *node)
-{
-	struct cl_barrier *barrier;
-
-	barrier = find_barrier(msg->name);
-
-	/* Ignore other peoples' messages */
-	if (!we_are_a_cluster_member)
-		return;
-	if (!barrier)
-		return;
-
-	P_BARRIER("Got %d for %s, from node %s\n", msg->subcmd, msg->name,
-		  node ? node->name : "unknown");
-
-	switch (msg->subcmd) {
-	case BARRIER_WAIT:
-		if (barrier->phase == 0)
-			barrier->phase = 1;
-
-		if (barrier->phase == 1) {
-			barrier->got_nodes++;
-			check_barrier_complete_phase1(barrier);
-		}
-		break;
-
-	case BARRIER_COMPLETE:
-		if (!barrier)
-			return;
-		/* Once we receive COMPLETE, we know that everyone has completed.
-		   I love VS */
-		barrier_complete_phase2(barrier, 0);
-		break;
-	}
-}
-
-
-/* Barrier API */
-static int barrier_register(struct connection *con, char *name, unsigned int flags, unsigned int nodes)
-{
-	struct cl_barrier *barrier;
-
-	/* We are not joined to a cluster */
-	if (!we_are_a_cluster_member)
-		return -ENOTCONN;
-
-	/* Must have a valid name */
-	if (name == NULL || strlen(name) > MAX_BARRIER_NAME_LEN - 1)
-		return -EINVAL;
-
-	/* We don't do this yet */
-	if (flags & BARRIER_ATTR_MULTISTEP)
-		return -EINVAL;
-
-	P_BARRIER("barrier_register %s, nodes = %d, flags =%x\n", name, nodes, flags);
-
-	/* See if it already exists */
-	if ((barrier = find_barrier(name))) {
-		if (nodes != barrier->expected_nodes) {
-			log_printf(LOG_ERR, "Barrier registration failed for '%s', expected nodes=%d, requested=%d\n",
-			       name, barrier->expected_nodes, nodes);
-			return -EINVAL;
-		}
-		else {
-			/* Fill this is as it may have been remote registered */
-			barrier->con = con;
-			return 0;
-		}
-	}
-
-	barrier = alloc_barrier(name, nodes);
-	if (!barrier)
-		return -ENOMEM;
-
-	barrier->flags = flags;
-	barrier->con = con;
-	return 0;
-}
-
-static int barrier_setattr_enabled(struct cl_barrier *barrier,
-				   unsigned int attr, unsigned long arg)
-{
-	int status;
-
-	/* Can't disable a barrier */
-	if (!arg) {
-		return -EINVAL;
-	}
-
-	/* We need to send WAIT now because the user may not
-	 * actually call barrier_wait() */
-	if (!barrier->waitsent) {
-		struct cl_barriermsg bmsg;
-
-		/* Send it to the rest of the cluster */
-		bmsg.cmd = CLUSTER_MSG_BARRIER;
-		bmsg.subcmd = BARRIER_WAIT;
-		strcpy(bmsg.name, barrier->name);
-
-		barrier->waitsent = 1;
-		barrier->phase = 1;
-
-		/* Start the timer if one was wanted */
-		if (barrier->timeout) {
-			corosync->timer_add_duration((unsigned long long)barrier->timeout*1000000000ULL, barrier,
-						   barrier_timer_fn, &barrier->timer);
-		}
-
-		P_BARRIER("Sending WAIT for %s\n", barrier->name);
-		status = comms_send_message((char *)&bmsg, sizeof(bmsg), 0,0, 0, MSG_TOTEM_SAFE);
-		if (status < 0) {
-			return status;
-		}
-	}
-	if (barrier && barrier->state == BARRIER_STATE_COMPLETE) {
-		return barrier->endreason;
-	}
-	return 0;	/* Nothing to propogate */
-}
-
-static int barrier_setattr(char *name, unsigned int attr, unsigned long arg)
-{
-	struct cl_barrier *barrier;
-
-	/* See if it already exists */
-	if (!(barrier = find_barrier(name))) {
-		return -ENOENT;
-	}
-
-	if (barrier->state == BARRIER_STATE_COMPLETE) {
-		return 0;
-	}
-
-	switch (attr) {
-	case BARRIER_SETATTR_AUTODELETE:
-		if (arg)
-			barrier->flags |= BARRIER_ATTR_AUTODELETE;
-		else
-			barrier->flags &= ~BARRIER_ATTR_AUTODELETE;
-		return 0;
-		break;
-
-	case BARRIER_SETATTR_TIMEOUT:
-		/* Can only change the timout of an inactive barrier */
-		if (barrier->state == BARRIER_STATE_WAITING
-		    || barrier->waitsent) {
-			return -EINVAL;
-		}
-		barrier->timeout = arg;
-		return 0;
-
-	case BARRIER_SETATTR_MULTISTEP:
-		return -EINVAL;
-
-	case BARRIER_SETATTR_ENABLED:
-		return barrier_setattr_enabled(barrier, attr, arg);
-
-	case BARRIER_SETATTR_NODES:
-		/* Can only change the expected node count of an inactive
-		 * barrier */
-		if (barrier->state == BARRIER_STATE_WAITING
-		    || barrier->waitsent)
-			return -EINVAL;
-		barrier->expected_nodes = arg;
-		break;
-	}
-
-	return 0;
-}
-
-static int barrier_delete(char *name)
-{
-	struct cl_barrier *barrier;
-
-	/* See if it exists */
-	if (!(barrier = find_barrier(name))) {
-		return -ENOENT;
-	}
-
-	/* Delete it */
-	list_del(&barrier->list);
-	free(barrier);
-	return 0;
-}
-
-static int barrier_wait(char *name)
-{
-	struct cl_barrier *barrier;
-
-	/* Enable it */
-	barrier_setattr(name, BARRIER_SETATTR_ENABLED, 1L);
-
-	/* See if it still exists - enable may have deleted it! */
-	if (!(barrier = find_barrier(name))) {
-		return -ENOENT;
-	}
-
-	/* If it has already completed then return the status */
-	if (barrier->state == BARRIER_STATE_COMPLETE) {
-		send_barrier_complete_msg(barrier);
-	}
-	else {
-		barrier->state = BARRIER_STATE_WAITING;
-	}
-
-	/* User will wait */
-	return -EWOULDBLOCK;
-}
-
-/* This is called from membership services when a node has left the cluster -
- * we signal all waiting barriers with ESRCH so they know to do something
- * else, if the number of nodes is left at 0 then we compare the new number of
- * nodes in the cluster with that at the barrier and return 0 (success) in that
- * case */
-void check_barrier_returns()
-{
-	struct list *blist;
-	struct cl_barrier *barrier;
-	int status = 0;
-
-	list_iterate(blist, &barrier_list) {
-		barrier = list_item(blist, struct cl_barrier);
-
-		if (barrier->waitsent) {
-			int wakeit = 0;
-
-			/* Check for a dynamic member barrier */
-			if (barrier->expected_nodes == 0) {
-				status = 0;
-				wakeit = 1;
-			}
-			else {
-				status = ESRCH;
-				wakeit = 1;
-			}
-
-			/* Do we need to tell the barrier? */
-			if (wakeit) {
-				if (barrier->state == BARRIER_STATE_WAITING) {
-					barrier->endreason = status;
-					send_barrier_complete_msg(barrier);
-				}
-			}
-		}
-	}
-}
-
-/* Remote command */
-int do_cmd_barrier(struct connection *con, char *cmdbuf, int *retlen)
-{
-	struct cl_barrier_info info;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	memcpy(&info, cmdbuf, sizeof(info));
-
-	switch (info.cmd) {
-	case BARRIER_CMD_REGISTER:
-		return barrier_register(con,
-					info.name,
-					info.flags,
-					info.arg);
-	case BARRIER_CMD_CHANGE:
-		return barrier_setattr(info.name,
-				       info.flags,
-				       info.arg);
-	case BARRIER_CMD_WAIT:
-		return barrier_wait(info.name);
-	case BARRIER_CMD_DELETE:
-		return barrier_delete(info.name);
-	default:
-		return -EINVAL;
-	}
-}
-
-/* Remove any barriers associated with this connection */
-void remove_barriers(struct connection *con)
-{
-	struct list *blist, *tmp;
-	struct cl_barrier *bar;
-
-	list_iterate_safe(blist, tmp, &barrier_list) {
-		bar = list_item(blist, struct cl_barrier);
-
-		if (con == bar->con) {
-			list_del(&bar->list);
-			free(bar);
-		}
-	}
-}
-
-void barrier_init()
-{
-	list_init(&barrier_list);
-}
diff --git a/cman/daemon/barrier.h b/cman/daemon/barrier.h
deleted file mode 100644
index 102d8b1..0000000
--- a/cman/daemon/barrier.h
+++ /dev/null
@@ -1,6 +0,0 @@
-void process_barrier_msg(struct cl_barriermsg *msg,
-			 struct cluster_node *node);
-int do_cmd_barrier(struct connection *con, char *cmdbuf, int *retlen);
-void barrier_init(void);
-void check_barrier_returns(void);
-void remove_barriers(struct connection *con);
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
deleted file mode 100644
index 4b721bf..0000000
--- a/cman/daemon/cman-preconfig.c
+++ /dev/null
@@ -1,1172 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-#include <sys/utsname.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include <netdb.h>
-#define SYSLOG_NAMES
-#include <sys/syslog.h>
-#include <ifaddrs.h>
-#include <arpa/inet.h>
-
-/* corosync headers */
-#include <corosync/engine/logsys.h>
-#include <corosync/lcr/lcr_comp.h>
-#include <corosync/engine/objdb.h>
-#include <corosync/engine/config.h>
-
-#include "cman.h"
-#define OBJDB_API struct objdb_iface_ver0
-#include "cnxman-socket.h"
-#include "nodelist.h"
-#include "logging.h"
-
-#define MAX_PATH_LEN PATH_MAX
-
-static unsigned int debug_mask;
-static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_string);
-static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, char **error_string);
-
-static char *nodename_env;
-static int expected_votes;
-static int votes;
-static int num_interfaces;
-static int startup_pipe;
-static unsigned int cluster_id;
-static char nodename[MAX_CLUSTER_MEMBER_NAME_LEN];
-static int nodeid;
-static int two_node;
-static unsigned int disable_openais;
-static unsigned int portnum;
-static int num_nodenames;
-static char *key_filename=NULL;
-static char *mcast_name;
-static char *cluster_name;
-static char error_reason[1024] = { '\0' };
-static unsigned int cluster_parent_handle;
-
-/*
- * Exports the interface for the service
- */
-static struct config_iface_ver0 cmanpreconfig_iface_ver0 = {
-	.config_readconfig        = cmanpre_readconfig,
-	.config_reloadconfig      = cmanpre_reloadconfig
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
-	{
-		.name		       	= "cmanpreconfig",
-		.version	       	= 0,
-		.versions_replace      	= 0,
-		.versions_replace_count	= 0,
-		.dependencies	       	= 0,
-		.dependency_count      	= 0,
-		.constructor	       	= NULL,
-		.destructor	       	= NULL,
-		.interfaces	       	= NULL,
-	}
-};
-
-static struct lcr_comp cmanpre_comp_ver0 = {
-	.iface_count				= 1,
-	.ifaces					= ifaces_ver0,
-};
-
-
-
-__attribute__ ((constructor)) static void cmanpre_comp_register(void) {
-	lcr_interfaces_set(&ifaces_ver0[0], &cmanpreconfig_iface_ver0);
-	lcr_component_register(&cmanpre_comp_ver0);
-}
-
-static char *facility_name_get (unsigned int facility)
-{
-	unsigned int i;
-
-	for (i = 0; facilitynames[i].c_name != NULL; i++) {
-		if (facility == facilitynames[i].c_val) {
-			return (facilitynames[i].c_name);
-		}
-	}
-	return (NULL);
-}
-
-static char *priority_name_get (unsigned int priority)
-{
-	unsigned int i;
-
-	for (i = 0; prioritynames[i].c_name != NULL; i++) {
-		if (priority == prioritynames[i].c_val) {
-			return (prioritynames[i].c_name);
-		}
-	}
-	return (NULL);
-}
-
-
-#define LOCALHOST_IPV4 "127.0.0.1"
-#define LOCALHOST_IPV6 "::1"
-
-/* Compare two addresses */
-static int ipaddr_equal(struct sockaddr_storage *addr1, struct sockaddr_storage *addr2)
-{
-	int addrlen = 0;
-	struct sockaddr *saddr1 = (struct sockaddr *)addr1;
-	struct sockaddr *saddr2 = (struct sockaddr *)addr2;
-
-	if (saddr1->sa_family != saddr2->sa_family)
-		return 0;
-
-	if (saddr1->sa_family == AF_INET) {
-		addrlen = sizeof(struct sockaddr_in);
-	}
-	if (saddr1->sa_family == AF_INET6) {
-		addrlen = sizeof(struct sockaddr_in6);
-	}
-	assert(addrlen);
-
-	if (memcmp(saddr1, saddr2, addrlen) == 0)
-		return 1;
-	else
-		return 0;
-
-}
-
-/* Build a localhost ip_address */
-static int get_localhost(int family, struct sockaddr_storage *localhost)
-{
-	char *addr_text;
-	struct addrinfo *ainfo;
-	struct addrinfo ahints;
-	int ret;
-
-	if (family == AF_INET) {
-		addr_text = LOCALHOST_IPV4;
-	} else {
-		addr_text = LOCALHOST_IPV6;
-	}
-
-	memset(&ahints, 0, sizeof(ahints));
-	ahints.ai_socktype = SOCK_DGRAM;
-	ahints.ai_protocol = IPPROTO_UDP;
-	ahints.ai_family = family;
-
-	/* Lookup the nodename address */
-	ret = getaddrinfo(addr_text, NULL, &ahints, &ainfo);
-	if (ret)
-		return -1;
-
-	memset(localhost, 0, sizeof(struct sockaddr_storage));
-	memcpy(localhost, ainfo->ai_addr, ainfo->ai_addrlen);
-
-	freeaddrinfo(ainfo);
-	return 0;
-}
-
-/* Return the address family of an IP[46] name */
-static int address_family(char *addr, struct sockaddr_storage *ssaddr)
-{
-	struct addrinfo *ainfo;
-	struct addrinfo ahints;
-	int family;
-	int ret;
-
-	memset(&ahints, 0, sizeof(ahints));
-	ahints.ai_socktype = SOCK_DGRAM;
-	ahints.ai_protocol = IPPROTO_UDP;
-
-	/* Lookup the nodename address */
-	ret = getaddrinfo(addr, NULL, &ahints, &ainfo);
-	if (ret)
-		return -1;
-
-	memset(ssaddr, 0, sizeof(struct sockaddr_storage));
-	memcpy(ssaddr, ainfo->ai_addr, ainfo->ai_addrlen);
-	family = ainfo->ai_family;
-
-	freeaddrinfo(ainfo);
-	return family;
-}
-
-
-/* Find the "CMAN" logger_subsys object. Or create one if it does not
-   exist
-*/
-static unsigned int find_cman_logger(struct objdb_iface_ver0 *objdb, unsigned int object_handle)
-{
-	unsigned int subsys_handle;
-	unsigned int find_handle;
-	char *str;
-
-	objdb->object_find_create(object_handle, "logger_subsys", strlen("logger_subsys"), &find_handle);
-	while (!objdb->object_find_next(object_handle, &subsys_handle)) {
-
-		if (objdb_get_string(objdb, subsys_handle, "subsys", &str)) {
-			continue;
-		}
-		if (strcmp(str, CMAN_NAME) == 0)
-			return subsys_handle;
-	}
-	objdb->object_find_destroy(find_handle);
-
-	/* We can't find it ... create one */
-	if (objdb->object_create(object_handle, &subsys_handle,
-				    "logger_subsys", strlen("logger_subsys")) == 0) {
-
-		objdb->object_key_create(subsys_handle, "subsys", strlen("subsys"),
-					    CMAN_NAME, strlen(CMAN_NAME)+1);
-	}
-
-	return subsys_handle;
-
-}
-
-
-static int add_ifaddr(struct objdb_iface_ver0 *objdb, char *mcast, char *ifaddr, int portnum)
-{
-	unsigned int totem_object_handle;
-	unsigned int find_handle;
-	unsigned int interface_object_handle;
-	struct sockaddr_storage if_addr, localhost, mcast_addr;
-	char tmp[132];
-	int ret = 0;
-
-	/* Check the families match */
-	if (address_family(mcast, &mcast_addr) !=
-	    address_family(ifaddr, &if_addr)) {
-		sprintf(error_reason, "Node address family does not match multicast address family");
-		return -1;
-	}
-
-	/* Check it's not bound to localhost, sigh */
-	get_localhost(if_addr.ss_family, &localhost);
-	if (ipaddr_equal(&localhost, &if_addr)) {
-		sprintf(error_reason, "Node address is localhost, please choose a real host address");
-		return -1;
-	}
-
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &find_handle);
-	if (objdb->object_find_next(find_handle, &totem_object_handle)) {
-
-		objdb->object_create(OBJECT_PARENT_HANDLE, &totem_object_handle,
-				     "totem", strlen("totem"));
-        }
-	objdb->object_find_destroy(find_handle);
-
-	if (objdb->object_create(totem_object_handle, &interface_object_handle,
-				 "interface", strlen("interface")) == 0) {
-
-		sprintf(tmp, "%d", num_interfaces);
-		objdb->object_key_create(interface_object_handle, "ringnumber", strlen("ringnumber"),
-					 tmp, strlen(tmp)+1);
-
-		objdb->object_key_create(interface_object_handle, "bindnetaddr", strlen("bindnetaddr"),
-					 ifaddr, strlen(ifaddr)+1);
-
-		objdb->object_key_create(interface_object_handle, "mcastaddr", strlen("mcastaddr"),
-					 mcast, strlen(mcast)+1);
-
-		sprintf(tmp, "%d", portnum);
-		objdb->object_key_create(interface_object_handle, "mcastport", strlen("mcastport"),
-					 tmp, strlen(tmp)+1);
-
-		num_interfaces++;
-	}
-	return ret;
-}
-
-static uint16_t generate_cluster_id(char *name)
-{
-	int i;
-	int value = 0;
-
-	for (i=0; i<strlen(name); i++) {
-		value <<= 1;
-		value += name[i];
-	}
-	sprintf(error_reason, "Generated cluster id for '%s' is %d\n", name, value & 0xFFFF);
-	return value & 0xFFFF;
-}
-
-static char *default_mcast(char *nodename, uint16_t cluster_id)
-{
-        struct addrinfo *ainfo;
-        struct addrinfo ahints;
-	int ret;
-	int family;
-	static char addr[132];
-
-        memset(&ahints, 0, sizeof(ahints));
-
-        /* Lookup the the nodename address and use it's IP type to
-	   default a multicast address */
-        ret = getaddrinfo(nodename, NULL, &ahints, &ainfo);
-	if (ret) {
-		sprintf(error_reason, "Can't determine address family of nodename %s\n", nodename);
-		write_cman_pipe("Can't determine address family of nodename");
-		return NULL;
-	}
-
-	family = ainfo->ai_family;
-	freeaddrinfo(ainfo);
-
-	if (family == AF_INET) {
-		snprintf(addr, sizeof(addr), "239.192.%d.%d", cluster_id >> 8, cluster_id % 0xFF);
-		return addr;
-	}
-	if (family == AF_INET6) {
-		snprintf(addr, sizeof(addr), "ff15::%x", cluster_id);
-		return addr;
-	}
-
-	return NULL;
-}
-
-static int verify_nodename(struct objdb_iface_ver0 *objdb, char *nodename)
-{
-	char nodename2[MAX_CLUSTER_MEMBER_NAME_LEN+1];
-	char nodename3[MAX_CLUSTER_MEMBER_NAME_LEN+1];
-	char *str, *dot = NULL;
-	struct ifaddrs *ifa, *ifa_list;
-	struct sockaddr *sa;
-	unsigned int nodes_handle;
-	unsigned int find_handle = 0;
-	int error;
-
-	/* nodename is either from commandline or from uname */
-	if (nodelist_byname(objdb, cluster_parent_handle, nodename))
-		return 0;
-
-	/* If nodename was from uname, try a domain-less version of it */
-	strcpy(nodename2, nodename);
-	dot = strchr(nodename2, '.');
-	if (dot) {
-		*dot = '\0';
-
-		if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-			strcpy(nodename, nodename2);
-			return 0;
-		}
-	}
-
-	/* If nodename (from uname) is domain-less, try to match against
-	   cluster.conf names which may have domainname specified */
-	nodes_handle = nodeslist_init(objdb, cluster_parent_handle, &find_handle);
-	do {
-		int len;
-
-		if (objdb_get_string(objdb, nodes_handle, "name", &str)) {
-			sprintf(error_reason, "Cannot get node name");
-			nodes_handle = nodeslist_next(objdb, find_handle);
-			continue;
-		}
-
-		strcpy(nodename3, str);
-		dot = strchr(nodename3, '.');
-		if (dot)
-			len = dot-nodename3;
-		else
-			len = strlen(nodename3);
-
-		if (strlen(nodename2) == len &&
-		    !strncmp(nodename2, nodename3, len)) {
-			strcpy(nodename, str);
-			return 0;
-		}
-		nodes_handle = nodeslist_next(objdb, find_handle);
-	} while (nodes_handle);
-	objdb->object_find_destroy(find_handle);
-
-
-	/* The cluster.conf names may not be related to uname at all,
-	   they may match a hostname on some network interface.
-	   NOTE: This is IPv4 only */
-	error = getifaddrs(&ifa_list);
-	if (error)
-		return -1;
-
-	for (ifa = ifa_list; ifa; ifa = ifa->ifa_next) {
-		/* Restore this */
-		strcpy(nodename2, nodename);
-		sa = ifa->ifa_addr;
-		if (!sa || sa->sa_family != AF_INET)
-			continue;
-
-		error = getnameinfo(sa, sizeof(*sa), nodename2,
-				    sizeof(nodename2), NULL, 0, 0);
-		if (error)
-			goto out;
-
-		if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-			strcpy(nodename, nodename2);
-			goto out;
-		}
-
-		/* truncate this name and try again */
-
-		dot = strchr(nodename2, '.');
-		if (!dot)
-			continue;
-		*dot = '\0';
-
-		if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-			strcpy(nodename, nodename2);
-			goto out;
-		}
-
-		/* See if it's the IP address that's in cluster.conf */
-		error = getnameinfo(sa, sizeof(*sa), nodename2,
-				    sizeof(nodename2), NULL, 0, NI_NUMERICHOST);
-		if (error)
-			goto out;
-
-		if (nodelist_byname(objdb, cluster_parent_handle, nodename2)) {
-			strcpy(nodename, nodename2);
-			goto out;
-		}
-	}
-
-	error = -1;
- out:
-	freeifaddrs(ifa_list);
-	return error;
-}
-
-/* Get any environment variable overrides */
-static int get_env_overrides()
-{
-	if (getenv("CMAN_CLUSTER_NAME")) {
-		cluster_name = strdup(getenv("CMAN_CLUSTER_NAME"));
-	}
-
-	nodename_env = getenv("CMAN_NODENAME");
-
-	expected_votes = 0;
-	if (getenv("CMAN_EXPECTEDVOTES")) {
-		expected_votes = atoi(getenv("CMAN_EXPECTEDVOTES"));
-		if (expected_votes < 1) {
-			expected_votes = 0;
-		}
-	}
-
-	/* optional port */
-	if (getenv("CMAN_IP_PORT")) {
-		portnum = atoi(getenv("CMAN_IP_PORT"));
-	}
-
-	/* optional security key filename */
-	if (getenv("CMAN_KEYFILE")) {
-		key_filename = strdup(getenv("CMAN_KEYFILE"));
-		if (key_filename == NULL) {
-			write_cman_pipe("Cannot allocate memory for key filename");
-			return -1;
-		}
-	}
-
-	/* find our own number of votes */
-	if (getenv("CMAN_VOTES")) {
-		votes = atoi(getenv("CMAN_VOTES"));
-	}
-
-	/* nodeid */
-	if (getenv("CMAN_NODEID")) {
-		nodeid = atoi(getenv("CMAN_NODEID"));
-	}
-
-	if (getenv("CMAN_MCAST_ADDR")) {
-		mcast_name = getenv("CMAN_MCAST_ADDR");
-	}
-
-	if (getenv("CMAN_2NODE")) {
-		two_node = 1;
-		expected_votes = 1;
-		votes = 1;
-	}
-	if (getenv("CMAN_DEBUGLOG")) {
-		debug_mask = atoi(getenv("CMAN_DEBUGLOG"));
-	}
-
-	return 0;
-}
-
-
-static int get_nodename(struct objdb_iface_ver0 *objdb)
-{
-	char *nodeid_str = NULL;
-	unsigned int object_handle;
-	unsigned int find_handle;
-	unsigned int node_object_handle;
-	unsigned int alt_object;
-	int error;
-
-	if (!getenv("CMAN_NOCONFIG")) {
-		/* our nodename */
-		if (nodename_env != NULL) {
-			if (strlen(nodename_env) >= sizeof(nodename)) {
-				sprintf(error_reason, "Overridden node name %s is too long", nodename);
-				write_cman_pipe("Overridden node name is too long");
-				error = -1;
-				goto out;
-			}
-
-			strcpy(nodename, nodename_env);
-
-			if (!(node_object_handle = nodelist_byname(objdb, cluster_parent_handle, nodename))) {
-				sprintf(error_reason, "Overridden node name %s is not in CCS", nodename);
-				write_cman_pipe("Overridden node name is not in CCS");
-				error = -1;
-				goto out;
-			}
-
-		} else {
-			struct utsname utsname;
-
-			error = uname(&utsname);
-			if (error) {
-				sprintf(error_reason, "cannot get node name, uname failed");
-				write_cman_pipe("Can't determine local node name");
-				error = -1;
-				goto out;
-			}
-
-			if (strlen(utsname.nodename) >= sizeof(nodename)) {
-				sprintf(error_reason, "node name from uname is too long");
-				write_cman_pipe("Can't determine local node name");
-				error = -1;
-				goto out;
-			}
-
-			strcpy(nodename, utsname.nodename);
-		}
-		if (verify_nodename(objdb, nodename))
-			return -1;
-
-	}
-
-	/* Add <cman> bits to pass down to the main module*/
-	if ( (node_object_handle = nodelist_byname(objdb, cluster_parent_handle, nodename))) {
-		if (objdb_get_string(objdb, node_object_handle, "nodeid", &nodeid_str)) {
-			sprintf(error_reason, "This node has no nodeid in cluster.conf");
-			write_cman_pipe("This node has no nodeid in cluster.conf");
-			return -1;
-		}
-	}
-
-	objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-
-	if (objdb->object_find_next(find_handle, &object_handle) == 0) {
-
-		unsigned int mcast_handle;
-		unsigned int find_handle2;
-
-		if (!mcast_name) {
-
-			objdb->object_find_create(object_handle, "multicast", strlen("multicast"), &find_handle2);
-			if (objdb->object_find_next(find_handle2, &mcast_handle) == 0) {
-
-				objdb_get_string(objdb, mcast_handle, "addr", &mcast_name);
-			}
-			objdb->object_find_destroy(find_handle2);
-		}
-
-		if (!mcast_name) {
-			mcast_name = default_mcast(nodename, cluster_id);
-		}
-
-		/* See if the user wants our default set of openais services (default=yes) */
-		objdb_get_int(objdb, object_handle, "disable_openais", &disable_openais, 0);
-
-		objdb->object_key_create(object_handle, "nodename", strlen("nodename"),
-					    nodename, strlen(nodename)+1);
-	}
-	objdb->object_find_destroy(find_handle);
-
-	nodeid = atoi(nodeid_str);
-	error = 0;
-
-	/* optional port */
-	if (!portnum) {
-		objdb_get_int(objdb, object_handle, "port", &portnum, DEFAULT_PORT);
-	}
-
-	if (add_ifaddr(objdb, mcast_name, nodename, portnum))
-		return -1;
-
-	/* Get all alternative node names */
-	num_nodenames = 1;
-	objdb->object_find_create(node_object_handle,"altname", strlen("altname"), &find_handle);
-	while (objdb->object_find_next(find_handle, &alt_object) == 0) {
-		unsigned int port;
-		char *nodename;
-		char *mcast;
-
-		if (objdb_get_string(objdb, alt_object, "name", &nodename)) {
-			continue;
-		}
-
-		objdb_get_int(objdb, alt_object, "port", &port, portnum);
-
-		if (objdb_get_string(objdb, alt_object, "mcast", &mcast)) {
-			mcast = mcast_name;
-		}
-
-		if (add_ifaddr(objdb, mcast, nodename, portnum))
-			return -1;
-
-		num_nodenames++;
-	}
-	objdb->object_find_destroy(find_handle);
-
-out:
-	return error;
-}
-
-/* These are basically cman overrides to the totem config bits */
-static void add_cman_overrides(struct objdb_iface_ver0 *objdb)
-{
-	unsigned int logger_object_handle;
-	char *logstr;
-	char *logfacility;
-	unsigned int object_handle;
-	unsigned int find_handle;
-	char tmp[256];
-
-	/* "totem" key already exists, because we have added the interfaces by now */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE,"totem", strlen("totem"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle) == 0)
-	{
-		char *value;
-
-		objdb->object_key_create(object_handle, "version", strlen("version"),
-					 "2", 2);
-
-		sprintf(tmp, "%d", nodeid);
-		objdb->object_key_create(object_handle, "nodeid", strlen("nodeid"),
-					 tmp, strlen(tmp)+1);
-
-		objdb->object_key_create(object_handle, "vsftype", strlen("vsftype"),
-					 "none", strlen("none")+1);
-
-		/* Set the token timeout is 10 seconds, but don't overrride anything that
-		   might be in cluster.conf */
-		if (objdb_get_string(objdb, object_handle, "token", &value)) {
-			objdb->object_key_create(object_handle, "token", strlen("token"),
-						 "10000", strlen("10000")+1);
-		}
-		if (objdb_get_string(objdb, object_handle, "token_retransmits_before_loss_const", &value)) {
-			objdb->object_key_create(object_handle, "token_retransmits_before_loss_const",
-						 strlen("token_retransmits_before_loss_const"),
-						 "20", strlen("20")+1);
-		}
-
-		/* Extend consensus & join timeouts per bz#214290 */
-		if (objdb_get_string(objdb, object_handle, "join", &value)) {
-			objdb->object_key_create(object_handle, "join", strlen("join"),
-						 "60", strlen("60")+1);
-		}
-		if (objdb_get_string(objdb, object_handle, "consensus", &value)) {
-			objdb->object_key_create(object_handle, "consensus", strlen("consensus"),
-						 "4800", strlen("4800")+1);
-		}
-
-		/* Set RRP mode appropriately */
-		if (objdb_get_string(objdb, object_handle, "rrp_mode", &value)) {
-			if (num_interfaces > 1) {
-				objdb->object_key_create(object_handle, "rrp_mode", strlen("rrp_mode"),
-							 "active", strlen("active")+1);
-			}
-			else {
-				objdb->object_key_create(object_handle, "rrp_mode", strlen("rrp_mode"),
-							 "none", strlen("none")+1);
-			}
-		}
-
-		if (objdb_get_string(objdb, object_handle, "secauth", &value)) {
-			sprintf(tmp, "%d", 1);
-			objdb->object_key_create(object_handle, "secauth", strlen("secauth"),
-						 tmp, strlen(tmp)+1);
-		}
-
-		/* optional security key filename */
-		if (!key_filename) {
-			objdb_get_string(objdb, object_handle, "keyfile", &key_filename);
-		}
-		else {
-			objdb->object_key_create(object_handle, "keyfile", strlen("keyfile"),
-						 key_filename, strlen(key_filename)+1);
-		}
-		if (!key_filename) {
-			/* Use the cluster name as key,
-			 * This isn't a good isolation strategy but it does make sure that
-			 * clusters on the same port/multicast by mistake don't actually interfere
-			 * and that we have some form of encryption going.
-			 */
-
-			int keylen;
-			memset(tmp, 0, sizeof(tmp));
-
-			strcpy(tmp, cluster_name);
-
-			/* Key length must be a multiple of 4 */
-			keylen = (strlen(cluster_name)+4) & 0xFC;
-			objdb->object_key_create(object_handle, "key", strlen("key"),
-						 tmp, keylen);
-		}
-	}
-	objdb->object_find_destroy(find_handle);
-
-	/* Make sure mainconfig doesn't stomp on our logging options */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "logging", strlen("logging"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle)) {
-
-                objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-					    "logging", strlen("logging"));
-        }
-	objdb->object_find_destroy(find_handle);
-
-	logfacility = facility_name_get(SYSLOGFACILITY);
-
-	logger_object_handle = find_cman_logger(objdb, object_handle);
-
-	if (objdb_get_string(objdb, object_handle, "syslog_facility", &logstr)) {
-		objdb->object_key_create(object_handle, "syslog_facility", strlen("syslog_facility"),
-					    logfacility, strlen(logfacility)+1);
-	}
-
-	if (objdb_get_string(objdb, object_handle, "to_file", &logstr)) {
-		objdb->object_key_create(object_handle, "to_file", strlen("to_file"),
-					    "yes", strlen("yes")+1);
-	}
-
-	if (objdb_get_string(objdb, object_handle, "logfile", &logstr)) {
-		objdb->object_key_create(object_handle, "logfile", strlen("logfile"),
-					    LOGDIR "/cman.log", strlen(LOGDIR "/cman.log")+1);
-	}
-
-	if (debug_mask) {
-		objdb->object_key_create(object_handle, "to_stderr", strlen("to_stderr"),
-					    "yes", strlen("yes")+1);
-		objdb->object_key_create(logger_object_handle, "debug", strlen("debug"),
-					    "on", strlen("on")+1);
-		objdb->object_key_create(logger_object_handle, "syslog_level", strlen("syslog_level"),
-					    "debug", strlen("debug")+1);
-
-	}
-	else {
-		char *loglevel;
-		loglevel = priority_name_get(SYSLOGLEVEL);
-		objdb->object_key_create(logger_object_handle, "syslog_level", strlen("syslog_level"),
-					    loglevel, strlen(loglevel)+1);
-	}
-
-
-	/* Don't run under user "ais" */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "aisexec", strlen("aisexec"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle) != 0) {
-		objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-					"aisexec", strlen("aisexec"));
-
-	}
-	objdb->object_find_destroy(find_handle);
-	objdb->object_key_create(object_handle, "user", strlen("user"),
-				    "root", strlen("root") + 1);
-	objdb->object_key_create(object_handle, "group", strlen("group"),
-				    "root", strlen("root") + 1);
-
-	objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle) == 0)
-	{
-		char str[255];
-
-		sprintf(str, "%d", cluster_id);
-
-		objdb->object_key_create(object_handle, "cluster_id", strlen("cluster_id"),
-					 str, strlen(str) + 1);
-
-		if (two_node) {
-			sprintf(str, "%d", 1);
-			objdb->object_key_create(object_handle, "two_node", strlen("two_node"),
-						 str, strlen(str) + 1);
-		}
-		if (debug_mask) {
-			sprintf(str, "%d", debug_mask);
-			objdb->object_key_create(object_handle, "debug_mask", strlen("debug_mask"),
-						 str, strlen(str) + 1);
-		}
-	}
-	objdb->object_find_destroy(find_handle);
-
-	/* Make sure we load our alter-ego - the main cman module */
-	objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-			     "service", strlen("service"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-				 "corosync_cman", strlen("corosync_cman") + 1);
-	objdb->object_key_create(object_handle, "ver", strlen("ver"),
-				 "0", 2);
-
-	/* Define cman as the quorum provider for corosync */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle) != 0) {
-		objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-					"quorum", strlen("quorum"));
-	}
-	objdb->object_find_destroy(find_handle);
-
-	objdb->object_key_create(object_handle, "provider", strlen("provider"),
-				 "quorum_cman", strlen("quorum_cman") + 1);
-}
-
-/* If ccs is not available then use some defaults */
-static int set_noccs_defaults(struct objdb_iface_ver0 *objdb)
-{
-	char tmp[255];
-	unsigned int object_handle;
-	unsigned int find_handle;
-
-	/* Enforce key */
-	key_filename = NOCCS_KEY_FILENAME;
-
-	if (!cluster_name)
-		cluster_name = DEFAULT_CLUSTER_NAME;
-
-	if (!cluster_id)
-		cluster_id = generate_cluster_id(cluster_name);
-
-	if (!nodename_env) {
-		int error;
-		struct utsname utsname;
-
-		error = uname(&utsname);
-		if (error) {
-			sprintf(error_reason, "cannot get node name, uname failed");
-			write_cman_pipe("Can't determine local node name");
-			return -1;
-		}
-
-		nodename_env = (char *)&utsname.nodename;
-	}
-	strcpy(nodename, nodename_env);
-	num_nodenames = 1;
-
-	if (!mcast_name) {
-		mcast_name = default_mcast(nodename, cluster_id);
-	}
-
-	/* This will increase as nodes join the cluster */
-	if (!expected_votes)
-		expected_votes = 1;
-	if (!votes)
-		votes = 1;
-
-	if (!portnum)
-		portnum = DEFAULT_PORT;
-
-	/* Invent a node ID */
-	if (!nodeid) {
-		struct addrinfo *ainfo;
-		struct addrinfo ahints;
-		int ret;
-
-		memset(&ahints, 0, sizeof(ahints));
-		ret = getaddrinfo(nodename, NULL, &ahints, &ainfo);
-		if (ret) {
-			sprintf(error_reason, "Can't determine address family of nodename %s\n", nodename);
-			write_cman_pipe("Can't determine address family of nodename");
-			return -1;
-		}
-
-		if (ainfo->ai_family == AF_INET) {
-			struct sockaddr_in *addr = (struct sockaddr_in *)ainfo->ai_addr;
-			memcpy(&nodeid, &addr->sin_addr, sizeof(int));
-		}
-		if (ainfo->ai_family == AF_INET6) {
-			struct sockaddr_in6 *addr = (struct sockaddr_in6 *)ainfo->ai_addr;
-			memcpy(&nodeid, &addr->sin6_addr.s6_addr32[3], sizeof(int));
-		}
-		freeaddrinfo(ainfo);
-	}
-
-	/* Write a local <clusternode> entry to keep the rest of the code happy */
-	objdb->object_create(cluster_parent_handle, &object_handle,
-			     "clusternodes", strlen("clusternodes"));
-	objdb->object_create(object_handle, &object_handle,
-			     "clusternode", strlen("clusternode"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-				 nodename, strlen(nodename)+1);
-
-	sprintf(tmp, "%d", votes);
-	objdb->object_key_create(object_handle, "votes", strlen("votes"),
-				 tmp, strlen(tmp)+1);
-
-	sprintf(tmp, "%d", nodeid);
-	objdb->object_key_create(object_handle, "nodeid", strlen("nodeid"),
-				 tmp, strlen(tmp)+1);
-
-	/* Write the default cluster name & ID in here too */
-	objdb->object_key_create(cluster_parent_handle, "name", strlen("name"),
-				 cluster_name, strlen(cluster_name)+1);
-
-
-	objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle) == 0) {
-
-                objdb->object_create(cluster_parent_handle, &object_handle,
-                                            "cman", strlen("cman"));
-        }
-	sprintf(tmp, "%d", cluster_id);
-	objdb->object_key_create(object_handle, "cluster_id", strlen("cluster_id"),
-				    tmp, strlen(tmp)+1);
-
-	sprintf(tmp, "%d", expected_votes);
-	objdb->object_key_create(object_handle, "expected_votes", strlen("expected_votes"),
-				    tmp, strlen(tmp)+1);
-
-	objdb->object_find_destroy(find_handle);
-	return 0;
-}
-
-/* Move an object/key tree */
-static int copy_config_tree(struct objdb_iface_ver0 *objdb, unsigned int source_object, unsigned int target_parent_object, int always_create)
-{
-	unsigned int object_handle;
-	unsigned int new_object;
-	unsigned int find_handle;
-	char object_name[1024];
-	int object_name_len;
-	void *key_name;
-	int key_name_len;
-	void *key_value;
-	int key_value_len;
-	int res;
-
-	/* Create new parent object if necessary */
-	objdb->object_name_get(source_object, object_name, &object_name_len);
-
-	objdb->object_find_create(target_parent_object, object_name, strlen(object_name), &find_handle);
-	if (always_create || objdb->object_find_next(find_handle, &object_handle))
-			objdb->object_create(target_parent_object, &new_object, object_name, object_name_len);
-	objdb->object_find_destroy(find_handle);
-
-	/* Copy the keys */
-	objdb->object_key_iter_reset(new_object);
-
-	while (!objdb->object_key_iter(source_object, &key_name, &key_name_len,
-				       &key_value, &key_value_len)) {
-
-		objdb->object_key_create(new_object, key_name, key_name_len,
-					 key_value, key_value_len);
-	}
-
-	/* Create sub-objects */
-	res = objdb->object_find_create(source_object, NULL, 0, &find_handle);
-	if (res) {
-		sprintf(error_reason, "error resetting object iterator for object %d: %d\n", source_object, res);
-		return -1;
-	}
-
-	while ( (res = objdb->object_find_next(find_handle, &object_handle) == 0)) {
-
-		/* Down we go ... */
-		copy_config_tree(objdb, object_handle, new_object, 0);
-	}
-	objdb->object_find_destroy(find_handle);
-
-	return 0;
-}
-
-/*
- * Copy trees from /cluster where they live in cluster.conf, into the root
- * of the config tree where corosync expects to find them.
- */
-static int copy_tree_to_root(struct objdb_iface_ver0 *objdb, char *name, int always_create)
-{
-	unsigned int find_handle;
-	unsigned int object_handle;
-	int res=0;
-
-	objdb->object_find_create(cluster_parent_handle, name, strlen(name), &find_handle);
-	while (objdb->object_find_next(find_handle, &object_handle) == 0) {
-		res = copy_config_tree(objdb, object_handle, OBJECT_PARENT_HANDLE, always_create);
-	}
-	objdb->object_find_destroy(find_handle);
-
-	return res;
-}
-
-static int get_cman_globals(struct objdb_iface_ver0 *objdb)
-{
-	unsigned int object_handle;
-	unsigned int find_handle;
-
-	objdb_get_string(objdb, cluster_parent_handle, "name", &cluster_name);
-
-	/* Get the <cman> bits that override <totem> bits */
-	objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle) == 0) {
-		if (!portnum)
-			objdb_get_int(objdb, object_handle, "port", &portnum, DEFAULT_PORT);
-
-		if (!key_filename)
-			objdb_get_string(objdb, object_handle, "keyfile", &key_filename);
-
-		if (!cluster_id)
-			objdb_get_int(objdb, object_handle, "cluster_id", &cluster_id, 0);
-
-		if (!cluster_id)
-			cluster_id = generate_cluster_id(cluster_name);
-	}
-	objdb->object_find_destroy(find_handle);
-	return 0;
-}
-
-static int cmanpre_reloadconfig(struct objdb_iface_ver0 *objdb, int flush, char **error_string)
-{
-	int ret = -1;
-	unsigned int object_handle;
-	unsigned int find_handle;
-	unsigned int cluster_parent_handle_new;
-
-	/* don't reload if we've been told to run configless */
-	if (getenv("CMAN_NOCONFIG")) {
-		sprintf(error_reason, "Config not updated because we were run with cman_tool -X");
-		ret = 0;
-		goto err;
-	}
-
-	/* find both /cluster entries */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
-	objdb->object_find_next(find_handle, &cluster_parent_handle);
-	if (!cluster_parent_handle) {
-		sprintf (error_reason, "%s", "Cannot find old /cluster/ key in configuration\n");
-		goto err;
-	}
-	objdb->object_find_next(find_handle, &cluster_parent_handle_new);
-	if (!cluster_parent_handle_new) {
-		sprintf (error_reason, "%s", "Cannot find new /cluster/ key in configuration\n");
-		goto err;
-	}
-	objdb->object_find_destroy(find_handle);
-
-	/* destroy the old one */
-	objdb->object_destroy(cluster_parent_handle);
-
-	/* update the reference to the new config */
-	cluster_parent_handle = cluster_parent_handle_new;
-
-	/* destroy top level /logging */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "logging", strlen("logging"), &find_handle);
-	objdb->object_find_next(find_handle, &object_handle);
-	objdb->object_find_destroy(find_handle);
-	if (object_handle) {
-		objdb->object_destroy(object_handle);
-	}
-
-	/* copy /cluster/logging to /logging */
-	ret = copy_tree_to_root(objdb, "logging", 0);
-
-	/* destroy top level /totem */
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &find_handle);
-	objdb->object_find_next(find_handle, &object_handle);
-	objdb->object_find_destroy(find_handle);
-	if (object_handle) {
-		objdb->object_destroy(object_handle);
-	}
-
-	/* copy /cluster/totem to /totem */
-	ret = copy_tree_to_root(objdb, "totem", 0);
-
-	return 0;
-
-err:
-	*error_string = error_reason;
-	return ret;
-}
-
-static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_string)
-{
-	int ret = 0;
-	unsigned int object_handle;
-	unsigned int find_handle;
-
-	if (getenv("CMAN_PIPE"))
-                startup_pipe = atoi(getenv("CMAN_PIPE"));
-
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "cluster", strlen("cluster"), &find_handle);
-        objdb->object_find_next(find_handle, &cluster_parent_handle);
-	objdb->object_find_destroy(find_handle);
-	if (!cluster_parent_handle) {
-                objdb->object_create(OBJECT_PARENT_HANDLE, &cluster_parent_handle,
-				     "cluster", strlen("cluster"));
-	}
-	else {
-		/* Move these to a place where corosync expects to find them */
-		ret = copy_tree_to_root(objdb, "totem", 0);
-		ret = copy_tree_to_root(objdb, "logging", 0);
-		ret = copy_tree_to_root(objdb, "event", 0);
-		ret = copy_tree_to_root(objdb, "amf", 0);
-		ret = copy_tree_to_root(objdb, "aisexec", 0);
-		ret = copy_tree_to_root(objdb, "service", 1);
-	}
-
-	objdb->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle)) {
-                objdb->object_create(cluster_parent_handle, &object_handle,
-					"cman", strlen("cman"));
-        }
-	objdb->object_find_destroy(find_handle);
-
-	/* This will create /libccs/@next_handle.
-	 * next_handle will be atomically incremented by corosync to return ccs_handle down the pipe.
-	 * We create it in cman-preconfig to avoid an "init" race in libccs.
-	 */
-
-	objdb->object_find_create(OBJECT_PARENT_HANDLE, "libccs", strlen("libccs"), &find_handle);
-	if (objdb->object_find_next(find_handle, &object_handle)) {
-		int next_handle = 0;
-
-		objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-					"libccs", strlen("libccs"));
-
-		objdb->object_key_create(object_handle, "next_handle", strlen("next_handle"),
-					 &next_handle, sizeof(int));
-	}
-	objdb->object_find_destroy(find_handle);
-
-	get_env_overrides();
-	if (getenv("CMAN_NOCONFIG"))
-		ret = set_noccs_defaults(objdb);
-	else
-		ret = get_cman_globals(objdb);
-
-	if (!ret) {
-		ret = get_nodename(objdb);
-		add_cman_overrides(objdb);
-	}
-
-
-	if (!ret) {
-		sprintf (error_reason, "%s", "Successfully parsed cman config\n");
-	}
-	else {
-		if (error_reason[0] == '\0')
-			sprintf (error_reason, "%s", "Error parsing cman config\n");
-	}
-        *error_string = error_reason;
-
-	return ret;
-}
-
-/* Write an error message down the CMAN startup pipe so
-   that cman_tool can display it */
-int write_cman_pipe(char *message)
-{
-	if (startup_pipe)
-		return write(startup_pipe, message, strlen(message)+1);
-
-	return 0;
-}
diff --git a/cman/daemon/cman.h b/cman/daemon/cman.h
deleted file mode 100644
index bba91aa..0000000
--- a/cman/daemon/cman.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* General cman bits */
-extern int write_cman_pipe(char *message);
-extern void close_cman_pipe(void);
-
-/* How we announce ourself in syslog */
-#define CMAN_NAME "CMAN"
-
-/* Defaults for configuration variables */
-#define NOCCS_KEY_FILENAME      "/etc/cluster/cman_authkey"
-#define DEFAULT_PORT            5405
-#define DEFAULT_CLUSTER_NAME    "RHCluster"
-#define DEFAULT_MAX_QUEUED       128
-#define DEFAULT_QUORUMDEV_POLL   10000
-#define DEFAULT_SHUTDOWN_TIMEOUT 5000
-#define DEFAULT_CCSD_POLL        1000
diff --git a/cman/daemon/cmanconfig.c b/cman/daemon/cmanconfig.c
deleted file mode 100644
index cf0cfd2..0000000
--- a/cman/daemon/cmanconfig.c
+++ /dev/null
@@ -1,297 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <netinet/in.h>
-#include <syslog.h>
-#include <string.h>
-#include <errno.h>
-#include <netdb.h>
-
-#include <corosync/ipc_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "logging.h"
-#include "commands.h"
-#include "cman.h"
-#define OBJDB_API struct corosync_api_v1
-#include "cmanconfig.h"
-#include "nodelist.h"
-#include "ais.h"
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME, LOG_INFO);
-
-/* Local vars - things we get from ccs */
-       int two_node;
-static int nodeid;
-static unsigned int cluster_id;
-static char cluster_name[MAX_CLUSTER_NAME_LEN + 1];
-static unsigned int expected_votes;
-static char *our_nodename;
-static int our_votes;
-
-/* Get all the cluster node names from objdb and
- * add them to our node list.
- * Called when we start up and on "cman_tool version".
- */
-int read_cman_nodes(struct corosync_api_v1 *corosync, unsigned int *config_version, int check_nodeids)
-{
-    int error;
-    unsigned int expected = 0;
-    unsigned int votes = 0;
-    int nodeid;
-    unsigned int object_handle;
-    unsigned int nodes_handle;
-    unsigned int find_handle;
-    char *nodename;
-    unsigned int cluster_parent_handle;
-
-    corosync->object_find_create(OBJECT_PARENT_HANDLE,
-				 "cluster", strlen("cluster"), &find_handle);
-
-    corosync->object_find_next(find_handle, &cluster_parent_handle);
-    corosync->object_find_destroy(find_handle);
-
-    /* New config version */
-    objdb_get_int(corosync, cluster_parent_handle, "config_version", config_version,0);
-
-    corosync->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-
-    if (corosync->object_find_next(find_handle, &object_handle) == 0)
-    {
-	    /* This overrides any other expected votes calculation /except/ for
-	       one specified on a join command-line */
-	    objdb_get_int(corosync, object_handle, "expected_votes", &expected, 0);
-	    objdb_get_int(corosync, object_handle, "two_node", (unsigned int *)&two_node, 0);
-	    objdb_get_int(corosync, object_handle, "cluster_id", &cluster_id, 0);
-	    objdb_get_string(corosync, object_handle, "nodename", &our_nodename);
-	    objdb_get_int(corosync, object_handle, "max_queued", &max_outstanding_messages, DEFAULT_MAX_QUEUED);
-    }
-    corosync->object_find_destroy(find_handle);
-
-    clear_reread_flags();
-
-    /* Get the nodes list */
-    nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
-    do {
-	    if (objdb_get_string(corosync, nodes_handle, "name", &nodename)) {
-		    nodes_handle = nodeslist_next(corosync, find_handle);
-		    continue;
-	    }
-
-	    objdb_get_int(corosync, nodes_handle, "votes", (unsigned int *)&votes, 1);
-	    objdb_get_int(corosync, nodes_handle, "nodeid", (unsigned int *)&nodeid, 0);
-	    if (check_nodeids && nodeid == 0) {
-		    char message[132];
-
-		    snprintf(message, sizeof(message),
-			     "No node ID for %s, run 'ccs_tool addnodeids' to fix",
-			     nodename);
-		    log_printf(LOG_ERR, "%s", message);
-		    write_cman_pipe(message);
-		    error = -EINVAL;
-		    goto out_err;
-	    }
-
-	    P_MEMB("Got node %s from ccs (id=%d, votes=%d)\n", nodename, nodeid, votes);
-	    add_ccs_node(nodename, nodeid, votes, expected);
-	    nodes_handle = nodeslist_next(corosync, find_handle);
-    } while (nodes_handle);
-    corosync->object_find_destroy(find_handle);
-
-    if (expected)
-	    override_expected(expected);
-
-    remove_unread_nodes();
-    error = 0;
-
-out_err:
-    return error;
-}
-
-static int join(struct corosync_api_v1 *corosync)
-{
-	int error;
-	error = cman_set_nodename(our_nodename);
-	error = cman_set_nodeid(nodeid);
-
-        /*
-	 * Setup join information
-	 */
-	error = cman_join_cluster(corosync, cluster_name, cluster_id,
-				  two_node, our_votes, expected_votes);
-	if (error == -EINVAL) {
-		write_cman_pipe("Cannot start, cluster name is too long or other CCS error");
-		return error;
-	}
-	if (error) {
-		write_cman_pipe("Cannot start, ais may already be running");
-		return error;
-	}
-
-	return 0;
-}
-
-static int get_cman_join_info(struct corosync_api_v1 *corosync)
-{
-	char *cname = NULL;
-	int  error, vote_sum = 0, node_count = 0;
-	int votes=0;
-	unsigned int object_handle;
-	unsigned int node_object;
-	unsigned int nodes_handle;
-	unsigned int find_handle;
-	unsigned int cluster_parent_handle;
-
-	corosync->object_find_create(OBJECT_PARENT_HANDLE,
-				     "cluster", strlen("cluster"), &find_handle);
-
-	corosync->object_find_next(find_handle, &cluster_parent_handle);
-	corosync->object_find_destroy(find_handle);
-
-	/* Cluster name */
-	if (objdb_get_string(corosync, cluster_parent_handle, "name", &cname)) {
-		log_printf(LOG_ERR, "cannot find cluster name in config file");
-		write_cman_pipe("Can't find cluster name in CCS");
-		error = -ENOENT;
-		goto out;
-	}
-
-	strcpy(cluster_name, cname);
-
-	expected_votes = 0;
-	if (getenv("CMAN_EXPECTEDVOTES")) {
-		expected_votes = atoi(getenv("CMAN_EXPECTEDVOTES"));
-		if (expected_votes < 1) {
-			log_printf(LOG_ERR, "CMAN_EXPECTEDVOTES environment variable is invalid, ignoring");
-			expected_votes = 0;
-		}
-		else {
-			log_printf(LOG_INFO, "Using override expected votes %d\n", expected_votes);
-		}
-	}
-
-	/* Sum node votes for expected. Even if we already know expected_votes, we need vote_sum
-	   later */
-	nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
-	do {
-		int votes;
-
-		node_count++;
-
-		objdb_get_int(corosync, nodes_handle, "votes", (unsigned int *)&votes, 1);
-		if (votes < 0) {
-			log_printf(LOG_ERR, "negative votes not allowed");
-			write_cman_pipe("Found negative votes for this node in CCS");
-			error = -EINVAL;
-			goto out;
-		}
-		vote_sum += votes;
-		nodes_handle = nodeslist_next(corosync, find_handle);
-	} while (nodes_handle);
-	corosync->object_find_destroy(find_handle);
-
-	if (expected_votes == 0) {
-		corosync->object_find_create(cluster_parent_handle, "cman", strlen("cman"), &find_handle);
-		if (corosync->object_find_next(find_handle, &object_handle) == 0)
-		{
-
-			/* optional expected_votes supercedes vote sum */
-			objdb_get_int(corosync, object_handle, "expected_votes", (unsigned int *)&expected_votes, 0);
-			if (!expected_votes)
-				expected_votes = vote_sum;
-		}
-		corosync->object_find_destroy(find_handle);
-	}
-
-	/* find our own number of votes */
-	if (getenv("CMAN_VOTES")) {
-		votes = atoi(getenv("CMAN_VOTES"));
-		log_printf(LOG_INFO, "Using override votes %d\n", votes);
-	}
-
-	node_object = nodelist_byname(corosync, cluster_parent_handle, our_nodename);
-	if (!node_object) {
-		log_printf(LOG_ERR, "unable to find votes for %s", our_nodename);
-		write_cman_pipe("Unable to find votes for node in CCS");
-		return -E2BIG;
-	}
-
-	if (!votes) {
-		unsigned int votestmp=-1;
-		objdb_get_int(corosync, node_object, "votes", &votestmp, 1);
-		if (votestmp < 0 || votestmp > 255) {
-			log_printf(LOG_ERR, "invalid votes value %d", votestmp);
-			write_cman_pipe("Found invalid votes for node in CCS");
-			return -EINVAL;
-		}
-		votes = votestmp;
-	}
-	our_votes = votes;
-
-	/* nodeid */
-	if (getenv("CMAN_NODEID")) {
-		nodeid = atoi(getenv("CMAN_NODEID"));
-		log_printf(LOG_INFO, "Using override nodeid %d\n", nodeid);
-	}
-
-	if (!nodeid) {
-		objdb_get_int(corosync, node_object, "nodeid", (unsigned int *)&nodeid, 0);
-	}
-
-	if (!nodeid) {
-		log_printf(LOG_ERR, "No nodeid specified in cluster.conf");
-		write_cman_pipe("CCS does not have a nodeid for this node, run 'ccs_tool addnodeids' to fix");
-		return -EINVAL;
-	}
-
-	/* two_node mode */
-	if (two_node) {
-		if (node_count != 2 || vote_sum != 2) {
-			log_printf(LOG_ERR, "the two-node option requires exactly two "
-				   "nodes with one vote each and expected "
-				   "votes of 1 (node_count=%d vote_sum=%d)",
-				   node_count, vote_sum);
-			write_cman_pipe("two_node set but there are more than 2 nodes");
-			error = -EINVAL;
-			goto out;
-		}
-
-		if (votes != 1) {
-			log_printf(LOG_ERR, "the two-node option requires exactly two "
-				   "nodes with one vote each and expected "
-				   "votes of 1 (votes=%d)", votes);
-			write_cman_pipe("two_node set but votes not set to 1");
-			error = -EINVAL;
-			goto out;
-		}
-	}
-
-	error = 0;
-
-out:
-	return error;
-}
-
-
-
-/* Read the stuff we need to get started.
-   This does what 'cman_tool join' used to to */
-int read_cman_config(struct corosync_api_v1 *corosync, unsigned int *config_version)
-{
-	int error;
-
-	read_cman_nodes(corosync, config_version, 1);
-	error = get_cman_join_info(corosync);
-	if (error) {
-		log_printf(LOG_ERR, "Error reading configuration, cannot start");
-		return error;
-	}
-
-	error = join(corosync);
-
-	return error;
-}
diff --git a/cman/daemon/cmanconfig.h b/cman/daemon/cmanconfig.h
deleted file mode 100644
index 2d66add..0000000
--- a/cman/daemon/cmanconfig.h
+++ /dev/null
@@ -1,3 +0,0 @@
-int read_cman_nodes(struct corosync_api_v1 *api, unsigned int *config_version, int check_nodeids);
-int read_cman_config(struct corosync_api_v1 *api, unsigned int *config_version);
-
diff --git a/cman/daemon/cnxman-private.h b/cman/daemon/cnxman-private.h
deleted file mode 100644
index 002480d..0000000
--- a/cman/daemon/cnxman-private.h
+++ /dev/null
@@ -1,183 +0,0 @@
-#ifndef __CNXMAN_PRIVATE_H
-#define __CNXMAN_PRIVATE_H
-
-/* Protocol Version triplet */
-#define CNXMAN_MAJOR_VERSION 6
-#define CNXMAN_MINOR_VERSION 2
-#define CNXMAN_PATCH_VERSION 0
-
-struct cman_timer
-{
-	struct list list;
-	struct timeval tv;
-	int active;
-	void (*callback)(void *arg);
-	void *arg;
-};
-
-/* A cluster internal protocol message - port number 0 */
-struct cl_protmsg {
-	unsigned char cmd;
-};
-
-
-/* A Cluster PORT OPENED/CLOSED message */
-struct cl_portmsg {
-	unsigned char cmd;	/* CLUSTER_CMD_PORTOPENED/CLOSED */
-	unsigned char port;
-};
-
-/* Subcommands for BARRIER message */
-#define BARRIER_REGISTER 1
-#define BARRIER_CHANGE   2
-#define BARRIER_WAIT     4
-#define BARRIER_COMPLETE 5
-
-/* A Cluster BARRIER message */
-struct cl_barriermsg {
-	unsigned char  cmd;	/* CLUSTER_CMD_BARRIER */
-	unsigned char  subcmd;	/* BARRIER sub command */
-	unsigned short pad;
-
-	char name[MAX_BARRIER_NAME_LEN];
-};
-
-struct cl_transmsg {
-	unsigned char cmd;
-	unsigned char first_trans;
-	uint16_t cluster_id;
-	int votes;
-	int expected_votes;
-
-	unsigned int   major_version;	/* Not backwards compatible */
-	unsigned int   minor_version;	/* Backwards compatible */
-	unsigned int   patch_version;	/* Backwards/forwards compatible */
-	unsigned int   config_version;
-	unsigned int   flags;
-	uint64_t       fence_time;
-	uint64_t       join_time;
-        char           clustername[16];
-	char           fence_agent[];
-};
-
-struct cl_killmsg {
-	unsigned char cmd;
-	unsigned char pad1;
-	uint16_t reason;
-	int nodeid;
-};
-
-struct cl_leavemsg {
-	unsigned char cmd;
-	unsigned char pad1;
-	uint16_t reason;
-};
-
-
-/* Reconfigure a cluster parameter */
-struct cl_reconfig_msg {
-	unsigned char  cmd;
-	unsigned char  param;
-	unsigned short pad;
-	int            nodeid;
-	unsigned int   value;
-};
-
-struct cl_fencemsg {
-	unsigned char cmd;
-	unsigned char fenced;
-	uint16_t      pad;
-	int           nodeid;
-	uint64_t      timesec;
-	char          agent[0];
-};
-
-typedef enum {CON_COMMS, CON_CLIENT_RENDEZVOUS, CON_ADMIN_RENDEZVOUS,
-	      CON_CLIENT, CON_ADMIN} con_type_t;
-
-/* One of these for every connection we have open
-   and need to select() on */
-struct connection
-{
-	int fd;
-	con_type_t type;
-	uint32_t   port;        /* If bound client */
-	enum {SHUTDOWN_REPLY_UNK=0, SHUTDOWN_REPLY_YES, SHUTDOWN_REPLY_NO} shutdown_reply;
-	uint32_t   events;      /* Registered for events */
-	uint32_t   confchg;     /* Registered for confchg */
-	struct list write_msgs; /* Queued messages to go to data clients */
-	uint32_t    num_write_msgs; /* Count of messages */
-	struct connection *next;
-	struct list list;       /* when on the client_list */
-};
-
-/* Parameters for RECONFIG command */
-#define RECONFIG_PARAM_EXPECTED_VOTES 1
-#define RECONFIG_PARAM_NODE_VOTES     2
-#define RECONFIG_PARAM_CONFIG_VERSION 3
-#define RECONFIG_PARAM_CCS            4
-
-/* NODE_FLAGS_BEENDOWN       - This node has been down.
-   NODE_FLAGS_FENCED         - This node has been fenced since it last went down.
-   NODE_FLAGS_FENCEDWHILEUP  - This node was fenced manually (probably).
-   NODE_FLAGS_SEESDISALLOWED - Only set in a transition message
-   NODE_FLAGS_DIRTY          - This node has internal state and must not join
-                               a cluster that also has state.
-   NODE_FLAGS_REREAD	     - Set when the node is re-read from config, so
-                               we can spot deleted nodes
-*/
-#define NODE_FLAGS_BEENDOWN           1
-#define NODE_FLAGS_FENCED             2
-#define NODE_FLAGS_FENCEDWHILEUP      4
-#define NODE_FLAGS_SEESDISALLOWED     8
-#define NODE_FLAGS_DIRTY             16
-#define NODE_FLAGS_REREAD            32
-
-/* There's one of these for each node in the cluster */
-struct cluster_node {
-	struct list list;
-	char *name;		/* Node/host name of node */
-	struct list addr_list;
-	int us;			/* This node is us */
-	unsigned int node_id;	/* Unique node ID */
-	int flags;
-	nodestate_t state;
-	struct timeval join_time;
-
-	/* When & how this node was last fenced */
-	uint64_t fence_time; /* A time_t */
-	char    *fence_agent;
-
-	uint64_t cman_join_time; /* A time_t */
-
-	struct timeval last_hello; /* Only used for quorum devices */
-
-	unsigned int votes;
-	unsigned int expected_votes;
-	unsigned int leave_reason;
-	uint64_t     incarnation;
-
-	/* 32 bytes gives us enough for 256 bits (8 bit port number) */
-#define PORT_BITS_SIZE 32
- 	unsigned char port_bits[PORT_BITS_SIZE]; /* bitmap of ports open on this node */
-};
-
-/* Cluster protocol commands sent to port 0 */
-#define CLUSTER_MSG_ACK          1
-#define CLUSTER_MSG_PORTOPENED   2
-#define CLUSTER_MSG_PORTCLOSED   3
-#define CLUSTER_MSG_BARRIER      4
-#define CLUSTER_MSG_TRANSITION   5
-#define CLUSTER_MSG_KILLNODE     6
-#define CLUSTER_MSG_LEAVE        7
-#define CLUSTER_MSG_RECONFIGURE  8
-#define CLUSTER_MSG_PORTENQ      9
-#define CLUSTER_MSG_PORTSTATUS  10
-#define CLUSTER_MSG_FENCESTATUS 11
-
-/* Kill reasons */
-#define CLUSTER_KILL_REJECTED   1
-#define CLUSTER_KILL_CMANTOOL   2
-#define CLUSTER_KILL_REJOIN     3
-
-#endif
diff --git a/cman/daemon/cnxman-socket.h b/cman/daemon/cnxman-socket.h
deleted file mode 100644
index 798fa02..0000000
--- a/cman/daemon/cnxman-socket.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * CMAN socket interface header
- * Should only be used by libcman - if you want to call CMAN then use the library!
- */
-
-#ifndef __CNXMAN_SOCKET_H
-#define __CNXMAN_SOCKET_H
-
-/*
- * Commands on the socket.
- * if the top bit is set then it is only allowed
- * on the ADMIN socket.
- */
-#define CMAN_CMD_NOTIFY             0x00000001
-#define CMAN_CMD_REMOVENOTIFY       0x00000002
-#define CMAN_CMD_SETEXPECTED_VOTES  0x80000004
-#define CMAN_CMD_ISQUORATE          0x00000005
-#define CMAN_CMD_ISLISTENING        0x00000006
-#define CMAN_CMD_GETALLMEMBERS      0x00000007
-#define CMAN_CMD_SET_VOTES          0x80000008
-#define CMAN_CMD_GET_VERSION        0x00000009
-#define CMAN_CMD_SET_VERSION        0x8000000a
-#define CMAN_CMD_ISACTIVE           0x0000000b
-#define CMAN_CMD_KILLNODE           0x8000000c
-#define CMAN_CMD_GET_JOINCOUNT      0x0000000d
-#define CMAN_CMD_GETNODECOUNT       0x0000000e
-#define CMAN_CMD_GETNODE	    0x00000090
-#define CMAN_CMD_GETCLUSTER	    0x00000091
-#define CMAN_CMD_GETEXTRAINFO	    0x00000092
-#define CMAN_CMD_BARRIER            0x000000a0
-#define CMAN_CMD_LEAVE_CLUSTER      0x800000b4
-#define CMAN_CMD_REG_QUORUMDEV      0x800000b5
-#define CMAN_CMD_UNREG_QUORUMDEV    0x800000b6
-#define CMAN_CMD_POLL_QUORUMDEV     0x800000b7
-#define CMAN_CMD_TRY_SHUTDOWN       0x800000bb
-#define CMAN_CMD_SHUTDOWN_REPLY     0x000000bc
-#define CMAN_CMD_UPDATE_FENCE_INFO  0x800000bd
-#define CMAN_CMD_GET_FENCE_INFO     0x000000be
-#define CMAN_CMD_GET_NODEADDRS      0x000000bf
-#define CMAN_CMD_START_CONFCHG      0x000000c0
-#define CMAN_CMD_STOP_CONFCHG       0x000000c1
-#define CMAN_CMD_SET_DIRTY          0x800000c2
-#define CMAN_CMD_SET_DEBUGLOG       0x800000c3
-#define CMAN_CMD_DUMP_OBJDB         0x800000c4
-
-#define CMAN_CMD_DATA               0x00000100
-#define CMAN_CMD_BIND               0x00000101
-#define CMAN_CMD_EVENT              0x00000102
-#define CMAN_CMD_CONFCHG            0x00000103
-
-#define CMAN_CMDFLAG_PRIV           0x80000000
-#define CMAN_CMDFLAG_REPLY          0x40000000
-#define CMAN_CMDMASK_CMD            0x0000FFFF
-
-
-/* Maximum size of a cluster message */
-#define MAX_CLUSTER_MESSAGE          1500
-#define MAX_CLUSTER_MEMBER_NAME_LEN   255
-#define MAX_BARRIER_NAME_LEN           33
-#define MAX_CLUSTER_NAME_LEN           16
-#define MAX_FENCE_AGENT_NAME_LEN      255
-
-/* Well-known cluster port numbers */
-#define CLUSTER_PORT_MEMBERSHIP  1	/* Mustn't block during cluster
-					 * transitions! */
-#define CLUSTER_PORT_SERVICES    2
-#define CLUSTER_PORT_SYSMAN      10	/* Remote execution daemon */
-#define CLUSTER_PORT_CLVMD       11	/* Cluster LVM daemon */
-
-/* Port numbers above this will be blocked when the cluster is inquorate or in
- * transition */
-#define HIGH_PROTECTED_PORT      9
-
-/* Nodeid passed to CMD_GETNODE to return the quorum device info */
-#define CLUSTER_GETNODE_QUORUMDEV -1
-
-/* Reasons for leaving the cluster */
-#define CLUSTER_LEAVEFLAG_DOWN     0	/* Normal shutdown */
-#define CLUSTER_LEAVEFLAG_KILLED   1
-#define CLUSTER_LEAVEFLAG_PANIC    2
-#define CLUSTER_LEAVEFLAG_REMOVED  3	/* This one can reduce quorum */
-#define CLUSTER_LEAVEFLAG_REJECTED 4	/* Not allowed into the cluster in the
-					 * first place */
-#define CLUSTER_LEAVEFLAG_INCONSISTENT 5	/* Our view of the cluster is
-						 * in a minority */
-#define CLUSTER_LEAVEFLAG_DEAD         6	/* Discovered to be dead */
-#define CLUSTER_LEAVEFLAG_NORESPONSE   7        /* Didn't ACK message */
-#define CLUSTER_LEAVEFLAG_FORCE     0x10	/* Forced by command-line */
-
-/* CMAN_CMD_EVENT reason codes */
-#define EVENT_REASON_PORTCLOSED   0
-#define EVENT_REASON_STATECHANGE  1
-#define EVENT_REASON_PORTOPENED   2
-#define EVENT_REASON_TRY_SHUTDOWN 3
-#define EVENT_REASON_CONFIG_UPDATE 4
-
-/* Shutdown flags */
-#define SHUTDOWN_ANYWAY           1
-#define SHUTDOWN_REMOVE           2
-
-/*
- * Sendmsg flags, these are above the normal sendmsg flags so they don't
- * interfere
- */
-#define MSG_TOTEM_AGREED 0x1000000
-#define MSG_TOTEM_SAFE   0x2000000
-#define MSG_BCASTSELF    0x4000000
-
-typedef enum { NODESTATE_JOINING=1, NODESTATE_MEMBER,
-	       NODESTATE_DEAD, NODESTATE_LEAVING, NODESTATE_AISONLY } nodestate_t;
-
-static const char CLIENT_SOCKNAME[]= "/var/run/cman_client";
-static const char ADMIN_SOCKNAME[]=  "/var/run/cman_admin";
-
-/* This struct should be in front of all messages
- * passed down the client and admin sockets.
- */
-#define CMAN_MAGIC 0x434d414e
-#define CMAN_VERSION 0x10000003
-struct sock_header {
-	uint32_t magic;
-	uint32_t version;
-	uint32_t length;
-	uint32_t command;
-	uint32_t flags;
-};
-
-/* Data message header */
-struct sock_data_header {
-	struct sock_header header;
-	int nodeid;
-	uint32_t port;
-	/* Data follows */
-};
-
-/* Reply message */
-struct sock_reply_header {
-	struct sock_header header;
-	int status;
-	/* Any returned information follows */
-};
-
-/* Event message */
-struct sock_event_message {
-	struct sock_header header;
-	int reason;
-	int arg;
-};
-
-/* confchg message */
-struct sock_confchg_message {
-	struct sock_header header;
-	int member_entries;
-	int left_entries;
-	int joined_entries;
-	unsigned int entries[]; // In above order.
-};
-
-/* Flags */
-#define CMAN_EXTRA_FLAG_2NODE     1
-#define CMAN_EXTRA_FLAG_ERROR     2
-#define CMAN_EXTRA_FLAG_SHUTDOWN  4
-#define CMAN_EXTRA_FLAG_UNCOUNTED 8
-#define CMAN_EXTRA_FLAG_DIRTY    16
-
-struct cl_extra_info {
-	int           node_state;
-	uint32_t      flags;
-	int           node_votes;
-	int           total_votes;
-	int           expected_votes;
-	int           quorum;
-	int           members;
-	char          ports[32];
-	int           num_addresses; /* Number of real addresses, so the array below has
-					<n>*2 addresses in it */
-	char          addresses[1];  /* Array of num_addresses sockaddr_storage
-					1st n are multicast addresses */
-};
-
-/* This is the structure, per node, returned from the membership call */
-struct cl_cluster_node {
-	unsigned int size;
-	unsigned int node_id;
-	unsigned int us;
-	unsigned int leave_reason;
-	unsigned int incarnation;
-	nodestate_t state;
-	char name[MAX_CLUSTER_MEMBER_NAME_LEN];
-	char addr[sizeof(struct sockaddr_storage)];
-	unsigned int addrlen;
-	struct timeval jointime;
-	unsigned char votes;
-};
-
-/* Structure passed to CMAN_CMD_ISLISTENING */
-struct cl_listen_request {
-	unsigned char port;
-        int           nodeid;
-};
-
-/* Get all version numbers or set the config version */
-struct cl_version {
-	unsigned int major;
-	unsigned int minor;
-	unsigned int patch;
-	unsigned int config;
-};
-
-/* structure passed to barrier command */
-struct cl_barrier_info {
-	char cmd;
-	char name[MAX_BARRIER_NAME_LEN];
-	unsigned int flags;
-	unsigned long arg;
-};
-
-struct cl_cluster_info {
-	char name[MAX_CLUSTER_NAME_LEN+1];
-	uint16_t number;
-	uint32_t generation;
-};
-
-struct cl_set_votes {
-	int nodeid;
-	int newvotes;
-};
-
-/* An array of these is returned */
-struct cl_node_addrs {
-	int addrlen;
-	struct sockaddr_storage addr;
-};
-
-struct cl_get_node_addrs {
-	int numaddrs;
-	struct cl_node_addrs addrs[];
-};
-
-#define FENCE_FLAGS_FENCED 2
-struct cl_fence_info {
-	int nodeid;
-	int flags;
-	uint64_t fence_time;
-	char fence_agent[MAX_FENCE_AGENT_NAME_LEN];
-};
-
-struct cl_qdev_info {
-	char name[MAX_CLUSTER_MEMBER_NAME_LEN];
-	int state;
-	int votes;
-};
-
-/* Commands to the barrier cmd */
-#define BARRIER_CMD_REGISTER 1
-#define BARRIER_CMD_CHANGE   2
-#define BARRIER_CMD_DELETE   3
-#define BARRIER_CMD_WAIT     4
-
-/* Attributes of a barrier - bitmask */
-#define BARRIER_ATTR_AUTODELETE 1
-#define BARRIER_ATTR_MULTISTEP  2
-#define BARRIER_ATTR_MANUAL     4
-#define BARRIER_ATTR_ENABLED    8
-#define BARRIER_ATTR_CALLBACK  16
-
-/* Attribute setting commands */
-#define BARRIER_SETATTR_AUTODELETE 1
-#define BARRIER_SETATTR_MULTISTEP  2
-#define BARRIER_SETATTR_ENABLED    3
-#define BARRIER_SETATTR_NODES      4
-#define BARRIER_SETATTR_CALLBACK   5
-#define BARRIER_SETATTR_TIMEOUT    6
-
-#endif
diff --git a/cman/daemon/commands.c b/cman/daemon/commands.c
deleted file mode 100644
index 34af7de..0000000
--- a/cman/daemon/commands.c
+++ /dev/null
@@ -1,2232 +0,0 @@
-#include <getopt.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <syslog.h>
-#include <string.h>
-#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/utsname.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/errno.h>
-#include <dlfcn.h>
-
-#include <corosync/ipc_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include "list.h"
-#include "cman.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "daemon.h"
-#include "barrier.h"
-#include "logging.h"
-#define OBJDB_API struct corosync_api_v1
-#include "cmanconfig.h"
-#include "nodelist.h"
-#include "commands.h"
-#include "ais.h"
-
-#define max(a,b) (((a) > (b)) ? (a) : (b))
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME, LOG_INFO);
-
-/* Reference counting for cluster applications */
-static int use_count;
-
-/* Array of "ports" allocated. This is just a list of pointers to the connection that
- * has this port bound. Port 0 is reserved for protocol messages */
-static struct connection *port_array[256];
-
-// Stuff that was more global
-static LIST_INIT(cluster_members_list);
-       int cluster_members;
-       int we_are_a_cluster_member;
-       unsigned int config_version;
-static struct cluster_node *us;
-static int quorum;
-extern int two_node;
-       unsigned int quorumdev_poll=DEFAULT_QUORUMDEV_POLL;
-       unsigned int shutdown_timeout=DEFAULT_SHUTDOWN_TIMEOUT;
-       unsigned int ccsd_poll_interval=DEFAULT_CCSD_POLL;
-static int cluster_is_quorate;
-       char cluster_name[MAX_CLUSTER_NAME_LEN+1];
-static char nodename[MAX_CLUSTER_MEMBER_NAME_LEN+1];
-static int wanted_nodeid;
-static struct cluster_node *quorum_device;
-static uint16_t cluster_id;
-static int ais_running;
-static time_t join_time;
-static corosync_timer_handle_t quorum_device_timer;
-static struct corosync_api_v1 *corosync;
-
-/* If CCS gets out of sync, we poll it until it isn't */
-static corosync_timer_handle_t ccsd_timer;
-static unsigned int wanted_config_version;
-static int config_error;
-
-static corosync_timer_handle_t shutdown_timer;
-static struct connection *shutdown_con;
-static uint32_t shutdown_flags;
-static int shutdown_yes;
-static int shutdown_no;
-static int shutdown_expected;
-
-static struct cluster_node *find_node_by_nodeid(int nodeid);
-static struct cluster_node *find_node_by_name(char *name);
-static int get_node_count(void);
-static int get_highest_nodeid(void);
-static int send_port_open_msg(unsigned char port);
-static int send_port_enquire(int nodeid);
-static void process_internal_message(char *data, int nodeid, int byteswap);
-static void recalculate_quorum(int allow_decrease, int by_current_nodes);
-static void send_kill(int nodeid, uint16_t reason);
-static char *killmsg_reason(int reason);
-static void ccsd_timer_fn(void *arg);
-
-
-static void set_port_bit(struct cluster_node *node, uint8_t port)
-{
-	int byte;
-	int bit;
-
-	byte = port/8;
-	bit  = port%8;
-
-	node->port_bits[byte] |= 1<<bit;
-}
-
-static void clear_port_bit(struct cluster_node *node, uint8_t port)
-{
-	int byte;
-	int bit;
-
-	byte = port/8;
-	bit  = port%8;
-
-	node->port_bits[byte] &= ~(1<<bit);
-}
-
-static int get_port_bit(struct cluster_node *node, uint8_t port)
-{
-	int byte;
-	int bit;
-
-	byte = port/8;
-	bit  = port%8;
-
-	return ((node->port_bits[byte] & (1<<bit)) != 0);
-}
-
-static int have_disallowed(void)
-{
-	struct cluster_node *node;
-
-	list_iterate_items(node, &cluster_members_list) {
-		if (node->state == NODESTATE_AISONLY)
-			return 1;
-	}
-
-	return 0;
-}
-
-/* Make a totem_ip_address into a usable sockaddr_storage */
-static int totemip_to_sockaddr(struct totem_ip_address *ip_addr,
-			       uint16_t port, struct sockaddr_storage *saddr, int *addrlen)
-{
-	int ret = -1;
-
-	if (ip_addr->family == AF_INET) {
-		struct sockaddr_in *sin = (struct sockaddr_in *)saddr;
-
-		memset(sin, 0, sizeof(struct sockaddr_in));
-		sin->sin_family = ip_addr->family;
-		sin->sin_port = port;
-		memcpy(&sin->sin_addr, ip_addr->addr, sizeof(struct in_addr));
-		*addrlen = sizeof(struct sockaddr_in);
-		ret = 0;
-	}
-
-	if (ip_addr->family == AF_INET6) {
-		struct sockaddr_in6 *sin = (struct sockaddr_in6 *)saddr;
-
-		memset(sin, 0, sizeof(struct sockaddr_in6));
-		sin->sin6_family = ip_addr->family;
-		sin->sin6_port = port;
-		sin->sin6_scope_id = 2;
-		memcpy(&sin->sin6_addr, ip_addr->addr, sizeof(struct in6_addr));
-
-		*addrlen = sizeof(struct sockaddr_in6);
-		ret = 0;
-	}
-
-	return ret;
-}
-
-/* If "cluster_is_quorate" is 0 then all activity apart from protected ports is
- * blocked. */
-static void set_quorate(int total_votes)
-{
-	int quorate;
-	unsigned int nodelist[PROCESSOR_COUNT_MAX];
-	int nodecount = 0;
-	struct cluster_node *node = NULL;
-	struct list *tmp;
-
-	if (quorum > total_votes || config_error) {
-		quorate = 0;
-	}
-	else {
-		quorate = 1;
-	}
-
-	if (cluster_is_quorate && !quorate)
-		log_printf(LOG_INFO, "quorum lost, blocking activity\n");
-	if (!cluster_is_quorate && quorate)
-		log_printf(LOG_INFO, "quorum regained, resuming activity\n");
-
-	/* If we are newly quorate, then kill any AISONLY nodes */
-	if (!cluster_is_quorate && quorate) {
-
-		list_iterate(tmp, &cluster_members_list) {
-			node = list_item(tmp, struct cluster_node);
-			if (node->state == NODESTATE_AISONLY)
-				send_kill(node->node_id, CLUSTER_KILL_REJOIN);
-		}
-	}
-
-	cluster_is_quorate = quorate;
-
-	/* Inform corosync subsystems */
-	list_iterate(tmp, &cluster_members_list) {
-		node = list_item(tmp, struct cluster_node);
-		if (node->state == NODESTATE_MEMBER) {
-			nodelist[nodecount++] = node->node_id;
-		}
-	}
-
-	corosync_set_quorum(nodelist, nodecount, quorate, &cman_ring_id);
-}
-
-static void node_add_ordered(struct cluster_node *newnode)
-{
-	struct cluster_node *node = NULL;
-	struct list *tmp;
-	struct list *newlist = &newnode->list;
-
-	list_iterate(tmp, &cluster_members_list) {
-		node = list_item(tmp, struct cluster_node);
-
-                if (newnode->node_id < node->node_id)
-                        break;
-        }
-
-        if (!node)
-		list_add(&cluster_members_list, &newnode->list);
-        else {
-                newlist->p = tmp->p;
-                newlist->n = tmp;
-                tmp->p->n = newlist;
-                tmp->p = newlist;
-        }
-}
-
-static struct cluster_node *add_new_node(char *name, int nodeid, int votes, int expected_votes,
-					 nodestate_t state)
-{
-	struct cluster_node *newnode = NULL;
-	int newalloc = 0;
-
-	if (nodeid)
-		newnode = find_node_by_nodeid(nodeid);
-
-	if (!newnode) {
-		newnode = malloc(sizeof(struct cluster_node));
-		if (!newnode) {
-			log_printf(LOG_ERR, "Unable to allocate memory for node %s\n", name);
-			return NULL;
-		}
-		memset(newnode, 0, sizeof(struct cluster_node));
-		newalloc = 1;
-		newnode->state = state;
-		if (state == NODESTATE_MEMBER)
-			newnode->incarnation = incarnation;
-	}
-	if (!newnode->name) {
-		newnode->name = malloc(strlen(name)+1);
-		if (!newnode->name) {
-			if (newalloc)
-				free(newnode);
-			return NULL;
-		}
-		strcpy(newnode->name, name);
-	}
-
-	if (!newnode->node_id) /* Don't clobber existing nodeid */
-		newnode->node_id = nodeid;
-	if (votes >= 0)
-		newnode->votes = votes;
-	if (expected_votes)
-		newnode->expected_votes = expected_votes;
-
-	/* If this node has a name passed in then use that rather than a previous generated one */
-	if (name && newnode->name && strcmp(name, newnode->name)) {
-		char *newname;
-
-		newname = strdup(name);
-		if (newname) {
-			P_MEMB("replacing old node name %s with %s\n", newnode->name, name);
-			free(newnode->name);
-			newnode->name = newname;
-		}
-	}
-
-	if (newalloc)
-		node_add_ordered(newnode);
-
-	newnode->flags |= NODE_FLAGS_REREAD;
-
-	P_MEMB("add_new_node: %s, (id=%d, votes=%d) newalloc=%d\n",
-	       name, nodeid, votes, newalloc);
-
-	return newnode;
-}
-
-static void send_reconfigure(int nodeid, int param, int value)
-{
-	struct cl_reconfig_msg msg;
-
-	msg.cmd = CLUSTER_MSG_RECONFIGURE;
-	msg.param = param;
-	msg.nodeid = nodeid;
-	msg.value = value;
-
-	comms_send_message((char *)&msg, sizeof(msg),
-			   0,0,
-			   0,  /* multicast */
-			   0); /* flags */
-}
-
-static int calculate_quorum(int allow_decrease, int max_expected, unsigned int *ret_total_votes)
-{
-	struct list *nodelist;
-	struct cluster_node *node;
-	unsigned int total_votes = 0;
-	unsigned int highest_expected = 0;
-	unsigned int newquorum, q1, q2;
-	unsigned int total_nodes = 0;
-
-	list_iterate(nodelist, &cluster_members_list) {
-		node = list_item(nodelist, struct cluster_node);
-
-		if (node->state == NODESTATE_MEMBER) {
-			if (max_expected)
-				node->expected_votes = max_expected;
-			else
-				highest_expected = max(highest_expected, node->expected_votes);
-			total_votes += node->votes;
-			total_nodes++;
-		}
-	}
-	if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
-		total_votes += quorum_device->votes;
-
-	if (max_expected > 0)
-		highest_expected = max_expected;
-
-	/* This quorum calculation is taken from the OpenVMS Cluster Systems
-	 * manual, but, then, you guessed that didn't you */
-	q1 = (highest_expected + 2) / 2;
-	q2 = (total_votes + 2) / 2;
-	newquorum = max(q1, q2);
-
-	/* Normally quorum never decreases but the system administrator can
-	 * force it down by setting expected votes to a maximum value */
-	if (!allow_decrease)
-		newquorum = max(quorum, newquorum);
-
-	/* The special two_node mode allows each of the two nodes to retain
-	 * quorum if the other fails.  Only one of the two should live past
-	 * fencing (as both nodes try to fence each other in split-brain.)
-	 * Also: if there are more than two nodes, force us inquorate to avoid
-	 * any damage or confusion.
-	 */
-	if (two_node && total_nodes <= 2)
-		newquorum = 1;
-
-	if (ret_total_votes)
-		*ret_total_votes = total_votes;
-	return newquorum;
-}
-
-/* Recalculate cluster quorum, set quorate and notify changes */
-static void recalculate_quorum(int allow_decrease, int by_current_nodes)
-{
-	unsigned int total_votes;
-
-	quorum = calculate_quorum(allow_decrease, by_current_nodes?cluster_members:0, &total_votes);
-	set_quorate(total_votes);
-	notify_listeners(NULL, EVENT_REASON_STATECHANGE, cluster_is_quorate);
-}
-
-/* Copy internal node format to userland format */
-static void copy_to_usernode(struct cluster_node *node,
-			     struct cl_cluster_node *unode)
-{
-	struct sockaddr_storage ss;
-	int addrlen=0;
-	unsigned int numaddrs=1;
-	char **status;
-	struct totem_ip_address node_ifs[INTERFACE_MAX];
-	/* totempg_ifaces_get always copies INTERFACE_MAX addresses */
-
-	strcpy(unode->name, node->name);
-	unode->jointime = node->join_time;
-	unode->size = sizeof(struct cl_cluster_node);
-	unode->votes = node->votes;
-	unode->state = node->state;
-	unode->us = node->us;
-	unode->node_id = node->node_id;
-	unode->leave_reason = node->leave_reason;
-	unode->incarnation = node->incarnation;
-
-	/* Just send the first address. If the user wants the full set they
-	   must ask for them */
-	corosync->totem_ifaces_get(node->node_id, node_ifs, &status, &numaddrs);
-
-	totemip_to_sockaddr(&node_ifs[0], 0, &ss, &addrlen);
-	memcpy(unode->addr, &ss, addrlen);
-	unode->addrlen = addrlen;
-}
-
-
-int cman_set_nodename(char *name)
-{
-	if (ais_running)
-		return -EALREADY;
-
-	strncpy(nodename, name, MAX_CLUSTER_MEMBER_NAME_LEN);
-	return 0;
-}
-
-int cman_set_nodeid(int nodeid)
-{
-	if (ais_running)
-		return -EALREADY;
-
-	wanted_nodeid = nodeid;
-	return 0;
-}
-
-int cman_join_cluster(struct corosync_api_v1 *api,
-		      char *name, unsigned short cl_id,
-		      int two_node_flag, int votes, int expected_votes)
-{
-	if (ais_running)
-		return -EALREADY;
-
-	if (strlen(name) > MAX_CLUSTER_NAME_LEN)
-		return -EINVAL;
-
-	cluster_id = cl_id;
-	strncpy(cluster_name, name, MAX_CLUSTER_NAME_LEN);
-	two_node = two_node_flag;
-	corosync = api;
-
-	quit_threads = 0;
-	ais_running = 1;
-
-	/* Make sure we have a node name */
-	if (nodename[0] == '\0') {
-		struct utsname un;
-		uname(&un);
-		strcpy(nodename, un.nodename);
-	}
-
-	time(&join_time);
-	us = add_new_node(nodename, wanted_nodeid, votes, expected_votes,
-			  NODESTATE_DEAD);
-	set_port_bit(us, 0);
-	us->us = 1;
-
-	return 0;
-}
-
-/* command processing functions */
-
-static int do_cmd_set_version(char *cmdbuf, int *retlen)
-{
-	struct cl_version *version = (struct cl_version *)cmdbuf;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	if (version->major != CNXMAN_MAJOR_VERSION ||
-	    version->minor != CNXMAN_MINOR_VERSION ||
-	    version->patch != CNXMAN_PATCH_VERSION)
-		return -EINVAL;
-
-	if (config_version == version->config)
-		return 0;
-
-	/* We will re-read CCS when we get our own message back */
-	send_reconfigure(us->node_id, RECONFIG_PARAM_CONFIG_VERSION, version->config);
-	return 0;
-}
-
-static int do_cmd_get_extrainfo(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
-	char *outbuf = *retbuf + offset;
-	struct cl_extra_info *einfo = (struct cl_extra_info *)outbuf;
-	struct totem_ip_address node_ifs[MAX_INTERFACES];
-	int total_votes = 0;
-	int max_expected = 0;
-	int addrlen;
-	int uncounted = 0;
-	unsigned int num_interfaces;
-	unsigned int totem_object_handle;
-	unsigned int object_handle;
-	unsigned int totem_find_handle;
-	unsigned int iface_find_handle;
-	char **status;
-	struct cluster_node *node;
-	struct sockaddr_storage *ss;
-	char *ptr;
-	int i;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	corosync->totem_ifaces_get(us->node_id, node_ifs, &status, &num_interfaces);
-
-	list_iterate_items(node, &cluster_members_list) {
-		if (node->state == NODESTATE_MEMBER) {
-			total_votes += node->votes;
-			max_expected = max(max_expected, node->expected_votes);
-		}
-		if (node->state == NODESTATE_AISONLY)
-			uncounted = 1;
-	}
-	if (quorum_device && quorum_device->state == NODESTATE_MEMBER)
-		total_votes += quorum_device->votes;
-
-        /* Enough room for addresses ? */
-	if (retsize < (sizeof(struct cl_extra_info) +
-		       sizeof(struct sockaddr_storage) * (MAX_INTERFACES*2))) {
-
-		*retbuf = malloc(sizeof(struct cl_extra_info) + sizeof(struct sockaddr_storage) * (MAX_INTERFACES*2));
-		outbuf = *retbuf + offset;
-		einfo = (struct cl_extra_info *)outbuf;
-
-		P_MEMB("get_extrainfo: allocated new buffer\n");
-	}
-
-	einfo->node_state = us->state;
-	einfo->node_votes = us->votes;
-	einfo->total_votes = total_votes;
-	einfo->expected_votes = max_expected;
-	einfo->quorum = quorum;
-	einfo->members = cluster_members;
-	einfo->num_addresses = num_interfaces;
-	memcpy(einfo->ports, us->port_bits, 32);
-	einfo->flags = 0;
-	if (two_node)
-		einfo->flags |= CMAN_EXTRA_FLAG_2NODE;
-	if (config_error)
-		einfo->flags |= CMAN_EXTRA_FLAG_ERROR;
-	if (shutdown_con)
-		einfo->flags |= CMAN_EXTRA_FLAG_SHUTDOWN;
-	if (uncounted)
-		einfo->flags |= CMAN_EXTRA_FLAG_UNCOUNTED;
-	if (us->flags & NODE_FLAGS_DIRTY)
-		einfo->flags |= CMAN_EXTRA_FLAG_DIRTY;
-
-	ptr = einfo->addresses;
-
-	corosync->object_find_create(OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &totem_find_handle);
-	if (corosync->object_find_next(totem_find_handle, &totem_object_handle) == 0) {
-
-		corosync->object_find_destroy(totem_find_handle);
-
-		corosync->object_find_create(totem_object_handle, "interface", strlen("interface"), &iface_find_handle);
-		while (corosync->object_find_next(iface_find_handle, &object_handle) == 0) {
-
-			char *mcast;
-			struct sockaddr_in *saddr4;
-			struct sockaddr_in6 *saddr6;
-
-			objdb_get_string(corosync, object_handle, "mcastaddr", &mcast);
-			memset(ptr, 0, sizeof(struct sockaddr_storage));
-
-			saddr4 = (struct sockaddr_in *)ptr;
-			saddr6 = (struct sockaddr_in6 *)ptr;
-			if ( inet_pton(AF_INET, mcast, &saddr4->sin_addr) >0) {
-				saddr4->sin_family = AF_INET;
-			}
-			else {
-				if (inet_pton(AF_INET6, mcast, &saddr6->sin6_addr) > 0)
-					saddr4->sin_family = AF_INET6;
-			}
-			ptr += sizeof(struct sockaddr_storage);
-		}
-	}
-	corosync->object_find_destroy(iface_find_handle);
-
-	for (i=0; i<num_interfaces; i++) {
-		ss = (struct sockaddr_storage *)ptr;
-		totemip_to_sockaddr(&node_ifs[i], 0, ss, &addrlen);
-		ptr += sizeof(struct sockaddr_storage);
-	}
-
-	*retlen = ptr - outbuf;
-	return 0;
-}
-
-static int do_cmd_get_all_members(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
-	struct cluster_node *node;
-	struct cl_cluster_node *user_node;
-	struct list *nodelist;
-	char *outbuf = *retbuf + offset;
-	int num_nodes = 0;
-	int total_nodes = 0;
-	int highest_node;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	highest_node = get_highest_nodeid();
-
-	/* Count nodes */
-	list_iterate(nodelist, &cluster_members_list) {
-		total_nodes++;
-	}
-	if (quorum_device)
-		total_nodes++;
-
-	/* if retsize == 0 then don't return node information */
-	if (retsize) {
-		/* If there is not enough space in the default buffer, allocate some more. */
-		if ((retsize / sizeof(struct cl_cluster_node)) < total_nodes) {
-			*retbuf = malloc(sizeof(struct cl_cluster_node) * total_nodes + offset);
-			outbuf = *retbuf + offset;
-			P_MEMB("get_all_members: allocated new buffer (retsize=%d)\n", retsize);
-		}
-	}
-	user_node = (struct cl_cluster_node *)outbuf;
-
-	/* This returns the full list */
-	list_iterate_items(node, &cluster_members_list) {
-		if (retsize) {
-			copy_to_usernode(node, user_node);
-
-			user_node++;
-			num_nodes++;
-		}
-	}
-
-	if (quorum_device) {
-		copy_to_usernode(quorum_device, user_node);
-		user_node++;
-		num_nodes++;
-	}
-
-	*retlen = sizeof(struct cl_cluster_node) * num_nodes;
-	P_MEMB("get_all_members: retlen = %d\n", *retlen);
-	return num_nodes;
-}
-
-
-static int do_cmd_get_cluster(char *cmdbuf, char *retbuf, int *retlen)
-{
-	struct cl_cluster_info *info = (struct cl_cluster_info *)retbuf;
-
-	info->number = cluster_id;
-	info->generation = incarnation;
-	memcpy(&info->name, cluster_name, strlen(cluster_name)+1);
-	*retlen = sizeof(struct cl_cluster_info);
-
-	return 0;
-}
-
-static int do_cmd_get_node(char *cmdbuf, char *retbuf, int *retlen)
-{
-	struct cluster_node *node;
-	struct cl_cluster_node *u_node = (struct cl_cluster_node *)cmdbuf;
-	struct cl_cluster_node *r_node = (struct cl_cluster_node *)retbuf;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	if (u_node->node_id == CLUSTER_GETNODE_QUORUMDEV) {
-		if (quorum_device)
-			node = quorum_device;
-		else
-			return -ENOENT;
-	}
-	else {
-		if (!u_node->name[0]) {
-			if (u_node->node_id == 0)
-				u_node->node_id = us->node_id;
-			node = find_node_by_nodeid(u_node->node_id);
-		}
-		else
-			node = find_node_by_name(u_node->name);
-
-		if (!node) {
-			P_MEMB("cmd_get_node failed: id=%d, name='%s'\n", u_node->node_id, u_node->name);
-			return -ENOENT;
-		}
-	}
-
-	copy_to_usernode(node, r_node);
-	*retlen = sizeof(struct cl_cluster_node);
-
-	return 0;
-}
-
-static int do_cmd_set_expected(char *cmdbuf, int *retlen)
-{
-	unsigned int total_votes;
-	unsigned int newquorum;
-	unsigned int newexp;
-	struct cluster_node *node = NULL;
-	struct list *tmp;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	/* If there are any AISONLY nodes then we can't allow
-	   the user to set expected votes as it may destroy data */
-	list_iterate(tmp, &cluster_members_list) {
-		node = list_item(tmp, struct cluster_node);
-		if (node->state == NODESTATE_AISONLY) {
-			log_printf(LOG_NOTICE, "Attempt to set expected votes when cluster has AISONLY nodes in it.");
-			return -EINVAL;
-		}
-	}
-
-	memcpy(&newexp, cmdbuf, sizeof(int));
-	newquorum = calculate_quorum(1, newexp, &total_votes);
-
-	if (newquorum < total_votes / 2
-	    || newquorum > total_votes) {
-		return -EINVAL;
-	}
-
-	override_expected(newexp);
-	send_reconfigure(us->node_id, RECONFIG_PARAM_EXPECTED_VOTES, newexp);
-
-	/* We will recalculate quorum when we get our own message back */
-	return 0;
-}
-
-static void send_kill(int nodeid, uint16_t reason)
-{
-	struct cl_killmsg msg;
-
-	P_MEMB("Sending KILL to node %d\n", nodeid);
-
-	msg.cmd = CLUSTER_MSG_KILLNODE;
-	msg.reason = reason;
-	msg.nodeid = nodeid;
-
-	comms_send_message((char *)&msg, sizeof(msg),
-			   0,0,
-			   nodeid,
-			   0); /* flags */
-}
-
-static void send_leave(uint16_t reason)
-{
-	struct cl_leavemsg msg;
-
-	P_MEMB("Sending LEAVE, reason %d\n", reason);
-
-	msg.cmd = CLUSTER_MSG_LEAVE;
-	msg.reason = reason;
-
-	comms_send_message((char *)&msg, sizeof(msg),
-			   0,0,
-			   0,  /* multicast */
-			   0); /* flags */
-}
-
-static int do_cmd_kill_node(char *cmdbuf, int *retlen)
-{
-	struct cluster_node *node;
-	int nodeid;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	memcpy(&nodeid, cmdbuf, sizeof(int));
-
-	if ((node = find_node_by_nodeid(nodeid)) == NULL)
-		return -EINVAL;
-
-	if (node->state != NODESTATE_MEMBER && node->state != NODESTATE_AISONLY)
-		return -EINVAL;
-
-	node->leave_reason = CLUSTER_LEAVEFLAG_KILLED;
-	node->state = NODESTATE_LEAVING;
-
-	/* Send a KILL message */
-	send_kill(nodeid, CLUSTER_KILL_CMANTOOL);
-
-	return 0;
-}
-
-
-static int do_cmd_islistening(struct connection *con, char *cmdbuf, int *retlen)
-{
-	struct cl_listen_request rq;
-	struct cluster_node *rem_node;
-	int nodeid;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	memcpy(&rq, cmdbuf, sizeof(rq));
-
-	nodeid = rq.nodeid;
-	if (!nodeid)
-		nodeid = us->node_id;
-
-	rem_node = find_node_by_nodeid(nodeid);
-
-	/* Node not in the cluster */
-	if (!rem_node)
-		return -ENOENT;
-
-	if (rem_node->state != NODESTATE_MEMBER)
-		return -ENOTCONN;
-
-	/* If the request is for us then just look in the ports
-	 * array */
-	if (rem_node->us)
-		return (port_array[rq.port] != 0) ? 1 : 0;
-
-
-	/* If we don't know the node's port status then ask it.
-	   This should only need to be done when we are the new node in
-	   a cluster that has been running for a while
-	*/
-       	if (!get_port_bit(rem_node, 0)) {
-		P_MEMB("islistening, no data for node %d, sending PORTENQ\n", nodeid);
-		send_port_enquire(rem_node->node_id);
-
-		/* Admit our ignorance */
-		return -EBUSY;
-	}
-	else {
-		P_MEMB("islistening, for node %d, low bytes are %x %x\n", nodeid, rem_node->port_bits[0], rem_node->port_bits[1]);
-		return get_port_bit(rem_node, rq.port);
-	}
-}
-
-
-static int do_cmd_set_votes(char *cmdbuf, int *retlen)
-{
-	unsigned int total_votes;
-	unsigned int newquorum;
-	int saved_votes;
-	struct cl_set_votes arg;
-	struct cluster_node *node;
-
-	if (!we_are_a_cluster_member)
-		return -ENOTCONN;
-
-	memcpy(&arg, cmdbuf, sizeof(arg));
-
-	if (!arg.nodeid)
-		arg.nodeid = us->node_id;
-
-	P_MEMB("Setting votes for node %d to %d\n", arg.nodeid, arg.newvotes);
-
-	node = find_node_by_nodeid(arg.nodeid);
-	if (!node)
-		return -ENOENT;
-
-	/* Check votes is valid */
-	saved_votes = node->votes;
-	node->votes = arg.newvotes;
-
-	newquorum = calculate_quorum(1, 0, &total_votes);
-
-	if (newquorum < total_votes / 2 || newquorum > total_votes) {
-		node->votes = saved_votes;
-		return -EINVAL;
-	}
-
-	recalculate_quorum(1, 0);
-
-	send_reconfigure(arg.nodeid, RECONFIG_PARAM_NODE_VOTES, arg.newvotes);
-
-	return 0;
-}
-
-static int do_cmd_bind(struct connection *con, char *cmdbuf)
-{
-	unsigned int port;
-	int ret = -EADDRINUSE;
-
-	memcpy(&port, cmdbuf, sizeof(int));
-
-	P_MEMB("requested bind to port %d, (us=%p)\n", port, con);
-
-	if (port == 0 || port > 255)
-		return -EINVAL;
-
-	if (port_array[port])
-		goto out;
-
-	ret = 0;
-	port_array[port] = con;
-	con->port = port;
-
-	set_port_bit(us, con->port);
-	send_port_open_msg(con->port);
-
- out:
-	return ret;
-}
-
-static int do_cmd_leave_cluster(char *cmdbuf, int *retlen)
-{
-	int leave_flags;
-
-	if (!ais_running)
-		return -ENOTCONN;
-
-	memcpy(&leave_flags, cmdbuf, sizeof(int));
-
-	/* Ignore the use count if FORCE is set */
-	if (!(leave_flags & CLUSTER_LEAVEFLAG_FORCE)) {
-		if (use_count)
-			return -ENOTCONN;
-	}
-
-	us->leave_reason = leave_flags;
-	quit_threads = 1;
-
-	/* No messaging available yet, just die */
-	if (!we_are_a_cluster_member)
-		exit(0);
-
-	send_leave(leave_flags);
-	use_count = 0;
-
-	/* When we get our leave message back, then quit */
-	return 0;
-}
-
-static void check_shutdown_status()
-{
-	int reply;
-	int leaveflags = CLUSTER_LEAVEFLAG_DOWN;
-
-	/* All replies safely gathered in ? */
-	if (shutdown_yes + shutdown_no >= shutdown_expected) {
-
-		corosync->timer_delete(shutdown_timer);
-
-		if (shutdown_yes >= shutdown_expected ||
-		    shutdown_flags & SHUTDOWN_ANYWAY) {
-			quit_threads = 1;
-			if (shutdown_flags & SHUTDOWN_REMOVE)
-				leaveflags |= CLUSTER_LEAVEFLAG_REMOVED;
-			send_leave(leaveflags);
-			reply = 0;
-		}
-		else {
-			reply = -EBUSY;
-
-			/* Tell originator that shutdown was cancelled */
-			send_status_return(shutdown_con, CMAN_CMD_TRY_SHUTDOWN, reply);
-			shutdown_con = NULL;
-		}
-
-		P_MEMB("shutdown decision is: %d (yes=%d, no=%d) flags=%x\n", reply, shutdown_yes, shutdown_no, shutdown_flags);
-	}
-}
-
-/* Not all nodes responded to the shutdown */
-static void shutdown_timer_fn(void *arg)
-{
-	P_MEMB("Shutdown timer fired. flags = %x\n", shutdown_flags);
-
-	/* Mark undecideds as "NO" */
-	shutdown_no = shutdown_expected;
-	check_shutdown_status();
-}
-
-/* A service's response to a TRY_SHUTDOWN event. This NEVER returns a response */
-static int do_cmd_shutdown_reply(struct connection *con, char *cmdbuf)
-{
-	int response = *(int *)cmdbuf;
-
-	/* Not shutting down, but don't respond. */
-	if (!shutdown_con)
-		return -EWOULDBLOCK;
-
-	P_MEMB("Shutdown reply is %d\n", response);
-
-	/* We only need to keep a track of a client's response in
-	   case it pulls the connection before the shutdown process
-	   has completed */
-	if (response) {
-		shutdown_yes++;
-		con->shutdown_reply = SHUTDOWN_REPLY_YES;
-	}
-	else {
-		shutdown_no++;
-		con->shutdown_reply = SHUTDOWN_REPLY_NO;
-	}
-	check_shutdown_status();
-
-	/* No response needed to this message */
-	return -EWOULDBLOCK;
-}
-
-/* User requested shutdown. We poll all listening clients and see if they are
-   willing to shutdown */
-static int do_cmd_try_shutdown(struct connection *con, char *cmdbuf)
-{
-	int flags = *(int *)cmdbuf;
-
-	/* Are we already in shutdown ? */
-	if (shutdown_con || quit_threads)
-		return -EALREADY;
-
-	shutdown_con = con;
-	shutdown_flags = flags;
-	shutdown_yes = 0;
-	shutdown_no = 0;
-	shutdown_expected = num_listeners();
-
-	/* If no-one is listening for events then we can just go down now */
-	if (shutdown_expected == 0) {
-		quit_threads = 1;
-		send_leave(CLUSTER_LEAVEFLAG_DOWN);
-		return 0;
-	}
-	else {
-
-		/* Start the timer. If we don't get a full set of replies before this goes
-		   off we'll cancel the shutdown */
-		corosync->timer_add_duration((unsigned long long)shutdown_timeout*1000000, NULL,
-					   shutdown_timer_fn, &shutdown_timer);
-
-		notify_listeners(NULL, EVENT_REASON_TRY_SHUTDOWN, flags);
-
-		return -EWOULDBLOCK;
-	}
-}
-
-static int do_cmd_register_quorum_device(char *cmdbuf, int *retlen)
-{
-	int votes;
-	char *name = cmdbuf+sizeof(int);
-
-	if (!ais_running)
-		return -ENOTCONN;
-
-	if (!we_are_a_cluster_member)
-		return -ENOENT;
-
-	if (quorum_device)
-                return -EBUSY;
-
-	if (strlen(name) > MAX_CLUSTER_MEMBER_NAME_LEN)
-		return -EINVAL;
-
-	if (find_node_by_name(name))
-                return -EALREADY;
-
-	memcpy(&votes, cmdbuf, sizeof(int));
-
-	quorum_device = malloc(sizeof(struct cluster_node));
-        if (!quorum_device)
-                return -ENOMEM;
-        memset(quorum_device, 0, sizeof(struct cluster_node));
-
-        quorum_device->name = malloc(strlen(name) + 1);
-        if (!quorum_device->name) {
-                free(quorum_device);
-                quorum_device = NULL;
-                return -ENOMEM;
-        }
-
-        strcpy(quorum_device->name, name);
-        quorum_device->votes = votes;
-        quorum_device->state = NODESTATE_DEAD;
-	gettimeofday(&quorum_device->join_time, NULL);
-
-        /* Keep this list valid so it doesn't confuse other code */
-        list_init(&quorum_device->addr_list);
-
-	log_printf(LOG_INFO, "quorum device registered\n");
-        return 0;
-}
-
-static int do_cmd_unregister_quorum_device(char *cmdbuf, int *retlen)
-{
-        if (!quorum_device)
-                return -EINVAL;
-
-        if (quorum_device->state == NODESTATE_MEMBER)
-                return -EBUSY;
-
-	free(quorum_device->name);
-	free(quorum_device);
-
-        quorum_device = NULL;
-
-	log_printf(LOG_INFO, "quorum device unregistered\n");
-        return 0;
-}
-
-static int reread_config(int new_version)
-{
-	int read_err;
-	char *reload_err = NULL;
-
-	wanted_config_version = new_version;
-
-	/* Tell objdb to reload */
-	read_err = corosync->object_reload_config(1, &reload_err);
-
-	/* Now get our bits */
-	if (!read_err)
-		read_err = read_cman_nodes(corosync, &config_version, 0);
-
-	if (read_err) {
-		config_error = 1;
-		log_printf(LOG_ERR, "Can't get updated config version %d: %s. Activity suspended on this node\n",
-			   wanted_config_version, reload_err?reload_err:"version mismatch on this node");
-	}
-
-	/* Still too old?? */
-	if (config_version < wanted_config_version) {
-		log_printf(LOG_ERR, "Can't get updated config version %d, config file is version %d.\n",
-			   wanted_config_version, config_version);
-	}
-
-	/* Keep looking */
-	if (read_err || config_version < wanted_config_version) {
-		corosync->timer_add_duration((unsigned long long)ccsd_poll_interval*1000000, NULL,
-					     ccsd_timer_fn, &ccsd_timer);
-	}
-
-	return read_err;
-}
-
-static void ccsd_timer_fn(void *arg)
-{
-	log_printf(LOG_DEBUG, "Polling configuration for updated information\n");
-	if (!reread_config(wanted_config_version) && config_version >= wanted_config_version) {
-		log_printf(LOG_ERR, "Now got config information version %d, continuing\n", config_version);
-		config_error = 0;
-		recalculate_quorum(0, 0);
-		notify_listeners(NULL, EVENT_REASON_CONFIG_UPDATE, config_version);
-	}
-}
-
-
-static void quorum_device_timer_fn(void *arg)
-{
-	struct timeval now;
-	if (!quorum_device || quorum_device->state == NODESTATE_DEAD)
-		return;
-
-	P_MEMB("quorum_device_timer_fn\n");
-	gettimeofday(&now, NULL);
-	if (quorum_device->last_hello.tv_sec + quorumdev_poll/1000 < now.tv_sec) {
-		quorum_device->state = NODESTATE_DEAD;
-		log_printf(LOG_INFO, "lost contact with quorum device\n");
-		recalculate_quorum(0, 0);
-	}
-	else {
-		corosync->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
-					   quorum_device_timer_fn, &quorum_device_timer);
-	}
-}
-
-static int do_cmd_poll_quorum_device(char *cmdbuf, int *retlen)
-{
-	int yesno;
-
-        if (!quorum_device)
-                return -EINVAL;
-
-	memcpy(&yesno, cmdbuf, sizeof(int));
-
-        if (yesno) {
-		gettimeofday(&quorum_device->last_hello, NULL);
-                if (quorum_device->state == NODESTATE_DEAD) {
-                        quorum_device->state = NODESTATE_MEMBER;
-                        recalculate_quorum(0, 0);
-
-			corosync->timer_add_duration((unsigned long long)quorumdev_poll*1000000, quorum_device,
-						   quorum_device_timer_fn, &quorum_device_timer);
-                }
-        }
-        else {
-                if (quorum_device->state == NODESTATE_MEMBER) {
-                        quorum_device->state = NODESTATE_DEAD;
-                        recalculate_quorum(0, 0);
-			corosync->timer_delete(quorum_device_timer);
-                }
-        }
-
-	return 0;
-}
-
-/* fence_tool tells us it has fenced a node */
-static int do_cmd_update_fence_info(char *cmdbuf)
-{
-	struct cl_fence_info *f = (struct cl_fence_info *)cmdbuf;
-	struct cluster_node *node;
-	char msg[sizeof(struct cl_fencemsg)+strlen(f->fence_agent)+1];
-	struct cl_fencemsg *fence_msg = (struct cl_fencemsg *)msg;
-
-	node = find_node_by_nodeid(f->nodeid);
-	if (!node)
-		return -EINVAL;
-
-	if (strlen(f->fence_agent) >= MAX_FENCE_AGENT_NAME_LEN)
-		return -EINVAL;
-
-	node->flags |= NODE_FLAGS_FENCED;
-	if (node->state == NODESTATE_MEMBER)
-		node->flags |= NODE_FLAGS_FENCEDWHILEUP;
-
-	/* Tell the rest of the cluster (and us!) */
-	fence_msg->cmd = CLUSTER_MSG_FENCESTATUS;
-	fence_msg->nodeid = f->nodeid;
-	fence_msg->timesec = f->fence_time;
-	fence_msg->fenced = 1;
-	strcpy(fence_msg->agent, f->fence_agent);
-	comms_send_message(msg, sizeof(msg), 0,0, 0, 0);
-
-	P_MEMB("node %d fenced by %s\n", f->nodeid, f->fence_agent);
-	return 0;
-}
-
-static int do_cmd_get_fence_info(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
-	int nodeid;
-	char *outbuf = *retbuf + offset;
-	struct cl_fence_info *f = (struct cl_fence_info *)outbuf;
-	struct cluster_node *node;
-
-	if (retsize < sizeof(struct cl_fence_info))
-		return -EINVAL;
-	memcpy(&nodeid, cmdbuf, sizeof(nodeid));
-
-	node = find_node_by_nodeid(nodeid);
-	if (!node)
-		return -EINVAL;
-
-	f->nodeid = nodeid;
-	f->fence_time = node->fence_time;
-	f->flags = node->flags&NODE_FLAGS_FENCED;
-
-	if (node->fence_agent)
-		strcpy(f->fence_agent, node->fence_agent);
-	else
-		f->fence_agent[0] = '\0';
-	*retlen = sizeof(struct cl_fence_info);
-	return 0;
-}
-
-static int do_cmd_get_node_addrs(char *cmdbuf, char **retbuf, int retsize, int *retlen, int offset)
-{
-	int nodeid;
-	int i;
-	char *outbuf = *retbuf + offset;
-	struct cl_get_node_addrs *addrs = (struct cl_get_node_addrs *)outbuf;
-	struct totem_ip_address node_ifs[INTERFACE_MAX]; /* totempg_ifaces_get always copies INTERFACE_MAX addresses */
-	struct cluster_node *node;
-	char **status;
-
-	if (retsize < sizeof(struct cl_node_addrs))
-		return -EINVAL;
-	memcpy(&nodeid, cmdbuf, sizeof(nodeid));
-
-	node = find_node_by_nodeid(nodeid);
-	if (!node)
-		return -EINVAL;
-
-	memset(outbuf, 0, retsize - offset);
-
-	/* AIS doesn't know about nodes that are not members */
-	if (node->state != NODESTATE_MEMBER)  {
-		addrs->numaddrs = 0;
-		*retlen = sizeof(struct cl_get_node_addrs);
-		return 0;
-	}
-
-	if (corosync->totem_ifaces_get(nodeid, node_ifs, &status, (unsigned int *)&addrs->numaddrs))
-		return -errno;
-
-	for (i=0; i<addrs->numaddrs; i++) {
-		totemip_to_sockaddr(&node_ifs[i], 0,
-				    &addrs->addrs[i].addr,
-				    &addrs->addrs[i].addrlen);
-	}
-	*retlen = sizeof(struct cl_get_node_addrs) +
-		addrs->numaddrs * sizeof(struct cl_node_addrs);
-
-	return 0;
-}
-
-int process_command(struct connection *con, int cmd, char *cmdbuf,
-		    char **retbuf, int *retlen, int retsize, int offset)
-{
-	int err = -EINVAL;
-	struct cl_version cnxman_version;
-	char *outbuf = *retbuf;
-	int value;
-#ifdef DEBUG
-	FILE *dumpfile;
-#endif
-
-	P_MEMB("command to process is %x\n", cmd);
-
-	switch (cmd) {
-
-	case CMAN_CMD_NOTIFY:
-		con->events = 1;
-		err = 0;
-		/* If a shutdown is in progress, ask the newcomer what it thinks... */
-		if (shutdown_con) {
-			notify_listeners(con, EVENT_REASON_TRY_SHUTDOWN, shutdown_flags);
-			shutdown_expected++;
-		}
-		break;
-
-	case CMAN_CMD_REMOVENOTIFY:
-		con->events = 0;
-		err = 0;
-		break;
-
-	case CMAN_CMD_SET_DIRTY:
-		us->flags |= NODE_FLAGS_DIRTY;
-		err = 0;
-		break;
-
-	case CMAN_CMD_SET_DEBUGLOG:
-		memcpy(&value, cmdbuf, sizeof(int));
-		set_debuglog(value);
-		err = 0;
-		break;
-#ifdef DEBUG
-	case CMAN_CMD_DUMP_OBJDB:
-		dumpfile = fopen(cmdbuf, "w+");
-		if (dumpfile)  {
-			corosync->object_dump(OBJECT_PARENT_HANDLE, dumpfile);
-			fclose(dumpfile);
-			err = 0;
-		}
-		else {
-			err = -errno;
-		}
-		break;
-#endif
-	case CMAN_CMD_START_CONFCHG:
-		con->confchg = 1;
-		err = 0;
-		break;
-
-	case CMAN_CMD_STOP_CONFCHG:
-		con->confchg = 0;
-		err = 0;
-		break;
-
-		/* Return the cnxman version number */
-	case CMAN_CMD_GET_VERSION:
-		err = 0;
-		cnxman_version.major = CNXMAN_MAJOR_VERSION;
-		cnxman_version.minor = CNXMAN_MINOR_VERSION;
-		cnxman_version.patch = CNXMAN_PATCH_VERSION;
-		cnxman_version.config = config_version;
-		memcpy(outbuf+offset, &cnxman_version, sizeof(struct cl_version));
-		*retlen = sizeof(struct cl_version);
-		break;
-
-		/* Set the cnxman config version number */
-	case CMAN_CMD_SET_VERSION:
-		err = do_cmd_set_version(cmdbuf, retlen);
-		break;
-
-		/* Bind to a "port" */
-	case CMAN_CMD_BIND:
-		err = do_cmd_bind(con, cmdbuf);
-		break;
-
-		/* Return the full membership list including dead nodes */
-	case CMAN_CMD_GETALLMEMBERS:
-		err = do_cmd_get_all_members(cmdbuf, retbuf, retsize, retlen, offset);
-		break;
-
-	case CMAN_CMD_GETNODECOUNT:
-		err = get_node_count();
-		break;
-
-	case CMAN_CMD_GETNODE:
-		err = do_cmd_get_node(cmdbuf, outbuf+offset, retlen);
-		break;
-
-	case CMAN_CMD_GETCLUSTER:
-		err = do_cmd_get_cluster(cmdbuf, outbuf+offset, retlen);
-		break;
-
-	case CMAN_CMD_GETEXTRAINFO:
-		err = do_cmd_get_extrainfo(cmdbuf, retbuf, retsize, retlen, offset);
-		break;
-
-	case CMAN_CMD_ISQUORATE:
-		return cluster_is_quorate;
-
-	case CMAN_CMD_ISACTIVE:
-		return ais_running;
-
-	case CMAN_CMD_SETEXPECTED_VOTES:
-		err = do_cmd_set_expected(cmdbuf, retlen);
-		break;
-
-		/* Change the number of votes for this node */
-	case CMAN_CMD_SET_VOTES:
-		err = do_cmd_set_votes(cmdbuf, retlen);
-		break;
-
-		/* Return 1 if the specified node is listening on a given port */
-	case CMAN_CMD_ISLISTENING:
-		err = do_cmd_islistening(con, cmdbuf, retlen);
-		break;
-
-		/* Forcibly kill a node */
-	case CMAN_CMD_KILLNODE:
-		err = do_cmd_kill_node(cmdbuf, retlen);
-		break;
-
-	case CMAN_CMD_BARRIER:
-		err = do_cmd_barrier(con, cmdbuf, retlen);
-		break;
-
-	case CMAN_CMD_LEAVE_CLUSTER:
-		err = do_cmd_leave_cluster(cmdbuf, retlen);
-		break;
-
-	case CMAN_CMD_GET_JOINCOUNT:
-		err = num_connections;
-		break;
-
-	case CMAN_CMD_TRY_SHUTDOWN:
-		err = do_cmd_try_shutdown(con, cmdbuf);
-		break;
-
-	case CMAN_CMD_SHUTDOWN_REPLY:
-		err = do_cmd_shutdown_reply(con, cmdbuf);
-		break;
-
-	case CMAN_CMD_REG_QUORUMDEV:
-		err = do_cmd_register_quorum_device(cmdbuf, retlen);
-		break;
-
-	case CMAN_CMD_UNREG_QUORUMDEV:
-		err = do_cmd_unregister_quorum_device(cmdbuf, retlen);
-		break;
-
-	case CMAN_CMD_POLL_QUORUMDEV:
-		err = do_cmd_poll_quorum_device(cmdbuf, retlen);
-		break;
-
-	case CMAN_CMD_UPDATE_FENCE_INFO:
-		err = do_cmd_update_fence_info(cmdbuf);
-		break;
-
-	case CMAN_CMD_GET_FENCE_INFO:
-		err = do_cmd_get_fence_info(cmdbuf, retbuf, retsize, retlen, offset);
-		break;
-
-	case CMAN_CMD_GET_NODEADDRS:
-		err = do_cmd_get_node_addrs(cmdbuf, retbuf, retsize, retlen, offset);
-		break;
-	}
-	P_MEMB("command return code is %d\n", err);
-	return err;
-}
-
-
-int send_to_userport(unsigned char fromport, unsigned char toport,
-		     int nodeid, int tgtid,
-		     char *recv_buf, int len,
-		     int endian_conv)
-{
-	int ret = -1;
-
-	if (toport == 0) {
-		process_internal_message(recv_buf, nodeid, endian_conv);
-		ret = 0;
-	}
-	else {
-		/* Send to external listener */
-		if (port_array[toport]) {
-			struct connection *c = port_array[toport];
-
-			P_MEMB("send_to_userport. cmd=%d,  endian_conv=%d\n", recv_buf[0],endian_conv);
-
-			send_data_reply(c, nodeid, fromport, recv_buf, len);
-			ret = 0;
-		}
-	}
-	return ret;
-}
-
-void cman_send_confchg(unsigned int *member_list, int member_list_entries,
-		       unsigned int *left_list, int left_list_entries,
-		       unsigned int *joined_list, int joined_list_entries)
-{
-	char buf[sizeof(struct sock_confchg_message) +
-		 (member_list_entries+left_list_entries+joined_list_entries) * sizeof(int)];
-	struct sock_confchg_message *msg = (struct sock_confchg_message *)buf;
-
-	msg->header.magic = CMAN_MAGIC;
-	msg->header.command = CMAN_CMD_CONFCHG;
-	msg->header.length = sizeof(buf);
-	msg->header.flags = 0;
-
-	msg->member_entries = member_list_entries;
-	msg->joined_entries = joined_list_entries;
-	msg->left_entries = left_list_entries;
-
-	memcpy(msg->entries, member_list, sizeof(int)*member_list_entries);
-	memcpy(msg->entries+member_list_entries, left_list, sizeof(int)*left_list_entries);
-	memcpy(msg->entries+member_list_entries+left_list_entries, joined_list, sizeof(int)*joined_list_entries);
-
-	notify_confchg((struct sock_header *)msg);
-}
-
-
-/* Send a port closedown message to all cluster nodes - this tells them that a
- * port listener has gone away */
-static int send_port_close_msg(unsigned char port)
-{
-	struct cl_portmsg portmsg;
-
-	/* Build the header */
-	portmsg.cmd = CLUSTER_MSG_PORTCLOSED;
-	portmsg.port = port;
-
-	return comms_send_message(&portmsg, sizeof(portmsg), 0,0, 0, 0);
-}
-
-static int send_port_enquire(int nodeid)
-{
-	char msg[1];
-
-	/* Build the header */
-	msg[0] = CLUSTER_MSG_PORTENQ;
-
-	return comms_send_message(msg, 1, 0,0, nodeid, 0);
-}
-
-static int send_port_open_msg(unsigned char port)
-{
-	struct cl_portmsg portmsg;
-
-	/* Build the header */
-	portmsg.cmd = CLUSTER_MSG_PORTOPENED;
-	portmsg.port = port;
-
-	return comms_send_message(&portmsg, sizeof(portmsg), 0,0, 0, 0);
-}
-
-void unbind_con(struct connection *con)
-{
-	if (con->port) {
-		P_MEMB("Unbinding con for port %d\n", con->port);
-		port_array[con->port] = NULL;
-		send_port_close_msg(con->port);
-		clear_port_bit(us, con->port);
-		con->port = 0;
-	}
-
-	/* If we're in shutdown and this client was listening for events
-	   then we take its closedown as a "Yes" to the "can we shutdown"
-	   question. If it previously answered "No", we need to change its vote */
-	if (shutdown_con && con->events) {
-		if (con->shutdown_reply) {
-			if (con->shutdown_reply == SHUTDOWN_REPLY_YES)
-				shutdown_yes--;
-			if (con->shutdown_reply == SHUTDOWN_REPLY_NO)
-				shutdown_no--;
-		}
-		con->shutdown_reply = SHUTDOWN_REPLY_YES; /* I'll take that as a "Yes" then */
-		shutdown_yes++;
-
-		check_shutdown_status();
-	}
-
-	/* If the controlling shutdown process has quit, then cancel the
-	   shutdown session */
-	if (con == shutdown_con)
-		shutdown_con = NULL;
-}
-
-/* Post a PORT OPEN/CLOSE event to anyone listening on this end */
-static void post_port_event(int reason, unsigned char port, int nodeid)
-{
-	struct connection *con = port_array[port];
-
-	if (con)
-		notify_listeners(con, reason, nodeid);
-}
-
-int our_nodeid()
-{
-	if (us)
-		return us->node_id;
-	else
-		return 0;
-}
-
-/* Sanity check TRANSITION message */
-static int valid_transition_msg(int nodeid, struct cl_transmsg *msg)
-{
-	if (strcmp(msg->clustername, cluster_name) != 0) {
-		log_printf(LOG_ERR, "Node %d conflict, remote cluster name='%s', local='%s'\n",
-			nodeid, msg->clustername, cluster_name);
-		return -1;
-	}
-
-	if (msg->cluster_id != cluster_id) {
-		log_printf(LOG_ERR, "Node %d conflict, remote cluster id=%d, local=%d\n",
-			nodeid, msg->cluster_id, cluster_id);
-		return -1;
-	}
-
-	if (msg->major_version != CNXMAN_MAJOR_VERSION) {
-
-		log_printf(LOG_ERR, "Node %d conflict, remote version id=%d, local=%d\n",
-			nodeid, msg->major_version, CNXMAN_MAJOR_VERSION);
-		return -1;
-	}
-
-	/* New config version - try to read new file */
-	if (msg->config_version > config_version) {
-
-		reread_config(msg->config_version);
-
-		if (config_version > msg->config_version) {
-			/* Tell everyone else to update */
-			send_reconfigure(us->node_id, RECONFIG_PARAM_CONFIG_VERSION, config_version);
-		}
-		recalculate_quorum(0, 0);
-		notify_listeners(NULL, EVENT_REASON_CONFIG_UPDATE, config_version);
-	}
-
-
-	if (msg->config_version != config_version) {
-		log_printf(LOG_ERR, "Node %d conflict, remote config version id=%d, local=%d\n",
-			nodeid, msg->config_version, config_version);
-		return -1;
-	}
-
-	return 0;
-}
-
-
-void send_transition_msg(int last_memb_count, int first_trans)
-{
-	char buf[sizeof(struct cl_transmsg)+1024] __attribute__((aligned(8)));
-	struct cl_transmsg *msg = (struct cl_transmsg *)buf;
-	int len = sizeof(struct cl_transmsg);
-
-	we_are_a_cluster_member = 1;
-
-	P_MEMB("sending TRANSITION message. cluster_name = %s\n", cluster_name);
-	msg->cmd = CLUSTER_MSG_TRANSITION;
-	msg->first_trans = first_trans;
-	msg->votes = us->votes;
-	msg->expected_votes = us->expected_votes;
-	msg->cluster_id = cluster_id;
-	msg->major_version = CNXMAN_MAJOR_VERSION;
-	msg->minor_version = CNXMAN_MINOR_VERSION;
-	msg->patch_version = CNXMAN_PATCH_VERSION;
-	msg->config_version = config_version;
-	msg->flags = us->flags;
-	msg->fence_time = us->fence_time;
-	msg->join_time = join_time;
-	strcpy(msg->clustername, cluster_name);
-	if (us->fence_agent)
-	{
-		strcpy(msg->fence_agent, us->fence_agent);
-		len += strlen(us->fence_agent)+1;
-	}
-	else
-	{
-		msg->fence_agent[0] = '\0';
-		len += 1;
-	}
-
-	if (have_disallowed())
-		msg->flags |= NODE_FLAGS_SEESDISALLOWED;
-
-	comms_send_message(msg, len,
-			   0,0,
-			   0,  /* multicast */
-			   0); /* flags */
-}
-
-static void byteswap_internal_message(char *data)
-{
-	struct cl_protmsg *msg = (struct cl_protmsg *)data;
-	struct cl_barriermsg *barriermsg;
-	struct cl_killmsg *killmsg;
-	struct cl_leavemsg *leavemsg;
-	struct cl_transmsg *transmsg;
-	struct cl_fencemsg *fencemsg;
-	struct cl_reconfig_msg *reconfmsg;
-
-	switch (msg->cmd) {
-	case CLUSTER_MSG_PORTOPENED:
-	case CLUSTER_MSG_PORTCLOSED:
-		/* Just a byte */
-		break;
-
-	case CLUSTER_MSG_TRANSITION:
-		transmsg = (struct cl_transmsg *)data;
-		transmsg->cluster_id = swab16(transmsg->cluster_id);
-		transmsg->votes = swab32(transmsg->votes);
-		transmsg->expected_votes = swab32(transmsg->expected_votes);
-		transmsg->major_version = swab32(transmsg->major_version);
-		transmsg->minor_version = swab32(transmsg->minor_version);
-		transmsg->patch_version = swab32(transmsg->patch_version);
-		transmsg->config_version = swab32(transmsg->config_version);
-		transmsg->flags = swab32(transmsg->flags);
-		transmsg->fence_time = swab64(transmsg->fence_time);
-		break;
-
-	case CLUSTER_MSG_KILLNODE:
-		killmsg = (struct cl_killmsg *)data;
-		killmsg->reason = swab16(killmsg->reason);
-		killmsg->nodeid = swab32(killmsg->nodeid);
-		break;
-
-	case CLUSTER_MSG_LEAVE:
-		leavemsg = (struct cl_leavemsg *)data;
-		leavemsg->reason = swab16(leavemsg->reason);
-		break;
-
-	case CLUSTER_MSG_BARRIER:
-		barriermsg = (struct cl_barriermsg *)data;
-		break;
-
-	case CLUSTER_MSG_RECONFIGURE:
-		reconfmsg = (struct cl_reconfig_msg *)data;
-		reconfmsg->nodeid = swab32(reconfmsg->nodeid);
-		reconfmsg->value = swab32(reconfmsg->value);
-		break;
-
-	case CLUSTER_MSG_FENCESTATUS:
-		fencemsg = (struct cl_fencemsg *)data;
-		fencemsg->timesec = swab64(fencemsg->timesec);
-		fencemsg->nodeid = swab32(fencemsg->nodeid);
-		break;
-	}
-}
-
-
-static void do_reconfigure_msg(void *data)
-{
-	struct cl_reconfig_msg *msg = data;
-	struct cluster_node *node;
-	struct list *nodelist;
-
-	node = find_node_by_nodeid(msg->nodeid);
-	if (!node)
-		return;
-
-	switch(msg->param)
-	{
-	case RECONFIG_PARAM_EXPECTED_VOTES:
-		node->expected_votes = msg->value;
-
-		list_iterate(nodelist, &cluster_members_list) {
-			node = list_item(nodelist, struct cluster_node);
-			if (node->state == NODESTATE_MEMBER &&
-			    node->expected_votes > msg->value) {
-				node->expected_votes = msg->value;
-			}
-		}
-		recalculate_quorum(1, 0);  /* Allow decrease */
-		break;
-
-	case RECONFIG_PARAM_NODE_VOTES:
-		node->votes = msg->value;
-		recalculate_quorum(1, 0);  /* Allow decrease */
-		break;
-
-	case RECONFIG_PARAM_CONFIG_VERSION:
-		if (config_version != msg->value) {
-			reread_config(msg->value);
-		}
-		notify_listeners(NULL, EVENT_REASON_CONFIG_UPDATE, config_version);
-		break;
-	}
-}
-
-static void do_fence_msg(void *data)
-{
-	struct cl_fencemsg *msg = data;
-	struct cluster_node *node;
-
-	P_DAEMON("got FENCE message, node %d fenced by %s\n", msg->nodeid, msg->agent);
-
-	node = find_node_by_nodeid(msg->nodeid);
-	if (!node)
-		return;
-
-	node->fence_time = msg->timesec;
-	if (node->fence_agent)
-		free(node->fence_agent);
-	node->fence_agent = strdup(msg->agent);
-	if (msg->fenced) {
-		node->flags |= NODE_FLAGS_FENCED;
-
-		if (node->state == NODESTATE_MEMBER)
-			node->flags |= NODE_FLAGS_FENCEDWHILEUP;
-	}
-
-}
-
-static void do_process_transition(int nodeid, char *data)
-{
-	struct cl_transmsg *msg = (struct cl_transmsg *)data;
-	struct cluster_node *node;
-
-	if (valid_transition_msg(nodeid, msg) != 0) {
-		P_MEMB("Transition message from %d does not match current config - should quit ?\n", nodeid);
-		// Now what ??
-		return;
-	}
-
-	/* If the remote node can see AISONLY nodes then we can't join as we don't
-	   know the full state */
-	if (msg->flags & NODE_FLAGS_SEESDISALLOWED && !have_disallowed()) {
-		/* Must use syslog directly here or the message will never arrive */
-		syslog(LOG_CRIT, "CMAN: Joined a cluster with disallowed nodes. must die");
-		exit(2);
-	}
-	msg->flags &= ~NODE_FLAGS_SEESDISALLOWED;
-
-	node = find_node_by_nodeid(nodeid);
-	if (!node) {
-		add_ais_node(nodeid, incarnation, num_ais_nodes);
-		node = find_node_by_nodeid(nodeid);
-	}
-	assert(node);
-
-	P_MEMB("Got TRANSITION message. msg->flags=%x, node->flags=%x, first_trans=%d\n",
-	       msg->flags, node->flags, msg->first_trans);
-
-	/* Newer nodes 6.1.0 onwards, set the DIRTY flag if they have state. If the new node has been down
-	   and has state then we mark it disallowed because we cannot merge stateful nodes */
-	if ( (msg->flags & NODE_FLAGS_DIRTY && (node->flags & NODE_FLAGS_BEENDOWN)) ||
-	     (msg->flags & NODE_FLAGS_DIRTY && msg->first_trans && !node->us)) {
-		/* Don't duplicate messages */
-		if (node->state != NODESTATE_AISONLY) {
-			if (cluster_is_quorate) {
-				P_MEMB("Killing node %s because it has rejoined the cluster with existing state", node->name);
-				log_printf(LOG_CRIT, "Killing node %s because it has rejoined the cluster with existing state", node->name);
-				node->state = NODESTATE_AISONLY;
-				send_kill(nodeid, CLUSTER_KILL_REJOIN);
-			}
-			else {
-				P_MEMB("Node %s not joined to cman because it has existing state", node->name);
-				log_printf(LOG_CRIT, "Node %s not joined to cman because it has existing state", node->name);
-				node->state = NODESTATE_AISONLY;
-			}
-		}
-		return;
-	}
-
-        /* This is for older nodes. If the join_time of the node matches that already stored AND
-	   the node has been down, then we kill it as this must be a rejoin */
-	if (msg->minor_version == 0 &&
-	    msg->join_time == node->cman_join_time && node->flags & NODE_FLAGS_BEENDOWN) {
-		/* Don't duplicate messages */
-		if (node->state != NODESTATE_AISONLY) {
-			if (cluster_is_quorate) {
-				P_MEMB("Killing node %s because it has rejoined the cluster without cman_tool join", node->name);
-				log_printf(LOG_CRIT, "Killing node %s because it has rejoined the cluster without cman_tool join", node->name);
-				node->state = NODESTATE_AISONLY;
-				send_kill(nodeid, CLUSTER_KILL_REJOIN);
-			}
-			else {
-				P_MEMB("Node %s not joined to cman because it has rejoined an inquorate cluster", node->name);
-				log_printf(LOG_CRIT, "Node %s not joined to cman because it has rejoined an inquorate cluster", node->name);
-				node->state = NODESTATE_AISONLY;
-			}
-		}
-		return;
-	}
-	else {
-		node->cman_join_time = msg->join_time;
-		add_ais_node(nodeid, incarnation, num_ais_nodes);
-	}
-
-	/* If the cluster already has some AISONLY nodes then we can't make
-	   sense of the membership. So the new node has to also be AISONLY
-	   until we are consistent again */
-	if (have_disallowed() && !node->us)
-		node->state = NODESTATE_AISONLY;
-
-	node->flags = msg->flags; /* This will clear the BEENDOWN flag of course */
-
-	/* Take into account any new expected_votes value that the new node has */
-	node->expected_votes = msg->expected_votes;
-	recalculate_quorum(0, 0);
-
-	if (node->fence_agent && msg->fence_agent[0] && strcmp(node->fence_agent, msg->fence_agent))
-	{
-		free(node->fence_agent);
-		node->fence_agent = strdup(msg->fence_agent);
-		node->fence_time = msg->fence_time;
-	}
-
-	/*
-	 * If this is a rejoined node then it won't know about its own fence data, send it
-	 * some
-	 */
-	if (node->fence_time && !msg->fence_time &&
-	    node->fence_agent && !msg->fence_agent[0])
-	{
-		char msg[sizeof(struct cl_fencemsg)+strlen(node->fence_agent)+1];
-		struct cl_fencemsg *fence_msg = (struct cl_fencemsg *)msg;
-
-		fence_msg->cmd = CLUSTER_MSG_FENCESTATUS;
-		fence_msg->nodeid = nodeid;
-		fence_msg->timesec = node->fence_time;
-		fence_msg->fenced = 0;
-		strcpy(fence_msg->agent, node->fence_agent);
-		comms_send_message(msg, sizeof(msg), 0,0, nodeid, 0);
-	}
-}
-
-static void process_internal_message(char *data, int nodeid, int need_byteswap)
-{
-	struct cl_protmsg *msg = (struct cl_protmsg *)data;
-	struct cl_portmsg *portmsg;
-	struct cl_barriermsg *barriermsg;
-	struct cl_killmsg *killmsg;
-	struct cl_leavemsg *leavemsg;
-	struct cluster_node *node = find_node_by_nodeid(nodeid);
-	unsigned char portresult[PORT_BITS_SIZE+1];
-
-	P_MEMB("Message on port 0 is %d\n", msg->cmd);
-
-	/* Byteswap messages if needed */
-	if (need_byteswap)
-		byteswap_internal_message(data);
-
-	switch (msg->cmd) {
-	case CLUSTER_MSG_PORTOPENED:
-		portmsg = (struct cl_portmsg *)data;
-		if (node)
-			set_port_bit(node, portmsg->port);
-		post_port_event(EVENT_REASON_PORTOPENED, portmsg->port, nodeid);
-		break;
-
-	case CLUSTER_MSG_PORTCLOSED:
-		portmsg = (struct cl_portmsg *)data;
-		if (node)
-			clear_port_bit(node, portmsg->port);
-		post_port_event(EVENT_REASON_PORTCLOSED, portmsg->port, nodeid);
-		break;
-
-	case CLUSTER_MSG_PORTENQ:
-		portresult[0] = CLUSTER_MSG_PORTSTATUS;
-		memcpy(portresult+1, us->port_bits, PORT_BITS_SIZE);
-		P_MEMB("Sending PORTRESULT, low bytes = %x %x\n", us->port_bits[0], us->port_bits[1]);
-
-		/* Broadcast reply as other new nodes may be interested */
-		comms_send_message(portresult, PORT_BITS_SIZE+1, 0,0, 0, 0);
-		break;
-
-	case CLUSTER_MSG_PORTSTATUS:
-		if (nodeid != us->node_id) {
-			P_MEMB("got PORTRESULT from %d, low bytes = %x %x\n", nodeid, data[1], data[2]);
-			if (node)
-				memcpy(node->port_bits, data+1, PORT_BITS_SIZE);
-		}
-		break;
-
-	case CLUSTER_MSG_TRANSITION:
-		P_MEMB("got TRANSITION from node %d\n", nodeid);
-		do_process_transition(nodeid, data);
-		break;
-
-	case CLUSTER_MSG_KILLNODE:
-		killmsg = (struct cl_killmsg *)data;
-		P_MEMB("got KILL for node %d\n", killmsg->nodeid);
-		if (killmsg->nodeid == wanted_nodeid) {
-			/* Must use syslog directly here or the message will never arrive */
-			syslog(LOG_CRIT, "cman killed by node %d because %s\n", nodeid,
-			       killmsg_reason(killmsg->reason));
-			exit(1);
-		}
-		break;
-
-	case CLUSTER_MSG_LEAVE:
-		leavemsg = (struct cl_leavemsg *)data;
-		P_MEMB("got LEAVE from node %d, reason = %d\n", nodeid, leavemsg->reason);
-
-		/* We got our own leave message back. now quit */
-		if (node && node->node_id == us->node_id) {
-			/* Tell whomever asked us to leave that we are now going down */
-			if (shutdown_con)
-				send_status_return(shutdown_con, CMAN_CMD_TRY_SHUTDOWN, 0);
-			exit(0);
-		}
-
-		/* Someone else, make a note of the reason for leaving */
-		if (node)
-			node->leave_reason = leavemsg->reason;
-
-		/* Mark it as leaving, and remove it when we get an AIS node down event for it */
-		if (node && (node->state == NODESTATE_MEMBER || node->state == NODESTATE_AISONLY))
-			node->state = NODESTATE_LEAVING;
-		break;
-
-	case CLUSTER_MSG_BARRIER:
-		barriermsg = (struct cl_barriermsg *)data;
-		if (node)
-			process_barrier_msg(barriermsg, node);
-		break;
-
-	case CLUSTER_MSG_RECONFIGURE:
-		do_reconfigure_msg(data);
-		break;
-
-	case CLUSTER_MSG_FENCESTATUS:
-		do_fence_msg(data);
-		break;
-
-	default:
-		log_printf(LOG_WARNING, "Unknown protocol message %d received\n", msg->cmd);
-		break;
-
-	}
-}
-
-void override_expected(int newexp)
-{
-	struct list *nodelist;
-	struct cluster_node *node;
-
-	list_iterate(nodelist, &cluster_members_list) {
-		node = list_item(nodelist, struct cluster_node);
-		if (node->state == NODESTATE_MEMBER
-		    && node->expected_votes > newexp) {
-			node->expected_votes = newexp;
-		}
-	}
-}
-
-void clear_reread_flags()
-{
-	struct list *nodelist;
-	struct cluster_node *node;
-
-	list_iterate(nodelist, &cluster_members_list) {
-		node = list_item(nodelist, struct cluster_node);
-		node->flags &= ~NODE_FLAGS_REREAD;
-	}
-}
-
-void remove_unread_nodes()
-{
-	struct list *nodelist, *tmp;
-	struct cluster_node *node;
-
-	list_iterate_safe(nodelist, tmp, &cluster_members_list) {
-		node = list_item(nodelist, struct cluster_node);
-		if (!(node->flags & NODE_FLAGS_REREAD) &&
-		    node->state == NODESTATE_DEAD) {
-
-			list_del(&node->list);
-			free(node);
-		}
-	}
-}
-
-/* Add a node from CCS, note that it may already exist if user has simply updated the config file */
-void add_ccs_node(char *nodename, int nodeid, int votes, int expected_votes)
-{
-	/* Update node entry */
-	add_new_node(nodename, nodeid, votes, expected_votes, NODESTATE_DEAD);
-}
-
-void add_ais_node(int nodeid, uint64_t incarnation, int total_members)
-{
-	struct cluster_node *node;
-
-	P_MEMB("add_ais_node ID=%d, incarnation = %" PRIu64 "\n",nodeid, incarnation);
-
-	node = find_node_by_nodeid(nodeid);
-	if (!node && total_members == 1) {
-		node = us;
-		P_MEMB("Adding AIS node for 'us'\n");
-	}
-
- 	/* This really should exist!! */
-	if (!node) {
-		char tempname[256];
-		log_printf(LOG_ERR, "Got node from AIS id %d with no config entry\n", nodeid);
-
-		/* Emergency nodename */
-		sprintf(tempname, "Node%d", nodeid);
-		node = add_new_node(tempname, nodeid, 1, total_members, NODESTATE_DEAD);
-	}
-
-	if (node->state == NODESTATE_DEAD || node->state == NODESTATE_LEAVING) {
-		gettimeofday(&node->join_time, NULL);
-		node->incarnation = incarnation;
-		node->state = NODESTATE_MEMBER;
-		cluster_members++;
-		recalculate_quorum(0, 0);
-	}
-}
-
-void del_ais_node(int nodeid)
-{
-	struct cluster_node *node;
-	time_t t;
-	P_MEMB("del_ais_node %d\n", nodeid);
-
-	node = find_node_by_nodeid(nodeid);
-	if (!node)
-		return;
-
-	/* If the node was fenced while up (ie independantly of fenced) then
-	 * don't clear the fenced flag. There is a timeout associated with
-	 * this so if we get the node down more than 2 minutes after the
-	 * fence message then we still clear fenced just to be certain that
-	 * fenced will do the job too.
-	 */
-	time(&t);
-	if (!(node->flags & NODE_FLAGS_FENCEDWHILEUP) || (t - node->fence_time > 120))
-		node->flags &= ~NODE_FLAGS_FENCED;
-
-	node->flags &= ~NODE_FLAGS_FENCEDWHILEUP;
-	node->flags |= NODE_FLAGS_BEENDOWN;
-
-	switch (node->state) {
-	case NODESTATE_MEMBER:
-		node->state = NODESTATE_DEAD;
-		memset(&node->port_bits, 0, sizeof(node->port_bits));
-		cluster_members--;
-		recalculate_quorum(0, 0);
-		break;
-
-	case NODESTATE_AISONLY:
-		node->state = NODESTATE_DEAD;
-		break;
-
-	case NODESTATE_LEAVING:
-		node->state = NODESTATE_DEAD;
-		cluster_members--;
-
-		P_MEMB("del_ais_node %s, leave_reason=%x\n", node->name, node->leave_reason);
-		if ((node->leave_reason & 0xF) == CLUSTER_LEAVEFLAG_REMOVED)
-			recalculate_quorum(1, 1);
-		else
-			recalculate_quorum(0, 0);
-		break;
-
-	case NODESTATE_JOINING:
-	case NODESTATE_DEAD:
-		break;
-	}
-}
-
-static int get_highest_nodeid()
-{
-	int highest = 0;
-	struct cluster_node *node;
-
-	list_iterate_items(node, &cluster_members_list) {
-		if (node->node_id > highest)
-			highest = node->node_id;
-	}
-	return highest;
-}
-
-static int get_node_count()
-{
-	int count = 0;
-
-	struct cluster_node *node;
-
-	list_iterate_items(node, &cluster_members_list) {
-		count++;
-	}
-	return count;
-}
-
-static struct cluster_node *find_node_by_nodeid(int nodeid)
-{
-	struct cluster_node *node;
-
-	list_iterate_items(node, &cluster_members_list) {
-		if (node->node_id == nodeid)
-			return node;
-	}
-	return NULL;
-}
-
-
-static struct cluster_node *find_node_by_name(char *name)
-{
-	struct cluster_node *node;
-
-	list_iterate_items(node, &cluster_members_list) {
-		if (node->name && strcmp(node->name, name) == 0)
-			return node;
-	}
-	return NULL;
-}
-
-static char *killmsg_reason(int reason)
-{
-	static char msg[1024];
-
-	switch (reason)
-	{
-	case CLUSTER_KILL_REJECTED:
-		return "our membership application was rejected";
-
-	case CLUSTER_KILL_CMANTOOL:
-		return "we were killed by cman_tool or other application";
-
-	case CLUSTER_KILL_REJOIN:
-		return "we rejoined the cluster without a full restart";
-
-	default:
-		sprintf(msg, "we got kill message number %d", reason);
-		return msg;
-	}
-}
diff --git a/cman/daemon/commands.h b/cman/daemon/commands.h
deleted file mode 100644
index 5d325ad..0000000
--- a/cman/daemon/commands.h
+++ /dev/null
@@ -1,37 +0,0 @@
-struct cluster_node;
-struct connection;
-extern void process_cnxman_message(char *data, char *addr, int addrlen,
-				  struct cluster_node *rem_node);
-
-extern int send_to_userport(unsigned char fromport, unsigned char toport,
-			    int nodeid, int tgtnodeid,
-			    char *recv_buf, int len,
-			    int endian_conv);
-extern void clean_dead_listeners(void);
-extern void unbind_con(struct connection *con);
-extern void commands_init(void);
-extern int process_command(struct connection *con, int cmd, char *cmdbuf,
-			   char **retbuf, int *retlen, int retsize, int offset);
-extern void send_transition_msg(int last_memb_count, int first_trans);
-
-extern void add_ais_node(int nodeid, uint64_t incarnation, int total_members);
-extern void del_ais_node(int nodeid);
-extern void add_ccs_node(char *name, int nodeid, int votes, int expected_votes);
-extern void override_expected(int expected);
-extern void cman_send_confchg(unsigned int *member_list, int member_list_entries,
-			      unsigned int *left_list, int left_list_entries,
-			      unsigned int *joined_list, int joined_list_entries);
-
-
-extern void clear_reread_flags(void);
-extern void remove_unread_nodes(void);
-
-/* Startup stuff called from cmanccs: */
-extern int cman_set_nodename(char *name);
-extern int cman_set_nodeid(int nodeid);
-extern int cman_join_cluster(struct corosync_api_v1 *api,
-			     char *name, unsigned short cluster_id, int two_node,
-			     int votes, int expected_votes);
-
-extern int cluster_members;
-extern uint32_t max_outstanding_messages;
diff --git a/cman/daemon/daemon.c b/cman/daemon/daemon.c
deleted file mode 100644
index 6cef080..0000000
--- a/cman/daemon/daemon.c
+++ /dev/null
@@ -1,539 +0,0 @@
-#include <getopt.h>
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <string.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/un.h>
-#include <sys/stat.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/signal.h>
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <sys/errno.h>
-
-#include <corosync/ipc_gen.h>
-#include <corosync/engine/coroapi.h>
-#include <corosync/engine/logsys.h>
-#include <corosync/totem/coropoll.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "daemon.h"
-#include "logging.h"
-#include "commands.h"
-#include "barrier.h"
-#include "ais.h"
-#include "cman.h"
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME, LOG_INFO);
-
-struct queued_reply
-{
-	struct list list;
-	int offset;
-	char buf[1];
-};
-
-/* We need to keep these in a list so we can notify of
-   cluster events */
-static LIST_INIT(client_list);
-
-/* Things to wake up for */
-volatile sig_atomic_t quit_threads=0;
-
-int num_connections = 0;
-poll_handle ais_poll_handle;
-uint32_t max_outstanding_messages = DEFAULT_MAX_QUEUED;
-
-static int process_client(poll_handle handle, int fd, int revent, void *data);
-static void remove_client(poll_handle handle, struct connection *con);
-
-/* Send it, or queue it for later if the socket is busy */
-static int send_reply_message(struct connection *con, struct sock_header *msg)
-{
-	int ret;
-
-	P_DAEMON("sending reply %x to fd %d\n", msg->command, con->fd);
-
-	/* If there are already queued messages then don't send this one
-	   out of order */
-	if (!list_empty(&con->write_msgs)) {
-		ret = -1;
-		errno = EAGAIN;
-	}
-	else {
-		ret = send(con->fd, (char *)msg, msg->length, MSG_DONTWAIT);
-	}
-
-	if ((ret > 0 && ret != msg->length) ||
-	    (ret == -1 && errno == EAGAIN)) {
-		struct queued_reply *qm;
-
-		/* Have we exceeded the allowed number of queued messages ? */
-		if (con->num_write_msgs > max_outstanding_messages) {
-			P_DAEMON("Disconnecting. client has more that %d replies outstanding (%d)\n", max_outstanding_messages, con->num_write_msgs);
-			remove_client(ais_poll_handle, con);
-			return -1;
-		}
-
-		/* Queue it */
-		qm = malloc(sizeof(struct queued_reply) + msg->length);
-		if (!qm)
-		{
-			perror("Error allocating queued message");
-			return -1;
-		}
-		memcpy(qm->buf, msg, msg->length);
-		if (ret > 0)
-			qm->offset = ret;
-		else
-			qm->offset = 0;
-		list_add(&con->write_msgs, &qm->list);
-		con->num_write_msgs++;
-		P_DAEMON("queued last message, count is %d\n", con->num_write_msgs);
-		poll_dispatch_modify(ais_poll_handle, con->fd, POLLIN | POLLOUT, process_client);
-	}
-	return 0;
-}
-
-static void remove_client(poll_handle handle, struct connection *con)
-{
-	struct list *tmp, *qmh;
-	struct queued_reply *qm;
-	int msgs=0;
-
-	poll_dispatch_delete(handle, con->fd);
-	close(con->fd);
-	if (con->type == CON_CLIENT)
-		list_del(&con->list);
-
-	unbind_con(con);
-	remove_barriers(con);
-
-	list_iterate_safe(qmh, tmp, &con->write_msgs) {
-		qm = list_item(qmh, struct queued_reply);
-
-		list_del(&qm->list);
-		free(qm);
-		msgs++;
-	}
-
-	P_DAEMON("Freed %d queued messages\n", msgs);
-	free(con);
-	num_connections--;
-}
-
-/* Send as many as we can */
-static void send_queued_reply(struct connection *con)
-{
-	struct queued_reply *qm;
-	struct sock_header *msg;
-	struct list *tmp, *qmh;
-	int ret;
-
-	list_iterate_safe(qmh, tmp, &con->write_msgs) {
-		qm = list_item(qmh, struct queued_reply);
-		msg = (struct sock_header *)qm->buf;
-		ret = send(con->fd, qm->buf + qm->offset, msg->length - qm->offset, MSG_DONTWAIT);
-		if (ret == msg->length - qm->offset)
-		{
-			list_del(&qm->list);
-			free(qm);
-			con->num_write_msgs--;
-		}
-		else
-		{
-			if (ret > 0)
-				qm->offset += ret;
-			break;
-		}
-	}
-	if (list_empty(&con->write_msgs)) {
-		/* Remove POLLOUT callback */
-		P_DAEMON("Removing POLLOUT from fd %d\n", con->fd);
-		poll_dispatch_modify(ais_poll_handle, con->fd, POLLIN, process_client);
-	}
-}
-
-/* Dispatch a request from a CLIENT or ADMIN socket */
-static int process_client(poll_handle handle, int fd, int revent, void *data)
-{
-	struct connection *con = data;
-
-	if (revent == POLLOUT) {
-		send_queued_reply(con);
-	} else {
-		char buf[MAX_CLUSTER_MESSAGE + sizeof(struct sock_header)];
-		struct sock_header *msg = (struct sock_header *)buf;
-		int len;
-		int totallen = 0;
-
-		memset(buf, 0, (MAX_CLUSTER_MESSAGE + sizeof(struct sock_header)));
-
-		len = read(fd, buf, sizeof(struct sock_header));
-
-		P_DAEMON("read %d bytes from fd %d\n", len, fd);
-
-		if (len == 0) {
-			remove_client(handle, con);
-			return -1;
-		}
-
-		if (len < 0 &&
-		    (errno == EINTR || errno == EAGAIN))
-			return 0;
-
-		if (len < 0) {
-			remove_client(handle, con);
-			return 0;
-		}
-
-		if (msg->magic != CMAN_MAGIC) {
-			P_DAEMON("bad magic in client command %x\n", msg->magic);
-			send_status_return(con, msg->command, -EINVAL);
-			return 0;
-		}
-		if (msg->version != CMAN_VERSION) {
-			P_DAEMON("bad version in client command. msg = 0x%x, us = 0x%x\n", msg->version, CMAN_VERSION);
-			send_status_return(con, msg->command, -EINVAL);
-			return 0;
-		}
-		if ((msg->length-len) > MAX_CLUSTER_MESSAGE) {
-			P_DAEMON("message on socket is too big\n");
-			send_status_return(con, msg->command, -EINVAL);
-			return 0;
-		}
-
-		totallen = len;
-
-		/* Read the rest */
-		while (totallen != msg->length) {
-			len = read(fd, buf+len, msg->length-len);
-			if (len == 0)
-				return -1;
-
-			if (len < 0 &&
-			    (errno == EINTR || errno == EAGAIN))
-				return 0;
-
-			if (len < 0) {
-				remove_client(handle, con);
-				return -1;
-			}
-			totallen += len;
-		}
-
-		P_DAEMON("client command is %x\n", msg->command);
-
-		/* Privileged functions can only be done on ADMIN sockets */
-		if (msg->command & CMAN_CMDFLAG_PRIV && con->type != CON_ADMIN) {
-			P_DAEMON("command disallowed from non-admin client\n");
-			send_status_return(con, msg->command, -EPERM);
-			return 0;
-		}
-
-		/* Slightly arbitrary this one, don't allow ADMIN sockets to
-		   send/receive data. The main loop doesn't keep a backlog queue
-		   of messages for ADMIN sockets
-		*/
-		if ((msg->command == CMAN_CMD_DATA || msg->command == CMAN_CMD_BIND ||
-		     msg->command == CMAN_CMD_NOTIFY) && con->type == CON_ADMIN) {
-			P_DAEMON("can't send data down an admin socket, sorry\n");
-			send_status_return(con, msg->command, -EINVAL);
-			return 0;
-		}
-
-		if (msg->command == CMAN_CMD_DATA) {
-			char *buf = (char *)msg;
-			int ret;
-			uint8_t port;
-			struct sock_data_header *dmsg = (struct sock_data_header *)msg;
-
-			P_DAEMON("sending %lu bytes of data to node %d, port %d\n",
-				 (unsigned long)(msg->length - sizeof(struct sock_data_header)), dmsg->nodeid, dmsg->port);
-
-			buf += sizeof(struct sock_data_header);
-
-			if (dmsg->port > 255) {
-				send_status_return(con, msg->command, -EINVAL);
-				return 0;
-			}
-
-			if (dmsg->port)
-				port = dmsg->port;
-			else
-				port = con->port;
-
-			ret = comms_send_message(buf, msg->length - sizeof(struct sock_data_header),
-						 port, con->port,
-						 dmsg->nodeid,
-						 msg->flags);
-			if (ret) {
-				send_status_return(con, msg->command, -EIO);
-			}
-		}
-		else {
-			char *cmdbuf = (char *)msg;
-			char small_retbuf[1024]; /* Enough for most needs */
-			char *retbuf = small_retbuf;
-			struct sock_reply_header *reply;
-			int ret;
-			int retlen = 0;
-
-			P_DAEMON("About to process command\n");
-
-			cmdbuf += sizeof(struct sock_header);
-
-			ret = process_command(con, msg->command, cmdbuf,
-					      &retbuf, &retlen, sizeof(small_retbuf),
-					      sizeof(struct sock_reply_header));
-
-			/* Reply message will come later on */
-			if (ret == -EWOULDBLOCK)
-				return 0;
-
-			reply = (struct sock_reply_header *)retbuf;
-
-			reply->header.magic = CMAN_MAGIC;
-			reply->header.flags = 0;
-			reply->header.command = msg->command | CMAN_CMDFLAG_REPLY;
-			reply->header.length = retlen + sizeof(struct sock_reply_header);
-			reply->status = ret;
-
-			P_DAEMON("Returning command data. length = %d\n", retlen);
-			send_reply_message(con, (struct sock_header *)reply);
-
-			if (retbuf != small_retbuf)
-				free(retbuf);
-		}
-	}
-	return 0;
-}
-
-
-/* Both client and admin rendezvous sockets use this */
-static int process_rendezvous(poll_handle handle, int fd, int revent, void *data)
-{
-	struct sockaddr_un socka;
-	struct connection *con = data;
-	socklen_t sl = sizeof(socka);
-	int client_fd;
-
-	client_fd = accept(fd, (struct sockaddr *) &socka, &sl);
-	if (client_fd >= 0) {
-		struct connection *newcon = malloc(sizeof(struct connection));
-		if (!newcon) {
-			close(client_fd);
-			return 0; /* returning -1 will remove us */
-		}
-
-		newcon->fd = client_fd;
-		newcon->type = con->type;
-		newcon->port = 0;
-		newcon->events = 0;
-		newcon->num_write_msgs = 0;
-		list_init(&newcon->write_msgs);
-		fcntl(client_fd, F_SETFL, fcntl(client_fd, F_GETFL, 0) | O_NONBLOCK);
-
-		poll_dispatch_add(handle, client_fd, POLLIN, newcon, process_client);
-		num_connections++;
-		if (newcon->type == CON_CLIENT)
-			list_add(&client_list, &newcon->list);
-	}
-	return 0;
-}
-
-static int open_local_sock(const char *name, int name_len, mode_t mode, poll_handle handle, int type)
-{
-	int local_socket;
-	struct sockaddr_un sockaddr;
-	struct connection *con;
-
-	/* Open local socket */
-	if (name[0] != '\0')
-		unlink(name);
-	local_socket = socket(PF_UNIX, SOCK_STREAM, 0);
-	if (local_socket < 0) {
-		log_printf(LOG_ERR, "Can't create local socket %s: %s\n", name, strerror(errno));
-		write_cman_pipe("Can't create local cman socket");
-		return -1;
-	}
-	/* Set Close-on-exec */
-	fcntl(local_socket, F_SETFD, 1);
-	fcntl(local_socket, F_SETFL, fcntl(local_socket, F_GETFL, 0) | O_NONBLOCK);
-
-	memset(&sockaddr, 0, sizeof(sockaddr));
-	memcpy(sockaddr.sun_path, name, name_len);
-	sockaddr.sun_family = AF_UNIX;
-	if (bind(local_socket, (struct sockaddr *) &sockaddr, sizeof(sockaddr))) {
-		log_printf(LOG_ERR, "can't bind local socket to %s: %s\n", name, strerror(errno));
-		write_cman_pipe("Can't bind to local cman socket");
-		close(local_socket);
-		return -1;
-	}
-	if (listen(local_socket, 1) != 0) {
-		log_printf(LOG_ERR, "listen on %s failed: %s\n", name, strerror(errno));
-		write_cman_pipe("listen failed on local cman socket");
-		close(local_socket);
-		return -1;
-	}
-	if (name[0] != '\0')
-		chmod(name, mode);
-
-
-	con = malloc(sizeof(struct connection));
-	if (!con) {
-		log_printf(LOG_ERR, "Can't allocate space for local connection: %s\n", strerror(errno));
-		write_cman_pipe("malloc failed for connection info");
-		close(local_socket);
-		return -1;
-	}
-	con->type = type;
-	con->fd = local_socket;
-	con->num_write_msgs = 0;
-
-	poll_dispatch_add(handle, con->fd, POLLIN, con, process_rendezvous);
-
-	return 0;
-}
-
-
-
-/* Send a simple return - usually just a failure status */
-int send_status_return(struct connection *con, uint32_t cmd, int status)
-{
-	struct sock_reply_header msg;
-
-	P_DAEMON("send status return: %d\n", status);
-	msg.header.magic = CMAN_MAGIC;
-	msg.header.command = cmd | CMAN_CMDFLAG_REPLY;
-	msg.header.length = sizeof(msg);
-	msg.header.flags = 0;
-	msg.status = status;
-
-	return send_reply_message(con, (struct sock_header *)&msg);
-}
-
-int send_data_reply(struct connection *con, int nodeid, int port, char *data, int len)
-{
-	char buf[len + sizeof(struct sock_data_header)];
-	struct sock_data_header *msg = (struct sock_data_header *)buf;
-
-	msg->header.magic = CMAN_MAGIC;
-	msg->header.command = CMAN_CMD_DATA | CMAN_CMDFLAG_REPLY;
-	msg->header.length = sizeof(*msg)+len;
-	msg->header.flags = 0;
-	msg->nodeid = nodeid;
-	msg->port = port;
-
-	memcpy(buf+sizeof(struct sock_data_header), data, len);
-	return send_reply_message(con, (struct sock_header *)msg);
-}
-
-/* This can be called by the membership thread as well as the daemon thread. */
-void notify_listeners(struct connection *con, int event, int arg)
-{
-	struct sock_event_message msg;
-	struct connection *thiscon;
-
-	msg.header.magic = CMAN_MAGIC;
-	msg.header.command = CMAN_CMD_EVENT;
-	msg.header.length = sizeof(msg);
-	msg.header.flags = 0;
-	msg.reason = event;
-	msg.arg = arg;
-
-	/* Unicast message */
-	if (con) {
-		send_reply_message(con, (struct sock_header *)&msg);
-		return;
-	}
-
-	/* Broadcast message */
-	list_iterate_items(thiscon, &client_list) {
-		if (thiscon->events)
-			send_reply_message(thiscon, (struct sock_header *)&msg);
-	}
-}
-
-void notify_confchg(struct sock_header *message)
-{
-	struct connection *thiscon;
-
-	list_iterate_items(thiscon, &client_list) {
-		if (thiscon->confchg)
-			send_reply_message(thiscon, message);
-	}
-}
-
-void wake_daemon(void)
-{
-	P_DAEMON("Wake daemon called\n");
-}
-
-
-int num_listeners(void)
-{
-	int count = 0;
-	struct connection *thiscon;
-
-	list_iterate_items(thiscon, &client_list) {
-		thiscon->shutdown_reply = SHUTDOWN_REPLY_UNK; /* Clear out for new shutdown request */
-		if (thiscon->events)
-			count++;
-	}
-	return count;
-}
-
-static void sigint_handler(int ignored)
-{
-	quit_threads = 1;
-}
-
-extern poll_handle aisexec_poll_handle;
-int cman_init()
-{
-	int fd;
-	struct sigaction sa;
-
-	ais_poll_handle = aisexec_poll_handle;
-	barrier_init();
-
-	log_printf(LOG_INFO, "CMAN %s (built %s %s) started\n",
-		   RELEASE_VERSION, __DATE__, __TIME__);
-
-	fd = open_local_sock(CLIENT_SOCKNAME, sizeof(CLIENT_SOCKNAME), 0660, ais_poll_handle, CON_CLIENT);
-	if (fd < 0)
-		return -2;
-
-	fd = open_local_sock(ADMIN_SOCKNAME, sizeof(ADMIN_SOCKNAME), 0600, ais_poll_handle, CON_ADMIN);
-	if (fd < 0)
-		return -2;
-
-	/* Shutdown trap */
-	sa.sa_handler = sigint_handler;
-	sigaction(SIGINT, &sa, NULL);
-	sigaction(SIGTERM, &sa, NULL);
-
-	sa.sa_handler = SIG_IGN;
-	sigaction(SIGPIPE, &sa, NULL);
-
-	return 0;
-}
-
-int cman_finish()
-{
-	/* Stop */
-	unlink(CLIENT_SOCKNAME);
- 	unlink(ADMIN_SOCKNAME);
-
-	return 0;
-}
-
diff --git a/cman/daemon/daemon.h b/cman/daemon/daemon.h
deleted file mode 100644
index 6907de3..0000000
--- a/cman/daemon/daemon.h
+++ /dev/null
@@ -1,12 +0,0 @@
-extern int send_status_return(struct connection *con, uint32_t cmd, int status);
-extern int send_data_reply(struct connection *con, int nodeid, int port, char *data, int len);
-extern void set_cman_timeout(int secs);
-extern void notify_listeners(struct connection *con, int reason, int arg);
-extern int num_listeners(void);
-extern void cman_set_realtime(void);
-extern int cman_init(void);
-extern int cman_finish(void);
-extern void notify_confchg(struct sock_header *message);
-
-extern volatile sig_atomic_t quit_threads;
-extern int num_connections;
diff --git a/cman/daemon/list.h b/cman/daemon/list.h
deleted file mode 100644
index aaee167..0000000
--- a/cman/daemon/list.h
+++ /dev/null
@@ -1,97 +0,0 @@
-#ifndef _LVM_LIST_H
-#define _LVM_LIST_H
-
-#include <assert.h>
-
-struct list {
-	struct list *n, *p;
-};
-
-#define LIST_INIT(name)	struct list name = { &(name), &(name) }
-
-static inline void list_init(struct list *head)
-{
-	head->n = head->p = head;
-}
-
-static inline void list_add(struct list *head, struct list *elem)
-{
-	assert(head->n);
-
-	elem->n = head;
-	elem->p = head->p;
-
-	head->p->n = elem;
-	head->p = elem;
-}
-
-static inline void list_add_h(struct list *head, struct list *elem)
-{
-	assert(head->n);
-
-	elem->n = head->n;
-	elem->p = head;
-
-	head->n->p = elem;
-	head->n = elem;
-}
-
-static inline void list_del(struct list *elem)
-{
-	elem->n->p = elem->p;
-	elem->p->n = elem->n;
-}
-
-static inline int list_empty(struct list *head)
-{
-	return head->n == head;
-}
-
-static inline int list_end(struct list *head, struct list *elem)
-{
-	return elem->n == head;
-}
-
-static inline struct list *list_next(struct list *head, struct list *elem)
-{
-	return (list_end(head, elem) ? NULL : elem->n);
-}
-
-#define list_item(v, t) \
-    ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->list))
-
-#define list_struct_base(v, t, h) \
-    ((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->h))
-
-/* Given a known element in a known structure, locate another */
-#define struct_field(v, t, e, f) \
-    (((t *)((uintptr_t)(v) - (uintptr_t)&((t *) 0)->e))->f)
-
-/* Given a known element in a known structure, locate the list head */
-#define list_head(v, t, e) struct_field(v, t, e, list)
-
-#define list_iterate(v, head) \
-	for (v = (head)->n; v != head; v = v->n)
-
-#define list_uniterate(v, head, start) \
-	for (v = (start)->p; v != head; v = v->p)
-
-#define list_iterate_safe(v, t, head) \
-	for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
-
-#define list_iterate_items(v, head) \
-	for (v = list_item((head)->n, typeof(*v)); &v->list != (head); \
-	     v = list_item(v->list.n, typeof(*v)))
-
-static inline unsigned int list_size(const struct list *head)
-{
-	unsigned int s = 0;
-	const struct list *v;
-
-	list_iterate(v, head)
-	    s++;
-
-	return s;
-}
-
-#endif
diff --git a/cman/daemon/logging.c b/cman/daemon/logging.c
deleted file mode 100644
index ad3359f..0000000
--- a/cman/daemon/logging.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <signal.h>
-#include <time.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-
-#include <corosync/engine/logsys.h>
-#include "list.h"
-#include "cman.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-#include "logging.h"
-
-LOGSYS_DECLARE_SUBSYS (CMAN_NAME, LOG_INFO);
-
-int subsys_mask = 0;
-
-void set_debuglog(int subsystems)
-{
-	subsys_mask = subsystems;
-}
diff --git a/cman/daemon/logging.h b/cman/daemon/logging.h
deleted file mode 100644
index 23ecb90..0000000
--- a/cman/daemon/logging.h
+++ /dev/null
@@ -1,17 +0,0 @@
-//#include <corosync/service/logsys.h>
-
-extern void set_debuglog(int subsystems);
-
-/* Debug macros */
-#define CMAN_DEBUG_NONE    1
-#define CMAN_DEBUG_BARRIER 2
-#define CMAN_DEBUG_MEMB    4
-#define CMAN_DEBUG_DAEMON  8
-#define CMAN_DEBUG_AIS    16
-
-extern int subsys_mask;
-
-#define P_BARRIER(fmt, args...) if (subsys_mask & CMAN_DEBUG_BARRIER) log_printf(LOG_LEVEL_DEBUG, "barrier: " fmt, ## args)
-#define P_MEMB(fmt, args...)    if (subsys_mask & CMAN_DEBUG_MEMB) log_printf(LOG_LEVEL_DEBUG, "memb: " fmt, ## args)
-#define P_DAEMON(fmt, args...)  if (subsys_mask & CMAN_DEBUG_DAEMON) log_printf(LOG_LEVEL_DEBUG , "daemon: " fmt, ## args)
-#define P_AIS(fmt, args...)     if (subsys_mask & CMAN_DEBUG_AIS) log_printf(LOG_LEVEL_DEBUG, "ais " fmt, ## args)
diff --git a/cman/daemon/nodelist.h b/cman/daemon/nodelist.h
deleted file mode 100644
index 02dfe17..0000000
--- a/cman/daemon/nodelist.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* These just make the access a little neater */
-static inline int objdb_get_string(OBJDB_API *corosync, unsigned int object_service_handle,
-				   char *key, char **value)
-{
-	int res;
-
-	*value = NULL;
-	if ( !(res = corosync->object_key_get(object_service_handle,
-					      key,
-					      strlen(key),
-					      (void *)value,
-					      NULL))) {
-		if (*value)
-			return 0;
-	}
-	return -1;
-}
-
-static inline void objdb_get_int(OBJDB_API *corosync, unsigned int object_service_handle,
-				 char *key, unsigned int *intvalue, unsigned int default_value)
-{
-	char *value = NULL;
-
-	*intvalue = default_value;
-
-	if (!corosync->object_key_get(object_service_handle, key, strlen(key),
-				 (void *)&value, NULL)) {
-		if (value) {
-			*intvalue = atoi(value);
-		}
-	}
-}
-
-
-/* Helper functions for navigating the nodes list */
-static inline unsigned int nodeslist_init(OBJDB_API *corosync,
-					  unsigned int cluster_parent_handle,
-					  unsigned int *find_handle)
-{
-	unsigned int object_handle;
-	unsigned int find_handle1;
-	unsigned int find_handle2;
-
-	corosync->object_find_create(cluster_parent_handle,"clusternodes", strlen("clusternodes"), &find_handle1);
-	if (corosync->object_find_next(find_handle1, &object_handle) == 0)
-	{
-		unsigned int nodes_handle;
-		corosync->object_find_destroy(find_handle1);
-
-		corosync->object_find_create(object_handle,"clusternode", strlen("clusternode"), &find_handle2);
-
-		if (corosync->object_find_next(find_handle2, &nodes_handle) == 0)
-		{
-			*find_handle = find_handle2;
-			return nodes_handle;
-		}
-	}
-	return 0;
-}
-
-static inline unsigned int nodeslist_next(OBJDB_API *corosync, unsigned int find_handle)
-{
-	unsigned int nodes_handle;
-
-	if (corosync->object_find_next(find_handle, &nodes_handle) == 0)
-		return nodes_handle;
-	else
-		return 0;
-}
-
-static inline unsigned int nodelist_byname(OBJDB_API *corosync,
-					   unsigned int cluster_parent_handle,
-					   char *name)
-{
-	char *nodename;
-	unsigned int nodes_handle;
-	unsigned int find_handle = 0;
-
-	nodes_handle = nodeslist_init(corosync, cluster_parent_handle, &find_handle);
-	while (nodes_handle) {
-		if (objdb_get_string(corosync, nodes_handle, "name", &nodename)) {
-			nodes_handle = nodeslist_next(corosync, find_handle);
-			continue;
-		}
-		if (strcmp(nodename, name) == 0)
-			return nodes_handle;
-
-		nodes_handle = nodeslist_next(corosync, find_handle);
-	}
-	corosync->object_find_destroy(find_handle);
-
-	return 0;
-}
diff --git a/cman/lib/Makefile b/cman/lib/Makefile
deleted file mode 100644
index da32992..0000000
--- a/cman/lib/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-TARGET= libcman
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/libs.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I${cmanincdir} -I$(S)/../daemon
-CFLAGS += -I${incdir}
diff --git a/cman/lib/libcman.c b/cman/lib/libcman.c
deleted file mode 100644
index b05011c..0000000
--- a/cman/lib/libcman.c
+++ /dev/null
@@ -1,1108 +0,0 @@
-#include <sys/types.h>
-#include <sys/un.h>
-#include <inttypes.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include "cnxman-socket.h"
-#include "libcman.h"
-
-/* List of saved messages */
-struct saved_message
-{
-	struct sock_header *msg;
-	struct saved_message *next;
-};
-
-struct cman_handle
-{
-	int magic;
-	int fd;
-	int zero_fd;
-	void *privdata;
-	int want_reply;
-	cman_callback_t event_callback;
-	cman_datacallback_t data_callback;
-	cman_confchgcallback_t confchg_callback;
-
-	void *reply_buffer;
-	int reply_buflen;
-	int reply_status;
-
-	struct saved_message *saved_data_msg;
-	struct saved_message *saved_event_msg;
-	struct saved_message *saved_reply_msg;
-};
-
-#define VALIDATE_HANDLE(h) do {if (!(h) || (h)->magic != CMAN_MAGIC) {errno = EINVAL; return -1;}} while (0)
-
-/*
- * Wait for an command/request reply.
- * Data/event messages will be queued.
- *
- */
-static int wait_for_reply(struct cman_handle *h, void *msg, int max_len)
-{
-	int ret;
-
-	h->want_reply = 1;
-	h->reply_buffer = msg;
-	h->reply_buflen = max_len;
-
-	do
-	{
-		ret = cman_dispatch(h, CMAN_DISPATCH_BLOCKING | CMAN_DISPATCH_IGNORE_EVENT | CMAN_DISPATCH_IGNORE_DATA);
-
-	} while (h->want_reply == 1 && ret >= 0);
-
-	h->reply_buffer = NULL;
-	h->reply_buflen = 0;
-
-	/* Error in local comms */
-	if (ret < 0) {
-		return -1;
-	}
-	/* cnxman daemon returns -ve errno values on error */
-	if (h->reply_status < 0) {
-		errno = -h->reply_status;
-		return -1;
-	}
-	else {
-		return h->reply_status;
-	}
-}
-
-
-static void copy_node(cman_node_t *unode, struct cl_cluster_node *knode)
-{
-	unode->cn_nodeid = knode->node_id;
-	unode->cn_member = knode->state == NODESTATE_MEMBER?1:0;
-	strcpy(unode->cn_name, knode->name);
-	unode->cn_incarnation = knode->incarnation;
-	unode->cn_jointime = knode->jointime;
-
-	memset(&unode->cn_address, 0, sizeof(unode->cn_address));
-	memcpy(&unode->cn_address.cna_address, knode->addr, knode->addrlen);
-	unode->cn_address.cna_addrlen = knode->addrlen;
-}
-
-/* Add to a list. saved_message *m is the head of the list in the cman_handle */
-static void add_to_waitlist(struct saved_message **m, struct sock_header *msg)
-{
-	struct saved_message *next = *m;
-	struct saved_message *last = *m;
-	struct saved_message *this;
-
-	this = malloc(sizeof(struct saved_message));
-	if (!this)
-		return;
-
-	this->msg = malloc(msg->length);
-	if (!this->msg)
-	{
-		free(this);
-		return;
-	}
-
-	memcpy(this->msg, msg, msg->length);
-	this->next = NULL;
-
-	if (!next)
-	{
-		*m = this;
-		return;
-	}
-
-	for (; next; next = next->next)
-	{
-		last = next;
-	}
-	last->next = this;
-}
-
-static int process_cman_message(struct cman_handle *h, int flags, struct sock_header *msg)
-{
-	/* Data for us */
-	if ((msg->command & CMAN_CMDMASK_CMD) == CMAN_CMD_DATA)
-	{
-		struct sock_data_header *dmsg = (struct sock_data_header *)msg;
-		char *buf = (char *)msg;
-
-		if (flags & CMAN_DISPATCH_IGNORE_DATA)
-		{
-			add_to_waitlist(&h->saved_data_msg, msg);
-		}
-		else
-		{
-			if (h->data_callback)
-				h->data_callback(h, h->privdata,
-						 buf+sizeof(*dmsg), msg->length-sizeof(*dmsg),
-						 dmsg->port, dmsg->nodeid);
-		}
-		return 0;
-	}
-
-	/* Got a reply to a previous information request */
-	if ((msg->command & CMAN_CMDFLAG_REPLY) && h->want_reply)
-	{
-		char *replybuf = (char *)msg;
-		int replylen = msg->length - sizeof(struct sock_reply_header);
-		struct sock_reply_header *reply = (struct sock_reply_header *)msg;
-
-		if (flags & CMAN_DISPATCH_IGNORE_REPLY)
-		{
-			add_to_waitlist(&h->saved_reply_msg, msg);
-			return 0;
-		}
-
-		replybuf += sizeof(struct sock_reply_header);
-		if (replylen <= h->reply_buflen)
-		{
-			memcpy(h->reply_buffer, replybuf, replylen);
-		}
-		h->want_reply = 0;
-		h->reply_status = reply->status;
-
-		return 1;
-	}
-
-	/* OOB event */
-	if (msg->command == CMAN_CMD_EVENT || msg->command == CMAN_CMD_CONFCHG)
-	{
-		if (flags & CMAN_DISPATCH_IGNORE_EVENT)
-		{
-			add_to_waitlist(&h->saved_event_msg, msg);
-		}
-		else
-		{
-			if (msg->command == CMAN_CMD_EVENT && h->event_callback) {
-				struct sock_event_message *emsg = (struct sock_event_message *)msg;
-				h->event_callback(h, h->privdata, emsg->reason, emsg->arg);
-			}
-
-			if (msg->command == CMAN_CMD_CONFCHG && h->confchg_callback)
-			{
-				struct sock_confchg_message *cmsg = (struct sock_confchg_message *)msg;
-
-				h->confchg_callback(h, h->privdata,
-						    cmsg->entries,cmsg->member_entries, 
-						    &cmsg->entries[cmsg->member_entries], cmsg->left_entries, 
-						    &cmsg->entries[cmsg->member_entries+cmsg->left_entries], cmsg->joined_entries);
-			}
-		}
-	}
-
-	return 0;
-}
-
-static int loopy_writev(int fd, struct iovec *iovptr, size_t iovlen)
-{
-	size_t byte_cnt=0;
-	int len;
-
-	while (iovlen > 0)
-	{
-		len = writev(fd, iovptr, iovlen);
-		if (len <= 0)
-			return len;
-
-		byte_cnt += len;
-		while (len >= iovptr->iov_len)
-		{
-			len -= iovptr->iov_len;
-			iovptr++;
-			iovlen--;
-		}
-
-		if ((ssize_t)iovlen <=0 )
-			break;
-
-		iovptr->iov_base += len;
-		iovptr->iov_len -= len;
-	}
-	return byte_cnt;
-}
-
-
-static int send_message(struct cman_handle *h, int msgtype, const void *inbuf, int inlen)
-{
-	struct sock_header header;
-	size_t len;
-	struct iovec iov[2];
-	size_t iovlen = 1;
-
-	header.magic = CMAN_MAGIC;
-	header.version = CMAN_VERSION;
-	header.command = msgtype;
-	header.flags = 0;
-	header.length = sizeof(header) + inlen;
-
-	iov[0].iov_len = sizeof(header);
-	iov[0].iov_base = &header;
-	if (inbuf)
-	{
-		iov[1].iov_len = inlen;
-		iov[1].iov_base = (void *) inbuf;
-		iovlen++;
-	}
-
-	len = loopy_writev(h->fd, iov, iovlen);
-	if (len < 0)
-		return len;
-	return 0;
-}
-
-/* Does something similar to the ioctl calls */
-static int info_call(struct cman_handle *h, int msgtype, const void *inbuf, int inlen, void *outbuf, int outlen)
-{
-	if (send_message(h, msgtype, inbuf, inlen))
-		return -1;
-
-	return wait_for_reply(h, outbuf, outlen);
-}
-
-static cman_handle_t open_socket(const char *name, int namelen, void *privdata)
-{
-	struct cman_handle *h;
-	struct sockaddr_un sockaddr;
-
-	h = malloc(sizeof(struct cman_handle));
-	if (!h)
-		return NULL;
-
-	h->magic = CMAN_MAGIC;
-	h->privdata = privdata;
-	h->event_callback = NULL;
-	h->data_callback = NULL;
-	h->confchg_callback = NULL;
-	h->want_reply = 0;
-	h->saved_data_msg = NULL;
-	h->saved_event_msg = NULL;
-	h->saved_reply_msg = NULL;
-
-	h->fd = socket(PF_UNIX, SOCK_STREAM, 0);
-	if (h->fd == -1)
-	{
-		int saved_errno = errno;
-		free(h);
-		errno = saved_errno;
-		return NULL;
-	}
-
-	fcntl(h->fd, F_SETFD, 1); /* Set close-on-exec */
-	memset(&sockaddr, 0, sizeof(sockaddr));
-	memcpy(sockaddr.sun_path, name, namelen);
-	sockaddr.sun_family = AF_UNIX;
-
-	if (connect(h->fd, (struct sockaddr *) &sockaddr, sizeof(sockaddr)) < 0)
-	{
-		int saved_errno = errno;
-		close(h->fd);
-		free(h);
-		errno = saved_errno;
-		return NULL;
-	}
-
-	/* Get a handle on /dev/zero too. This is always active so we
-	   can return it from cman_get_fd() if we have cached messages */
-	h->zero_fd = open("/dev/zero", O_RDONLY);
-	if (h->zero_fd < 0)
-	{
-		int saved_errno = errno;
-		close(h->fd);
-		free(h);
-		h = NULL;
-		errno = saved_errno;
-	}
-
-	return (cman_handle_t)h;
-}
-
-cman_handle_t cman_admin_init(void *privdata)
-{
-	return open_socket(ADMIN_SOCKNAME, sizeof(ADMIN_SOCKNAME), privdata);
-}
-
-cman_handle_t cman_init(void *privdata)
-{
-	return open_socket(CLIENT_SOCKNAME, sizeof(CLIENT_SOCKNAME), privdata);
-}
-
-int cman_finish(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	h->magic = 0;
-	close(h->fd);
-	close(h->zero_fd);
-	free(h);
-
-	return 0;
-}
-
-int cman_setprivdata(cman_handle_t handle, void *privdata)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	h->privdata = privdata;
-	return 0;
-}
-
-int cman_getprivdata(cman_handle_t handle, void **privdata)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	*privdata = h->privdata;
-
-	return 0;
-}
-
-
-int cman_start_notification(cman_handle_t handle, cman_callback_t callback)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!callback)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	if (info_call(h, CMAN_CMD_NOTIFY, NULL, 0, NULL, 0))
-		return -1;
-	h->event_callback = callback;
-
-	return 0;
-}
-
-int cman_stop_notification(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (info_call(h, CMAN_CMD_REMOVENOTIFY, NULL, 0, NULL, 0))
-		return -1;
-	h->event_callback = NULL;
-
-	return 0;
-}
-
-int cman_start_confchg(cman_handle_t handle, cman_confchgcallback_t callback)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!callback)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	if (info_call(h, CMAN_CMD_START_CONFCHG, NULL, 0, NULL, 0))
-		return -1;
-	h->confchg_callback = callback;
-
-	return 0;
-}
-
-int cman_stop_confchg(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (info_call(h, CMAN_CMD_STOP_CONFCHG, NULL, 0, NULL, 0))
-		return -1;
-	h->confchg_callback = NULL;
-
-	return 0;
-}
-
-
-int cman_get_fd(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	/* If we have saved messages then return an FD to /dev/zero which
-	   will always be readable */
-	if (h->saved_data_msg || h->saved_event_msg || h->saved_reply_msg)
-		return h->zero_fd;
-	else
-		return h->fd;
-}
-
-int cman_dispatch(cman_handle_t handle, int flags)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	int len;
-	int offset;
-	int recv_flags = 0;
-	char buf[PIPE_BUF];
-	VALIDATE_HANDLE(h);
-
-	if (!(flags & CMAN_DISPATCH_BLOCKING))
-		recv_flags |= MSG_DONTWAIT;
-
-	do
-	{
-		int res;
-		char *bufptr = buf;
-		struct sock_header *header = (struct sock_header *)buf;
-
-		/* First, drain any waiting queues */
-		if (h->saved_reply_msg && !(flags & CMAN_DISPATCH_IGNORE_REPLY))
-		{
-			struct saved_message *smsg = h->saved_reply_msg;
-
-			res = process_cman_message(h, flags, smsg->msg);
-			h->saved_reply_msg = smsg->next;
-			len = smsg->msg->length;
-			free(smsg->msg);
-			free(smsg);
-			if (res || (flags & CMAN_DISPATCH_ONE))
-				break;
-			else
-				continue;
-		}
-		if (h->saved_data_msg && !(flags & CMAN_DISPATCH_IGNORE_DATA))
-		{
-			struct saved_message *smsg = h->saved_data_msg;
-
-			res = process_cman_message(h, flags, smsg->msg);
-			h->saved_data_msg = smsg->next;
-			len = smsg->msg->length;
-			free(smsg->msg);
-			free(smsg);
-			if (res || (flags & CMAN_DISPATCH_ONE))
-				break;
-			else
-				continue;
-		}
-		if (h->saved_event_msg && !(flags & CMAN_DISPATCH_IGNORE_EVENT))
-		{
-			struct saved_message *smsg = h->saved_event_msg;
-
-			res = process_cman_message(h, flags, smsg->msg);
-			h->saved_event_msg = smsg->next;
-			len = smsg->msg->length;
-			free(smsg->msg);
-			free(smsg);
-			if (res || (flags & CMAN_DISPATCH_ONE))
-				break;
-			else
-				continue;
-		}
-
-		/* Now look for new messages */
-		len = recv(h->fd, buf, sizeof(struct sock_header), recv_flags);
-
-		if (len == 0) {
-			errno = EHOSTDOWN;
-			return -1;
-		}
-
-		if (len < 0 &&
-		    (errno == EINTR || errno == EAGAIN))
-			return 0;
-
-		if (len < 0)
-			return -1;
-
-		offset = len;
-
-		/* It's too big! */
-		if (header->length > sizeof(buf))
-		{
-			bufptr = malloc(header->length);
-			if (!bufptr)
-				return -1;
-			memcpy(bufptr, buf, sizeof(*header));
-			header = (struct sock_header *)bufptr;
-		}
-
-		/* Read the rest */
-		while (offset < header->length)
-		{
-			len = read(h->fd, bufptr+offset, header->length-offset);
-			if (len == 0) {
-				errno = EHOSTDOWN;
-				return -1;
-			}
-
-			if (len < 0 &&
-			    (errno == EINTR || errno == EAGAIN))
-				return 0;
-
-			if (len < 0)
-				return -1;
-			offset += len;
-		}
-
-		res = process_cman_message(h, flags, header);
-		if (bufptr != buf)
-			free(bufptr);
-
-		if (res)
-			break;
-
-	} while ( flags & CMAN_DISPATCH_ALL &&
-		  !(len < 0 && errno == EAGAIN) );
-
-	return len;
-}
-
-/* GET_ALLMEMBERS returns the number of nodes as status */
-int cman_get_node_count(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, NULL, 0);
-}
-
-int cman_get_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_cluster_node *cman_nodes;
-	int status;
-	int buflen;
-	int count = 0;
-	VALIDATE_HANDLE(h);
-
-	if (!retnodes || !nodes || maxnodes < 1)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	buflen = sizeof(struct cl_cluster_node) * maxnodes;
-	cman_nodes = malloc(buflen);
-	if (!cman_nodes)
-		return -1;
-
-	status = info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, cman_nodes, buflen);
-	if (status < 0)
-	{
-		int saved_errno = errno;
-		free(cman_nodes);
-		errno = saved_errno;
-		return -1;
-	}
-
-	if (cman_nodes[0].size != sizeof(struct cl_cluster_node))
-	{
-		free(cman_nodes);
-		errno = EINVAL;
-		return -1;
-	}
-
-	if (status > maxnodes)
-		status = maxnodes;
-
-	for (count = 0; count < status; count++)
-	{
-		copy_node(&nodes[count], &cman_nodes[count]);
-	}
-	free(cman_nodes);
-	*retnodes = status;
-	return 0;
-}
-
-int cman_get_disallowed_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_cluster_node *cman_nodes;
-	int status;
-	int buflen;
-	int count = 0;
-	int out_count = 0;
-	VALIDATE_HANDLE(h);
-
-	if (!retnodes || !nodes || maxnodes < 1)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	buflen = sizeof(struct cl_cluster_node) * maxnodes;
-	cman_nodes = malloc(buflen);
-	if (!cman_nodes)
-		return -1;
-
-	status = info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, cman_nodes, buflen);
-	if (status < 0)
-	{
-		int saved_errno = errno;
-		free(cman_nodes);
-		errno = saved_errno;
-		return -1;
-	}
-
-	if (cman_nodes[0].size != sizeof(struct cl_cluster_node))
-	{
-		free(cman_nodes);
-		errno = EINVAL;
-		return -1;
-	}
-
-	for (count = 0; count < status; count++)
-	{
-		if (cman_nodes[count].state == NODESTATE_AISONLY && out_count < maxnodes)
-			copy_node(&nodes[out_count++], &cman_nodes[count]);
-	}
-	free(cman_nodes);
-	*retnodes = out_count;
-	return 0;
-}
-
-int cman_get_node(cman_handle_t handle, int nodeid, cman_node_t *node)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_cluster_node cman_node;
-	int status;
-	VALIDATE_HANDLE(h);
-
-	if (!node || strlen(node->cn_name) > sizeof(cman_node.name))
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	cman_node.node_id = nodeid;
-	strcpy(cman_node.name, node->cn_name);
-	status = info_call(h, CMAN_CMD_GETNODE, &cman_node, sizeof(struct cl_cluster_node),
-			   &cman_node, sizeof(struct cl_cluster_node));
-	if (status < 0)
-		return -1;
-
-	copy_node(node, &cman_node);
-
-	return 0;
-}
-
-int cman_get_subsys_count(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_GET_JOINCOUNT, NULL,0, NULL, 0);
-}
-
-int cman_is_active(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_ISACTIVE, NULL, 0, NULL, 0);
-}
-
-int cman_is_listening(cman_handle_t handle, int nodeid, uint8_t port)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_listen_request req;
-	VALIDATE_HANDLE(h);
-
-	req.port = port;
-	req.nodeid = nodeid;
-	return info_call(h, CMAN_CMD_ISLISTENING, &req, sizeof(struct cl_listen_request), NULL, 0);
-}
-
-int cman_is_quorate(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_ISQUORATE, NULL, 0, NULL, 0);
-}
-
-
-int cman_get_version(cman_handle_t handle, cman_version_t *version)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!version)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	return info_call(h, CMAN_CMD_GET_VERSION, NULL, 0, version, sizeof(cman_version_t));
-}
-
-int cman_set_version(cman_handle_t handle, const cman_version_t *version)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!version)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	return info_call(h, CMAN_CMD_SET_VERSION, version, sizeof(cman_version_t), NULL, 0);
-}
-
-int cman_kill_node(cman_handle_t handle, int nodeid)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!nodeid)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	return info_call(h, CMAN_CMD_KILLNODE, &nodeid, sizeof(nodeid), NULL, 0);
-}
-
-int cman_set_votes(cman_handle_t handle, int votes, int nodeid)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_set_votes newv;
-	VALIDATE_HANDLE(h);
-
-	if (!votes)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	newv.nodeid = nodeid;
-	newv.newvotes  = votes;
-	return info_call(h, CMAN_CMD_SET_VOTES, &newv, sizeof(newv), NULL, 0);
-}
-
-int cman_set_expected_votes(cman_handle_t handle, int evotes)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!evotes)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	return info_call(h, CMAN_CMD_SETEXPECTED_VOTES, &evotes, sizeof(evotes), NULL, 0);
-}
-
-int cman_leave_cluster(cman_handle_t handle, int reason)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_LEAVE_CLUSTER, &reason, sizeof(reason), NULL, 0);
-}
-
-int cman_get_cluster(cman_handle_t handle, cman_cluster_t *clinfo)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!clinfo)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	return info_call(h, CMAN_CMD_GETCLUSTER, NULL, 0, clinfo, sizeof(cman_cluster_t));
-}
-
-int cman_get_extra_info(cman_handle_t handle, cman_extra_info_t *info, int maxlen)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	if (!info || maxlen < sizeof(cman_extra_info_t))
-	{
-		errno = EINVAL;
-		return -1;
-	}
-	return info_call(h, CMAN_CMD_GETEXTRAINFO, NULL, 0, info, maxlen);
-}
-
-int cman_send_data(cman_handle_t handle, const void *buf, int len, int flags, uint8_t port, int nodeid)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct iovec iov[2];
-	struct sock_data_header header;
-	VALIDATE_HANDLE(h);
-
-	header.header.magic = CMAN_MAGIC;
-	header.header.version = CMAN_VERSION;
-	header.header.command = CMAN_CMD_DATA;
-	header.header.flags = flags;
-	header.header.length = len + sizeof(header);
-	header.nodeid = nodeid;
-	header.port = port;
-
-	iov[0].iov_len = sizeof(header);
-	iov[0].iov_base = &header;
-	iov[1].iov_len = len;
-	iov[1].iov_base = (void *) buf;
-
-	return loopy_writev(h->fd, iov, 2);
-}
-
-
-int cman_start_recv_data(cman_handle_t handle, cman_datacallback_t callback, uint8_t port)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	int portparam;
-	int status;
-	VALIDATE_HANDLE(h);
-
-/* Do a "bind" */
-	portparam = port;
-	status = info_call(h, CMAN_CMD_BIND, &portparam, sizeof(portparam), NULL, 0);
-
-	if (status == 0)
-		h->data_callback = callback;
-
-	return status;
-}
-
-int cman_end_recv_data(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	h->data_callback = NULL;
-	return 0;
-}
-
-
-int cman_barrier_register(cman_handle_t handle, const char *name, int flags, int nodes)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_barrier_info binfo;
-	VALIDATE_HANDLE(h);
-
-	if (strlen(name) > MAX_BARRIER_NAME_LEN)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	binfo.cmd = BARRIER_CMD_REGISTER;
-	strcpy(binfo.name, name);
-	binfo.arg = nodes;
-	binfo.flags = flags;
-
-	return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-}
-
-
-int cman_barrier_change(cman_handle_t handle, const char *name, int flags, int arg)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_barrier_info binfo;
-	VALIDATE_HANDLE(h);
-
-	if (strlen(name) > MAX_BARRIER_NAME_LEN)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	binfo.cmd = BARRIER_CMD_CHANGE;
-	strcpy(binfo.name, name);
-	binfo.arg = arg;
-	binfo.flags = flags;
-
-	return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-
-}
-
-int cman_barrier_wait(cman_handle_t handle, const char *name)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_barrier_info binfo;
-	VALIDATE_HANDLE(h);
-
-	if (strlen(name) > MAX_BARRIER_NAME_LEN)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	binfo.cmd = BARRIER_CMD_WAIT;
-	strcpy(binfo.name, name);
-
-	return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-}
-
-int cman_barrier_delete(cman_handle_t handle, const char *name)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_barrier_info binfo;
-	VALIDATE_HANDLE(h);
-
-	if (strlen(name) > MAX_BARRIER_NAME_LEN)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	binfo.cmd = BARRIER_CMD_DELETE;
-	strcpy(binfo.name, name);
-
-	return info_call(h, CMAN_CMD_BARRIER, &binfo, sizeof(binfo), NULL, 0);
-}
-
-int cman_shutdown(cman_handle_t handle, int flags)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_TRY_SHUTDOWN, &flags, sizeof(int), NULL, 0);
-}
-
-int cman_set_dirty(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_SET_DIRTY, NULL, 0, NULL, 0);
-}
-
-int cman_set_debuglog(cman_handle_t handle, int subsystems)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_SET_DEBUGLOG, &subsystems, sizeof(int), NULL, 0);
-}
-
-int cman_replyto_shutdown(cman_handle_t handle, int yesno)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	send_message(h, CMAN_CMD_SHUTDOWN_REPLY, &yesno, sizeof(int));
-	return 0;
-}
-
-
-int cman_register_quorum_device(cman_handle_t handle, char *name, int votes)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	char buf[strlen(name)+1 + sizeof(int)];
-	VALIDATE_HANDLE(h);
-
-	if (strlen(name) > MAX_CLUSTER_MEMBER_NAME_LEN)
-	{
-		errno = EINVAL;
-		return -1;
-	}
-
-	memcpy(buf, &votes, sizeof(int));
-	strcpy(buf+sizeof(int), name);
-	return info_call(h, CMAN_CMD_REG_QUORUMDEV, buf, strlen(name)+1+sizeof(int), NULL, 0);
-}
-
-int cman_unregister_quorum_device(cman_handle_t handle)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_UNREG_QUORUMDEV, NULL, 0, NULL, 0);
-}
-
-int cman_poll_quorum_device(cman_handle_t handle, int isavailable)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_POLL_QUORUMDEV, &isavailable, sizeof(int), NULL, 0);
-}
-
-int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	int ret;
-	struct cl_cluster_node cman_node;
-	VALIDATE_HANDLE(h);
-
-	cman_node.node_id = CLUSTER_GETNODE_QUORUMDEV;
-	ret = info_call(h, CMAN_CMD_GETNODE, &cman_node, sizeof(cman_node), &cman_node, sizeof(cman_node));
-	if (!ret) {
-		strcpy(info->qi_name, cman_node.name);
-		info->qi_state = cman_node.state;
-		info->qi_votes = cman_node.votes;
-	}
-	return ret;
-}
-
-int cman_get_fenceinfo(cman_handle_t handle, int nodeid, uint64_t *time, int *fenced, char *agent)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	int ret;
-	struct cl_fence_info f;
-	VALIDATE_HANDLE(h);
-
-	ret = info_call(h, CMAN_CMD_GET_FENCE_INFO, &nodeid, sizeof(int), &f, sizeof(f));
-	if (!ret) {
-		*time = f.fence_time;
-		if (agent)
-			strcpy(agent, f.fence_agent);
-		*fenced = ((f.flags & FENCE_FLAGS_FENCED) != 0);
-	}
-	return ret;
-}
-
-int cman_get_node_addrs(cman_handle_t handle, int nodeid, int max_addrs, int *num_addrs, struct cman_node_address *addrs)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	int ret;
-	char buf[sizeof(struct cl_get_node_addrs) + sizeof(struct cl_node_addrs)*max_addrs];
-	struct cl_get_node_addrs *outbuf = (struct cl_get_node_addrs *)buf;
-	VALIDATE_HANDLE(h);
-
-	ret = info_call(h, CMAN_CMD_GET_NODEADDRS, &nodeid, sizeof(int), buf, sizeof(buf));
-	if (!ret) {
-		int i;
-
-		*num_addrs = outbuf->numaddrs;
-
-		if (outbuf->numaddrs > max_addrs)
-			outbuf->numaddrs = max_addrs;
-
-		for (i=0; i < outbuf->numaddrs; i++) {
-			memcpy(&addrs[i].cna_address, &outbuf->addrs[i].addr, outbuf->addrs[i].addrlen);
-			addrs[i].cna_addrlen = outbuf->addrs[i].addrlen;
-		}
-	}
-	return ret;
-}
-
-int cman_node_fenced(cman_handle_t handle, int nodeid, uint64_t time, char *agent)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	struct cl_fence_info f;
-	VALIDATE_HANDLE(h);
-
-	if (strlen(agent) >= MAX_FENCE_AGENT_NAME_LEN) {
-		errno = EINVAL;
-		return -1;
-	}
-
-	f.nodeid = nodeid;
-	f.fence_time = time;
-	strcpy(f.fence_agent, agent);
-	return info_call(h, CMAN_CMD_UPDATE_FENCE_INFO, &f, sizeof(f), NULL, 0);
-}
-
-#ifdef DEBUG
-int cman_dump_objdb(cman_handle_t handle, char *filename)
-{
-	struct cman_handle *h = (struct cman_handle *)handle;
-	VALIDATE_HANDLE(h);
-
-	return info_call(h, CMAN_CMD_DUMP_OBJDB, filename, strlen(filename)+1, NULL, 0);
-}
-#endif
diff --git a/cman/lib/libcman.h b/cman/lib/libcman.h
deleted file mode 100644
index 37058df..0000000
--- a/cman/lib/libcman.h
+++ /dev/null
@@ -1,423 +0,0 @@
-#ifndef _LIBCMAN_H_
-#define _LIBCMAN_H_
-
-#include <netinet/in.h>
-
-#define LIBCMAN_VERSION 3
-
-/*
- * Some maxima
- */
-#define CMAN_MAX_ADDR_LEN             sizeof(struct sockaddr_in6)
-#define CMAN_MAX_NODENAME_LEN         255
-#define MAX_CLUSTER_NAME_LEN           16
-#define CMAN_MAX_FENCE_AGENT_NAME_LEN 255
-
-/*
- * Pass this into cman_get_node() as the nodeid to get local node information
- */
-#define CMAN_NODEID_US     0
-
-/*
- * Pass this into cman_get_node() as the nodeid to get quorum device information
- */
-#define CMAN_NODEID_QDISK -1
-
-
-/* Pass this into cman_send_data to send a message to all nodes */
-#define CMAN_NODEID_ALL 0
-
-/*
- * Hang onto this, it's your key into the library. get one from cman_init() or
- * cman_admin_init()
- */
-typedef void *cman_handle_t;
-
-/*
- * Reasons we get an event callback.
- * PORTOPENED & TRY_SHUTDOWN only exist when LIBCMAN_VERSION >= 2
- *
- * The 'arg' parameter varies depending on the callback type.
- * for PORTCLOSED/PORTOPENED  arg == the port opened/closed
- * for STATECHANGE            arg is quorum state (1=quorate, 0=not)
- * for TRY_SHUTDOWN           arg == 1 for ANYWAY, otherwise 0 (ie if arg == 1 
- * 			      then cman WILL shutdown regardless
- *                            of your response, think of this as advance warning)
- * for CONFIG_UPDATE          arg will be the new config version
- */
-typedef enum {CMAN_REASON_PORTCLOSED,
-	      CMAN_REASON_STATECHANGE,
-              CMAN_REASON_PORTOPENED,
-              CMAN_REASON_TRY_SHUTDOWN,
-              CMAN_REASON_CONFIG_UPDATE} cman_call_reason_t;
-
-/*
- * Reason flags for cman_leave
- */
-#define CMAN_LEAVEFLAG_DOWN    0
-#define CMAN_LEAVEFLAG_REMOVED 3
-#define CMAN_LEAVEFLAG_FORCE   0x10
-
-/*
- * Flags for cman_shutdown
- *    ANYWAY   -  cman will shutdown regardless of clients' responses (but they
- *    		   will still get told)
- *    REMOVED  -  the rest of the cluster will adjust quorum to stay quorate
- */
-#define CMAN_SHUTDOWN_ANYWAY   1
-#define CMAN_SHUTDOWN_REMOVED  2
-
-/*
- * Flags passed to cman_dispatch():
- * CMAN_DISPATCH_ONE dispatches a single message then returns,
- * CMAN_DISPATCH_ALL dispatches all outstanding messages (ie till EAGAIN) then 
- *                   returns,
- * CMAN_DISPATCH_BLOCKING forces it to wait for a message (clears MSG_DONTWAIT 
- * 			  in recvmsg)
- * CMAN_DISPATCH_IGNORE_* allows the caller to select which messages to process.
- */
-#define CMAN_DISPATCH_ONE           0
-#define CMAN_DISPATCH_ALL           1
-#define CMAN_DISPATCH_BLOCKING      2
-#define CMAN_DISPATCH_IGNORE_REPLY  4
-#define CMAN_DISPATCH_IGNORE_DATA   8
-#define CMAN_DISPATCH_IGNORE_EVENT 16
-#define CMAN_DISPATCH_TYPE_MASK     3
-#define CMAN_DISPATCH_IGNORE_MASK  46
-
-/*
- * A node address. This is a complete sockaddr_in[6]
- * To explain:
- *  If you cast cna_address to a 'struct sockaddr', the sa_family field
- *  will be AF_INET or AF_INET6. Armed with that knowledge you can then
- *  cast it to a sockaddr_in or sockaddr_in6 and pull out the address.
- *  No other sockaddr fields are valid.
- *  Also, you must ignore any part of the sockaddr beyond the length supplied
- */
-typedef struct cman_node_address
-{
-	int  cna_addrlen;
-	char cna_address[CMAN_MAX_ADDR_LEN];
-} cman_node_address_t;
-
-/*
- * Return from cman_get_node()
- */
-typedef struct cman_node
-{
-	int cn_nodeid;
-	cman_node_address_t cn_address;
-	char cn_name[CMAN_MAX_NODENAME_LEN+1];
-	int cn_member;
-	int cn_incarnation;
-	struct timeval cn_jointime;
-} cman_node_t;
-
-/*
- * Returned from cman_get_version(),
- * input to cman_set_version(), though only cv_config can be changed
- */
-typedef struct cman_version
-{
-	unsigned int cv_major;
-	unsigned int cv_minor;
-	unsigned int cv_patch;
-	unsigned int cv_config;
-} cman_version_t;
-
-/*
- * Return from cman_get_cluster()
- */
-typedef struct cman_cluster
-{
-	char     ci_name[MAX_CLUSTER_NAME_LEN+1];
-	uint16_t ci_number;
-	uint32_t ci_generation;
-} cman_cluster_t;
-
-/*
- * This is returned from cman_get_extra_info - it's really
- * only for use by cman_tool, don't depend on this not changing
- */
-
-/* Flags in ei_flags */
-#define CMAN_EXTRA_FLAG_2NODE      1
-#define CMAN_EXTRA_FLAG_ERROR      2
-#define CMAN_EXTRA_FLAG_SHUTDOWN   4
-#define CMAN_EXTRA_FLAG_DISALLOWED 8
-#define CMAN_EXTRA_FLAG_DIRTY     16
-
-typedef struct cman_extra_info {
-	int           ei_node_state;
-	int           ei_flags;
-	int           ei_node_votes;
-	int           ei_total_votes;
-	int           ei_expected_votes;
-	int           ei_quorum;
-	int           ei_members;
-	char          ei_ports[32];
-	int           ei_num_addresses;
-	char          ei_addresses[1]; /* Array of num_addresses*sockaddr_storage*2
-					  First batch is the multicast address list */
-} cman_extra_info_t;
-
-/* Quorum device info, returned from cman_get_quorum_device() */
-typedef struct cman_qdev_info {
-	char qi_name[CMAN_MAX_NODENAME_LEN+1];
-	int  qi_state;
-	int  qi_votes;
-} cman_qdev_info_t;
-
-/*
- * NOTE: Apart from cman_replyto_shutdown(), you must not
- * call other cman_* functions while in these two callbacks:
- */
-
-/* Callback routine for a membership or other event */
-typedef void (*cman_callback_t)(cman_handle_t handle, void *privdata, int reason, int arg);
-
-/* Callback routine for data received */
-typedef void (*cman_datacallback_t)(cman_handle_t handle, void *privdata,
-				    char *buf, int len, uint8_t port, int nodeid);
-
-/* Callback for nodes joining/leaving */
-typedef void (*cman_confchgcallback_t)(cman_handle_t handle, void *privdata,
-				       unsigned int *member_list, int member_list_entries,
-				       unsigned int *left_list, int left_list_entries,
-				       unsigned int *joined_list, int joined_list_entries);
-
-/*
- * cman_init        returns the handle you need to pass to the other API calls.
- * cman_admin_init  opens admin socket for privileged operations.
- * cman_finish      destroys that handle.
- *
- * Note that admin sockets can't send data messages or receive callbacks.
- */
-cman_handle_t cman_init(void *privdata);
-cman_handle_t cman_admin_init(void *privdata);
-int cman_finish(cman_handle_t handle);
-
-/* Update/retrieve the private data */
-int cman_setprivdata(cman_handle_t h, void *privdata);
-int cman_getprivdata(cman_handle_t h, void **privdata);
-
-/*
- * Notification of membership change events. Note that these are sent after
- * a transition, so multiple nodes may have left or joined the cluster.
- */
-int cman_start_notification(cman_handle_t handle, cman_callback_t callback);
-int cman_stop_notification(cman_handle_t handle);
-
-/*
- * Start/stop AIS-style confchg callbacks. These are less racy than the
- * old cman callbacks in that the caller will get one for each AIS
- * confchg message and it will contain all of the nodes that joined &
- * left in that transition.
- */
-int cman_start_confchg(cman_handle_t handle, cman_confchgcallback_t callback);
-int cman_stop_confchg(cman_handle_t handle);
-
-/* Call this if you get a TRY_SHUTDOWN event to signal whether you
- * will let cman shutdown or not.
- * Note that getting this callback does not mean that cman WILL shutdown,
- * only that it might. To detect a cman shutdown see cman_dispatch() below.
- */
-int cman_replyto_shutdown(cman_handle_t, int yesno);
-
-
-/*
- * Get the internal CMAN fd so you can pass it into poll() or select().
- * When it's active then call cman_dispatch() on the handle to process the event
- * NOTE: This fd can change between calls to cman_dispatch() so always call this
- * routine to get the latest one. (This is mainly due to message caching).
- * One upshot of this is that you must never read or write this FD (it may on 
- * occasion point to /dev/zero if you have messages cached!)
- */
-int cman_get_fd(cman_handle_t handle);
-
-/*
- * cman_dispatch() will return -1 with errno == EHOSTDOWN if the cluster is
- * shut down, 0 if nothing was read, or a positive number if something was 
- * dispatched.
- */
-
-int cman_dispatch(cman_handle_t handle, int flags);
-
-
-/*
- * -----------------------------------------------------------------------------
- * Get info calls.
- */
-
-/* Return the number of nodes we know about. This will normally
- *  be the number of nodes in CCS 
- */
-int cman_get_node_count(cman_handle_t handle);
-
-/* Returns the number of connected clients. This isn't as useful as a it used to
- * be as a count >1 does not automatically mean cman won't shut down. Subsystems
- * can decide for themselves whether a clean shutdown is possible. 
- */
-int cman_get_subsys_count(cman_handle_t handle);
-
-/* Returns an array of node info structures. Call cman_get_node_count() first
- * to determine how big your array needs to be 
- */
-int cman_get_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes);
-
-/* Returns a list of nodes that are known to AIS but blocked from joining the
- * CMAN cluster because they rejoined with cluster without a cman_tool join 
- */
-int cman_get_disallowed_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes);
-
-/*
- * cman_get_node() can get node info by nodeid OR by name. If the first
- * char of node->cn_name is zero then the nodeid will be used, otherwise
- * the name will be used. I'll say this differently: If you want to look
- * up a node by nodeid, you MUST clear out the cman_node_t structure passed
- * into cman_get_node(). nodeid can be CMAN_NODEID_US.
- */
-int cman_get_node(cman_handle_t handle, int nodeid, cman_node_t *node);
-
-/* cman_get_node() only returns the first address of a node (whatever /that/
- * may mean). If you want to know all of them you need to call this.
- * max_addrs is the size of the 'addrs' array. num_addrs will be filled in by 
- * the number of addresses the node has, regardless of the size of max_addrs. 
- * So if you don't allocate enough space for the first call, you should know how
- * much is needed for a second!
- */
-int cman_get_node_addrs(cman_handle_t handle, int nodeid, int max_addrs, int *num_addrs, struct cman_node_address *addrs);
-
-/* Returns 1 if cman has completed initialisation and aisexec is running */
-int cman_is_active(cman_handle_t handle);
-
-/*
- * Returns 1 if a client is registered for data callbacks on a particular
- * port on a particular node. if cman returns -1 (errno==EBUSY) then it
- * doesn't currently know the status but has requested it, so try again
- * later or wait for a PORTOPENED notification.
- * nodeid can be CMAN_NODEID_US
- */
-int cman_is_listening(cman_handle_t handle, int nodeid, uint8_t port);
-
-/* Do we have quorum? */
-int cman_is_quorate(cman_handle_t handle);
-
-/* Return software & config (cluster.conf file) version */
-int cman_get_version(cman_handle_t handle, cman_version_t *version);
-
-/* Get cluster name and number */
-int cman_get_cluster(cman_handle_t handle, cman_cluster_t *clinfo);
-
-/* Get fence information for a node.
- * 'int *fenced' is only valid if the node is down, it is set to
- * 1 if the node has been fenced since it left the cluster.
- * agent should be CMAN_MAX_FENCE_AGENT_NAME_LEN
- */
-int cman_get_fenceinfo(cman_handle_t handle, int nodeid, uint64_t *fence_time, int *fenced, char *agent);
-
-/* Get stuff for cman_tool. Nobody else should use this */
-int cman_get_extra_info(cman_handle_t handle, cman_extra_info_t *info, int maxlen);
-
-/* Dump the objdb contents (only works if compiled with DEBUG enabled) */
-int cman_dump_objdb(cman_handle_t handle, char *filename);
-
-/*
- * -----------------------------------------------------------------------------
- * Admin functions. You will need privileges and have a handle created by 
- * cman_admin_init() to use them.
- */
-
-/* Change the config file version. This should be needed much less now, as 
- * cman will re-read the config file if a new node joins with a new config 
- * version */
-int cman_set_version(cman_handle_t handle, const cman_version_t *version);
-
-/* Deprecated in favour of cman_shutdown(). Use cman_tool anyway please. */
-int cman_leave_cluster(cman_handle_t handle, int reason);
-
-/* Change the number of votes for this node. NOTE: a CCS update will
-   overwrite this, so make sure you change both. Or, better, change CCS
-   and call set_version() */
-int cman_set_votes(cman_handle_t handle, int votes, int nodeid);
-
-/* As above, for expected_votes */
-int cman_set_expected_votes(cman_handle_t handle, int expected_votes);
-
-/* Tell a particular node to leave the cluster NOW */
-int cman_kill_node(cman_handle_t handle, int nodeid);
-
-/* Tell CMAN a node has been fenced, when and by what means. */
-int cman_node_fenced(cman_handle_t handle, int nodeid, uint64_t fence_time, char *agent);
-
-/*
- * cman_shutdown() will send a REASON_TRY_SHUTDOWN event to all
- * clients registered for notifications. They should respond by calling
- * cman_replyto_shutdown() to indicate whether they will allow
- * cman to close down or not. If cman gets >=1 "no" (0) replies or the
- * request times out (default 5 seconds) then shutdown will be
- * cancelled and cman_shutdown() will return -1 with errno == EBUSY.
- *
- * Set flags to CMAN_SHUTDOWN_ANYWAY to force shutdown. Clients will still
- * be notified /and/ they will know you want a forced shutdown.
- *
- * Setting flags to CMAN_SHUTDOWN_REMOVED will tell the rest of the
- * cluster to adjust quorum to keep running with this node has left
- */
-int cman_shutdown(cman_handle_t, int flags);
-
-/* -----------------------------------------------------------------------------
- * Data transmission API. Uses the same FD as the rest of the calls.
- * If the nodeid passed to cman_send_data() is zero then it will be
- * broadcast to all nodes in the cluster.
- * cman_start_recv_data() is like a bind(), and marks the port
- * as "listening". See cman_is_listening() above.
- */
-int cman_send_data(cman_handle_t handle, const void *buf, int len, int flags, uint8_t port, int nodeid);
-int cman_start_recv_data(cman_handle_t handle, cman_datacallback_t, uint8_t port);
-int cman_end_recv_data(cman_handle_t handle);
-
-/*
- * Barrier API.
- * Here for backwards compatibility. Most of the things you would achieve
- * with this can now be better done using openAIS services or just messaging.
- */
-int cman_barrier_register(cman_handle_t handle, const char *name, int flags, int nodes);
-int cman_barrier_change(cman_handle_t handle, const char *name, int flags, int arg);
-int cman_barrier_wait(cman_handle_t handle, const char *name);
-int cman_barrier_delete(cman_handle_t handle, const char *name);
-
-/*
- * Add your own quorum device here, needs an admin socket
- *
- * After creating a quorum device you will need to call 'poll_quorum_device'
- * at least once every (default) 10 seconds (this can be changed in CCS)
- * otherwise it will time-out and the cluster will lose its vote.
- */
-int cman_register_quorum_device(cman_handle_t handle, char *name, int votes);
-int cman_unregister_quorum_device(cman_handle_t handle);
-int cman_poll_quorum_device(cman_handle_t handle, int isavailable);
-int cman_get_quorum_device(cman_handle_t handle, struct cman_qdev_info *info);
-
-/*
- * Sets the dirty bit inside cman. This indicates that the node has
- * some internal 'state' (eg in a daemon, filesystem or lock manager)
- * and cannot merge with another cluster that already has state.
- * This needs an admin socket. It cannot be reset. 
- */
-int cman_set_dirty(cman_handle_t handle);
-
-
-/*
- * Changes the debug logging level inside cman.
- * subsystems is a bitmask of:
- */
-#define CMAN_DEBUGLOG_NONE       0
-#define CMAN_DEBUGLOG_BARRIER    2
-#define CMAN_DEBUGLOG_MEMBERSHIP 4
-#define CMAN_DEBUGLOG_DAEMON     8
-#define CMAN_DEBUGLOG_AIS       16
-
-int cman_set_debuglog(cman_handle_t handle, int subsystems);
-
-#endif
diff --git a/configure b/configure
index 424e83e..c7a0e52 100755
--- a/configure
+++ b/configure
@@ -153,7 +153,7 @@ if ($help || !$err) {
   print "--incdir=\tthe base directory for include files.  (Default: {prefix}/include)\n";
   print "--ccsincdir=\tthe base directory for ccs include files.  (Default: ./config/libs/libccsconfdb)\n";
   print "--ccslibdir=\tthe base directory for ccs libraries.  (Default: ./config/libs/libccsconfdb)\n";
-  print "--cmanincdir=\tthe base directory for cman include files.  (Default: ./cman/lib)\n";
+  print "--cmanincdir=\tthe base directory for cman include files.  (Default: ./cman/services/cman/lib)\n";
   print "--cmanlibdir=\tthe base directory for cman libraries.  (Default: ./cman/services/cman/lib)\n";
   print "--logtincdir=\tthe base directory for logthread include files.  (Default: ./common/liblogthread)\n";
   print "--logtlibdir=\tthe base directory for logthread libraries.  (Default: ./common/liblogthread)\n";
@@ -261,7 +261,7 @@ if (!$ccslibdir) {
   $ccslibdir="${objdir}/config/libs/libccsconfdb";
 }
 if (!$cmanincdir) {
-  $cmanincdir="${cdir}/cman/lib";
+  $cmanincdir="${cdir}/cman/services/cman/lib";
 }
 if (!$cmanlibdir) {
   $cmanlibdir="${objdir}/cman/services/cman/lib";



More information about the Cluster-cvs mailing list