evs.h 4.6 KB

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