evs.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /*
  2. * Copyright (c) 2004 MontaVista Software, Inc.
  3. * Copyright (c) 2006 Sun Microsystems, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@mvista.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 OPENAIS_EVS_H_DEFINED
  36. #define OPENAIS_EVS_H_DEFINED
  37. #include <sys/types.h>
  38. #include <netinet/in.h>
  39. /**
  40. * @defgroup openais Other API services provided by openais
  41. */
  42. /**
  43. * @addtogroup evs_openais
  44. *
  45. * @{
  46. */
  47. typedef uint64_t evs_handle_t;
  48. typedef enum {
  49. EVS_DISPATCH_ONE,
  50. EVS_DISPATCH_ALL,
  51. EVS_DISPATCH_BLOCKING
  52. } evs_dispatch_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. typedef enum {
  60. EVS_OK = 1,
  61. EVS_ERR_LIBRARY = 2,
  62. EVS_ERR_TIMEOUT = 5,
  63. EVS_ERR_TRY_AGAIN = 6,
  64. EVS_ERR_INVALID_PARAM = 7,
  65. EVS_ERR_NO_MEMORY = 8,
  66. EVS_ERR_BAD_HANDLE = 9,
  67. EVS_ERR_ACCESS = 11,
  68. EVS_ERR_NOT_EXIST = 12,
  69. EVS_ERR_EXIST = 14,
  70. EVS_ERR_NOT_SUPPORTED = 20,
  71. EVS_ERR_SECURITY = 29,
  72. EVS_ERR_TOO_MANY_GROUPS=30
  73. } evs_error_t;
  74. #define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
  75. /** These are the things that get passed around */
  76. struct evs_address {
  77. unsigned int nodeid;
  78. unsigned short family;
  79. unsigned char addr[TOTEMIP_ADDRLEN];
  80. };
  81. struct evs_group {
  82. char key[32];
  83. };
  84. typedef void (*evs_deliver_fn_t) (
  85. unsigned int nodeid,
  86. void *msg,
  87. int msg_len);
  88. typedef void (*evs_confchg_fn_t) (
  89. unsigned int *member_list, int member_list_entries,
  90. unsigned int *left_list, int left_list_entries,
  91. unsigned int *joined_list, int joined_list_entries);
  92. typedef struct {
  93. evs_deliver_fn_t evs_deliver_fn;
  94. evs_confchg_fn_t evs_confchg_fn;
  95. } evs_callbacks_t;
  96. /** @} */
  97. /*
  98. * Create a new evs connection
  99. */
  100. evs_error_t evs_initialize (
  101. evs_handle_t *handle,
  102. evs_callbacks_t *callbacks);
  103. /*
  104. * Close the evs handle
  105. */
  106. evs_error_t evs_finalize (
  107. evs_handle_t handle);
  108. /*
  109. * Get a file descriptor on which to poll. evs_handle_t is NOT a
  110. * file descriptor and may not be used directly.
  111. */
  112. evs_error_t evs_fd_get (
  113. evs_handle_t handle,
  114. int *fd);
  115. /*
  116. * Dispatch messages and configuration changes
  117. */
  118. evs_error_t evs_dispatch (
  119. evs_handle_t handle,
  120. evs_dispatch_t dispatch_types);
  121. /*
  122. * Join one or more groups.
  123. * messages multicasted with evs_mcast_joined will be sent to every
  124. * group that has been joined on handle handle. Any message multicasted
  125. * to a group that has been previously joined will be delivered in evs_dispatch
  126. */
  127. evs_error_t evs_join (
  128. evs_handle_t handle,
  129. struct evs_group *groups,
  130. int group_cnt);
  131. /*
  132. * Leave one or more groups
  133. */
  134. evs_error_t evs_leave (
  135. evs_handle_t handle,
  136. struct evs_group *groups,
  137. int group_cnt);
  138. /*
  139. * Multicast to groups joined with evs_join.
  140. * The iovec described by iovec will be multicasted to all groups joined with
  141. * the evs_join interface for handle.
  142. */
  143. evs_error_t evs_mcast_joined (
  144. evs_handle_t handle,
  145. evs_guarantee_t guarantee,
  146. struct iovec *iovec,
  147. int iov_len);
  148. /*
  149. * Multicast to specified groups.
  150. * Messages will be multicast to groups specified in the api call and not those
  151. * that have been joined (unless they are in the groups parameter).
  152. */
  153. evs_error_t evs_mcast_groups (
  154. evs_handle_t handle,
  155. evs_guarantee_t guarantee,
  156. struct evs_group *groups,
  157. int group_cnt,
  158. struct iovec *iovec,
  159. int iov_len);
  160. /*
  161. * Get membership information from evs
  162. */
  163. evs_error_t evs_membership_get (
  164. evs_handle_t handle,
  165. unsigned int *local_nodeid,
  166. unsigned int *member_list,
  167. unsigned int *member_list_entries);
  168. #endif /* OPENAIS_EVS_H_DEFINED */