repl-session-plugin.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2010 Red Hat, Inc.
  35. * All rights reserved.
  36. * END COPYRIGHT BLOCK **/
  37. #ifndef REPL_SESSION_PLUGIN_PUBLIC_API
  38. #define REPL_SESSION_PLUGIN_PUBLIC_API
  39. #ifdef HAVE_CONFIG_H
  40. # include <config.h>
  41. #endif
  42. #include "slapi-plugin.h"
  43. /*
  44. * Replication Session plug-in API
  45. */
  46. #define REPL_SESSION_v1_0_GUID "210D7559-566B-41C6-9B03-5523BDF30880"
  47. /*
  48. * This callback is called when a replication agreement is created.
  49. * The repl_subtree from the agreement is read-only.
  50. * The callback can allocate some private data to return. If so
  51. * the callback must define a repl_session_plugin_destroy_agmt_cb
  52. * so that the private data can be freed. This private data is passed
  53. * to other callback functions on a master as the void *cookie argument.
  54. */
  55. typedef void * (*repl_session_plugin_agmt_init_cb)(const Slapi_DN *repl_subtree);
  56. #define REPL_SESSION_PLUGIN_AGMT_INIT_CB 1
  57. /*
  58. * Callbacks called when acquiring a replica
  59. *
  60. * The pre and post callbacks are called on the sending (master) side.
  61. * The receive and reply callbacks are called on the receiving (replica)
  62. * side.
  63. *
  64. * Data can be exchanged between the sending and receiving sides using
  65. * these callbacks by using the data_guid and data parameters. The data
  66. * guid is used as an identifier to confirm the data type. Your callbacks
  67. * that receive data must consult the data_guid before attempting to read
  68. * the data parameter. This allows you to confirm that the same replication
  69. * session plug-in is being used on both sides before making assumptions
  70. * about the format of the data. The callbacks use these parameters as
  71. * follows:
  72. *
  73. * pre - send data to replica
  74. * recv - receive data from master
  75. * reply - send data to master
  76. * post - receive data from replica
  77. *
  78. * The memory used by data_guid and data should be allocated in the pre
  79. * and reply callbacks. The replication plug-in is responsible for
  80. * freeing this memory, so they should not be free'd in the callbacks.
  81. *
  82. * The return value of the callbacks should be 0 to allow replication
  83. * to continue. A non-0 return value will cause the replication session
  84. * to be abandoned, causing the master to go into incremental backoff
  85. * mode.
  86. */
  87. typedef int (*repl_session_plugin_pre_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree,
  88. int is_total, char **data_guid, struct berval **data);
  89. #define REPL_SESSION_PLUGIN_PRE_ACQUIRE_CB 2
  90. typedef int (*repl_session_plugin_reply_acquire_cb)(const char *repl_subtree, int is_total,
  91. char **data_guid, struct berval **data);
  92. #define REPL_SESSION_PLUGIN_REPLY_ACQUIRE_CB 3
  93. typedef int (*repl_session_plugin_post_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree,
  94. int is_total, const char *data_guid, const struct berval *data);
  95. #define REPL_SESSION_PLUGIN_POST_ACQUIRE_CB 4
  96. typedef int (*repl_session_plugin_recv_acquire_cb)(const char *repl_subtree, int is_total,
  97. const char *data_guid, const struct berval *data);
  98. #define REPL_SESSION_PLUGIN_RECV_ACQUIRE_CB 5
  99. /*
  100. * Callbacks called when the agreement is destroyed.
  101. *
  102. * The replication subtree from the agreement is passed in.
  103. * This is read only.
  104. * The plugin must define this function to free the cookie allocated
  105. * in the init function, if any.
  106. */
  107. typedef void (*repl_session_plugin_destroy_agmt_cb)(void *cookie, const Slapi_DN *repl_subtree);
  108. #define REPL_SESSION_PLUGIN_DESTROY_AGMT_CB 6
  109. #endif /* REPL_SESSION_PLUGIN_PUBLIC_API */