1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the License). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/CDDL.txt 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/CDDL.txt. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets [] replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _CLUSTM_H_ 28 #define _CLUSTM_H_ 29 30 #pragma ident "@(#)clustm.h 1.6 08/05/20 SMI" 31 32 /* 33 * clustm.h 34 * 35 * Definitions needed to use the cluster monitor library. 36 */ 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * Cluster nodes are identified by integers starting from zero. 44 */ 45 typedef short nodeid_t; 46 47 /* 48 * THIS_NODE is used as the argument to cm_stop_node/cm_abort_node 49 * functions to specify the local node as the command target. 50 */ 51 #define THIS_NODEID ((nodeid_t)-2) 52 53 /* 54 * Cluster monitor handle. 55 */ 56 typedef void *clustmh_t; 57 58 /* 59 * The state of the node. 60 */ 61 typedef enum { 62 NS_NOTCONF, /* the node not configured */ 63 NS_UNKNOWN, /* the node state is unknown */ 64 NS_DOWN, /* the node is down */ 65 NS_START, /* executing the start transition */ 66 NS_RETURN, /* executing the return transition */ 67 NS_STOP, /* executing the stop transition */ 68 NS_ABORT, /* executing the abort transition */ 69 NS_BEGIN, /* in the begin state */ 70 NS_STEP, /* executing a reconfiguration step */ 71 NS_END /* in the end state */ 72 } nodestate_t; 73 74 /* 75 * Error codes returned from cluster monitor functions. 76 */ 77 typedef enum { 78 CS_SUCCESS, /* successful return */ 79 CS_BAD_CLUSTNAME, /* invalid cluster name */ 80 CS_BAD_NODEID, /* invalid nodeid */ 81 CS_INVAL, /* invalid parameter */ 82 CS_PERM, /* permission denied */ 83 CS_TIMEOUT, /* request to clustd timed out */ 84 CS_NOMEM, /* can't malloc */ 85 CS_VERS, /* bad protocol version number */ 86 CS_COMM /* can't communicate with clustd */ 87 } cm_stat_t; 88 89 /* 90 * Cluster membership information structure. 91 */ 92 typedef struct clust_state { 93 nodeid_t cs_nnodes; 94 nodeid_t cs_local_nodeid; 95 nodestate_t cs_curr_state; 96 int cs_min_quorum; 97 int cs_curr_quorum; 98 int cs_max_step; 99 int cs_curr_step; 100 unsigned long cs_rseqnum; 101 void *cs_all_nodes; 102 void *cs_curr_members; 103 } clust_state_t; 104 105 /* 106 * These macros should be used to access the cluster membership sets. 107 */ 108 #define CS_ISMEMBER(cs, nd) __clustm_ns_test((cs)->cs_curr_members, (nd)) 109 #define CS_ISCONFIG(cs, nd) __clustm_ns_test((cs)->cs_all_nodes, (nd)) 110 #define CS_HASQUORUM(cs) ((cs)->cs_curr_quorum >= (cs)->cs_min_quorum) 111 112 #ifdef _REENTRANT 113 extern int *__cm_errno(); 114 #define cm_errno (*(__cm_errno())) 115 #else 116 extern int cm_errno; 117 #endif /* _REENTRANT */ 118 119 /* 120 * Cluster monitor API functions. A zero return value indicates a successful 121 * completion, the value of -1 indicates an error. After an error, 122 * the cm_errno contains the specific error code (see cm_stat_t). 123 */ 124 #ifdef __STDC__ 125 extern clustmh_t cm_getclustmbyname(char *clustname); 126 extern void cm_freeclustmh(clustmh_t cmh); 127 128 extern int cm_stop_node(clustmh_t cmh, nodeid_t nodeid); 129 extern int cm_abort_node(clustmh_t cmh, nodeid_t nodeid); 130 extern int cm_stop_all(clustmh_t cmh); 131 extern int cm_abort_all(clustmh_t cmh); 132 extern int cm_reconfigure(clustmh_t cmh); 133 extern int cm_getstate(clustmh_t cmh, clust_state_t *csp); 134 extern void cm_freestate(clust_state_t *csp); 135 136 extern int cm_control(clustmh_t cmh, int cmd, void *arg); 137 extern void cm_perror(char *msg); 138 extern char *cm_sperror(); 139 140 extern int __clustm_ns_test(void *p, nodeid_t nd); 141 #else /* __STDC__ */ 142 extern clustmh_t cm_getclustmbyname(); 143 extern void cm_freeclustmh(); 144 145 extern int cm_stop_node(); 146 extern int cm_abort_node(); 147 extern int cm_stop_all(); 148 extern int cm_abort_all(); 149 extern int cm_reconfigure(); 150 extern int cm_getstate(); 151 extern void cm_freestate(); 152 153 extern int cm_control(); 154 extern void cm_perror(); 155 extern char *cm_sperror(); 156 157 extern int __clustm_ns_test(); 158 #endif /* __STDC__ */ 159 160 /* 161 * cm_control() is used for the following functions: 162 * 163 * int cm_control(clustmh_t cmh, CMSET_TIMEOUT, int timeout); 164 * int cm_control(clustmh_t cmh, CMGET_TIMEOUT, int *timeout); 165 * int cm_control(clustmh_t cmh, CMSET_RETRY_TIMEOUT, int timeout); 166 * int cm_control(clustmh_t cmh, CMGET_RETRY_TIMEOUT, int *timeout); 167 * (all the timeout values are in milliseconds). 168 */ 169 #define CMSET_TIMEOUT 1 170 #define CMGET_TIMEOUT 2 171 #define CMSET_RETRY_TIMEOUT 3 172 #define CMGET_RETRY_TIMEOUT 4 173 174 #ifdef __cplusplus 175 } 176 #endif 177 178 #endif /* _CLUSTM_H_ */ 179