Patch to add new api to logsys to get priority names from subsystem names.
[openais.git] / include / cpg.h
blobc2c40b6af3ca76d1020f58efafcccf3affc5ef36
1 /*
2 * Copyright (c) 2006 Red Hat, Inc.
4 * All rights reserved.
6 * Author: Patrick Caulfield (pcaulfi@redhat.com)
8 * This software licensed under BSD license, the text of which follows:
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither the name of the MontaVista Software, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
34 #ifndef OPENAIS_CPG_H_DEFINED
35 #define OPENAIS_CPG_H_DEFINED
37 #include <netinet/in.h>
39 /**
40 * @addtogroup cpg_openais
42 * @{
44 typedef uint64_t cpg_handle_t;
46 typedef enum {
47 CPG_DISPATCH_ONE,
48 CPG_DISPATCH_ALL,
49 CPG_DISPATCH_BLOCKING
50 } cpg_dispatch_t;
52 typedef enum {
53 CPG_TYPE_UNORDERED, /* not implemented */
54 CPG_TYPE_FIFO, /* same as agreed */
55 CPG_TYPE_AGREED,
56 CPG_TYPE_SAFE /* not implemented */
57 } cpg_guarantee_t;
59 typedef enum {
60 CPG_FLOW_CONTROL_DISABLED, /* flow control is disabled - new messages may be sent */
61 CPG_FLOW_CONTROL_ENABLED /* flow control is enabled - new messages should not be sent */
62 } cpg_flow_control_state_t;
64 typedef enum {
65 CPG_OK = 1,
66 CPG_ERR_LIBRARY = 2,
67 CPG_ERR_TIMEOUT = 5,
68 CPG_ERR_TRY_AGAIN = 6,
69 CPG_ERR_INVALID_PARAM = 7,
70 CPG_ERR_NO_MEMORY = 8,
71 CPG_ERR_BAD_HANDLE = 9,
72 CPG_ERR_ACCESS = 11,
73 CPG_ERR_NOT_EXIST = 12,
74 CPG_ERR_EXIST = 14,
75 CPG_ERR_NOT_SUPPORTED = 20,
76 CPG_ERR_SECURITY = 29,
77 CPG_ERR_TOO_MANY_GROUPS=30
78 } cpg_error_t;
80 typedef enum {
81 CPG_REASON_JOIN = 1,
82 CPG_REASON_LEAVE = 2,
83 CPG_REASON_NODEDOWN = 3,
84 CPG_REASON_NODEUP = 4,
85 CPG_REASON_PROCDOWN = 5
86 } cpg_reason_t;
88 struct cpg_address {
89 uint32_t nodeid;
90 uint32_t pid;
91 uint32_t reason;
94 #define CPG_MAX_NAME_LENGTH 128
95 struct cpg_name {
96 uint32_t length;
97 char value[CPG_MAX_NAME_LENGTH];
100 #define CPG_MEMBERS_MAX 128
102 typedef void (*cpg_deliver_fn_t) (
103 cpg_handle_t handle,
104 struct cpg_name *group_name,
105 uint32_t nodeid,
106 uint32_t pid,
107 void *msg,
108 int msg_len);
110 typedef void (*cpg_confchg_fn_t) (
111 cpg_handle_t handle,
112 struct cpg_name *group_name,
113 struct cpg_address *member_list, int member_list_entries,
114 struct cpg_address *left_list, int left_list_entries,
115 struct cpg_address *joined_list, int joined_list_entries);
117 typedef struct {
118 cpg_deliver_fn_t cpg_deliver_fn;
119 cpg_confchg_fn_t cpg_confchg_fn;
120 } cpg_callbacks_t;
122 /** @} */
125 * Create a new cpg connection
127 cpg_error_t cpg_initialize (
128 cpg_handle_t *handle,
129 cpg_callbacks_t *callbacks);
132 * Close the cpg handle
134 cpg_error_t cpg_finalize (
135 cpg_handle_t handle);
138 * Get a file descriptor on which to poll. cpg_handle_t is NOT a
139 * file descriptor and may not be used directly.
141 cpg_error_t cpg_fd_get (
142 cpg_handle_t handle,
143 int *fd);
146 * Get and set contexts for a CPG handle
148 cpg_error_t cpg_context_get (
149 cpg_handle_t handle,
150 void **context);
152 cpg_error_t cpg_context_set (
153 cpg_handle_t handle,
154 void *context);
158 * Dispatch messages and configuration changes
160 cpg_error_t cpg_dispatch (
161 cpg_handle_t handle,
162 cpg_dispatch_t dispatch_types);
165 * Join one or more groups.
166 * messages multicasted with cpg_mcast_joined will be sent to every
167 * group that has been joined on handle handle. Any message multicasted
168 * to a group that has been previously joined will be delivered in cpg_dispatch
170 cpg_error_t cpg_join (
171 cpg_handle_t handle,
172 struct cpg_name *group);
175 * Leave one or more groups
177 cpg_error_t cpg_leave (
178 cpg_handle_t handle,
179 struct cpg_name *group);
182 * Multicast to groups joined with cpg_join.
183 * The iovec described by iovec will be multicasted to all groups joined with
184 * the cpg_join interface for handle.
186 cpg_error_t cpg_mcast_joined (
187 cpg_handle_t handle,
188 cpg_guarantee_t guarantee,
189 struct iovec *iovec,
190 int iov_len);
194 * Get membership information from cpg
196 cpg_error_t cpg_membership_get (
197 cpg_handle_t handle,
198 struct cpg_name *groupName,
199 struct cpg_address *member_list,
200 int *member_list_entries);
202 cpg_error_t cpg_local_get (
203 cpg_handle_t handle,
204 unsigned int *local_nodeid);
206 cpg_error_t cpg_flow_control_state_get (
207 cpg_handle_t handle,
208 cpg_flow_control_state_t *flow_control_enabled);
210 #endif /* OPENAIS_CPG_H_DEFINED */