cfg.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * Copyright (c) 2005 MontaVista Software, Inc.
  3. * Copyright (c) 2006 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 AIS_COROSYNCCFG_H_DEFINED
  36. #define AIS_COROSYNCCFG_H_DEFINED
  37. #include <netinet/in.h>
  38. #include <corosync/corotypes.h>
  39. typedef uint64_t corosync_cfg_handle_t;
  40. typedef enum {
  41. COROSYNC_CFG_ADMINISTRATIVETARGET_SERVICEUNIT = 0,
  42. COROSYNC_CFG_ADMINISTRATIVETARGET_SERVICEGROUP = 1,
  43. COROSYNC_CFG_ADMINISTRATIVETARGET_COMPONENTSERVICEINSTANCE = 2,
  44. COROSYNC_CFG_ADMINISTRATIVETARGET_NODE = 3
  45. } CorosyncCfgAdministrativeTargetT;
  46. typedef enum {
  47. COROSYNC_CFG_ADMINISTRATIVESTATE_UNLOCKED = 0,
  48. COROSYNC_CFG_ADMINISTRATIVESTATE_LOCKED = 1,
  49. COROSYNC_CFG_ADMINISTRATIVESTATE_STOPPING = 2
  50. } CorosyncCfgAdministrativeStateT;
  51. typedef enum {
  52. COROSYNC_CFG_OPERATIONALSTATE_ENABLED = 1,
  53. COROSYNC_CFG_OPERATIONALSTATE_DISABLED = 2
  54. } CorosyncCfgOperationalStateT;
  55. typedef enum {
  56. COROSYNC_CFG_READINESSSTATE_OUTOFSERVICE = 1,
  57. COROSYNC_CFG_READINESSSTATE_INSERVICE = 2,
  58. COROSYNC_CFG_READINESSSTATE_STOPPING = 3
  59. } CorosyncCfgReadinessStateT;
  60. typedef enum {
  61. COROSYNC_CFG_PRESENCESTATE_UNINSTANTIATED = 1,
  62. COROSYNC_CFG_PRESENCESTATE_INSTANTIATING = 2,
  63. COROSYNC_CFG_PRESENCESTATE_INSTANTIATED = 3,
  64. COROSYNC_CFG_PRESENCESTATE_TERMINATING = 4,
  65. COROSYNC_CFG_PRESENCESTATE_RESTARTING = 5,
  66. COROSYNC_CFG_PRESENCESTATE_INSTANTIATION_FAILED = 6,
  67. COROSYNC_CFG_PRESENCESTATE_TERMINATION_FAILED = 7
  68. } CorosyncCfgPresenceStateT;
  69. typedef enum {
  70. COROSYNC_CFG_STATETYPE_OPERATIONAL = 0,
  71. COROSYNC_CFG_STATETYPE_ADMINISTRATIVE = 1,
  72. COROSYNC_CFG_STATETYPE_READINESS = 2,
  73. COROSYNC_CFG_STATETYPE_HA = 3,
  74. COROSYNC_CFG_STATETYPE_PRESENCE = 4
  75. } CorosyncCfgStateTypeT;
  76. /* Shutdown types.
  77. REQUEST is the normal shutdown. other daemons will be consulted
  78. REGARDLESS will tell other daemons but ignore their opinions
  79. IMMEDIATE will shut down straight away (but still tell other nodes)
  80. */
  81. typedef enum {
  82. COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST = 0,
  83. COROSYNC_CFG_SHUTDOWN_FLAG_REGARDLESS = 1,
  84. COROSYNC_CFG_SHUTDOWN_FLAG_IMMEDIATE = 2,
  85. } CorosyncCfgShutdownFlagsT;
  86. typedef enum {
  87. COROSYNC_CFG_SHUTDOWN_FLAG_NO = 0,
  88. COROSYNC_CFG_SHUTDOWN_FLAG_YES = 1,
  89. } CorosyncCfgShutdownReplyFlagsT;
  90. typedef struct {
  91. cs_name_t name;
  92. CorosyncCfgStateTypeT stateType;
  93. CorosyncCfgAdministrativeStateT administrativeState;
  94. } CorosyncCfgStateNotificationT;
  95. typedef struct {
  96. uint32_t numberOfItems;
  97. CorosyncCfgStateNotificationT *notification;
  98. } CorosyncCfgStateNotificationBufferT;
  99. typedef void (*CorosyncCfgStateTrackCallbackT) (
  100. CorosyncCfgStateNotificationBufferT *notificationBuffer,
  101. cs_error_t error);
  102. typedef void (*CorosyncCfgShutdownCallbackT) (
  103. corosync_cfg_handle_t cfg_handle,
  104. CorosyncCfgShutdownFlagsT flags);
  105. typedef struct {
  106. CorosyncCfgStateTrackCallbackT
  107. corosyncCfgStateTrackCallback;
  108. CorosyncCfgShutdownCallbackT
  109. corosyncCfgShutdownCallback;
  110. } CorosyncCfgCallbacksT;
  111. /*
  112. * Interfaces
  113. */
  114. #ifdef __cplusplus
  115. extern "C" {
  116. #endif
  117. cs_error_t
  118. corosync_cfg_initialize (
  119. corosync_cfg_handle_t *cfg_handle,
  120. const CorosyncCfgCallbacksT *cfgCallbacks);
  121. cs_error_t
  122. corosync_cfg_fd_get (
  123. corosync_cfg_handle_t cfg_handle,
  124. int32_t *selection_fd);
  125. cs_error_t
  126. corosync_cfg_dispatch (
  127. corosync_cfg_handle_t cfg_handle,
  128. cs_dispatch_flags_t dispatchFlags);
  129. cs_error_t
  130. corosync_cfg_finalize (
  131. corosync_cfg_handle_t cfg_handle);
  132. cs_error_t
  133. corosync_cfg_ring_status_get (
  134. corosync_cfg_handle_t cfg_handle,
  135. char ***interface_names,
  136. char ***status,
  137. unsigned int *interface_count);
  138. cs_error_t
  139. corosync_cfg_ring_reenable (
  140. corosync_cfg_handle_t cfg_handle);
  141. cs_error_t
  142. corosync_cfg_service_load (
  143. corosync_cfg_handle_t cfg_handle,
  144. char *service_name,
  145. unsigned int service_ver);
  146. cs_error_t
  147. corosync_cfg_service_unload (
  148. corosync_cfg_handle_t cfg_handle,
  149. char *service_name,
  150. unsigned int service_ver);
  151. cs_error_t
  152. corosync_cfg_administrative_state_get (
  153. corosync_cfg_handle_t cfg_handle,
  154. CorosyncCfgAdministrativeTargetT administrativeTarget,
  155. CorosyncCfgAdministrativeStateT *administrativeState);
  156. cs_error_t
  157. corosync_cfg_administrative_state_set (
  158. corosync_cfg_handle_t cfg_handle,
  159. CorosyncCfgAdministrativeTargetT administrativeTarget,
  160. CorosyncCfgAdministrativeStateT administrativeState);
  161. cs_error_t
  162. corosync_cfg_kill_node (
  163. corosync_cfg_handle_t cfg_handle,
  164. unsigned int nodeid,
  165. char *reason);
  166. cs_error_t
  167. corosync_cfg_try_shutdown (
  168. corosync_cfg_handle_t cfg_handle,
  169. CorosyncCfgShutdownFlagsT flags);
  170. cs_error_t
  171. corosync_cfg_replyto_shutdown (
  172. corosync_cfg_handle_t cfg_handle,
  173. CorosyncCfgShutdownReplyFlagsT flags);
  174. cs_error_t
  175. corosync_cfg_state_track (
  176. corosync_cfg_handle_t cfg_handle,
  177. uint8_t trackFlags,
  178. const CorosyncCfgStateNotificationT *notificationBuffer);
  179. cs_error_t
  180. corosync_cfg_state_track_stop (
  181. corosync_cfg_handle_t cfg_handle);
  182. #ifdef __cplusplus
  183. }
  184. #endif
  185. #endif /* AIS_COROSYNCCFG_H_DEFINED */