cfg.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2012 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 COROSYNC_CFG_H_DEFINED
  36. #define COROSYNC_CFG_H_DEFINED
  37. #include <netinet/in.h>
  38. #include <corosync/corotypes.h>
  39. typedef uint64_t corosync_cfg_handle_t;
  40. /**
  41. * Shutdown types.
  42. */
  43. typedef enum {
  44. /**
  45. * REQUEST is the normal shutdown.
  46. * Other daemons will be consulted.
  47. */
  48. COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST = 0,
  49. /**
  50. * REGARDLESS will tell other daemons but ignore their opinions.
  51. */
  52. COROSYNC_CFG_SHUTDOWN_FLAG_REGARDLESS = 1,
  53. /**
  54. * IMMEDIATE will shut down straight away
  55. * (but still tell other nodes).
  56. */
  57. COROSYNC_CFG_SHUTDOWN_FLAG_IMMEDIATE = 2,
  58. } corosync_cfg_shutdown_flags_t;
  59. typedef enum {
  60. COROSYNC_CFG_SHUTDOWN_FLAG_NO = 0,
  61. COROSYNC_CFG_SHUTDOWN_FLAG_YES = 1,
  62. } corosync_cfg_shutdown_reply_flags_t;
  63. typedef void (*corosync_cfg_shutdown_callback_t) (
  64. corosync_cfg_handle_t cfg_handle,
  65. corosync_cfg_shutdown_flags_t flags);
  66. typedef struct {
  67. corosync_cfg_shutdown_callback_t corosync_cfg_shutdown_callback;
  68. } corosync_cfg_callbacks_t;
  69. /**
  70. * A node address. This is a complete sockaddr_in[6]
  71. *
  72. * To explain:
  73. * If you cast cna_address to a 'struct sockaddr', the sa_family field
  74. * will be AF_INET or AF_INET6. Armed with that knowledge you can then
  75. * cast it to a sockaddr_in or sockaddr_in6 and pull out the address.
  76. * No other sockaddr fields are valid.
  77. * Also, you must ignore any part of the sockaddr beyond the length supplied
  78. */
  79. typedef struct
  80. {
  81. int address_length; /**< @todo FIXME: set but never used */
  82. char address[sizeof(struct sockaddr_in6)];
  83. } corosync_cfg_node_address_t;
  84. /*
  85. * Interfaces
  86. */
  87. #ifdef __cplusplus
  88. extern "C" {
  89. #endif
  90. cs_error_t
  91. corosync_cfg_initialize (
  92. corosync_cfg_handle_t *cfg_handle,
  93. const corosync_cfg_callbacks_t *cfg_callbacks);
  94. cs_error_t
  95. corosync_cfg_fd_get (
  96. corosync_cfg_handle_t cfg_handle,
  97. int32_t *selection_fd);
  98. cs_error_t
  99. corosync_cfg_dispatch (
  100. corosync_cfg_handle_t cfg_handle,
  101. cs_dispatch_flags_t dispatch_flags);
  102. cs_error_t
  103. corosync_cfg_finalize (
  104. corosync_cfg_handle_t cfg_handle);
  105. cs_error_t
  106. corosync_cfg_ring_status_get (
  107. corosync_cfg_handle_t cfg_handle,
  108. char ***interface_names,
  109. char ***status,
  110. unsigned int *interface_count);
  111. cs_error_t
  112. corosync_cfg_ring_reenable (
  113. corosync_cfg_handle_t cfg_handle);
  114. cs_error_t
  115. corosync_cfg_kill_node (
  116. corosync_cfg_handle_t cfg_handle,
  117. unsigned int nodeid,
  118. const char *reason);
  119. cs_error_t
  120. corosync_cfg_try_shutdown (
  121. corosync_cfg_handle_t cfg_handle,
  122. corosync_cfg_shutdown_flags_t flags);
  123. cs_error_t
  124. corosync_cfg_replyto_shutdown (
  125. corosync_cfg_handle_t cfg_handle,
  126. corosync_cfg_shutdown_reply_flags_t flags);
  127. cs_error_t
  128. corosync_cfg_get_node_addrs (
  129. corosync_cfg_handle_t cfg_handle,
  130. int nodeid,
  131. size_t max_addrs,
  132. int *num_addrs,
  133. corosync_cfg_node_address_t *addrs);
  134. cs_error_t
  135. corosync_cfg_local_get (
  136. corosync_cfg_handle_t handle,
  137. unsigned int *local_nodeid);
  138. cs_error_t
  139. corosync_cfg_crypto_set (
  140. corosync_cfg_handle_t handle,
  141. unsigned int type);
  142. #ifdef __cplusplus
  143. }
  144. #endif
  145. #endif /* COROSYNC_CFG_H_DEFINED */