1 /*	$NetBSD: clvmd-comms.h,v 1.1.1.3 2009/12/02 00:27:01 haad Exp $	*/
2 
3 /*
4  * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
5  * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
6  *
7  * This file is part of LVM2.
8  *
9  * This copyrighted material is made available to anyone wishing to use,
10  * modify, copy, or redistribute it subject to the terms and conditions
11  * of the GNU General Public License v.2.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  */
17 
18 /*
19  * Abstraction layer for clvmd cluster communications
20  */
21 
22 #ifndef _CLVMD_COMMS_H
23 #define _CLVMD_COMMS_H
24 
25 struct local_client;
26 
27 struct cluster_ops {
28 	void (*cluster_init_completed) (void);
29 
30 	int (*cluster_send_message) (const void *buf, int msglen,
31 				     const char *csid,
32 				     const char *errtext);
33 	int (*name_from_csid) (const char *csid, char *name);
34 	int (*csid_from_name) (char *csid, const char *name);
35 	int (*get_num_nodes) (void);
36 	int (*cluster_fd_callback) (struct local_client *fd, char *buf, int len,
37 				    const char *csid,
38 				    struct local_client **new_client);
39 	int (*get_main_cluster_fd) (void);	/* gets accept FD or cman cluster socket */
40 	int (*cluster_do_node_callback) (struct local_client *client,
41 					 void (*callback) (struct local_client *,
42 							   const char *csid,
43 							   int node_up));
44 	int (*is_quorate) (void);
45 
46 	void (*get_our_csid) (char *csid);
47 	void (*add_up_node) (const char *csid);
48 	void (*reread_config) (void);
49 	void (*cluster_closedown) (void);
50 
51 	int (*get_cluster_name)(char *buf, int buflen);
52 
53 	int (*sync_lock) (const char *resource, int mode,
54 			  int flags, int *lockid);
55 	int (*sync_unlock) (const char *resource, int lockid);
56 
57 };
58 
59 #ifdef USE_GULM
60 #  include "tcp-comms.h"
61 struct cluster_ops *init_gulm_cluster(void);
62 #define MAX_CSID_LEN 			GULM_MAX_CSID_LEN
63 #define MAX_CLUSTER_MEMBER_NAME_LEN	GULM_MAX_CLUSTER_MEMBER_NAME_LEN
64 #endif
65 
66 #ifdef USE_CMAN
67 #  include <netinet/in.h>
68 #  include "libcman.h"
69 #  define CMAN_MAX_CSID_LEN 4
70 #  ifndef MAX_CSID_LEN
71 #    define MAX_CSID_LEN CMAN_MAX_CSID_LEN
72 #  endif
73 #  undef MAX_CLUSTER_MEMBER_NAME_LEN
74 #  define MAX_CLUSTER_MEMBER_NAME_LEN   CMAN_MAX_NODENAME_LEN
75 #  define CMAN_MAX_CLUSTER_MESSAGE 1500
76 #  define CLUSTER_PORT_CLVMD 11
77 struct cluster_ops *init_cman_cluster(void);
78 #endif
79 
80 #ifdef USE_OPENAIS
81 #  include <openais/saAis.h>
82 #  include <corosync/totem/totem.h>
83 #  define OPENAIS_CSID_LEN (sizeof(int))
84 #  define OPENAIS_MAX_CLUSTER_MESSAGE         MESSAGE_SIZE_MAX
85 #  define OPENAIS_MAX_CLUSTER_MEMBER_NAME_LEN SA_MAX_NAME_LENGTH
86 #  ifndef MAX_CLUSTER_MEMBER_NAME_LEN
87 #    define MAX_CLUSTER_MEMBER_NAME_LEN       SA_MAX_NAME_LENGTH
88 #  endif
89 #  ifndef CMAN_MAX_CLUSTER_MESSAGE
90 #    define CMAN_MAX_CLUSTER_MESSAGE          MESSAGE_SIZE_MAX
91 #  endif
92 #  ifndef MAX_CSID_LEN
93 #    define MAX_CSID_LEN sizeof(int)
94 #  endif
95 struct cluster_ops *init_openais_cluster(void);
96 #endif
97 
98 #ifdef USE_COROSYNC
99 #  include <corosync/corotypes.h>
100 #  define COROSYNC_CSID_LEN (sizeof(int))
101 #  define COROSYNC_MAX_CLUSTER_MESSAGE         65535
102 #  define COROSYNC_MAX_CLUSTER_MEMBER_NAME_LEN CS_MAX_NAME_LENGTH
103 #  ifndef MAX_CLUSTER_MEMBER_NAME_LEN
104 #    define MAX_CLUSTER_MEMBER_NAME_LEN       CS_MAX_NAME_LENGTH
105 #  endif
106 #  ifndef CMAN_MAX_CLUSTER_MESSAGE
107 #    define CMAN_MAX_CLUSTER_MESSAGE          65535
108 #  endif
109 #  ifndef MAX_CSID_LEN
110 #    define MAX_CSID_LEN sizeof(int)
111 #  endif
112 struct cluster_ops *init_corosync_cluster(void);
113 #endif
114 
115 
116 #endif
117