coroapi.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. /*
  2. * Copyright (c) 2008, 2009 Red Hat, Inc.
  3. *
  4. * All rights reserved.
  5. *
  6. * Author: Steven Dake (sdake@redhat.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 COROAPI_H_DEFINED
  35. #define COROAPI_H_DEFINED
  36. #include <stdio.h>
  37. #ifdef COROSYNC_BSD
  38. #include <sys/uio.h>
  39. #endif
  40. #include <corosync/hdb.h>
  41. #include <corosync/swab.h>
  42. typedef struct {
  43. uint32_t nodeid __attribute__((aligned(8)));
  44. void *conn __attribute__((aligned(8)));
  45. } mar_message_source_t __attribute__((aligned(8)));
  46. static inline void swab_mar_message_source_t (mar_message_source_t *to_swab)
  47. {
  48. swab32 (to_swab->nodeid);
  49. /*
  50. * if it is from a byteswapped machine, then we can safely
  51. * ignore its conn info data structure since this is only
  52. * local to the machine
  53. */
  54. to_swab->conn = NULL;
  55. }
  56. typedef void * corosync_timer_handle_t;
  57. struct corosync_tpg_group {
  58. const void *group;
  59. size_t group_len;
  60. };
  61. #define TOTEMIP_ADDRLEN (sizeof(struct in6_addr))
  62. #define INTERFACE_MAX 2
  63. #ifdef HAVE_SMALL_MEMORY_FOOTPRINT
  64. #define PROCESSOR_COUNT_MAX 16
  65. #define MESSAGE_SIZE_MAX 1024*64
  66. #define MESSAGE_QUEUE_MAX 512
  67. #else
  68. #define PROCESSOR_COUNT_MAX 384
  69. #define MESSAGE_SIZE_MAX 1024*1024 /* (1MB) */
  70. #define MESSAGE_QUEUE_MAX MESSAGE_SIZE_MAX / totem_config->net_mtu
  71. #endif /* HAVE_SMALL_MEMORY_FOOTPRINT */
  72. #define TOTEM_AGREED 0
  73. #define TOTEM_SAFE 1
  74. #define MILLI_2_NANO_SECONDS 1000000ULL
  75. #if !defined(TOTEM_IP_ADDRESS)
  76. struct totem_ip_address {
  77. unsigned int nodeid;
  78. unsigned short family;
  79. unsigned char addr[TOTEMIP_ADDRLEN];
  80. } __attribute__((packed));
  81. #endif
  82. #if !defined(MEMB_RING_ID)
  83. struct memb_ring_id {
  84. struct totem_ip_address rep;
  85. unsigned long long seq;
  86. } __attribute__((packed));
  87. #endif
  88. #if !defined(TOTEM_CONFIGURATION_TYPE)
  89. enum totem_configuration_type {
  90. TOTEM_CONFIGURATION_REGULAR,
  91. TOTEM_CONFIGURATION_TRANSITIONAL
  92. };
  93. #endif
  94. #if !defined(TOTEM_CALLBACK_TOKEN_TYPE)
  95. enum totem_callback_token_type {
  96. TOTEM_CALLBACK_TOKEN_RECEIVED = 1,
  97. TOTEM_CALLBACK_TOKEN_SENT = 2
  98. };
  99. #endif
  100. enum cs_lib_flow_control {
  101. CS_LIB_FLOW_CONTROL_REQUIRED = 1,
  102. CS_LIB_FLOW_CONTROL_NOT_REQUIRED = 2
  103. };
  104. #define corosync_lib_flow_control cs_lib_flow_control
  105. #define COROSYNC_LIB_FLOW_CONTROL_REQUIRED CS_LIB_FLOW_CONTROL_REQUIRED
  106. #define COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED CS_LIB_FLOW_CONTROL_NOT_REQUIRED
  107. enum cs_lib_allow_inquorate {
  108. CS_LIB_DISALLOW_INQUORATE = 0, /* default */
  109. CS_LIB_ALLOW_INQUORATE = 1
  110. };
  111. #if !defined (COROSYNC_FLOW_CONTROL_STATE)
  112. enum cs_flow_control_state {
  113. CS_FLOW_CONTROL_STATE_DISABLED,
  114. CS_FLOW_CONTROL_STATE_ENABLED
  115. };
  116. #define corosync_flow_control_state cs_flow_control_state
  117. #define CS_FLOW_CONTROL_STATE_DISABLED CS_FLOW_CONTROL_STATE_DISABLED
  118. #define CS_FLOW_CONTROL_STATE_ENABLED CS_FLOW_CONTROL_STATE_ENABLED
  119. #endif /* COROSYNC_FLOW_CONTROL_STATE */
  120. enum cs_sync_mode {
  121. CS_SYNC_V1 = 0,
  122. CS_SYNC_V2 = 1,
  123. CS_SYNC_V1_APIV2 = 2
  124. };
  125. typedef enum {
  126. COROSYNC_FATAL_ERROR_EXIT = -1,
  127. COROSYNC_LIBAIS_SOCKET = -6,
  128. COROSYNC_LIBAIS_BIND = -7,
  129. COROSYNC_READKEY = -8,
  130. COROSYNC_INVALID_CONFIG = -9,
  131. COROSYNC_DYNAMICLOAD = -12,
  132. COROSYNC_OUT_OF_MEMORY = -15,
  133. COROSYNC_FATAL_ERR = -16
  134. } cs_fatal_error_t;
  135. #define corosync_fatal_error_t cs_fatal_error_t;
  136. #ifndef OBJECT_PARENT_HANDLE
  137. #define OBJECT_PARENT_HANDLE 0xffffffff00000000ULL
  138. struct object_valid {
  139. char *object_name;
  140. size_t object_len;
  141. };
  142. struct object_key_valid {
  143. char *key_name;
  144. size_t key_len;
  145. int (*validate_callback) (const void *key, size_t key_len,
  146. const void *value, size_t value_len);
  147. };
  148. /* deprecated */
  149. typedef enum {
  150. OBJDB_VALUETYPE_INT16,
  151. OBJDB_VALUETYPE_UINT16,
  152. OBJDB_VALUETYPE_INT32,
  153. OBJDB_VALUETYPE_UINT32,
  154. OBJDB_VALUETYPE_INT64,
  155. OBJDB_VALUETYPE_UINT64,
  156. OBJDB_VALUETYPE_FLOAT,
  157. OBJDB_VALUETYPE_DOUBLE,
  158. OBJDB_VALUETYPE_STRING,
  159. OBJDB_VALUETYPE_ANY,
  160. } objdb_value_types_t;
  161. typedef enum {
  162. OBJECT_TRACK_DEPTH_ONE,
  163. OBJECT_TRACK_DEPTH_RECURSIVE
  164. } object_track_depth_t;
  165. typedef enum {
  166. OBJECT_KEY_CREATED,
  167. OBJECT_KEY_REPLACED,
  168. OBJECT_KEY_DELETED
  169. } object_change_type_t;
  170. typedef enum {
  171. OBJDB_RELOAD_NOTIFY_START,
  172. OBJDB_RELOAD_NOTIFY_END,
  173. OBJDB_RELOAD_NOTIFY_FAILED
  174. } objdb_reload_notify_type_t;
  175. typedef void (*object_key_change_notify_fn_t)(
  176. object_change_type_t change_type,
  177. hdb_handle_t parent_object_handle,
  178. hdb_handle_t object_handle,
  179. const void *object_name_pt, size_t object_name_len,
  180. const void *key_name_pt, size_t key_len,
  181. const void *key_value_pt, size_t key_value_len,
  182. void *priv_data_pt);
  183. typedef void (*object_create_notify_fn_t) (
  184. hdb_handle_t parent_object_handle,
  185. hdb_handle_t object_handle,
  186. const uint8_t *name_pt, size_t name_len,
  187. void *priv_data_pt);
  188. typedef void (*object_destroy_notify_fn_t) (
  189. hdb_handle_t parent_object_handle,
  190. const uint8_t *name_pt, size_t name_len,
  191. void *priv_data_pt);
  192. typedef void (*object_notify_callback_fn_t)(
  193. hdb_handle_t object_handle,
  194. const void *key_name, size_t key_len,
  195. const void *value, size_t value_len,
  196. object_change_type_t type,
  197. const void * priv_data_pt);
  198. typedef void (*object_reload_notify_fn_t) (
  199. objdb_reload_notify_type_t,
  200. int flush,
  201. void *priv_data_pt);
  202. #endif /* OBJECT_PARENT_HANDLE_DEFINED */
  203. #ifndef QUORUM_H_DEFINED
  204. typedef void (*quorum_callback_fn_t) (int quorate, void *context);
  205. struct quorum_callin_functions
  206. {
  207. int (*quorate) (void);
  208. int (*register_callback) (quorum_callback_fn_t callback_fn, void *context);
  209. int (*unregister_callback) (quorum_callback_fn_t callback_fn, void *context);
  210. };
  211. typedef void (*sync_callback_fn_t) (
  212. const unsigned int *view_list,
  213. size_t view_list_entries,
  214. int primary_designated,
  215. struct memb_ring_id *ring_id);
  216. #endif /* QUORUM_H_DEFINED */
  217. struct corosync_api_v1 {
  218. /*
  219. * Object and configuration APIs
  220. */
  221. int (*object_create) (
  222. hdb_handle_t parent_object_handle,
  223. hdb_handle_t *object_handle,
  224. const void *object_name,
  225. size_t object_name_len);
  226. int (*object_priv_set) (
  227. hdb_handle_t object_handle,
  228. void *priv);
  229. int (*object_key_create) (
  230. hdb_handle_t object_handle,
  231. const void *key_name,
  232. size_t key_len,
  233. const void *value,
  234. size_t value_len);
  235. int (*object_destroy) (
  236. hdb_handle_t object_handle);
  237. int (*object_valid_set) (
  238. hdb_handle_t object_handle,
  239. struct object_valid *object_valid_list,
  240. size_t object_valid_list_entries);
  241. int (*object_key_valid_set) (
  242. hdb_handle_t object_handle,
  243. struct object_key_valid *object_key_valid_list,
  244. size_t object_key_valid_list_entries);
  245. int (*object_find_create) (
  246. hdb_handle_t parent_object_handle,
  247. const void *object_name,
  248. size_t object_name_len,
  249. hdb_handle_t *object_find_handle);
  250. int (*object_find_next) (
  251. hdb_handle_t object_find_handle,
  252. hdb_handle_t *object_handle);
  253. int (*object_find_destroy) (
  254. hdb_handle_t object_find_handle);
  255. int (*object_key_get) (
  256. hdb_handle_t object_handle,
  257. const void *key_name,
  258. size_t key_len,
  259. void **value,
  260. size_t *value_len);
  261. int (*object_priv_get) (
  262. hdb_handle_t jobject_handle,
  263. void **priv);
  264. int (*object_key_replace) (
  265. hdb_handle_t object_handle,
  266. const void *key_name,
  267. size_t key_len,
  268. const void *new_value,
  269. size_t new_value_len);
  270. int (*object_key_delete) (
  271. hdb_handle_t object_handle,
  272. const void *key_name,
  273. size_t key_len);
  274. int (*object_iter_reset) (
  275. hdb_handle_t parent_object_handle);
  276. int (*object_iter) (
  277. hdb_handle_t parent_object_handle,
  278. void **object_name,
  279. size_t *name_len,
  280. hdb_handle_t *object_handle);
  281. int (*object_key_iter_reset) (
  282. hdb_handle_t object_handle);
  283. int (*object_key_iter) (
  284. hdb_handle_t parent_object_handle,
  285. void **key_name,
  286. size_t *key_len,
  287. void **value,
  288. size_t *value_len);
  289. int (*object_parent_get) (
  290. hdb_handle_t object_handle,
  291. hdb_handle_t *parent_handle);
  292. int (*object_name_get) (
  293. hdb_handle_t object_handle,
  294. char *object_name,
  295. size_t *object_name_len);
  296. int (*object_dump) (
  297. hdb_handle_t object_handle,
  298. FILE *file);
  299. int (*object_key_iter_from) (
  300. hdb_handle_t parent_object_handle,
  301. hdb_handle_t start_pos,
  302. void **key_name,
  303. size_t *key_len,
  304. void **value,
  305. size_t *value_len);
  306. int (*object_track_start) (
  307. hdb_handle_t object_handle,
  308. object_track_depth_t depth,
  309. object_key_change_notify_fn_t key_change_notify_fn,
  310. object_create_notify_fn_t object_create_notify_fn,
  311. object_destroy_notify_fn_t object_destroy_notify_fn,
  312. object_reload_notify_fn_t object_reload_notify_fn,
  313. void * priv_data_pt);
  314. void (*object_track_stop) (
  315. object_key_change_notify_fn_t key_change_notify_fn,
  316. object_create_notify_fn_t object_create_notify_fn,
  317. object_destroy_notify_fn_t object_destroy_notify_fn,
  318. object_reload_notify_fn_t object_reload_notify_fn,
  319. void * priv_data_pt);
  320. int (*object_write_config) (const char **error_string);
  321. int (*object_reload_config) (int flush,
  322. const char **error_string);
  323. int (*object_key_increment) (
  324. hdb_handle_t object_handle,
  325. const void *key_name,
  326. size_t key_len,
  327. unsigned int *value);
  328. int (*object_key_decrement) (
  329. hdb_handle_t object_handle,
  330. const void *key_name,
  331. size_t key_len,
  332. unsigned int *value);
  333. /*
  334. * Time and timer APIs
  335. */
  336. int (*timer_add_duration) (
  337. unsigned long long nanoseconds_in_future,
  338. void *data,
  339. void (*timer_nf) (void *data),
  340. corosync_timer_handle_t *handle);
  341. int (*timer_add_absolute) (
  342. unsigned long long nanoseconds_from_epoch,
  343. void *data,
  344. void (*timer_fn) (void *data),
  345. corosync_timer_handle_t *handle);
  346. void (*timer_delete) (
  347. corosync_timer_handle_t timer_handle);
  348. unsigned long long (*timer_time_get) (void);
  349. unsigned long long (*timer_expire_time_get) (
  350. corosync_timer_handle_t timer_handle);
  351. /*
  352. * IPC APIs
  353. */
  354. void (*ipc_source_set) (mar_message_source_t *source, void *conn);
  355. int (*ipc_source_is_local) (const mar_message_source_t *source);
  356. void *(*ipc_private_data_get) (void *conn);
  357. int (*ipc_response_send) (void *conn, const void *msg, size_t mlen);
  358. int (*ipc_response_iov_send) (void *conn,
  359. const struct iovec *iov, unsigned int iov_len);
  360. int (*ipc_dispatch_send) (void *conn, const void *msg, size_t mlen);
  361. int (*ipc_dispatch_iov_send) (void *conn,
  362. const struct iovec *iov, unsigned int iov_len);
  363. void (*ipc_refcnt_inc) (void *conn);
  364. void (*ipc_refcnt_dec) (void *conn);
  365. /*
  366. * Totem APIs
  367. */
  368. unsigned int (*totem_nodeid_get) (void);
  369. int (*totem_family_get) (void);
  370. int (*totem_ring_reenable) (void);
  371. int (*totem_mcast) (const struct iovec *iovec,
  372. unsigned int iov_len, unsigned int guarantee);
  373. int (*totem_ifaces_get) (
  374. unsigned int nodeid,
  375. struct totem_ip_address *interfaces,
  376. char ***status,
  377. unsigned int *iface_count);
  378. const char *(*totem_ifaces_print) (unsigned int nodeid);
  379. const char *(*totem_ip_print) (const struct totem_ip_address *addr);
  380. int (*totem_crypto_set) (unsigned int type);
  381. int (*totem_callback_token_create) (
  382. void **handle_out,
  383. enum totem_callback_token_type type,
  384. int delete,
  385. int (*callback_fn) (enum totem_callback_token_type type,
  386. const void *),
  387. const void *data);
  388. /*
  389. * Totem open process groups API for those service engines
  390. * wanting their own groups
  391. */
  392. int (*tpg_init) (
  393. hdb_handle_t *handle,
  394. void (*deliver_fn) (
  395. unsigned int nodeid,
  396. const void *msg,
  397. unsigned int msg_len,
  398. int endian_conversion_required),
  399. void (*confchg_fn) (
  400. enum totem_configuration_type configuration_type,
  401. const unsigned int *member_list,
  402. size_t member_list_entries,
  403. const unsigned int *left_list,
  404. size_t left_list_entries,
  405. const unsigned int *joined_list,
  406. size_t joined_list_entries,
  407. const struct memb_ring_id *ring_id));
  408. int (*tpg_exit) (
  409. hdb_handle_t handle);
  410. int (*tpg_join) (
  411. hdb_handle_t handle,
  412. const struct corosync_tpg_group *groups,
  413. size_t group_cnt);
  414. int (*tpg_leave) (
  415. hdb_handle_t handle,
  416. const struct corosync_tpg_group *groups,
  417. size_t group_cnt);
  418. int (*tpg_joined_mcast) (
  419. hdb_handle_t handle,
  420. const struct iovec *iovec,
  421. unsigned int iov_len,
  422. int guarantee);
  423. int (*tpg_joined_reserve) (
  424. hdb_handle_t handle,
  425. const struct iovec *iovec,
  426. unsigned int iov_len);
  427. int (*tpg_joined_release) (
  428. int reserved_msgs);
  429. int (*tpg_groups_mcast) (
  430. hdb_handle_t handle,
  431. int guarantee,
  432. const struct corosync_tpg_group *groups,
  433. size_t groups_cnt,
  434. const struct iovec *iovec,
  435. unsigned int iov_len);
  436. int (*tpg_groups_reserve) (
  437. hdb_handle_t handle,
  438. const struct corosync_tpg_group *groups,
  439. size_t groups_cnt,
  440. const struct iovec *iovec,
  441. unsigned int iov_len);
  442. int (*tpg_groups_release) (
  443. int reserved_msgs);
  444. int (*schedwrk_create) (
  445. hdb_handle_t *handle,
  446. int (schedwrk_fn) (const void *),
  447. const void *context);
  448. void (*schedwrk_destroy) (hdb_handle_t handle);
  449. int (*sync_request) (
  450. const char *service_name);
  451. /*
  452. * User plugin-callable functions for quorum
  453. */
  454. int (*quorum_is_quorate) (void);
  455. int (*quorum_register_callback) (quorum_callback_fn_t callback_fn, void *context);
  456. int (*quorum_unregister_callback) (quorum_callback_fn_t callback_fn, void *context);
  457. /*
  458. * This one is for the quorum management plugin's use
  459. */
  460. int (*quorum_initialize)(struct quorum_callin_functions *fns);
  461. /*
  462. * Plugin loading and unloading
  463. */
  464. int (*plugin_interface_reference) (
  465. hdb_handle_t *handle,
  466. const char *iface_name,
  467. int version,
  468. void **interface,
  469. void *context);
  470. int (*plugin_interface_release) (hdb_handle_t handle);
  471. /*
  472. * Service loading and unloading APIs
  473. */
  474. unsigned int (*service_link_and_init) (
  475. struct corosync_api_v1 *corosync_api_v1,
  476. const char *service_name,
  477. unsigned int service_ver);
  478. unsigned int (*service_unlink_and_exit) (
  479. struct corosync_api_v1 *corosync_api_v1,
  480. const char *service_name,
  481. unsigned int service_ver);
  482. /*
  483. * Error handling APIs
  484. */
  485. void (*error_memory_failure) (void) __attribute__ ((noreturn));
  486. #define corosync_fatal_error(err) api->fatal_error ((err), __FILE__, __LINE__)
  487. void (*fatal_error) (cs_fatal_error_t err,
  488. const char *file,
  489. unsigned int line) __attribute__ ((noreturn));
  490. void (*shutdown_request) (void);
  491. void (*state_dump) (void);
  492. /*
  493. * The use of this interface is highly discouraged.
  494. * Please avoid using any of coropoll apis in your service engines.
  495. */
  496. hdb_handle_t (*poll_handle_get) (void);
  497. int (*object_key_create_typed) (
  498. hdb_handle_t object_handle,
  499. const char *key_name,
  500. const void *value,
  501. size_t value_len,
  502. objdb_value_types_t type);
  503. int (*object_key_get_typed) (
  504. hdb_handle_t object_handle,
  505. const char *key_name,
  506. void **value,
  507. size_t *value_len,
  508. objdb_value_types_t *type);
  509. int (*object_key_iter_typed) (
  510. hdb_handle_t parent_object_handle,
  511. char **key_name,
  512. void **value,
  513. size_t *value_len,
  514. objdb_value_types_t *type);
  515. void *(*totem_get_stats)(void);
  516. int (*schedwrk_create_nolock) (
  517. hdb_handle_t *handle,
  518. int (schedwrk_fn) (const void *),
  519. const void *context);
  520. int (*poll_dispatch_add) (hdb_handle_t handle,
  521. int fd,
  522. int events,
  523. void *data,
  524. int (*dispatch_fn) (hdb_handle_t handle,
  525. int fd,
  526. int revents,
  527. void *data));
  528. int (*poll_dispatch_delete) (
  529. hdb_handle_t handle,
  530. int fd);
  531. };
  532. #define SERVICE_ID_MAKE(a,b) ( ((a)<<16) | (b) )
  533. #define SERVICE_HANDLER_MAXIMUM_COUNT 64
  534. struct corosync_lib_handler {
  535. void (*lib_handler_fn) (void *conn, const void *msg);
  536. enum cs_lib_flow_control flow_control;
  537. };
  538. struct corosync_exec_handler {
  539. void (*exec_handler_fn) (const void *msg, unsigned int nodeid);
  540. void (*exec_endian_convert_fn) (void *msg);
  541. };
  542. struct corosync_service_engine_iface_ver0 {
  543. struct corosync_service_engine *(*corosync_get_service_engine_ver0) (void);
  544. };
  545. typedef void (*sync_init_v1_fn_t) (
  546. const unsigned int *member_list,
  547. size_t member_list_entries,
  548. const struct memb_ring_id *ring_id) ;
  549. struct corosync_service_engine {
  550. const char *name;
  551. unsigned short id;
  552. unsigned short priority; /* Lower priority are loaded first, unloaded last.
  553. * 0 is a special case which always loaded _and_ unloaded last
  554. */
  555. unsigned int private_data_size;
  556. enum cs_lib_flow_control flow_control;
  557. enum cs_lib_allow_inquorate allow_inquorate;
  558. int (*exec_init_fn) (struct corosync_api_v1 *);
  559. int (*exec_exit_fn) (void);
  560. void (*exec_dump_fn) (void);
  561. int (*lib_init_fn) (void *conn);
  562. int (*lib_exit_fn) (void *conn);
  563. struct corosync_lib_handler *lib_engine;
  564. int lib_engine_count;
  565. struct corosync_exec_handler *exec_engine;
  566. int exec_engine_count;
  567. int (*config_init_fn) (struct corosync_api_v1 *);
  568. void (*confchg_fn) (
  569. enum totem_configuration_type configuration_type,
  570. const unsigned int *member_list, size_t member_list_entries,
  571. const unsigned int *left_list, size_t left_list_entries,
  572. const unsigned int *joined_list, size_t joined_list_entries,
  573. const struct memb_ring_id *ring_id);
  574. enum cs_sync_mode sync_mode;
  575. sync_init_v1_fn_t sync_init;
  576. int (*sync_process) (void);
  577. void (*sync_activate) (void);
  578. void (*sync_abort) (void);
  579. };
  580. #endif /* COROAPI_H_DEFINED */