repl-session-plugin.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #include "slapi-plugin.h"
  40. /*
  41. * Replication Session plug-in API
  42. */
  43. #define REPL_SESSION_v1_0_GUID "210D7559-566B-41C6-9B03-5523BDF30880"
  44. /*
  45. * This callback is called when a replication agreement is created.
  46. * The repl_subtree from the agreement is read-only.
  47. * The callback can allocate some private data to return. If so
  48. * the callback must define a repl_session_plugin_destroy_agmt_cb
  49. * so that the private data can be freed. This private data is passed
  50. * to other callback functions on a master as the void *cookie argument.
  51. */
  52. typedef void * (*repl_session_plugin_agmt_init_cb)(const Slapi_DN *repl_subtree);
  53. #define REPL_SESSION_PLUGIN_AGMT_INIT_CB 1
  54. /*
  55. * Callbacks called when acquiring a replica
  56. *
  57. * The pre and post callbacks are called on the sending (master) side.
  58. * The receive and reply callbacks are called on the receiving (replica)
  59. * side.
  60. *
  61. * Data can be exchanged between the sending and receiving sides using
  62. * these callbacks by using the data_guid and data parameters. The data
  63. * guid is used as an identifier to confirm the data type. Your callbacks
  64. * that receive data must consult the data_guid before attempting to read
  65. * the data parameter. This allows you to confirm that the same replication
  66. * session plug-in is being used on both sides before making assumptions
  67. * about the format of the data. The callbacks use these parameters as
  68. * follows:
  69. *
  70. * pre - send data to replica
  71. * recv - receive data from master
  72. * reply - send data to master
  73. * post - receive data from replica
  74. *
  75. * The memory used by data_guid and data should be allocated in the pre
  76. * and reply callbacks. The replication plug-in is responsible for
  77. * freeing this memory, so they should not be free'd in the callbacks.
  78. *
  79. * The return value of the callbacks should be 0 to allow replication
  80. * to continue. A non-0 return value will cause the replication session
  81. * to be abandoned, causing the master to go into incremental backoff
  82. * mode.
  83. */
  84. typedef int (*repl_session_plugin_pre_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree,
  85. int is_total, char **data_guid, struct berval **data);
  86. #define REPL_SESSION_PLUGIN_PRE_ACQUIRE_CB 2
  87. typedef int (*repl_session_plugin_reply_acquire_cb)(const char *repl_subtree, int is_total,
  88. char **data_guid, struct berval **data);
  89. #define REPL_SESSION_PLUGIN_REPLY_ACQUIRE_CB 3
  90. typedef int (*repl_session_plugin_post_acquire_cb)(void *cookie, const Slapi_DN *repl_subtree,
  91. int is_total, const char *data_guid, const struct berval *data);
  92. #define REPL_SESSION_PLUGIN_POST_ACQUIRE_CB 4
  93. typedef int (*repl_session_plugin_recv_acquire_cb)(const char *repl_subtree, int is_total,
  94. const char *data_guid, const struct berval *data);
  95. #define REPL_SESSION_PLUGIN_RECV_ACQUIRE_CB 5
  96. /*
  97. * Callbacks called when the agreement is destroyed.
  98. *
  99. * The replication subtree from the agreement is passed in.
  100. * This is read only.
  101. * The plugin must define this function to free the cookie allocated
  102. * in the init function, if any.
  103. */
  104. typedef void (*repl_session_plugin_destroy_agmt_cb)(void *cookie, const Slapi_DN *repl_subtree);
  105. #define REPL_SESSION_PLUGIN_DESTROY_AGMT_CB 6
  106. #endif /* REPL_SESSION_PLUGIN_PUBLIC_API */