evs.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /**
  42. * @defgroup corosync Other API services provided by corosync
  43. */
  44. /**
  45. * @addtogroup evs_corosync
  46. *
  47. * @{
  48. */
  49. typedef uint64_t evs_handle_t;
  50. typedef enum {
  51. EVS_TYPE_UNORDERED, /* not implemented */
  52. EVS_TYPE_FIFO, /* same as agreed */
  53. EVS_TYPE_AGREED,
  54. EVS_TYPE_SAFE /* not implemented */
  55. } evs_guarantee_t;
  56. #define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
  57. /** These are the things that get passed around */
  58. struct evs_address {
  59. unsigned int nodeid;
  60. unsigned short family;
  61. unsigned char addr[TOTEMIP_ADDRLEN];
  62. };
  63. struct evs_group {
  64. char key[32];
  65. };
  66. typedef void (*evs_deliver_fn_t) (
  67. unsigned int nodeid,
  68. const void *msg,
  69. size_t msg_len);
  70. typedef void (*evs_confchg_fn_t) (
  71. unsigned int *member_list, size_t member_list_entries,
  72. unsigned int *left_list, size_t left_list_entries,
  73. unsigned int *joined_list, size_t joined_list_entries);
  74. typedef struct {
  75. evs_deliver_fn_t evs_deliver_fn;
  76. evs_confchg_fn_t evs_confchg_fn;
  77. } evs_callbacks_t;
  78. /** @} */
  79. /*
  80. * Create a new evs connection
  81. */
  82. cs_error_t evs_initialize (
  83. evs_handle_t *handle,
  84. evs_callbacks_t *callbacks);
  85. /*
  86. * Close the evs handle
  87. */
  88. cs_error_t evs_finalize (
  89. evs_handle_t handle);
  90. /*
  91. * Get a file descriptor on which to poll. evs_handle_t is NOT a
  92. * file descriptor and may not be used directly.
  93. */
  94. cs_error_t evs_fd_get (
  95. evs_handle_t handle,
  96. int *fd);
  97. /*
  98. * Dispatch messages and configuration changes
  99. */
  100. cs_error_t evs_dispatch (
  101. evs_handle_t handle,
  102. cs_dispatch_flags_t dispatch_types);
  103. /*
  104. * Join one or more groups.
  105. * messages multicasted with evs_mcast_joined will be sent to every
  106. * group that has been joined on handle handle. Any message multicasted
  107. * to a group that has been previously joined will be delivered in evs_dispatch
  108. */
  109. cs_error_t evs_join (
  110. evs_handle_t handle,
  111. const struct evs_group *groups,
  112. size_t group_cnt);
  113. /*
  114. * Leave one or more groups
  115. */
  116. cs_error_t evs_leave (
  117. evs_handle_t handle,
  118. const struct evs_group *groups,
  119. size_t group_cnt);
  120. /*
  121. * Multicast to groups joined with evs_join.
  122. * The iovec described by iovec will be multicasted to all groups joined with
  123. * the evs_join interface for handle.
  124. */
  125. cs_error_t evs_mcast_joined (
  126. evs_handle_t handle,
  127. evs_guarantee_t guarantee,
  128. const struct iovec *iovec,
  129. unsigned int iov_len);
  130. /*
  131. * Multicast to specified groups.
  132. * Messages will be multicast to groups specified in the api call and not those
  133. * that have been joined (unless they are in the groups parameter).
  134. */
  135. cs_error_t evs_mcast_groups (
  136. evs_handle_t handle,
  137. evs_guarantee_t guarantee,
  138. const struct evs_group *groups,
  139. size_t group_cnt,
  140. const struct iovec *iovec,
  141. unsigned int iov_len);
  142. /*
  143. * Get membership information from evs
  144. */
  145. cs_error_t evs_membership_get (
  146. evs_handle_t handle,
  147. unsigned int *local_nodeid,
  148. unsigned int *member_list,
  149. size_t *member_list_entries);
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif /* COROSYNC_EVS_H_DEFINED */