4
0

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@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 <netinet/in.h>
  37. typedef unsigned int evs_handle_t;
  38. typedef enum {
  39. EVS_DISPATCH_ONE,
  40. EVS_DISPATCH_ALL,
  41. EVS_DISPATCH_BLOCKING
  42. } evs_dispatch_t;
  43. typedef enum {
  44. EVS_PRIO_RECOVERY,
  45. EVS_PRIO_HIGH,
  46. EVS_PRIO_MED,
  47. EVS_PRIO_LOW
  48. } evs_priority_t;
  49. typedef enum {
  50. EVS_TYPE_UNORDERED, /* not implemented */
  51. EVS_TYPE_FIFO, /* same as agreed */
  52. EVS_TYPE_AGREED,
  53. EVS_TYPE_SAFE /* not implemented */
  54. } evs_guarantee_t;
  55. typedef enum {
  56. EVS_OK = 1,
  57. EVS_ERR_LIBRARY = 2,
  58. EVS_ERR_TIMEOUT = 5,
  59. EVS_ERR_TRY_AGAIN = 6,
  60. EVS_ERR_INVALID_PARAM = 7,
  61. EVS_ERR_NO_MEMORY = 8,
  62. EVS_ERR_BAD_HANDLE = 9,
  63. EVS_ERR_ACCESS = 11,
  64. EVS_ERR_NOT_EXIST = 12,
  65. EVS_ERR_EXIST = 14,
  66. EVS_ERR_NOT_SUPPORTED = 20,
  67. EVS_ERR_SECURITY = 29,
  68. EVS_ERR_TOO_MANY_GROUPS=30
  69. } evs_error_t;
  70. struct evs_group {
  71. char key[32];
  72. };
  73. typedef void (*evs_deliver_fn_t) (
  74. struct in_addr source_addr,
  75. void *msg,
  76. int msg_len);
  77. typedef void (*evs_confchg_fn_t) (
  78. struct in_addr *member_list, int member_list_entries,
  79. struct in_addr *left_list, int left_list_entries,
  80. struct in_addr *joined_list, int joined_list_entries);
  81. typedef struct {
  82. evs_deliver_fn_t evs_deliver_fn;
  83. evs_confchg_fn_t evs_confchg_fn;
  84. } evs_callbacks_t;
  85. /*
  86. * Create a new evs connection
  87. */
  88. evs_error_t evs_initialize (
  89. evs_handle_t *handle,
  90. evs_callbacks_t *callbacks);
  91. /*
  92. * Close the evs handle
  93. */
  94. evs_error_t evs_finalize (
  95. evs_handle_t *handle);
  96. /*
  97. * Get a file descriptor on which to poll. evs_handle_t is NOT a
  98. * file descriptor and may not be used directly.
  99. */
  100. evs_error_t evs_fd_get (
  101. evs_handle_t *handle,
  102. int *fd);
  103. /*
  104. * Dispatch messages and configuration changes
  105. */
  106. evs_error_t evs_dispatch (
  107. evs_handle_t *handle,
  108. evs_dispatch_t dispatch_types);
  109. /*
  110. * Join one or more groups.
  111. * messages multicasted with evs_mcast_joined will be sent to every
  112. * group that has been joined on handle handle. Any message multicasted
  113. * to a group that has been previously joined will be delivered in evs_dispatch
  114. */
  115. evs_error_t evs_join (
  116. evs_handle_t *handle,
  117. struct evs_group *groups,
  118. int group_cnt);
  119. /*
  120. * Leave one or more groups
  121. */
  122. evs_error_t evs_leave (
  123. evs_handle_t *handle,
  124. struct evs_group *groups,
  125. int group_cnt);
  126. /*
  127. * Multicast to groups joined with evs_join.
  128. * The iovec described by iovec will be multicasted to all groups joined with
  129. * the evs_join interface for handle.
  130. */
  131. evs_error_t evs_mcast_joined (
  132. evs_handle_t *handle,
  133. evs_guarantee_t guarantee,
  134. evs_priority_t priority,
  135. struct iovec *iovec,
  136. int iov_len);
  137. /*
  138. * Multicast to specified groups.
  139. * Messages will be multicast to groups specified in the api call and not those
  140. * that have been joined (unless they are in the groups parameter).
  141. */
  142. evs_error_t evs_mcast_groups (
  143. evs_handle_t *handle,
  144. evs_guarantee_t guarantee,
  145. evs_priority_t priority,
  146. struct evs_group *groups,
  147. int group_cnt,
  148. struct iovec *iovec,
  149. int iov_len);
  150. #endif /* OPENAIS_EVS_H_DEFINED */