| 1 |
/* |
| 2 |
* ccmlib.h: internal definations for ccm library files. |
| 3 |
* |
| 4 |
* Copyright (c) International Business Machines Corp., 2002 |
| 5 |
* Author: Ram Pai ([email protected]) |
| 6 |
* |
| 7 |
* This library is free software; you can redistribute it and/or |
| 8 |
* modify it under the terms of the GNU Lesser General Public |
| 9 |
* License as published by the Free Software Foundation; either |
| 10 |
* version 2.1 of the License, or (at your option) any later version. |
| 11 |
* |
| 12 |
* This software is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 |
* Lesser General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU Lesser General Public |
| 18 |
* License along with this library; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
*/ |
| 21 |
#ifndef __CCMLIB_H_ |
| 22 |
#define __CCMLIB_H_ |
| 23 |
#include <errno.h> |
| 24 |
#include <unistd.h> |
| 25 |
#include <stdio.h> |
| 26 |
#include <assert.h> |
| 27 |
#include <stdlib.h> |
| 28 |
#include <glib.h> |
| 29 |
#include <string.h> |
| 30 |
#include <ipc.h> |
| 31 |
#include <clplumbing/realtime.h> |
| 32 |
#include <sys/time.h> |
| 33 |
|
| 34 |
#ifdef __CCM_LIBRARY__ |
| 35 |
#include <ocf/oc_event.h> |
| 36 |
void oc_ev_special(const oc_ev_t *, oc_ev_class_t , int ); |
| 37 |
#endif |
| 38 |
|
| 39 |
#define NODEIDSIZE 255 /* if this value is changed change it |
| 40 |
also in ccm.h */ |
| 41 |
#define CCMFIFO HA_VARRUNDIR "/heartbeat/ccm/ccm" /* if this value |
| 42 |
is changed change it also in ccm.h */ |
| 43 |
|
| 44 |
size_t strnlen(const char *, size_t); /*TOBEDONE*/ |
| 45 |
typedef struct born_s { |
| 46 |
int index; |
| 47 |
int bornon; |
| 48 |
} born_t; |
| 49 |
/* to be include by the client side of ccm */ |
| 50 |
typedef struct ccm_meminfo_s { |
| 51 |
int ev; |
| 52 |
int n; |
| 53 |
int trans; |
| 54 |
int quorum; |
| 55 |
born_t member[0]; |
| 56 |
} ccm_meminfo_t; |
| 57 |
|
| 58 |
/* bornon structure sent to the client */ |
| 59 |
typedef struct ccm_born_s { |
| 60 |
int n; |
| 61 |
born_t born[0]; |
| 62 |
} ccm_born_t; |
| 63 |
|
| 64 |
typedef struct ccm_llm_s { /* information about low level membership info */ |
| 65 |
int ev; |
| 66 |
uint n; /* number of nodes in the cluster */ |
| 67 |
int mynode; /* index of mynode */ |
| 68 |
struct node_s { |
| 69 |
uint Uuid; /* a cluster unique id for the node */ |
| 70 |
char Id[NODEIDSIZE]; |
| 71 |
} node[0]; |
| 72 |
} ccm_llm_t; |
| 73 |
#define CLLM_GET_MYNODE(cllm) cllm->mynode |
| 74 |
#define CLLM_GET_NODECOUNT(cllm) cllm->n |
| 75 |
#define CLLM_GET_UUID(cllm,i) cllm->node[i].Uuid |
| 76 |
#define CLLM_GET_MYUUID(cllm) CLLM_GET_UUID(cllm, CLLM_GET_MYNODE(cllm)) |
| 77 |
#define CLLM_GET_NODEID(cllm,i) cllm->node[i].Id |
| 78 |
#define CLLM_GET_MYNODEID(cllm) CLLM_GET_NODEID(cllm, CLLM_GET_MYNODE(cllm)) |
| 79 |
#define CLLM_SET_MYNODE(cllm,indx) cllm->mynode = indx |
| 80 |
#define CLLM_SET_NODECOUNT(cllm, count) cllm->n = count |
| 81 |
#define CLLM_SET_UUID(cllm,i, uuid) cllm->node[i].Uuid = uuid |
| 82 |
#define CLLM_SET_MYUUID(cllm, uuid) CLLM_SET_UUID(cllm, CLLM_GET_MYNODE(cllm), uuid) |
| 83 |
#define CLLM_SET_NODEID(cllm, i, name) \ |
| 84 |
(strncpy(cllm->node[i].Id,name,NODEIDSIZE)) |
| 85 |
#define CLLM_SET_MYNODEID(cllm, name) \ |
| 86 |
CLLM_SET_NODEID(cllm, CLLM_GET_MYNODE(cllm), name) |
| 87 |
|
| 88 |
#ifdef __CCM_LIBRARY__ |
| 89 |
typedef struct class_s { |
| 90 |
int type; |
| 91 |
oc_ev_callback_t *(*set_callback)(struct class_s *, |
| 92 |
oc_ev_callback_t(*)); |
| 93 |
gboolean (*handle_event) (struct class_s *); |
| 94 |
int (*activate) (struct class_s *); |
| 95 |
void (*unregister) (struct class_s *); |
| 96 |
gboolean (*is_my_nodeid) (struct class_s *, const oc_node_t *); |
| 97 |
void (*special) (struct class_s *, int); |
| 98 |
void *private; |
| 99 |
} class_t; |
| 100 |
class_t *oc_ev_memb_class(oc_ev_callback_t *); |
| 101 |
#endif |
| 102 |
|
| 103 |
#define CCM_EVICTED 1 |
| 104 |
#define CCM_NEW_MEMBERSHIP 2 |
| 105 |
#define CCM_INFLUX 3 |
| 106 |
#define CCM_LLM 4 |
| 107 |
|
| 108 |
|
| 109 |
#endif /* __CCMLIB_H_ */ |