repl-session-plugin.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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,
  56. int is_total, char **data_guid, struct berval **data);
  57. #define REPL_SESSION_PLUGIN_PRE_ACQUIRE_CB 2
  58. typedef int (*repl_session_plugin_reply_acquire_cb)(const char *repl_subtree, int is_total,
  59. char **data_guid, struct berval **data);
  60. #define REPL_SESSION_PLUGIN_REPLY_ACQUIRE_CB 3
  61. typedef int (*repl_session_plugin_post_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree,
  62. int is_total, const char *data_guid, const struct berval *data);
  63. #define REPL_SESSION_PLUGIN_POST_ACQUIRE_CB 4
  64. typedef int (*repl_session_plugin_recv_acquire_cb)(const char *repl_subtree, int is_total,
  65. const char *data_guid, const struct berval *data);
  66. #define REPL_SESSION_PLUGIN_RECV_ACQUIRE_CB 5
  67. /*
  68. * Callbacks called when the agreement is destroyed.
  69. *
  70. * The replication subtree from the agreement is passed in.
  71. * This is read only.
  72. * The plugin must define this function to free the cookie allocated
  73. * in the init function, if any.
  74. */
  75. typedef void (*repl_session_plugin_destroy_agmt_cb)(void *cookie, const Slapi_DN *repl_subtree);
  76. #define REPL_SESSION_PLUGIN_DESTROY_AGMT_CB 6
  77. #endif /* REPL_SESSION_PLUGIN_PUBLIC_API */