apidef.c
Go to the documentation of this file.
/*
* Copyright (c) 2008-2012 Red Hat, Inc.
*
* All rights reserved.
*
* Author: Steven Dake (sdake@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.
*/
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <qb/qbutil.h>
#include <qb/qbloop.h>
#include <qb/qbipcs.h>
#include <corosync/corotypes.h>
#include <corosync/totem/totempg.h>
#include <corosync/totem/totemip.h>
#include <corosync/totem/totem.h>
#include <corosync/logsys.h>
#include "util.h"
#include "timer.h"
#include "quorum.h"
#include "schedwrk.h"
#include "main.h"
#include "apidef.h"
#include "service.h"
LOGSYS_DECLARE_SUBSYS ("APIDEF");
/*
* Remove compile warnings about type name changes in corosync_tpg_group
*/
typedef int (*typedef_tpg_join) (
void *,
const struct corosync_tpg_group *,
size_t);
typedef int (*typedef_tpg_leave) (void *,
const struct corosync_tpg_group *,
size_t);
typedef int (*typedef_tpg_groups_mcast_groups) (
void *, int,
const struct corosync_tpg_group *,
size_t groups_cnt,
const struct iovec *,
unsigned int);
typedef int (*typedef_tpg_groups_send_ok) (
void *,
const struct corosync_tpg_group *,
size_t groups_cnt,
struct iovec *,
int);
static inline void _corosync_public_exit_error (cs_fatal_error_t err,
const char *file,
unsigned int line)
__attribute__((noreturn));
static inline void _corosync_public_exit_error (
cs_fatal_error_t err, const char *file, unsigned int line)
{
_corosync_exit_error (err, file, line);
}
static struct corosync_api_v1 apidef_corosync_api_v1 = {
.timer_add_duration = corosync_timer_add_duration,
.timer_add_absolute = corosync_timer_add_absolute,
.timer_delete = corosync_timer_delete,
.timer_time_get = cs_timer_time_get,
.timer_expire_time_get = corosync_timer_expire_time_get,
.ipc_source_set = message_source_set,
.ipc_source_is_local = message_source_is_local,
.ipc_private_data_get = cs_ipcs_private_data_get,
.ipc_response_iov_send = cs_ipcs_response_iov_send,
.ipc_response_send = cs_ipcs_response_send,
.ipc_dispatch_send = cs_ipcs_dispatch_send,
.ipc_dispatch_iov_send = cs_ipcs_dispatch_iov_send,
.ipc_refcnt_inc = cs_ipc_refcnt_inc,
.ipc_refcnt_dec = cs_ipc_refcnt_dec,
.totem_nodeid_get = totempg_my_nodeid_get,
.totem_family_get = totempg_my_family_get,
.totem_mcast = main_mcast,
.totem_ifaces_get = totempg_ifaces_get,
.totem_ifaces_print = totempg_ifaces_print,
.totem_ip_print = totemip_print,
.totem_crypto_set = totempg_crypto_set,
.totem_callback_token_create = totempg_callback_token_create,
.totem_get_stats = totempg_get_stats,
.tpg_init = totempg_groups_initialize,
.tpg_exit = NULL, /* missing from totempg api */
.tpg_join = (typedef_tpg_join)totempg_groups_join,
.tpg_leave = (typedef_tpg_leave)totempg_groups_leave,
.tpg_joined_mcast = totempg_groups_mcast_joined,
.tpg_joined_reserve = totempg_groups_joined_reserve,
.tpg_joined_release = totempg_groups_joined_release,
.tpg_groups_mcast = (typedef_tpg_groups_mcast_groups)totempg_groups_mcast_groups,
.tpg_groups_reserve = NULL,
.tpg_groups_release = NULL,
.schedwrk_create = schedwrk_create,
.schedwrk_create_nolock = schedwrk_create_nolock,
.schedwrk_destroy = schedwrk_destroy,
.sync_request = NULL, //sync_request,
.quorum_is_quorate = corosync_quorum_is_quorate,
.quorum_register_callback = corosync_quorum_register_callback,
.quorum_unregister_callback = corosync_quorum_unregister_callback,
.quorum_initialize = corosync_quorum_initialize,
.error_memory_failure = _corosync_out_of_memory_error,
.fatal_error = _corosync_public_exit_error,
.shutdown_request = corosync_shutdown_request,
.state_dump = corosync_state_dump,
.poll_handle_get = cs_poll_handle_get,
.poll_dispatch_add = cs_poll_dispatch_add,
.poll_dispatch_delete = cs_poll_dispatch_delete
};
struct corosync_api_v1 *apidef_get (void)
{
return (&apidef_corosync_api_v1);
}
apidef_get
struct corosync_api_v1 * apidef_get(void)
Definition apidef.c:146
typedef_tpg_groups_send_ok
int(* typedef_tpg_groups_send_ok)(void *, const struct corosync_tpg_group *, size_t groups_cnt, struct iovec *, int)
Definition apidef.c:78
typedef_tpg_groups_mcast_groups
int(* typedef_tpg_groups_mcast_groups)(void *, int, const struct corosync_tpg_group *, size_t groups_cnt, const struct iovec *, unsigned int)
Definition apidef.c:71
typedef_tpg_join
int(* typedef_tpg_join)(void *, const struct corosync_tpg_group *, size_t)
Definition apidef.c:62
typedef_tpg_leave
int(* typedef_tpg_leave)(void *, const struct corosync_tpg_group *, size_t)
Definition apidef.c:67
apidef.h
config.h
cs_fatal_error_t
cs_fatal_error_t
The cs_fatal_error_t enum.
Definition coroapi.h:183
corotypes.h
corosync_quorum_register_callback
int corosync_quorum_register_callback(quorum_callback_fn_t fn, void *context)
Definition exec/quorum.c:75
corosync_quorum_is_quorate
int corosync_quorum_is_quorate(void)
Definition exec/quorum.c:65
corosync_quorum_unregister_callback
int corosync_quorum_unregister_callback(quorum_callback_fn_t fn, void *context)
Definition exec/quorum.c:85
corosync_quorum_initialize
int corosync_quorum_initialize(struct quorum_callin_functions *fns)
Definition exec/quorum.c:95
quorum.h
util.h
cs_ipcs_private_data_get
void * cs_ipcs_private_data_get(void *conn)
Definition ipc_glue.c:312
cs_ipc_refcnt_inc
void cs_ipc_refcnt_inc(void *conn)
Definition ipc_glue.c:302
cs_ipc_refcnt_dec
void cs_ipc_refcnt_dec(void *conn)
Definition ipc_glue.c:307
cs_ipcs_dispatch_iov_send
int cs_ipcs_dispatch_iov_send(void *conn, const struct iovec *iov, unsigned int iov_len)
Definition ipc_glue.c:483
cs_ipcs_response_send
int cs_ipcs_response_send(void *conn, const void *msg, size_t mlen)
Definition ipc_glue.c:374
cs_ipcs_response_iov_send
int cs_ipcs_response_iov_send(void *conn, const struct iovec *iov, unsigned int iov_len)
Definition ipc_glue.c:363
cs_ipcs_dispatch_send
int cs_ipcs_dispatch_send(void *conn, const void *msg, size_t mlen)
Definition ipc_glue.c:474
quorum_initialize
cs_error_t quorum_initialize(quorum_handle_t *handle, quorum_callbacks_t *callbacks, uint32_t *quorum_type)
Create a new quorum connection.
Definition lib/quorum.c:73
logsys.h
LOGSYS_DECLARE_SUBSYS
#define LOGSYS_DECLARE_SUBSYS(subsys)
The LOGSYS_DECLARE_SUBSYS macro.
Definition logsys.h:306
corosync_state_dump
void corosync_state_dump(void)
Definition main.c:201
cs_poll_dispatch_add
int cs_poll_dispatch_add(qb_loop_t *handle, int fd, int events, void *data, int(*dispatch_fn)(int fd, int revents, void *data))
Definition main.c:183
message_source_set
void message_source_set(mar_message_source_t *source, void *conn)
Definition main.c:807
main_mcast
int main_mcast(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
Definition main.c:627
cs_poll_handle_get
qb_loop_t * cs_poll_handle_get(void)
Definition main.c:178
message_source_is_local
int message_source_is_local(const mar_message_source_t *source)
Definition main.c:796
cs_poll_dispatch_delete
int cs_poll_dispatch_delete(qb_loop_t *handle, int fd)
Definition main.c:196
corosync_shutdown_request
void corosync_shutdown_request(void)
Definition main.c:258
main.h
schedwrk_create
int schedwrk_create(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
Definition schedwrk.c:138
schedwrk_destroy
void schedwrk_destroy(hdb_handle_t handle)
Definition schedwrk.c:154
schedwrk_create_nolock
int schedwrk_create_nolock(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
Definition schedwrk.c:146
schedwrk.h
service.h
corosync_api_v1
The corosync_api_v1 struct.
Definition coroapi.h:225
corosync_api_v1::poll_dispatch_delete
int(* poll_dispatch_delete)(qb_loop_t *handle, int fd)
Definition coroapi.h:452
corosync_api_v1::tpg_groups_release
int(* tpg_groups_release)(int reserved_msgs)
Definition coroapi.h:369
corosync_api_v1::fatal_error
void(* fatal_error)(cs_fatal_error_t err, const char *file, unsigned int line) __attribute__((noreturn))
Definition coroapi.h:425
corosync_api_v1::tpg_leave
int(* tpg_leave)(void *instance, const struct corosync_tpg_group *groups, size_t group_cnt)
Definition coroapi.h:335
corosync_api_v1::shutdown_request
void(* shutdown_request)(void)
Definition coroapi.h:429
corosync_api_v1::sync_request
int(* sync_request)(const char *service_name)
Definition coroapi.h:379
corosync_api_v1::poll_dispatch_add
int(* poll_dispatch_add)(qb_loop_t *handle, int fd, int events, void *data, int(*dispatch_fn)(int fd, int revents, void *data))
Definition coroapi.h:442
corosync_api_v1::error_memory_failure
void(* error_memory_failure)(void) __attribute__((noreturn))
Definition coroapi.h:422
corosync_api_v1::state_dump
void(* state_dump)(void)
Definition coroapi.h:431
corosync_api_v1::tpg_groups_reserve
int(* tpg_groups_reserve)(void *instance, const struct corosync_tpg_group *groups, size_t groups_cnt, const struct iovec *iovec, unsigned int iov_len)
Definition coroapi.h:362
corosync_api_v1::poll_handle_get
qb_loop_t *(* poll_handle_get)(void)
Definition coroapi.h:433
corosync_api_v1::quorum_is_quorate
int(* quorum_is_quorate)(void)
Definition coroapi.h:385
corosync_tpg_group
The corosync_tpg_group struct.
Definition coroapi.h:81
corosync_timer_add_absolute
int corosync_timer_add_absolute(unsigned long long nanosec_from_epoch, void *data, void(*timer_fn)(void *data), corosync_timer_handle_t *handle)
Definition timer.c:43
corosync_timer_add_duration
int corosync_timer_add_duration(unsigned long long nanosec_duration, void *data, void(*timer_fn)(void *data), corosync_timer_handle_t *handle)
Definition timer.c:58
cs_timer_time_get
unsigned long long cs_timer_time_get(void)
Definition timer.c:92
corosync_timer_expire_time_get
unsigned long long corosync_timer_expire_time_get(corosync_timer_handle_t th)
Definition timer.c:78
corosync_timer_delete
void corosync_timer_delete(corosync_timer_handle_t th)
Definition timer.c:72
timer.h
totem.h
__attribute__
typedef __attribute__
totemip.h
totemip_print
const char * totemip_print(const struct totem_ip_address *addr)
Definition totemip.c:256
totempg.h
Totem Single Ring Protocol.
totempg_my_family_get
int totempg_my_family_get(void)
Definition totempg.c:1537
totempg_my_nodeid_get
unsigned int totempg_my_nodeid_get(void)
Definition totempg.c:1532
totempg_callback_token_create
int totempg_callback_token_create(void **handle_out, enum totem_callback_token_type type, int delete, int(*callback_fn)(enum totem_callback_token_type type, const void *), const void *data)
Definition totempg.c:1099
totempg_ifaces_print
const char * totempg_ifaces_print(unsigned int nodeid)
Definition totempg.c:1501
totempg_crypto_set
int totempg_crypto_set(const char *cipher_type, const char *hash_type)
Definition totempg.c:1489
totempg_groups_leave
int totempg_groups_leave(void *instance, const struct totempg_group *groups, size_t group_cnt)
Definition totempg.c:1214
totempg_groups_mcast_joined
int totempg_groups_mcast_joined(void *instance, const struct iovec *iovec, unsigned int iov_len, int guarantee)
Definition totempg.c:1232
totempg_groups_joined_release
int totempg_groups_joined_release(int msg_count)
Definition totempg.c:1346
totempg_ifaces_get
int totempg_ifaces_get(unsigned int nodeid, unsigned int *interface_id, struct totem_ip_address *interfaces, unsigned int interfaces_size, char ***status, unsigned int *iface_count)
Definition totempg.c:1457
totempg_groups_joined_reserve
int totempg_groups_joined_reserve(void *instance, const struct iovec *iovec, unsigned int iov_len)
Definition totempg.c:1302
totempg_groups_join
int totempg_groups_join(void *instance, const struct totempg_group *groups, size_t group_cnt)
Definition totempg.c:1182
totempg_groups_mcast_groups
int totempg_groups_mcast_groups(void *instance, int guarantee, const struct totempg_group *groups, size_t groups_cnt, const struct iovec *iovec, unsigned int iov_len)
Definition totempg.c:1360
totempg_get_stats
void * totempg_get_stats(void)
Definition totempg.c:1484
totempg_groups_initialize
int totempg_groups_initialize(void **instance, void(*deliver_fn)(unsigned int nodeid, const void *msg, unsigned int msg_len, int endian_conversion_required), void(*confchg_fn)(enum totem_configuration_type configuration_type, const unsigned int *member_list, size_t member_list_entries, const unsigned int *left_list, size_t left_list_entries, const unsigned int *joined_list, size_t joined_list_entries, const struct memb_ring_id *ring_id))
Initialize a groups instance.
Definition totempg.c:1134
_corosync_out_of_memory_error
void _corosync_out_of_memory_error(void)
Definition util.c:118
_corosync_exit_error
void _corosync_exit_error(enum e_corosync_done err, const char *file, unsigned int line) __attribute__((noreturn))
Definition util.c:128