corosync  3.0.4
apidef.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2012 Red Hat, Inc.
3  *
4  * All rights reserved.
5  *
6  * Author: Steven Dake (sdake@redhat.com)
7  *
8  * This software licensed under BSD license, the text of which follows:
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
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.
21  *
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.
33  */
34 
35 #include <config.h>
36 
37 #include <stdlib.h>
38 #include <string.h>
39 
40 #include <qb/qbutil.h>
41 #include <qb/qbloop.h>
42 #include <qb/qbipcs.h>
43 
44 #include <corosync/corotypes.h>
45 #include <corosync/totem/totempg.h>
46 #include <corosync/totem/totemip.h>
47 #include <corosync/totem/totem.h>
48 #include <corosync/logsys.h>
49 #include "util.h"
50 #include "timer.h"
51 #include "quorum.h"
52 #include "schedwrk.h"
53 #include "main.h"
54 #include "apidef.h"
55 #include "service.h"
56 
58 
59 /*
60  * Remove compile warnings about type name changes in corosync_tpg_group
61  */
62 typedef int (*typedef_tpg_join) (
63  void *,
64  const struct corosync_tpg_group *,
65  size_t);
66 
67 typedef int (*typedef_tpg_leave) (void *,
68  const struct corosync_tpg_group *,
69  size_t);
70 
72  void *, int,
73  const struct corosync_tpg_group *,
74  size_t groups_cnt,
75  const struct iovec *,
76  unsigned int);
77 
79  void *,
80  const struct corosync_tpg_group *,
81  size_t groups_cnt,
82  struct iovec *,
83  int);
84 
85 static inline void _corosync_public_exit_error (cs_fatal_error_t err,
86  const char *file,
87  unsigned int line)
88  __attribute__((noreturn));
89 static inline void _corosync_public_exit_error (
90  cs_fatal_error_t err, const char *file, unsigned int line)
91 {
92  _corosync_exit_error (err, file, line);
93 }
94 
95 static struct corosync_api_v1 apidef_corosync_api_v1 = {
97  .timer_add_absolute = corosync_timer_add_absolute,
98  .timer_delete = corosync_timer_delete,
99  .timer_time_get = cs_timer_time_get,
100  .timer_expire_time_get = corosync_timer_expire_time_get,
101  .ipc_source_set = message_source_set,
102  .ipc_source_is_local = message_source_is_local,
103  .ipc_private_data_get = cs_ipcs_private_data_get,
104  .ipc_response_iov_send = cs_ipcs_response_iov_send,
105  .ipc_response_send = cs_ipcs_response_send,
106  .ipc_dispatch_send = cs_ipcs_dispatch_send,
107  .ipc_dispatch_iov_send = cs_ipcs_dispatch_iov_send,
108  .ipc_refcnt_inc = cs_ipc_refcnt_inc,
109  .ipc_refcnt_dec = cs_ipc_refcnt_dec,
110  .totem_nodeid_get = totempg_my_nodeid_get,
111  .totem_family_get = totempg_my_family_get,
112  .totem_mcast = main_mcast,
113  .totem_ifaces_get = totempg_ifaces_get,
114  .totem_ifaces_print = totempg_ifaces_print,
115  .totem_ip_print = totemip_print,
116  .totem_crypto_set = totempg_crypto_set,
117  .totem_callback_token_create = totempg_callback_token_create,
118  .totem_get_stats = totempg_get_stats,
119  .tpg_init = totempg_groups_initialize,
120  .tpg_exit = NULL, /* missing from totempg api */
123  .tpg_joined_mcast = totempg_groups_mcast_joined,
124  .tpg_joined_reserve = totempg_groups_joined_reserve,
125  .tpg_joined_release = totempg_groups_joined_release,
127  .tpg_groups_reserve = NULL,
128  .tpg_groups_release = NULL,
132  .sync_request = NULL, //sync_request,
138  .fatal_error = _corosync_public_exit_error,
144 };
145 
147 {
148  return (&apidef_corosync_api_v1);
149 }
corosync_api_v1
The corosync_api_v1 struct.
Definition: coroapi.h:225
apidef.h
corosync_timer_expire_time_get
unsigned long long corosync_timer_expire_time_get(corosync_timer_handle_t th)
Definition: timer.c:78
totempg_groups_join
int totempg_groups_join(void *instance, const struct totempg_group *groups, size_t group_cnt)
Definition: totempg.c:1182
totem.h
LOGSYS_DECLARE_SUBSYS
LOGSYS_DECLARE_SUBSYS("APIDEF")
totempg_my_family_get
int totempg_my_family_get(void)
Definition: totempg.c:1530
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
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
main_mcast
int main_mcast(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
Definition: main.c:614
message_source_is_local
int message_source_is_local(const mar_message_source_t *source)
Definition: main.c:787
corosync_state_dump
void corosync_state_dump(void)
Definition: main.c:193
totempg.h
Totem Single Ring Protocol.
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:175
service.h
cs_fatal_error_t
cs_fatal_error_t
The cs_fatal_error_t enum.
Definition: coroapi.h:183
totempg_groups_joined_release
int totempg_groups_joined_release(int msg_count)
Definition: totempg.c:1346
totemip_print
const char * totemip_print(const struct totem_ip_address *addr)
Definition: totemip.c:256
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
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
corosync_api_v1::quorum_unregister_callback
int(* quorum_unregister_callback)(quorum_callback_fn_t callback_fn, void *context)
Definition: coroapi.h:387
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_ipcs_dispatch_send
int cs_ipcs_dispatch_send(void *conn, const void *msg, size_t mlen)
Definition: ipc_glue.c:474
corosync_quorum_unregister_callback
int corosync_quorum_unregister_callback(quorum_callback_fn_t fn, void *context)
Definition: exec/quorum.c:85
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
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
cs_poll_handle_get
qb_loop_t * cs_poll_handle_get(void)
Definition: main.c:170
corosync_quorum_initialize
int corosync_quorum_initialize(struct quorum_callin_functions *fns)
Definition: exec/quorum.c:95
corosync_tpg_group
The corosync_tpg_group struct.
Definition: coroapi.h:81
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_mcast_joined
int totempg_groups_mcast_joined(void *instance, const struct iovec *iovec, unsigned int iov_len, int guarantee)
Definition: totempg.c:1232
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
cs_ipcs_private_data_get
void * cs_ipcs_private_data_get(void *conn)
Definition: ipc_glue.c:312
totemip.h
corosync_timer_delete
void corosync_timer_delete(corosync_timer_handle_t th)
Definition: timer.c:72
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:1450
totempg_crypto_set
int totempg_crypto_set(const char *cipher_type, const char *hash_type)
Definition: totempg.c:1482
timer.h
__attribute__
typedef __attribute__
message_source_set
void message_source_set(mar_message_source_t *source, void *conn)
Definition: main.c:798
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::timer_add_duration
int(* timer_add_duration)(unsigned long long nanoseconds_in_future, void *data, void(*timer_nf)(void *data), corosync_timer_handle_t *handle)
Definition: coroapi.h:229
totempg_ifaces_print
const char * totempg_ifaces_print(unsigned int nodeid)
Definition: totempg.c:1494
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:69
_corosync_out_of_memory_error
void _corosync_out_of_memory_error(void)
Definition: util.c:116
totempg_get_stats
void * totempg_get_stats(void)
Definition: totempg.c:1477
schedwrk.h
cs_ipcs_response_send
int cs_ipcs_response_send(void *conn, const void *msg, size_t mlen)
Definition: ipc_glue.c:374
typedef_tpg_leave
int(* typedef_tpg_leave)(void *, const struct corosync_tpg_group *, size_t)
Definition: apidef.c:67
cs_poll_dispatch_delete
int cs_poll_dispatch_delete(qb_loop_t *handle, int fd)
Definition: main.c:188
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
corosync_api_v1::quorum_register_callback
int(* quorum_register_callback)(quorum_callback_fn_t callback_fn, void *context)
Definition: coroapi.h:386
corosync_shutdown_request
void corosync_shutdown_request(void)
Definition: main.c:250
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
totempg_my_nodeid_get
unsigned int totempg_my_nodeid_get(void)
Definition: totempg.c:1525
corosync_api_v1::tpg_groups_release
int(* tpg_groups_release)(int reserved_msgs)
Definition: coroapi.h:369
cs_ipc_refcnt_inc
void cs_ipc_refcnt_inc(void *conn)
Definition: ipc_glue.c:302
corosync_api_v1::error_memory_failure
void(* error_memory_failure)(void) __attribute__((noreturn))
Definition: coroapi.h:422
quorum.h
main.h
util.h
schedwrk_destroy
void schedwrk_destroy(hdb_handle_t handle)
Definition: schedwrk.c:154
corosync_api_v1::state_dump
void(* state_dump)(void)
Definition: coroapi.h:431
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
corosync_api_v1::poll_dispatch_delete
int(* poll_dispatch_delete)(qb_loop_t *handle, int fd)
Definition: coroapi.h:452
cs_ipc_refcnt_dec
void cs_ipc_refcnt_dec(void *conn)
Definition: ipc_glue.c:307
corosync_api_v1::shutdown_request
void(* shutdown_request)(void)
Definition: coroapi.h:429
config.h
cs_timer_time_get
unsigned long long cs_timer_time_get(void)
Definition: timer.c:92
corosync_api_v1::quorum_is_quorate
int(* quorum_is_quorate)(void)
Definition: coroapi.h:385
logsys.h
corotypes.h
apidef_get
struct corosync_api_v1 * apidef_get(void)
Definition: apidef.c:146
totempg_groups_leave
int totempg_groups_leave(void *instance, const struct totempg_group *groups, size_t group_cnt)
Definition: totempg.c:1214
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::sync_request
int(* sync_request)(const char *service_name)
Definition: coroapi.h:379
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
schedwrk_create_nolock
int schedwrk_create_nolock(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
Definition: schedwrk.c:146
_corosync_exit_error
void _corosync_exit_error(enum e_corosync_done err, const char *file, unsigned int line) __attribute__((noreturn))
Definition: util.c:126
schedwrk_create
int schedwrk_create(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
Definition: schedwrk.c:138
corosync_api_v1::poll_handle_get
qb_loop_t *(* poll_handle_get)(void)
Definition: coroapi.h:433
typedef_tpg_join
int(* typedef_tpg_join)(void *, const struct corosync_tpg_group *, size_t)
Definition: apidef.c:62