corosync  3.1.7
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 }
struct corosync_api_v1 * apidef_get(void)
Definition: apidef.c:146
int(* typedef_tpg_groups_send_ok)(void *, const struct corosync_tpg_group *, size_t groups_cnt, struct iovec *, int)
Definition: apidef.c:78
LOGSYS_DECLARE_SUBSYS("APIDEF")
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
int(* typedef_tpg_join)(void *, const struct corosync_tpg_group *, size_t)
Definition: apidef.c:62
int(* typedef_tpg_leave)(void *, const struct corosync_tpg_group *, size_t)
Definition: apidef.c:67
cs_fatal_error_t
The cs_fatal_error_t enum.
Definition: coroapi.h:183
int corosync_quorum_register_callback(quorum_callback_fn_t fn, void *context)
Definition: exec/quorum.c:75
int corosync_quorum_is_quorate(void)
Definition: exec/quorum.c:65
int corosync_quorum_unregister_callback(quorum_callback_fn_t fn, void *context)
Definition: exec/quorum.c:85
int corosync_quorum_initialize(struct quorum_callin_functions *fns)
Definition: exec/quorum.c:95
void cs_ipc_refcnt_inc(void *conn)
Definition: ipc_glue.c:302
void cs_ipc_refcnt_dec(void *conn)
Definition: ipc_glue.c:307
int cs_ipcs_dispatch_iov_send(void *conn, const struct iovec *iov, unsigned int iov_len)
Definition: ipc_glue.c:483
int cs_ipcs_response_send(void *conn, const void *msg, size_t mlen)
Definition: ipc_glue.c:374
int cs_ipcs_response_iov_send(void *conn, const struct iovec *iov, unsigned int iov_len)
Definition: ipc_glue.c:363
void * cs_ipcs_private_data_get(void *conn)
Definition: ipc_glue.c:312
int cs_ipcs_dispatch_send(void *conn, const void *msg, size_t mlen)
Definition: ipc_glue.c:474
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
void corosync_state_dump(void)
Definition: main.c:201
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
void message_source_set(mar_message_source_t *source, void *conn)
Definition: main.c:807
int main_mcast(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
Definition: main.c:627
int message_source_is_local(const mar_message_source_t *source)
Definition: main.c:796
qb_loop_t * cs_poll_handle_get(void)
Definition: main.c:178
int cs_poll_dispatch_delete(qb_loop_t *handle, int fd)
Definition: main.c:196
void corosync_shutdown_request(void)
Definition: main.c:258
int schedwrk_create(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
Definition: schedwrk.c:138
void schedwrk_destroy(hdb_handle_t handle)
Definition: schedwrk.c:154
int schedwrk_create_nolock(hdb_handle_t *handle, int(schedwrk_fn)(const void *), const void *context)
Definition: schedwrk.c:146
The corosync_api_v1 struct.
Definition: coroapi.h:225
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
int(* poll_dispatch_delete)(qb_loop_t *handle, int fd)
Definition: coroapi.h:452
qb_loop_t *(* poll_handle_get)(void)
Definition: coroapi.h:433
int(* tpg_groups_release)(int reserved_msgs)
Definition: coroapi.h:369
void(* fatal_error)(cs_fatal_error_t err, const char *file, unsigned int line) __attribute__((noreturn))
Definition: coroapi.h:425
int(* tpg_leave)(void *instance, const struct corosync_tpg_group *groups, size_t group_cnt)
Definition: coroapi.h:335
void(* shutdown_request)(void)
Definition: coroapi.h:429
int(* quorum_register_callback)(quorum_callback_fn_t callback_fn, void *context)
Definition: coroapi.h:386
int(* sync_request)(const char *service_name)
Definition: coroapi.h:379
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
void(* error_memory_failure)(void) __attribute__((noreturn))
Definition: coroapi.h:422
void(* state_dump)(void)
Definition: coroapi.h:431
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
int(* quorum_unregister_callback)(quorum_callback_fn_t callback_fn, void *context)
Definition: coroapi.h:387
int(* quorum_is_quorate)(void)
Definition: coroapi.h:385
The corosync_tpg_group struct.
Definition: coroapi.h:81
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
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
unsigned long long cs_timer_time_get(void)
Definition: timer.c:92
unsigned long long corosync_timer_expire_time_get(corosync_timer_handle_t th)
Definition: timer.c:78
void corosync_timer_delete(corosync_timer_handle_t th)
Definition: timer.c:72
typedef __attribute__
const char * totemip_print(const struct totem_ip_address *addr)
Definition: totemip.c:256
Totem Single Ring Protocol.
int totempg_my_family_get(void)
Definition: totempg.c:1537
unsigned int totempg_my_nodeid_get(void)
Definition: totempg.c:1532
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
int totempg_crypto_set(const char *cipher_type, const char *hash_type)
Definition: totempg.c:1489
int totempg_groups_leave(void *instance, const struct totempg_group *groups, size_t group_cnt)
Definition: totempg.c:1214
int totempg_groups_mcast_joined(void *instance, const struct iovec *iovec, unsigned int iov_len, int guarantee)
Definition: totempg.c:1232
void * totempg_get_stats(void)
Definition: totempg.c:1484
int totempg_groups_joined_release(int msg_count)
Definition: totempg.c:1346
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
const char * totempg_ifaces_print(unsigned int nodeid)
Definition: totempg.c:1501
int totempg_groups_joined_reserve(void *instance, const struct iovec *iovec, unsigned int iov_len)
Definition: totempg.c:1302
int totempg_groups_join(void *instance, const struct totempg_group *groups, size_t group_cnt)
Definition: totempg.c:1182
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
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
void _corosync_out_of_memory_error(void)
Definition: util.c:118
void _corosync_exit_error(enum e_corosync_done err, const char *file, unsigned int line) __attribute__((noreturn))
Definition: util.c:128