corosync  2.4.5
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 
57 LOGSYS_DECLARE_SUBSYS ("APIDEF");
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_ring_reenable = totempg_ring_reenable,
113  .totem_mcast = main_mcast,
114  .totem_ifaces_get = totempg_ifaces_get,
115  .totem_ifaces_print = totempg_ifaces_print,
116  .totem_ip_print = totemip_print,
117  .totem_crypto_set = totempg_crypto_set,
118  .totem_callback_token_create = totempg_callback_token_create,
119  .totem_get_stats = totempg_get_stats,
120  .tpg_init = totempg_groups_initialize,
121  .tpg_exit = NULL, /* missing from totempg api */
124  .tpg_joined_mcast = totempg_groups_mcast_joined,
125  .tpg_joined_reserve = totempg_groups_joined_reserve,
126  .tpg_joined_release = totempg_groups_joined_release,
128  .tpg_groups_reserve = NULL,
129  .tpg_groups_release = NULL,
133  .sync_request = NULL, //sync_request,
139  .fatal_error = _corosync_public_exit_error,
145 };
146 
148 {
149  return (&apidef_corosync_api_v1);
150 }