2 * Copyright (c) 2005 MontaVista Software, Inc.
3 * Copyright (c) 2006-2007 Red Hat, Inc.
7 * Author: Steven Dake (sdake@redhat.com)
9 * This software licensed under BSD license, the text of which follows:
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions are met:
14 * - Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * - Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * - Neither the name of the MontaVista Software, Inc. nor the names of its
20 * contributors may be used to endorse or promote products derived from this
21 * software without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGE.
37 #include <sys/types.h>
39 #include <sys/socket.h>
42 #include <sys/ioctl.h>
43 #include <sys/param.h>
44 #include <netinet/in.h>
45 #include <arpa/inet.h>
62 totemsrp_handle totemsrp_handle_in
;
64 void (*pg_deliver_fn
) (
68 int endian_conversion_required
) = 0;
70 void (*pg_confchg_fn
) (
71 enum totem_configuration_type configuration_type
,
72 unsigned int *member_list
, int member_list_entries
,
73 unsigned int *left_list
, int left_list_entries
,
74 unsigned int *joined_list
, int joined_list_entries
,
75 struct memb_ring_id
*ring_id
) = 0;
77 void totemmrp_deliver_fn (
81 int endian_conversion_required
)
83 pg_deliver_fn (nodeid
, iovec
, iov_len
, endian_conversion_required
);
86 void totemmrp_confchg_fn (
87 enum totem_configuration_type configuration_type
,
88 unsigned int *member_list
, int member_list_entries
,
89 unsigned int *left_list
, int left_list_entries
,
90 unsigned int *joined_list
, int joined_list_entries
,
91 struct memb_ring_id
*ring_id
)
93 pg_confchg_fn (configuration_type
,
94 member_list
, member_list_entries
,
95 left_list
, left_list_entries
,
96 joined_list
, joined_list_entries
,
101 * Initialize the totem multiple ring protocol
103 int totemmrp_initialize (
104 poll_handle poll_handle
,
105 struct totem_config
*totem_config
,
111 int endian_conversion_required
),
113 enum totem_configuration_type configuration_type
,
114 unsigned int *member_list
, int member_list_entries
,
115 unsigned int *left_list
, int left_list_entries
,
116 unsigned int *joined_list
, int joined_list_entries
,
117 struct memb_ring_id
*ring_id
))
120 pg_deliver_fn
= deliver_fn
;
121 pg_confchg_fn
= confchg_fn
;
123 result
= totemsrp_initialize (
128 totemmrp_confchg_fn
);
133 void totemmrp_finalize (void)
135 totemsrp_finalize (totemsrp_handle_in
);
139 * Multicast a message
146 return totemsrp_mcast (totemsrp_handle_in
, iovec
, iov_len
, priority
);
150 * Return number of available messages that can be queued
152 int totemmrp_avail (void)
154 return (totemsrp_avail (totemsrp_handle_in
));
157 int totemmrp_callback_token_create (
159 enum totem_callback_token_type type
,
161 int (*callback_fn
) (enum totem_callback_token_type type
, void *),
164 return totemsrp_callback_token_create (totemsrp_handle_in
, handle_out
, type
, delete, callback_fn
, data
);
167 void totemmrp_callback_token_destroy (
170 totemsrp_callback_token_destroy (totemsrp_handle_in
, handle_out
);
173 void totemmrp_new_msg_signal (void) {
174 totemsrp_new_msg_signal (totemsrp_handle_in
);
177 int totemmrp_ifaces_get (
179 struct totem_ip_address
*interfaces
,
181 unsigned int *iface_count
)
185 res
= totemsrp_ifaces_get (
195 int totemmrp_my_nodeid_get (void)
197 return (totemsrp_my_nodeid_get (totemsrp_handle_in
));
200 int totemmrp_my_family_get (void)
202 return (totemsrp_my_family_get (totemsrp_handle_in
));
205 extern int totemmrp_ring_reenable (void)
209 res
= totemsrp_ring_reenable (