evs.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* * Copyright (c) 2004 MontaVista Software, Inc.
  2. *
  3. * All rights reserved.
  4. *
  5. * Author: Steven Dake (sdake@redhat.com)
  6. *
  7. * This software licensed under BSD license, the text of which follows:
  8. *
  9. * Redistribution and use in source and binary forms, with or without
  10. * modification, are permitted provided that the following conditions are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright notice,
  13. * this list of conditions and the following disclaimer.
  14. * - Redistributions in binary form must reproduce the above copyright notice,
  15. * this list of conditions and the following disclaimer in the documentation
  16. * and/or other materials provided with the distribution.
  17. * - Neither the name of the MontaVista Software, Inc. nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  22. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  25. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  26. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  27. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  28. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  29. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  30. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
  31. * THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #ifndef COROSYNC_EVS_H_DEFINED
  34. #define COROSYNC_EVS_H_DEFINED
  35. #include <inttypes.h>
  36. #include <netinet/in.h>
  37. #include <corosync/corotypes.h>
  38. #include <corosync/hdb.h>
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. /**
  43. * @defgroup corosync Other API services provided by corosync
  44. */
  45. /**
  46. * @addtogroup evs_corosync
  47. *
  48. * @{
  49. */
  50. typedef uint64_t evs_handle_t;
  51. typedef enum {
  52. EVS_TYPE_UNORDERED, /* not implemented */
  53. EVS_TYPE_FIFO, /* same as agreed */
  54. EVS_TYPE_AGREED,
  55. EVS_TYPE_SAFE /* not implemented */
  56. } evs_guarantee_t;
  57. #define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
  58. /** These are the things that get passed around */
  59. struct evs_group {
  60. char key[32];
  61. };
  62. struct evs_ring_id {
  63. unsigned int nodeid;
  64. unsigned long long seq;
  65. };
  66. typedef void (*evs_deliver_fn_t) (
  67. hdb_handle_t handle,
  68. unsigned int nodeid,
  69. const void *msg,
  70. size_t msg_len);
  71. typedef void (*evs_confchg_fn_t) (
  72. hdb_handle_t handle,
  73. const unsigned int *member_list, size_t member_list_entries,
  74. const unsigned int *left_list, size_t left_list_entries,
  75. const unsigned int *joined_list, size_t joined_list_entries,
  76. const struct evs_ring_id *ring_id);
  77. typedef struct {
  78. evs_deliver_fn_t evs_deliver_fn;
  79. evs_confchg_fn_t evs_confchg_fn;
  80. } evs_callbacks_t;
  81. /** @} */
  82. /**
  83. * Create a new evs connection
  84. */
  85. cs_error_t evs_initialize (
  86. evs_handle_t *handle,
  87. evs_callbacks_t *callbacks);
  88. /**
  89. * Close the evs handle
  90. */
  91. cs_error_t evs_finalize (
  92. evs_handle_t handle);
  93. /**
  94. * Get a file descriptor on which to poll.
  95. *
  96. * evs_handle_t is NOT a file descriptor and may not be used directly.
  97. */
  98. cs_error_t evs_fd_get (
  99. evs_handle_t handle,
  100. int *fd);
  101. /**
  102. * Get contexts for a EVS handle
  103. */
  104. cs_error_t evs_context_get (
  105. evs_handle_t handle,
  106. void **context);
  107. /**
  108. * Set contexts for a EVS handle
  109. */
  110. cs_error_t evs_context_set (
  111. evs_handle_t handle,
  112. void *context);
  113. /**
  114. * Dispatch messages and configuration changes
  115. */
  116. cs_error_t evs_dispatch (
  117. evs_handle_t handle,
  118. cs_dispatch_flags_t dispatch_types);
  119. /**
  120. * Join one or more groups.
  121. *
  122. * messages multicasted with evs_mcast_joined will be sent to every
  123. * group that has been joined on handle handle. Any message multicasted
  124. * to a group that has been previously joined will be delivered in evs_dispatch
  125. */
  126. cs_error_t evs_join (
  127. evs_handle_t handle,
  128. const struct evs_group *groups,
  129. size_t group_cnt);
  130. /**
  131. * Leave one or more groups
  132. */
  133. cs_error_t evs_leave (
  134. evs_handle_t handle,
  135. const struct evs_group *groups,
  136. size_t group_cnt);
  137. /**
  138. * Multicast to groups joined with evs_join.
  139. *
  140. * @param handle
  141. * @param guarantee
  142. * @param iovec This iovec will be multicasted to all groups joined with
  143. * the evs_join interface for handle.
  144. * @param iov_len
  145. */
  146. cs_error_t evs_mcast_joined (
  147. evs_handle_t handle,
  148. evs_guarantee_t guarantee,
  149. const struct iovec *iovec,
  150. unsigned int iov_len);
  151. /**
  152. * Multicast to specified groups.
  153. *
  154. * Messages will be multicast to groups specified in the api call and not those
  155. * that have been joined (unless they are in the groups parameter).
  156. */
  157. cs_error_t evs_mcast_groups (
  158. evs_handle_t handle,
  159. evs_guarantee_t guarantee,
  160. const struct evs_group *groups,
  161. size_t group_cnt,
  162. const struct iovec *iovec,
  163. unsigned int iov_len);
  164. /**
  165. * Get membership information from evs
  166. */
  167. cs_error_t evs_membership_get (
  168. evs_handle_t handle,
  169. unsigned int *local_nodeid,
  170. unsigned int *member_list,
  171. size_t *member_list_entries);
  172. #ifdef __cplusplus
  173. }
  174. #endif
  175. #endif /* COROSYNC_EVS_H_DEFINED */