evs.h 5.0 KB

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