corosync  3.1.9
cpg.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006-2019 Red Hat, Inc.
3  *
4  * All rights reserved.
5  *
6  * Author: Christine Caulfield (ccaulfi@redhat.com)
7  * Author: Jan Friesse (jfriesse@redhat.com)
8  *
9  * This software licensed under BSD license, the text of which follows:
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions are met:
13  *
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.
22  *
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.
34  */
35 #ifndef COROSYNC_CPG_H_DEFINED
36 #define COROSYNC_CPG_H_DEFINED
37 
38 #include <netinet/in.h>
39 #include <sys/socket.h>
40 #include <corosync/corotypes.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
54 typedef uint64_t cpg_handle_t;
55 
59 typedef uint64_t cpg_iteration_handle_t;
60 
64 typedef enum {
70 
74 typedef enum {
78 
79 
83 typedef enum {
90 } cpg_reason_t;
91 
95 typedef enum {
100 
104 typedef enum {
106 } cpg_model_t;
107 
111 struct cpg_address {
112  uint32_t nodeid;
113  uint32_t pid;
114  uint32_t reason;
115 };
116 
117 #define CPG_MAX_NAME_LENGTH 128
118 
121 struct cpg_name {
122  uint32_t length;
124 };
125 
126 #define CPG_MEMBERS_MAX 128
127 
132  struct cpg_name group;
133  uint32_t nodeid;
134  uint32_t pid;
135 };
136 
140 struct cpg_ring_id {
141  uint32_t nodeid;
142  uint64_t seq;
143 };
144 
148 typedef void (*cpg_deliver_fn_t) (
149  cpg_handle_t handle,
150  const struct cpg_name *group_name,
151  uint32_t nodeid,
152  uint32_t pid,
157  void *msg,
158  size_t msg_len);
159 
163 typedef void (*cpg_confchg_fn_t) (
164  cpg_handle_t handle,
165  const struct cpg_name *group_name,
166  const struct cpg_address *member_list, size_t member_list_entries,
167  const struct cpg_address *left_list, size_t left_list_entries,
168  const struct cpg_address *joined_list, size_t joined_list_entries);
169 
173 typedef void (*cpg_totem_confchg_fn_t) (
174  cpg_handle_t handle,
175  struct cpg_ring_id ring_id,
176  uint32_t member_list_entries,
177  const uint32_t *member_list);
178 
182 typedef struct {
186 
190 typedef struct {
193 
194 #define CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF 0x01
195 
199 typedef struct {
204  unsigned int flags;
206 
207 
217  cpg_handle_t *handle,
218  cpg_callbacks_t *callbacks);
219 
229  cpg_handle_t *handle,
230  cpg_model_t model,
231  cpg_model_data_t *model_data,
232  void *context);
233 
240  cpg_handle_t handle);
241 
252  cpg_handle_t handle,
253  int *fd);
254 
262  cpg_handle_t handle,
263  uint32_t *size);
264 
272  cpg_handle_t handle,
273  void **context);
274 
282  cpg_handle_t handle,
283  void *context);
284 
292  cpg_handle_t handle,
293  cs_dispatch_flags_t dispatch_types);
294 
307  cpg_handle_t handle,
308  const struct cpg_name *group);
309 
317  cpg_handle_t handle,
318  const struct cpg_name *group);
319 
330  cpg_handle_t handle,
332  const struct iovec *iovec,
333  unsigned int iov_len);
334 
344  cpg_handle_t handle,
345  struct cpg_name *groupName,
346  struct cpg_address *member_list,
347  int *member_list_entries);
355  cpg_handle_t handle,
356  unsigned int *local_nodeid);
357 
365  cpg_handle_t handle,
366  cpg_flow_control_state_t *flow_control_enabled);
367 
376  cpg_handle_t handle,
377  size_t size,
378  void **buffer);
379 
387  cpg_handle_t handle,
388  void *buffer);
389 
399  cpg_handle_t handle,
401  void *msg,
402  size_t msg_len);
403 
413  cpg_handle_t handle,
414  cpg_iteration_type_t iteration_type,
415  const struct cpg_name *group,
416  cpg_iteration_handle_t *cpg_iteration_handle);
417 
425  cpg_iteration_handle_t handle,
426  struct cpg_iteration_description_t *description);
427 
434  cpg_iteration_handle_t handle);
435 
436 #ifdef __cplusplus
437 }
438 #endif
439 
440 #endif /* COROSYNC_CPG_H_DEFINED */
uint32_t pid
Definition: cpg.h:113
The cpg_ring_id struct.
Definition: cpg.h:140
The cpg_callbacks_t struct.
Definition: cpg.h:182
cs_error_t cpg_iteration_next(cpg_iteration_handle_t handle, struct cpg_iteration_description_t *description)
cpg_iteration_next
Definition: lib/cpg.c:1333
cs_error_t cpg_flow_control_state_get(cpg_handle_t handle, cpg_flow_control_state_t *flow_control_enabled)
cpg_flow_control_state_get
Definition: lib/cpg.c:844
#define CPG_MAX_NAME_LENGTH
Definition: cpg.h:117
cpg_deliver_fn_t cpg_deliver_fn
Definition: cpg.h:201
cpg_flow_control_state_t
The cpg_flow_control_state_t enum.
Definition: cpg.h:74
cs_error_t cpg_context_set(cpg_handle_t handle, void *context)
Set contexts for a CPG handle.
Definition: lib/cpg.c:351
cpg_confchg_fn_t cpg_confchg_fn
Definition: cpg.h:184
The cpg_name struct.
Definition: cpg.h:121
cs_error_t cpg_local_get(cpg_handle_t handle, unsigned int *local_nodeid)
cpg_local_get
Definition: lib/cpg.c:806
cs_error_t cpg_membership_get(cpg_handle_t handle, struct cpg_name *groupName, struct cpg_address *member_list, int *member_list_entries)
Get membership information from cpg.
Definition: lib/cpg.c:743
The cpg_address struct.
Definition: cpg.h:111
cs_error_t cpg_iteration_finalize(cpg_iteration_handle_t handle)
cpg_iteration_finalize
Definition: lib/cpg.c:1383
int guarantee
Definition: totemsrp.c:266
The cpg_iteration_description_t struct.
Definition: cpg.h:131
cpg_guarantee_t
The cpg_guarantee_t enum.
Definition: cpg.h:64
cpg_confchg_fn_t cpg_confchg_fn
Definition: cpg.h:202
cpg_reason_t
The cpg_reason_t enum.
Definition: cpg.h:83
cs_error_t cpg_fd_get(cpg_handle_t handle, int *fd)
Get a file descriptor on which to poll.
Definition: lib/cpg.c:294
cpg_model_t model
Definition: cpg.h:200
void(* cpg_confchg_fn_t)(cpg_handle_t handle, const struct cpg_name *group_name, const struct cpg_address *member_list, size_t member_list_entries, const struct cpg_address *left_list, size_t left_list_entries, const struct cpg_address *joined_list, size_t joined_list_entries)
The cpg_confchg_fn_t callback.
Definition: cpg.h:163
cs_error_t cpg_zcb_alloc(cpg_handle_t handle, size_t size, void **buffer)
cpg_zcb_alloc
Definition: lib/cpg.c:944
cpg_totem_confchg_fn_t cpg_totem_confchg_fn
Definition: cpg.h:203
unsigned int flags
Definition: cpg.h:204
cs_error_t cpg_zcb_mcast_joined(cpg_handle_t handle, cpg_guarantee_t guarantee, void *msg, size_t msg_len)
cpg_zcb_mcast_joined
Definition: lib/cpg.c:1050
void(* cpg_totem_confchg_fn_t)(cpg_handle_t handle, struct cpg_ring_id ring_id, uint32_t member_list_entries, const uint32_t *member_list)
The cpg_totem_confchg_fn_t callback.
Definition: cpg.h:173
not implemented
Definition: cpg.h:68
uint64_t cpg_handle_t
cpg_handle_t
Definition: cpg.h:54
cs_error_t cpg_mcast_joined(cpg_handle_t handle, cpg_guarantee_t guarantee, const struct iovec *iovec, unsigned int iov_len)
Multicast to groups joined with cpg_join.
Definition: lib/cpg.c:1192
cs_error_t
The cs_error_t enum.
Definition: corotypes.h:98
char value[CPG_MAX_NAME_LENGTH]
Definition: cpg.h:123
cs_error_t cpg_dispatch(cpg_handle_t handle, cs_dispatch_flags_t dispatch_types)
Dispatch messages and configuration changes.
Definition: lib/cpg.c:370
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition: corotypes.h:84
struct cpg_name group
Definition: cpg.h:132
uint32_t nodeid
Definition: cpg.h:112
cs_error_t cpg_join(cpg_handle_t handle, const struct cpg_name *group)
Join one or more groups.
Definition: lib/cpg.c:644
uint32_t nodeid
Definition: cpg.h:141
not implemented
Definition: cpg.h:65
cpg_model_t model
Definition: cpg.h:191
cpg_iteration_type_t
The cpg_iteration_type_t enum.
Definition: cpg.h:95
flow control is enabled - new messages should not be sent
Definition: cpg.h:76
flow control is disabled - new messages may be sent
Definition: cpg.h:75
void(* cpg_deliver_fn_t)(cpg_handle_t handle, const struct cpg_name *group_name, uint32_t nodeid, uint32_t pid, void *msg, size_t msg_len)
The cpg_deliver_fn_t callback.
Definition: cpg.h:148
cs_error_t cpg_finalize(cpg_handle_t handle)
Close the cpg handle.
Definition: lib/cpg.c:249
uint32_t reason
Definition: cpg.h:114
cs_error_t cpg_leave(cpg_handle_t handle, const struct cpg_name *group)
Leave one or more groups.
Definition: lib/cpg.c:698
cs_error_t cpg_model_initialize(cpg_handle_t *handle, cpg_model_t model, cpg_model_data_t *model_data, void *context)
Create a new cpg connection, initialize with model.
Definition: lib/cpg.c:185
cs_error_t cpg_context_get(cpg_handle_t handle, void **context)
Get contexts for a CPG handle.
Definition: lib/cpg.c:332
uint64_t cpg_iteration_handle_t
cpg_iteration_handle_t
Definition: cpg.h:59
uint32_t length
Definition: cpg.h:122
cs_error_t cpg_initialize(cpg_handle_t *handle, cpg_callbacks_t *callbacks)
Create a new cpg connection.
Definition: lib/cpg.c:169
The cpg_model_v1_data_t struct.
Definition: cpg.h:199
cpg_model_t
The cpg_model_t enum.
Definition: cpg.h:104
The cpg_model_data_t struct.
Definition: cpg.h:190
cs_error_t cpg_iteration_initialize(cpg_handle_t handle, cpg_iteration_type_t iteration_type, const struct cpg_name *group, cpg_iteration_handle_t *cpg_iteration_handle)
cpg_iteration_initialize
Definition: lib/cpg.c:1240
unsigned int nodeid
Definition: coroapi.h:75
struct memb_ring_id ring_id
Definition: totemsrp.c:264
same as agreed
Definition: cpg.h:66
uint64_t seq
Definition: cpg.h:142
cpg_deliver_fn_t cpg_deliver_fn
Definition: cpg.h:183
cs_error_t cpg_zcb_free(cpg_handle_t handle, void *buffer)
cpg_zcb_free
Definition: lib/cpg.c:1001
cs_error_t cpg_max_atomic_msgsize_get(cpg_handle_t handle, uint32_t *size)
Get maximum size of a message that will not be fragmented.
Definition: lib/cpg.c:313