Patch to remove segfault on the exiting of a service.
[openais.git] / include / evs.h
blobac987b8ed544b7f488c597cb8fddb384ac943175
1 /*
2 * Copyright (c) 2004 MontaVista Software, Inc.
3 * Copyright (c) 2006 Sun Microsystems, Inc.
5 * All rights reserved.
7 * Author: Steven Dake (sdake@mvista.com)
9 * This software licensed under BSD license, the text of which follows:
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither the name of the MontaVista Software, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived from this
21 * software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef OPENAIS_EVS_H_DEFINED
36 #define OPENAIS_EVS_H_DEFINED
38 #include <sys/types.h>
39 #include <netinet/in.h>
41 /**
42 * @defgroup openais Other API services provided by openais
44 /**
45 * @addtogroup evs_openais
47 * @{
50 typedef uint64_t evs_handle_t;
52 typedef enum {
53 EVS_DISPATCH_ONE,
54 EVS_DISPATCH_ALL,
55 EVS_DISPATCH_BLOCKING
56 } evs_dispatch_t;
58 typedef enum {
59 EVS_TYPE_UNORDERED, /* not implemented */
60 EVS_TYPE_FIFO, /* same as agreed */
61 EVS_TYPE_AGREED,
62 EVS_TYPE_SAFE /* not implemented */
63 } evs_guarantee_t;
65 typedef enum {
66 EVS_OK = 1,
67 EVS_ERR_LIBRARY = 2,
68 EVS_ERR_TIMEOUT = 5,
69 EVS_ERR_TRY_AGAIN = 6,
70 EVS_ERR_INVALID_PARAM = 7,
71 EVS_ERR_NO_MEMORY = 8,
72 EVS_ERR_BAD_HANDLE = 9,
73 EVS_ERR_ACCESS = 11,
74 EVS_ERR_NOT_EXIST = 12,
75 EVS_ERR_EXIST = 14,
76 EVS_ERR_NOT_SUPPORTED = 20,
77 EVS_ERR_SECURITY = 29,
78 EVS_ERR_TOO_MANY_GROUPS=30
79 } evs_error_t;
81 #define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
83 /** These are the things that get passed around */
84 struct evs_address {
85 unsigned int nodeid;
86 unsigned short family;
87 unsigned char addr[TOTEMIP_ADDRLEN];
90 struct evs_group {
91 char key[32];
94 typedef void (*evs_deliver_fn_t) (
95 unsigned int nodeid,
96 void *msg,
97 int msg_len);
99 typedef void (*evs_confchg_fn_t) (
100 unsigned int *member_list, int member_list_entries,
101 unsigned int *left_list, int left_list_entries,
102 unsigned int *joined_list, int joined_list_entries);
104 typedef struct {
105 evs_deliver_fn_t evs_deliver_fn;
106 evs_confchg_fn_t evs_confchg_fn;
107 } evs_callbacks_t;
109 /** @} */
112 * Create a new evs connection
114 evs_error_t evs_initialize (
115 evs_handle_t *handle,
116 evs_callbacks_t *callbacks);
119 * Close the evs handle
121 evs_error_t evs_finalize (
122 evs_handle_t handle);
125 * Get a file descriptor on which to poll. evs_handle_t is NOT a
126 * file descriptor and may not be used directly.
128 evs_error_t evs_fd_get (
129 evs_handle_t handle,
130 int *fd);
133 * Dispatch messages and configuration changes
135 evs_error_t evs_dispatch (
136 evs_handle_t handle,
137 evs_dispatch_t dispatch_types);
140 * Join one or more groups.
141 * messages multicasted with evs_mcast_joined will be sent to every
142 * group that has been joined on handle handle. Any message multicasted
143 * to a group that has been previously joined will be delivered in evs_dispatch
145 evs_error_t evs_join (
146 evs_handle_t handle,
147 struct evs_group *groups,
148 int group_cnt);
151 * Leave one or more groups
153 evs_error_t evs_leave (
154 evs_handle_t handle,
155 struct evs_group *groups,
156 int group_cnt);
159 * Multicast to groups joined with evs_join.
160 * The iovec described by iovec will be multicasted to all groups joined with
161 * the evs_join interface for handle.
163 evs_error_t evs_mcast_joined (
164 evs_handle_t handle,
165 evs_guarantee_t guarantee,
166 struct iovec *iovec,
167 int iov_len);
170 * Multicast to specified groups.
171 * Messages will be multicast to groups specified in the api call and not those
172 * that have been joined (unless they are in the groups parameter).
174 evs_error_t evs_mcast_groups (
175 evs_handle_t handle,
176 evs_guarantee_t guarantee,
177 struct evs_group *groups,
178 int group_cnt,
179 struct iovec *iovec,
180 int iov_len);
183 * Get membership information from evs
185 evs_error_t evs_membership_get (
186 evs_handle_t handle,
187 unsigned int *local_nodeid,
188 unsigned int *member_list,
189 unsigned int *member_list_entries);
191 #endif /* OPENAIS_EVS_H_DEFINED */