cpg.h
Go to the documentation of this file.
/*
* Copyright (c) 2006-2019 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Christine Caulfield (ccaulfi@redhat.com)
* Author: Jan Friesse (jfriesse@redhat.com)
*
* This software licensed under BSD license, the text of which follows:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* - Neither the name of the MontaVista Software, Inc. nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef COROSYNC_CPG_H_DEFINED
#define COROSYNC_CPG_H_DEFINED
#include <netinet/in.h>
#include <corosync/corotypes.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint64_t cpg_handle_t;
typedef uint64_t cpg_iteration_handle_t;
typedef enum {
CPG_TYPE_UNORDERED,
CPG_TYPE_FIFO,
CPG_TYPE_AGREED,
CPG_TYPE_SAFE
} cpg_guarantee_t;
typedef enum {
CPG_FLOW_CONTROL_DISABLED,
CPG_FLOW_CONTROL_ENABLED
} cpg_flow_control_state_t;
typedef enum {
CPG_REASON_UNDEFINED = 0,
CPG_REASON_JOIN = 1,
CPG_REASON_LEAVE = 2,
CPG_REASON_NODEDOWN = 3,
CPG_REASON_NODEUP = 4,
CPG_REASON_PROCDOWN = 5
} cpg_reason_t;
typedef enum {
CPG_ITERATION_NAME_ONLY = 1,
CPG_ITERATION_ONE_GROUP = 2,
CPG_ITERATION_ALL = 3,
} cpg_iteration_type_t;
typedef enum {
CPG_MODEL_V1 = 1,
} cpg_model_t;
struct cpg_address {
uint32_t nodeid;
uint32_t pid;
uint32_t reason;
};
#define CPG_MAX_NAME_LENGTH 128
struct cpg_name {
uint32_t length;
char value[CPG_MAX_NAME_LENGTH];
};
#define CPG_MEMBERS_MAX 128
struct cpg_iteration_description_t {
struct cpg_name group;
uint32_t nodeid;
uint32_t pid;
};
struct cpg_ring_id {
uint32_t nodeid;
uint64_t seq;
};
typedef 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);
typedef 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);
typedef 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);
typedef struct {
cpg_deliver_fn_t cpg_deliver_fn;
cpg_confchg_fn_t cpg_confchg_fn;
} cpg_callbacks_t;
typedef struct {
cpg_model_t model;
} cpg_model_data_t;
#define CPG_MODEL_V1_DELIVER_INITIAL_TOTEM_CONF 0x01
typedef struct {
cpg_model_t model;
cpg_deliver_fn_t cpg_deliver_fn;
cpg_confchg_fn_t cpg_confchg_fn;
cpg_totem_confchg_fn_t cpg_totem_confchg_fn;
unsigned int flags;
} cpg_model_v1_data_t;
cs_error_t cpg_initialize (
cpg_handle_t *handle,
cpg_callbacks_t *callbacks);
cs_error_t cpg_model_initialize (
cpg_handle_t *handle,
cpg_model_t model,
cpg_model_data_t *model_data,
void *context);
cs_error_t cpg_finalize (
cpg_handle_t handle);
cs_error_t cpg_fd_get (
cpg_handle_t handle,
int *fd);
cs_error_t cpg_max_atomic_msgsize_get (
cpg_handle_t handle,
uint32_t *size);
cs_error_t cpg_context_get (
cpg_handle_t handle,
void **context);
cs_error_t cpg_context_set (
cpg_handle_t handle,
void *context);
cs_error_t cpg_dispatch (
cpg_handle_t handle,
cs_dispatch_flags_t dispatch_types);
cs_error_t cpg_join (
cpg_handle_t handle,
const struct cpg_name *group);
cs_error_t cpg_leave (
cpg_handle_t handle,
const struct cpg_name *group);
cs_error_t cpg_mcast_joined (
cpg_handle_t handle,
cpg_guarantee_t guarantee,
const struct iovec *iovec,
unsigned int iov_len);
cs_error_t cpg_membership_get (
cpg_handle_t handle,
struct cpg_name *groupName,
struct cpg_address *member_list,
int *member_list_entries);
cs_error_t cpg_local_get (
cpg_handle_t handle,
unsigned int *local_nodeid);
cs_error_t cpg_flow_control_state_get (
cpg_handle_t handle,
cpg_flow_control_state_t *flow_control_enabled);
cs_error_t cpg_zcb_alloc (
cpg_handle_t handle,
size_t size,
void **buffer);
cs_error_t cpg_zcb_free (
cpg_handle_t handle,
void *buffer);
cs_error_t cpg_zcb_mcast_joined (
cpg_handle_t handle,
cpg_guarantee_t guarantee,
void *msg,
size_t msg_len);
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);
cs_error_t cpg_iteration_next(
cpg_iteration_handle_t handle,
struct cpg_iteration_description_t *description);
cs_error_t cpg_iteration_finalize (
cpg_iteration_handle_t handle);
#ifdef __cplusplus
}
#endif
#endif /* COROSYNC_CPG_H_DEFINED */
nodeid
unsigned int nodeid
Definition: coroapi.h:0
corotypes.h
cs_dispatch_flags_t
cs_dispatch_flags_t
The cs_dispatch_flags_t enum.
Definition: corotypes.h:84
cs_error_t
cs_error_t
The cs_error_t enum.
Definition: corotypes.h:98
cpg_flow_control_state_get
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
cpg_iteration_next
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
cpg_model_initialize
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
cpg_max_atomic_msgsize_get
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
cpg_mcast_joined
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
cpg_leave
cs_error_t cpg_leave(cpg_handle_t handle, const struct cpg_name *group)
Leave one or more groups.
Definition: lib/cpg.c:698
cpg_context_get
cs_error_t cpg_context_get(cpg_handle_t handle, void **context)
Get contexts for a CPG handle.
Definition: lib/cpg.c:332
cpg_fd_get
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_join
cs_error_t cpg_join(cpg_handle_t handle, const struct cpg_name *group)
Join one or more groups.
Definition: lib/cpg.c:644
cpg_zcb_free
cs_error_t cpg_zcb_free(cpg_handle_t handle, void *buffer)
cpg_zcb_free
Definition: lib/cpg.c:1001
cpg_iteration_finalize
cs_error_t cpg_iteration_finalize(cpg_iteration_handle_t handle)
cpg_iteration_finalize
Definition: lib/cpg.c:1383
cpg_zcb_alloc
cs_error_t cpg_zcb_alloc(cpg_handle_t handle, size_t size, void **buffer)
cpg_zcb_alloc
Definition: lib/cpg.c:944
cpg_membership_get
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
cpg_initialize
cs_error_t cpg_initialize(cpg_handle_t *handle, cpg_callbacks_t *callbacks)
Create a new cpg connection.
Definition: lib/cpg.c:169
cpg_local_get
cs_error_t cpg_local_get(cpg_handle_t handle, unsigned int *local_nodeid)
cpg_local_get
Definition: lib/cpg.c:806
cpg_iteration_initialize
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
cpg_context_set
cs_error_t cpg_context_set(cpg_handle_t handle, void *context)
Set contexts for a CPG handle.
Definition: lib/cpg.c:351
cpg_finalize
cs_error_t cpg_finalize(cpg_handle_t handle)
Close the cpg handle.
Definition: lib/cpg.c:249
cpg_dispatch
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
cpg_zcb_mcast_joined
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
cpg_flow_control_state_t
cpg_flow_control_state_t
The cpg_flow_control_state_t enum.
Definition: cpg.h:73
cpg_deliver_fn_t
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:147
CPG_MAX_NAME_LENGTH
#define CPG_MAX_NAME_LENGTH
Definition: cpg.h:116
cpg_guarantee_t
cpg_guarantee_t
The cpg_guarantee_t enum.
Definition: cpg.h:63
cpg_iteration_type_t
cpg_iteration_type_t
The cpg_iteration_type_t enum.
Definition: cpg.h:94
cpg_confchg_fn_t
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:162
cpg_handle_t
uint64_t cpg_handle_t
cpg_handle_t
Definition: cpg.h:53
cpg_iteration_handle_t
uint64_t cpg_iteration_handle_t
cpg_iteration_handle_t
Definition: cpg.h:58
cpg_model_t
cpg_model_t
The cpg_model_t enum.
Definition: cpg.h:103
cpg_reason_t
cpg_reason_t
The cpg_reason_t enum.
Definition: cpg.h:82
cpg_totem_confchg_fn_t
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:172
CPG_FLOW_CONTROL_DISABLED
@ CPG_FLOW_CONTROL_DISABLED
flow control is disabled - new messages may be sent
Definition: cpg.h:74
CPG_FLOW_CONTROL_ENABLED
@ CPG_FLOW_CONTROL_ENABLED
flow control is enabled - new messages should not be sent
Definition: cpg.h:75
CPG_TYPE_UNORDERED
@ CPG_TYPE_UNORDERED
not implemented
Definition: cpg.h:64
CPG_TYPE_FIFO
@ CPG_TYPE_FIFO
same as agreed
Definition: cpg.h:65
CPG_TYPE_AGREED
@ CPG_TYPE_AGREED
Definition: cpg.h:66
CPG_TYPE_SAFE
@ CPG_TYPE_SAFE
not implemented
Definition: cpg.h:67
CPG_ITERATION_ONE_GROUP
@ CPG_ITERATION_ONE_GROUP
Definition: cpg.h:96
CPG_ITERATION_ALL
@ CPG_ITERATION_ALL
Definition: cpg.h:97
CPG_ITERATION_NAME_ONLY
@ CPG_ITERATION_NAME_ONLY
Definition: cpg.h:95
CPG_MODEL_V1
@ CPG_MODEL_V1
Definition: cpg.h:104
CPG_REASON_UNDEFINED
@ CPG_REASON_UNDEFINED
Definition: cpg.h:83
CPG_REASON_JOIN
@ CPG_REASON_JOIN
Definition: cpg.h:84
CPG_REASON_NODEUP
@ CPG_REASON_NODEUP
Definition: cpg.h:87
CPG_REASON_LEAVE
@ CPG_REASON_LEAVE
Definition: cpg.h:85
CPG_REASON_PROCDOWN
@ CPG_REASON_PROCDOWN
Definition: cpg.h:88
CPG_REASON_NODEDOWN
@ CPG_REASON_NODEDOWN
Definition: cpg.h:86
cpg_address
The cpg_address struct.
Definition: cpg.h:110
cpg_address::reason
uint32_t reason
Definition: cpg.h:113
cpg_address::pid
uint32_t pid
Definition: cpg.h:112
cpg_address::nodeid
uint32_t nodeid
Definition: cpg.h:111
cpg_callbacks_t
The cpg_callbacks_t struct.
Definition: cpg.h:181
cpg_callbacks_t::cpg_deliver_fn
cpg_deliver_fn_t cpg_deliver_fn
Definition: cpg.h:182
cpg_callbacks_t::cpg_confchg_fn
cpg_confchg_fn_t cpg_confchg_fn
Definition: cpg.h:183
cpg_iteration_description_t
The cpg_iteration_description_t struct.
Definition: cpg.h:130
cpg_iteration_description_t::nodeid
uint32_t nodeid
Definition: cpg.h:132
cpg_iteration_description_t::group
struct cpg_name group
Definition: cpg.h:131
cpg_iteration_description_t::pid
uint32_t pid
Definition: cpg.h:133
cpg_model_data_t
The cpg_model_data_t struct.
Definition: cpg.h:189
cpg_model_data_t::model
cpg_model_t model
Definition: cpg.h:190
cpg_model_v1_data_t
The cpg_model_v1_data_t struct.
Definition: cpg.h:198
cpg_model_v1_data_t::model
cpg_model_t model
Definition: cpg.h:199
cpg_model_v1_data_t::cpg_totem_confchg_fn
cpg_totem_confchg_fn_t cpg_totem_confchg_fn
Definition: cpg.h:202
cpg_model_v1_data_t::flags
unsigned int flags
Definition: cpg.h:203
cpg_model_v1_data_t::cpg_confchg_fn
cpg_confchg_fn_t cpg_confchg_fn
Definition: cpg.h:201
cpg_model_v1_data_t::cpg_deliver_fn
cpg_deliver_fn_t cpg_deliver_fn
Definition: cpg.h:200
cpg_name
The cpg_name struct.
Definition: cpg.h:120
cpg_name::value
char value[CPG_MAX_NAME_LENGTH]
Definition: cpg.h:122
cpg_name::length
uint32_t length
Definition: cpg.h:121
cpg_ring_id
The cpg_ring_id struct.
Definition: cpg.h:139
cpg_ring_id::seq
uint64_t seq
Definition: cpg.h:141
cpg_ring_id::nodeid
uint32_t nodeid
Definition: cpg.h:140
guarantee
int guarantee
Definition: totemsrp.c:6
ring_id
struct memb_ring_id ring_id
Definition: totemsrp.c:4