evs.h 4.6 KB

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