repl-session-plugin.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2010 Red Hat, Inc.
  3. * All rights reserved.
  4. *
  5. * License: GPL (version 3 or any later version).
  6. * See LICENSE for details.
  7. * END COPYRIGHT BLOCK **/
  8. #ifndef REPL_SESSION_PLUGIN_PUBLIC_API
  9. #define REPL_SESSION_PLUGIN_PUBLIC_API
  10. #include "slapi-plugin.h"
  11. /*
  12. * Replication Session plug-in API
  13. */
  14. #define REPL_SESSION_v1_0_GUID "210D7559-566B-41C6-9B03-5523BDF30880"
  15. /*
  16. * This callback is called when a replication agreement is created.
  17. * The repl_subtree from the agreement is read-only.
  18. * The callback can allocate some private data to return. If so
  19. * the callback must define a repl_session_plugin_destroy_agmt_cb
  20. * so that the private data can be freed. This private data is passed
  21. * to other callback functions on a master as the void *cookie argument.
  22. */
  23. typedef void *(*repl_session_plugin_agmt_init_cb)(const Slapi_DN *repl_subtree);
  24. #define REPL_SESSION_PLUGIN_AGMT_INIT_CB 1
  25. /*
  26. * Callbacks called when acquiring a replica
  27. *
  28. * The pre and post callbacks are called on the sending (master) side.
  29. * The receive and reply callbacks are called on the receiving (replica)
  30. * side.
  31. *
  32. * Data can be exchanged between the sending and receiving sides using
  33. * these callbacks by using the data_guid and data parameters. The data
  34. * guid is used as an identifier to confirm the data type. Your callbacks
  35. * that receive data must consult the data_guid before attempting to read
  36. * the data parameter. This allows you to confirm that the same replication
  37. * session plug-in is being used on both sides before making assumptions
  38. * about the format of the data. The callbacks use these parameters as
  39. * follows:
  40. *
  41. * pre - send data to replica
  42. * recv - receive data from master
  43. * reply - send data to master
  44. * post - receive data from replica
  45. *
  46. * The memory used by data_guid and data should be allocated in the pre
  47. * and reply callbacks. The replication plug-in is responsible for
  48. * freeing this memory, so they should not be free'd in the callbacks.
  49. *
  50. * The return value of the callbacks should be 0 to allow replication
  51. * to continue. A non-0 return value will cause the replication session
  52. * to be abandoned, causing the master to go into incremental backoff
  53. * mode.
  54. */
  55. typedef int (*repl_session_plugin_pre_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree, int is_total, char **data_guid, struct berval **data);
  56. #define REPL_SESSION_PLUGIN_PRE_ACQUIRE_CB 2
  57. typedef int (*repl_session_plugin_reply_acquire_cb)(const char *repl_subtree, int is_total, char **data_guid, struct berval **data);
  58. #define REPL_SESSION_PLUGIN_REPLY_ACQUIRE_CB 3
  59. typedef int (*repl_session_plugin_post_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree, int is_total, const char *data_guid, const struct berval *data);
  60. #define REPL_SESSION_PLUGIN_POST_ACQUIRE_CB 4
  61. typedef int (*repl_session_plugin_recv_acquire_cb)(const char *repl_subtree, int is_total, const char *data_guid, const struct berval *data);
  62. #define REPL_SESSION_PLUGIN_RECV_ACQUIRE_CB 5
  63. /*
  64. * Callbacks called when the agreement is destroyed.
  65. *
  66. * The replication subtree from the agreement is passed in.
  67. * This is read only.
  68. * The plugin must define this function to free the cookie allocated
  69. * in the init function, if any.
  70. */
  71. typedef void (*repl_session_plugin_destroy_agmt_cb)(void *cookie, const Slapi_DN *repl_subtree);
  72. #define REPL_SESSION_PLUGIN_DESTROY_AGMT_CB 6
  73. #endif /* REPL_SESSION_PLUGIN_PUBLIC_API */