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