evs.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /*
  2. * Copyright (c) 2004 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2011 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.com)
  8. *
  9. * This software licensed under BSD license, the text of which follows:
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions are met:
  13. *
  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.
  22. *
  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.
  34. */
  35. #ifndef COROSYNC_EVS_H_DEFINED
  36. #define COROSYNC_EVS_H_DEFINED
  37. #include <inttypes.h>
  38. #include <netinet/in.h>
  39. #include <corosync/corotypes.h>
  40. #include <corosync/hdb.h>
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /**
  45. * @defgroup corosync Other API services provided by corosync
  46. */
  47. /**
  48. * @addtogroup evs_corosync
  49. *
  50. * @{
  51. */
  52. typedef uint64_t evs_handle_t;
  53. typedef enum {
  54. EVS_TYPE_UNORDERED, /* not implemented */
  55. EVS_TYPE_FIFO, /* same as agreed */
  56. EVS_TYPE_AGREED,
  57. EVS_TYPE_SAFE /* not implemented */
  58. } evs_guarantee_t;
  59. #define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
  60. /** These are the things that get passed around */
  61. struct evs_group {
  62. char key[32];
  63. };
  64. struct evs_ring_id {
  65. unsigned int nodeid;
  66. unsigned long long seq;
  67. };
  68. typedef void (*evs_deliver_fn_t) (
  69. hdb_handle_t handle,
  70. unsigned int nodeid,
  71. const void *msg,
  72. size_t msg_len);
  73. typedef void (*evs_confchg_fn_t) (
  74. hdb_handle_t handle,
  75. const unsigned int *member_list, size_t member_list_entries,
  76. const unsigned int *left_list, size_t left_list_entries,
  77. const unsigned int *joined_list, size_t joined_list_entries,
  78. const struct evs_ring_id *ring_id);
  79. typedef struct {
  80. evs_deliver_fn_t evs_deliver_fn;
  81. evs_confchg_fn_t evs_confchg_fn;
  82. } evs_callbacks_t;
  83. /** @} */
  84. /**
  85. * Create a new evs connection
  86. */
  87. cs_error_t evs_initialize (
  88. evs_handle_t *handle,
  89. evs_callbacks_t *callbacks);
  90. /**
  91. * Close the evs handle
  92. */
  93. cs_error_t evs_finalize (
  94. evs_handle_t handle);
  95. /**
  96. * Get a file descriptor on which to poll.
  97. *
  98. * evs_handle_t is NOT a file descriptor and may not be used directly.
  99. */
  100. cs_error_t evs_fd_get (
  101. evs_handle_t handle,
  102. int *fd);
  103. /**
  104. * Get contexts for a EVS handle
  105. */
  106. cs_error_t evs_context_get (
  107. evs_handle_t handle,
  108. void **context);
  109. /**
  110. * Set contexts for a EVS handle
  111. */
  112. cs_error_t evs_context_set (
  113. evs_handle_t handle,
  114. void *context);
  115. /**
  116. * Dispatch messages and configuration changes
  117. */
  118. cs_error_t evs_dispatch (
  119. evs_handle_t handle,
  120. cs_dispatch_flags_t dispatch_types);
  121. /**
  122. * Join one or more groups.
  123. *
  124. * messages multicasted with evs_mcast_joined will be sent to every
  125. * group that has been joined on handle handle. Any message multicasted
  126. * to a group that has been previously joined will be delivered in evs_dispatch
  127. */
  128. cs_error_t evs_join (
  129. evs_handle_t handle,
  130. const struct evs_group *groups,
  131. size_t group_cnt);
  132. /**
  133. * Leave one or more groups
  134. */
  135. cs_error_t evs_leave (
  136. evs_handle_t handle,
  137. const struct evs_group *groups,
  138. size_t group_cnt);
  139. /**
  140. * Multicast to groups joined with evs_join.
  141. *
  142. * @param handle
  143. * @param guarantee
  144. * @param iovec This iovec will be multicasted to all groups joined with
  145. * the evs_join interface for handle.
  146. * @param iov_len
  147. */
  148. cs_error_t evs_mcast_joined (
  149. evs_handle_t handle,
  150. evs_guarantee_t guarantee,
  151. const struct iovec *iovec,
  152. unsigned int iov_len);
  153. /**
  154. * Multicast to specified groups.
  155. *
  156. * Messages will be multicast to groups specified in the api call and not those
  157. * that have been joined (unless they are in the groups parameter).
  158. */
  159. cs_error_t evs_mcast_groups (
  160. evs_handle_t handle,
  161. evs_guarantee_t guarantee,
  162. const struct evs_group *groups,
  163. size_t group_cnt,
  164. const struct iovec *iovec,
  165. unsigned int iov_len);
  166. /**
  167. * Get membership information from evs
  168. */
  169. cs_error_t evs_membership_get (
  170. evs_handle_t handle,
  171. unsigned int *local_nodeid,
  172. unsigned int *member_list,
  173. size_t *member_list_entries);
  174. #ifdef __cplusplus
  175. }
  176. #endif
  177. #endif /* COROSYNC_EVS_H_DEFINED */