evs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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. evs_handle_t is NOT a
  95. * file descriptor and may not be used directly.
  96. */
  97. cs_error_t evs_fd_get (
  98. evs_handle_t handle,
  99. int *fd);
  100. /*
  101. * Get and set contexts for a EVS handle
  102. */
  103. cs_error_t evs_context_get (
  104. evs_handle_t handle,
  105. void **context);
  106. cs_error_t evs_context_set (
  107. evs_handle_t handle,
  108. void *context);
  109. /*
  110. * Dispatch messages and configuration changes
  111. */
  112. cs_error_t evs_dispatch (
  113. evs_handle_t handle,
  114. cs_dispatch_flags_t dispatch_types);
  115. /*
  116. * Join one or more groups.
  117. * messages multicasted with evs_mcast_joined will be sent to every
  118. * group that has been joined on handle handle. Any message multicasted
  119. * to a group that has been previously joined will be delivered in evs_dispatch
  120. */
  121. cs_error_t evs_join (
  122. evs_handle_t handle,
  123. const struct evs_group *groups,
  124. size_t group_cnt);
  125. /*
  126. * Leave one or more groups
  127. */
  128. cs_error_t evs_leave (
  129. evs_handle_t handle,
  130. const struct evs_group *groups,
  131. size_t group_cnt);
  132. /*
  133. * Multicast to groups joined with evs_join.
  134. * The iovec described by iovec will be multicasted to all groups joined with
  135. * the evs_join interface for handle.
  136. */
  137. cs_error_t evs_mcast_joined (
  138. evs_handle_t handle,
  139. evs_guarantee_t guarantee,
  140. const struct iovec *iovec,
  141. unsigned int iov_len);
  142. /*
  143. * Multicast to specified groups.
  144. * Messages will be multicast to groups specified in the api call and not those
  145. * that have been joined (unless they are in the groups parameter).
  146. */
  147. cs_error_t evs_mcast_groups (
  148. evs_handle_t handle,
  149. evs_guarantee_t guarantee,
  150. const struct evs_group *groups,
  151. size_t group_cnt,
  152. const struct iovec *iovec,
  153. unsigned int iov_len);
  154. /*
  155. * Get membership information from evs
  156. */
  157. cs_error_t evs_membership_get (
  158. evs_handle_t handle,
  159. unsigned int *local_nodeid,
  160. unsigned int *member_list,
  161. size_t *member_list_entries);
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. #endif /* COROSYNC_EVS_H_DEFINED */