cfg.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006-2013 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. /**
  60. * @brief enum corosync_cfg_shutdown_reply_flags_t
  61. */
  62. typedef enum {
  63. COROSYNC_CFG_SHUTDOWN_FLAG_NO = 0,
  64. COROSYNC_CFG_SHUTDOWN_FLAG_YES = 1,
  65. } corosync_cfg_shutdown_reply_flags_t;
  66. /**
  67. * @brief corosync_cfg_shutdown_callback_t callback
  68. */
  69. typedef void (*corosync_cfg_shutdown_callback_t) (
  70. corosync_cfg_handle_t cfg_handle,
  71. corosync_cfg_shutdown_flags_t flags);
  72. /**
  73. * @brief struct corosync_cfg_shutdown_callback_t
  74. */
  75. typedef struct {
  76. corosync_cfg_shutdown_callback_t corosync_cfg_shutdown_callback;
  77. } corosync_cfg_callbacks_t;
  78. /**
  79. * A node address. This is a complete sockaddr_in[6]
  80. *
  81. * To explain:
  82. * If you cast cna_address to a 'struct sockaddr', the sa_family field
  83. * will be AF_INET or AF_INET6. Armed with that knowledge you can then
  84. * cast it to a sockaddr_in or sockaddr_in6 and pull out the address.
  85. * No other sockaddr fields are valid.
  86. * Also, you must ignore any part of the sockaddr beyond the length supplied
  87. */
  88. typedef struct
  89. {
  90. int address_length; /**< @todo FIXME: set but never used */
  91. char address[sizeof(struct sockaddr_in6)];
  92. } corosync_cfg_node_address_t;
  93. /*
  94. * Interfaces
  95. */
  96. #ifdef __cplusplus
  97. extern "C" {
  98. #endif
  99. /**
  100. * @brief corosync_cfg_initialize
  101. * @param cfg_handle
  102. * @param cfg_callbacks
  103. * @return
  104. */
  105. cs_error_t
  106. corosync_cfg_initialize (
  107. corosync_cfg_handle_t *cfg_handle,
  108. const corosync_cfg_callbacks_t *cfg_callbacks);
  109. /**
  110. * @brief corosync_cfg_fd_get
  111. * @param cfg_handle
  112. * @param selection_fd
  113. * @return
  114. */
  115. cs_error_t
  116. corosync_cfg_fd_get (
  117. corosync_cfg_handle_t cfg_handle,
  118. int32_t *selection_fd);
  119. /**
  120. * @brief corosync_cfg_dispatch
  121. * @param cfg_handle
  122. * @param dispatch_flags
  123. * @return
  124. */
  125. cs_error_t
  126. corosync_cfg_dispatch (
  127. corosync_cfg_handle_t cfg_handle,
  128. cs_dispatch_flags_t dispatch_flags);
  129. /**
  130. * @brief corosync_cfg_finalize
  131. * @param cfg_handle
  132. * @return
  133. */
  134. cs_error_t
  135. corosync_cfg_finalize (
  136. corosync_cfg_handle_t cfg_handle);
  137. /**
  138. * @brief corosync_cfg_ring_status_get
  139. * @param cfg_handle
  140. * @param interface_names
  141. * @param status
  142. * @param interface_count
  143. * @return
  144. */
  145. cs_error_t
  146. corosync_cfg_ring_status_get (
  147. corosync_cfg_handle_t cfg_handle,
  148. char ***interface_names,
  149. char ***status,
  150. unsigned int *interface_count);
  151. /**
  152. * @brief corosync_cfg_kill_node
  153. * @param cfg_handle
  154. * @param nodeid
  155. * @param reason
  156. * @return
  157. */
  158. cs_error_t
  159. corosync_cfg_kill_node (
  160. corosync_cfg_handle_t cfg_handle,
  161. unsigned int nodeid,
  162. const char *reason);
  163. /**
  164. * @brief corosync_cfg_try_shutdown
  165. * @param cfg_handle
  166. * @param flags
  167. * @return
  168. */
  169. cs_error_t
  170. corosync_cfg_try_shutdown (
  171. corosync_cfg_handle_t cfg_handle,
  172. corosync_cfg_shutdown_flags_t flags);
  173. /**
  174. * @brief corosync_cfg_replyto_shutdown
  175. * @param cfg_handle
  176. * @param flags
  177. * @return
  178. */
  179. cs_error_t
  180. corosync_cfg_replyto_shutdown (
  181. corosync_cfg_handle_t cfg_handle,
  182. corosync_cfg_shutdown_reply_flags_t flags);
  183. /**
  184. * @brief corosync_cfg_get_node_addrs
  185. * @param cfg_handle
  186. * @param nodeid
  187. * @param max_addrs
  188. * @param num_addrs
  189. * @param addrs
  190. * @return
  191. */
  192. cs_error_t
  193. corosync_cfg_get_node_addrs (
  194. corosync_cfg_handle_t cfg_handle,
  195. unsigned int nodeid,
  196. size_t max_addrs,
  197. int *num_addrs,
  198. corosync_cfg_node_address_t *addrs);
  199. /**
  200. * @brief corosync_cfg_local_get
  201. * @param handle
  202. * @param local_nodeid
  203. * @return
  204. */
  205. cs_error_t
  206. corosync_cfg_local_get (
  207. corosync_cfg_handle_t handle,
  208. unsigned int *local_nodeid);
  209. /**
  210. * @brief corosync_cfg_reload_config
  211. * @param handle
  212. * @return
  213. */
  214. cs_error_t corosync_cfg_reload_config (
  215. corosync_cfg_handle_t handle);
  216. /**
  217. * @brief Reopen logging files
  218. * @param handle CFG service handle
  219. * @return CS_OK on success, CS_ERR_NOT_SUPPORTED if reopening of logging files is not available,
  220. * otherwise one of common errors.
  221. */
  222. cs_error_t corosync_cfg_reopen_log_files (
  223. corosync_cfg_handle_t handle);
  224. #ifdef __cplusplus
  225. }
  226. #endif
  227. #endif /* COROSYNC_CFG_H_DEFINED */