totempg.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. /*
  2. * Copyright (c) 2003-2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2007, 2009 Red Hat, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. * Author: Steven Dake (sdake@redhat.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 TOTEMPG_H_DEFINED
  36. #define TOTEMPG_H_DEFINED
  37. #ifdef __cplusplus
  38. extern "C" {
  39. #endif
  40. #include <netinet/in.h>
  41. #include "totem.h"
  42. #include "coropoll.h"
  43. #include <corosync/hdb.h>
  44. struct totempg_group {
  45. const void *group;
  46. size_t group_len;
  47. };
  48. #define TOTEMPG_AGREED 0
  49. #define TOTEMPG_SAFE 1
  50. /*
  51. * Totem Single Ring Protocol
  52. * depends on poll abstraction, POSIX, IPV4
  53. */
  54. /*
  55. * Initialize the totem process groups abstraction
  56. */
  57. extern int totempg_initialize (
  58. hdb_handle_t poll_handle,
  59. struct totem_config *totem_config
  60. );
  61. extern void totempg_finalize (void);
  62. extern int totempg_callback_token_create (void **handle_out,
  63. enum totem_callback_token_type type,
  64. int delete,
  65. int (*callback_fn) (enum totem_callback_token_type type, const void *),
  66. const void *data);
  67. extern void totempg_callback_token_destroy (void *handle);
  68. /*
  69. * Initialize a groups instance
  70. */
  71. extern int totempg_groups_initialize (
  72. hdb_handle_t *handle,
  73. void (*deliver_fn) (
  74. unsigned int nodeid,
  75. const void *msg,
  76. unsigned int msg_len,
  77. int endian_conversion_required),
  78. void (*confchg_fn) (
  79. enum totem_configuration_type configuration_type,
  80. const unsigned int *member_list, size_t member_list_entries,
  81. const unsigned int *left_list, size_t left_list_entries,
  82. const unsigned int *joined_list, size_t joined_list_entries,
  83. const struct memb_ring_id *ring_id));
  84. extern int totempg_groups_finalize (
  85. hdb_handle_t handle);
  86. extern int totempg_groups_join (
  87. hdb_handle_t handle,
  88. const struct totempg_group *groups,
  89. size_t group_cnt);
  90. extern int totempg_groups_leave (
  91. hdb_handle_t handle,
  92. const struct totempg_group *groups,
  93. size_t group_cnt);
  94. extern int totempg_groups_mcast_joined (
  95. hdb_handle_t handle,
  96. const struct iovec *iovec,
  97. unsigned int iov_len,
  98. int guarantee);
  99. extern int totempg_groups_joined_reserve (
  100. hdb_handle_t handle,
  101. const struct iovec *iovec,
  102. unsigned int iov_len);
  103. extern int totempg_groups_joined_release (
  104. int msg_count);
  105. extern int totempg_groups_mcast_groups (
  106. hdb_handle_t handle,
  107. int guarantee,
  108. const struct totempg_group *groups,
  109. size_t groups_cnt,
  110. const struct iovec *iovec,
  111. unsigned int iov_len);
  112. extern int totempg_groups_send_ok_groups (
  113. hdb_handle_t handle,
  114. const struct totempg_group *groups,
  115. size_t groups_cnt,
  116. const struct iovec *iovec,
  117. unsigned int iov_len);
  118. extern int totempg_ifaces_get (
  119. unsigned int nodeid,
  120. struct totem_ip_address *interfaces,
  121. char ***status,
  122. unsigned int *iface_count);
  123. extern void* totempg_get_stats (void);
  124. void totempg_event_signal (enum totem_event_type type, int value);
  125. extern const char *totempg_ifaces_print (unsigned int nodeid);
  126. extern unsigned int totempg_my_nodeid_get (void);
  127. extern int totempg_my_family_get (void);
  128. extern int totempg_crypto_set (unsigned int type);
  129. extern int totempg_ring_reenable (void);
  130. extern void totempg_service_ready_register (
  131. void (*totem_service_ready) (void));
  132. extern int totempg_member_add (
  133. const struct totem_ip_address *member,
  134. int ring_no);
  135. extern int totempg_member_remove (
  136. const struct totem_ip_address *member,
  137. int ring_no);
  138. #ifdef __cplusplus
  139. }
  140. #endif
  141. #endif /* TOTEMPG_H_DEFINED */