repl5.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2010 Red Hat, Inc.
  4. * Copyright (C) 2009 Hewlett-Packard Development Company, L.P.
  5. * All rights reserved.
  6. *
  7. * License: GPL (version 3 or any later version).
  8. * See LICENSE for details.
  9. * END COPYRIGHT BLOCK **/
  10. #ifdef HAVE_CONFIG_H
  11. #include <config.h>
  12. #endif
  13. /* repl5.h - 5.0 replication header */
  14. #ifndef _REPL5_H_
  15. #define _REPL5_H_
  16. #include <limits.h>
  17. #include <time.h>
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <sys/param.h>
  21. #include "portable.h" /* GGOODREPL - is this cheating? */
  22. #include "repl_shared.h"
  23. #include "llist.h"
  24. #include "repl5_ruv.h"
  25. #include "plstr.h"
  26. #define START_UPDATE_DELAY 2 /* 2 second */
  27. #define REPLICA_TYPE_WINDOWS 1
  28. #define REPLICA_TYPE_MULTIMASTER 0
  29. #define REPL_DIRSYNC_CONTROL_OID "1.2.840.113556.1.4.841"
  30. #define REPL_RETURN_DELETED_OBJS_CONTROL_OID "1.2.840.113556.1.4.417"
  31. #define REPL_WIN2K3_AD_OID "1.2.840.113556.1.4.1670"
  32. #define LDAP_CONTROL_REPL_MODRDN_EXTRAMODS "2.16.840.1.113730.3.4.999"
  33. #define REPLICATION_SUBSYSTEM "replication"
  34. /* DS 5.0 replication protocol OIDs */
  35. #define REPL_START_NSDS50_REPLICATION_REQUEST_OID "2.16.840.1.113730.3.5.3"
  36. #define REPL_END_NSDS50_REPLICATION_REQUEST_OID "2.16.840.1.113730.3.5.5"
  37. #define REPL_NSDS50_REPLICATION_ENTRY_REQUEST_OID "2.16.840.1.113730.3.5.6"
  38. #define REPL_NSDS50_REPLICATION_RESPONSE_OID "2.16.840.1.113730.3.5.4"
  39. #define REPL_NSDS50_UPDATE_INFO_CONTROL_OID "2.16.840.1.113730.3.4.13"
  40. #define REPL_NSDS50_INCREMENTAL_PROTOCOL_OID "2.16.840.1.113730.3.6.1"
  41. #define REPL_NSDS50_TOTAL_PROTOCOL_OID "2.16.840.1.113730.3.6.2"
  42. /* DS7.1 introduces pipelineing in the protocol : really not much different to the 5.0
  43. * protocol, but enough change to make it unsafe to interoperate the two. So we define
  44. * new OIDs for 7.1 here. The supplier server looks for these on the consumer and
  45. * if they're not there it falls back to the older 5.0 non-pipelined protocol */
  46. #define REPL_NSDS71_INCREMENTAL_PROTOCOL_OID "2.16.840.1.113730.3.6.4"
  47. #define REPL_NSDS71_TOTAL_PROTOCOL_OID "2.16.840.1.113730.3.6.3"
  48. /* The new protocol OIDs above do not help us with determining if a consumer
  49. * Supports them or not. That's because they're burried inside the start replication
  50. * extended operation, and are not visible in the support controls and operations list
  51. * So, we add a new extended operation for the 7.1 total protocol. This is partly because
  52. * the total protocol is slightly different (no LDAP_BUSY allowed in 7.1) and partly
  53. * because we need a handy way to spot the difference between a pre-7.1 and post-7.0
  54. * consumer at the supplier */
  55. #define REPL_NSDS71_REPLICATION_ENTRY_REQUEST_OID "2.16.840.1.113730.3.5.9"
  56. /* DS9.0 introduces replication session callbacks that can send/receive
  57. * arbitrary data when starting a replication session. This requires a
  58. * new set of start and response extops. */
  59. #define REPL_START_NSDS90_REPLICATION_REQUEST_OID "2.16.840.1.113730.3.5.12"
  60. #define REPL_NSDS90_REPLICATION_RESPONSE_OID "2.16.840.1.113730.3.5.13"
  61. /* cleanallruv extended ops */
  62. #define REPL_CLEANRUV_OID "2.16.840.1.113730.3.6.5"
  63. #define REPL_ABORT_CLEANRUV_OID "2.16.840.1.113730.3.6.6"
  64. #define REPL_CLEANRUV_GET_MAXCSN_OID "2.16.840.1.113730.3.6.7"
  65. #define REPL_CLEANRUV_CHECK_STATUS_OID "2.16.840.1.113730.3.6.8"
  66. #define REPL_ABORT_SESSION_OID "2.16.840.1.113730.3.6.9"
  67. #define SESSION_ACQUIRED 0
  68. #define ABORT_SESSION 1
  69. #define SESSION_ABORTED 2
  70. #define CLEANRUV_ACCEPTED "accepted"
  71. #define CLEANRUV_REJECTED "rejected"
  72. #define CLEANRUV_FINISHED "finished"
  73. #define CLEANRUV_CLEANING "cleaning"
  74. #define CLEANRUV_NO_MAXCSN "no maxcsn"
  75. /* DS 5.0 replication protocol error codes */
  76. #define NSDS50_REPL_REPLICA_READY 0x00 /* Replica ready, go ahead */
  77. #define NSDS50_REPL_REPLICA_BUSY 0x01 /* Replica busy, try later */
  78. #define NSDS50_REPL_EXCESSIVE_CLOCK_SKEW 0x02 /* Supplier clock too far ahead */
  79. #define NSDS50_REPL_PERMISSION_DENIED 0x03 /* Bind DN not allowed to send updates */
  80. #define NSDS50_REPL_DECODING_ERROR 0x04 /* Consumer couldn't decode extended operation */
  81. #define NSDS50_REPL_UNKNOWN_UPDATE_PROTOCOL 0x05 /* Consumer doesn't understand suplier's update protocol */
  82. #define NSDS50_REPL_NO_SUCH_REPLICA 0x06 /* Consumer holds no such replica */
  83. #define NSDS50_REPL_BELOW_PURGEPOINT 0x07 /* Supplier provided a CSN below the consumer's purge point */
  84. #define NSDS50_REPL_INTERNAL_ERROR 0x08 /* Something bad happened on consumer */
  85. #define NSDS50_REPL_REPLICA_RELEASE_SUCCEEDED 0x09 /* Replica released successfully */
  86. #define NSDS50_REPL_REPLICAID_ERROR 0x0B /* replicaID doesn't seem to be unique */
  87. #define NSDS50_REPL_DISABLED 0x0C /* replica suffix is disabled */
  88. #define NSDS50_REPL_UPTODATE 0x0D /* replica is uptodate */
  89. #define NSDS50_REPL_BACKOFF 0x0E /* replica wants master to go into backoff mode */
  90. #define NSDS50_REPL_CL_ERROR 0x0F /* Problem reading changelog */
  91. #define NSDS50_REPL_CONN_ERROR 0x10 /* Problem with replication connection*/
  92. #define NSDS50_REPL_CONN_TIMEOUT 0x11 /* Connection timeout */
  93. #define NSDS50_REPL_TRANSIENT_ERROR 0x12 /* Transient error */
  94. #define NSDS50_REPL_RUV_ERROR 0x13 /* Problem with the RUV */
  95. #define NSDS50_REPL_REPLICA_NO_RESPONSE 0xff /* No response received */
  96. /* Protocol status */
  97. #define PROTOCOL_STATUS_UNKNOWN 701
  98. #define PROTOCOL_STATUS_INCREMENTAL_AWAITING_CHANGES 702
  99. #define PROTOCOL_STATUS_INCREMENTAL_ACQUIRING_REPLICA 703
  100. #define PROTOCOL_STATUS_INCREMENTAL_RELEASING_REPLICA 704
  101. #define PROTOCOL_STATUS_INCREMENTAL_SENDING_UPDATES 705
  102. #define PROTOCOL_STATUS_INCREMENTAL_BACKING_OFF 706
  103. #define PROTOCOL_STATUS_INCREMENTAL_NEEDS_TOTAL_UPDATE 707
  104. #define PROTOCOL_STATUS_INCREMENTAL_FATAL_ERROR 708
  105. #define PROTOCOL_STATUS_TOTAL_ACQUIRING_REPLICA 709
  106. #define PROTOCOL_STATUS_TOTAL_RELEASING_REPLICA 710
  107. #define PROTOCOL_STATUS_TOTAL_SENDING_DATA 711
  108. #define DEFAULT_PROTOCOL_TIMEOUT 120
  109. /* To Allow Consumer Initialization when adding an agreement - */
  110. #define STATE_PERFORMING_TOTAL_UPDATE 501
  111. #define STATE_PERFORMING_INCREMENTAL_UPDATE 502
  112. #define MAX_NUM_OF_MASTERS 256
  113. #define REPL_SESSION_ID_SIZE 64
  114. #define REPL_GET_DN(addrp) slapi_sdn_get_dn((addrp)->sdn)
  115. #define REPL_GET_DN_LEN(addrp) slapi_sdn_get_ndn_len((addrp)->sdn)
  116. /* Attribute names for replication agreement attributes */
  117. extern const char *type_nsds5ReplicaHost;
  118. extern const char *type_nsds5ReplicaPort;
  119. extern const char *type_nsds5TransportInfo;
  120. extern const char *type_nsds5ReplicaBindDN;
  121. extern const char *type_nsds5ReplicaBindDNGroup;
  122. extern const char *type_nsds5ReplicaBindDNGroupCheckInterval;
  123. extern const char *type_nsds5ReplicaCredentials;
  124. extern const char *type_nsds5ReplicaBindMethod;
  125. extern const char *type_nsds5ReplicaRoot;
  126. extern const char *type_nsds5ReplicatedAttributeList;
  127. extern const char *type_nsds5ReplicatedAttributeListTotal;
  128. extern const char *type_nsds5ReplicaUpdateSchedule;
  129. extern const char *type_nsds5ReplicaInitialize;
  130. extern const char *type_nsds5ReplicaTimeout;
  131. extern const char *type_nsds5ReplicaBusyWaitTime;
  132. extern const char *type_nsds5ReplicaSessionPauseTime;
  133. extern const char *type_nsds5ReplicaEnabled;
  134. extern const char *type_nsds5ReplicaStripAttrs;
  135. extern const char *type_nsds5ReplicaFlowControlWindow;
  136. extern const char *type_nsds5ReplicaFlowControlPause;
  137. extern const char *type_replicaProtocolTimeout;
  138. extern const char *type_replicaReleaseTimeout;
  139. extern const char *type_replicaBackoffMin;
  140. extern const char *type_replicaBackoffMax;
  141. extern const char *type_replicaPrecisePurge;
  142. extern const char *type_replicaIgnoreMissingChange;
  143. /* Attribute names for windows replication agreements */
  144. extern const char *type_nsds7WindowsReplicaArea;
  145. extern const char *type_nsds7DirectoryReplicaArea;
  146. extern const char *type_nsds7CreateNewUsers;
  147. extern const char *type_nsds7CreateNewGroups;
  148. extern const char *type_nsds7DirsyncCookie;
  149. extern const char *type_nsds7WindowsDomain;
  150. extern const char *type_winSyncInterval;
  151. extern const char *type_oneWaySync;
  152. extern const char *type_winsyncMoveAction;
  153. extern const char *type_winSyncWindowsFilter;
  154. extern const char *type_winSyncDirectoryFilter;
  155. extern const char *type_winSyncSubtreePair;
  156. /* To Allow Consumer Initialization when adding an agreement - */
  157. extern const char *type_nsds5BeginReplicaRefresh;
  158. /* For tuning replica release */
  159. extern const char *type_nsds5WaitForAsyncResults;
  160. /* replica related attributes */
  161. extern const char *attr_replicaId;
  162. extern const char *attr_replicaRoot;
  163. extern const char *attr_replicaType;
  164. extern const char *attr_replicaBindDn;
  165. extern const char *attr_replicaBindDnGroup;
  166. extern const char *attr_replicaBindDnGroupCheckInterval;
  167. extern const char *attr_state;
  168. extern const char *attr_flags;
  169. extern const char *attr_replicaName;
  170. extern const char *attr_replicaReferral;
  171. extern const char *type_ruvElement;
  172. extern const char *type_agmtMaxCSN;
  173. extern const char *type_replicaPurgeDelay;
  174. extern const char *type_replicaChangeCount;
  175. extern const char *type_replicaTombstonePurgeInterval;
  176. extern const char *type_replicaCleanRUV;
  177. extern const char *type_replicaAbortCleanRUV;
  178. extern const char *type_ruvElementUpdatetime;
  179. /* multimaster plugin points */
  180. int multimaster_preop_bind(Slapi_PBlock *pb);
  181. int multimaster_preop_add(Slapi_PBlock *pb);
  182. int multimaster_preop_delete(Slapi_PBlock *pb);
  183. int multimaster_preop_modify(Slapi_PBlock *pb);
  184. int multimaster_preop_modrdn(Slapi_PBlock *pb);
  185. int multimaster_preop_search(Slapi_PBlock *pb);
  186. int multimaster_preop_compare(Slapi_PBlock *pb);
  187. int multimaster_ruv_search(Slapi_PBlock *pb);
  188. int multimaster_bepreop_add(Slapi_PBlock *pb);
  189. int multimaster_bepreop_delete(Slapi_PBlock *pb);
  190. int multimaster_bepreop_modify(Slapi_PBlock *pb);
  191. int multimaster_bepreop_modrdn(Slapi_PBlock *pb);
  192. int replica_ruv_smods_for_op(Slapi_PBlock *pb, char **uniqueid, Slapi_Mods **smods);
  193. int multimaster_bepostop_modrdn(Slapi_PBlock *pb);
  194. int multimaster_bepostop_delete(Slapi_PBlock *pb);
  195. int multimaster_postop_bind(Slapi_PBlock *pb);
  196. int multimaster_postop_add(Slapi_PBlock *pb);
  197. int multimaster_postop_delete(Slapi_PBlock *pb);
  198. int multimaster_postop_modify(Slapi_PBlock *pb);
  199. int multimaster_postop_modrdn(Slapi_PBlock *pb);
  200. int multimaster_betxnpostop_modrdn(Slapi_PBlock *pb);
  201. int multimaster_betxnpostop_delete(Slapi_PBlock *pb);
  202. int multimaster_betxnpostop_add(Slapi_PBlock *pb);
  203. int multimaster_betxnpostop_modify(Slapi_PBlock *pb);
  204. int multimaster_be_betxnpostop_modrdn(Slapi_PBlock *pb);
  205. int multimaster_be_betxnpostop_delete(Slapi_PBlock *pb);
  206. int multimaster_be_betxnpostop_add(Slapi_PBlock *pb);
  207. int multimaster_be_betxnpostop_modify(Slapi_PBlock *pb);
  208. /* In repl5_replica.c */
  209. typedef struct replica Replica;
  210. /* csn pending lists */
  211. #define CSNPL_CTX_REPLCNT 4
  212. typedef struct CSNPL_CTX
  213. {
  214. CSN *prim_csn;
  215. size_t repl_alloc; /* max number of replicas */
  216. size_t repl_cnt; /* number of replicas affected by operation */
  217. Replica *prim_repl; /* pirmary replica */
  218. Replica **sec_repl; /* additional replicas affected */
  219. } CSNPL_CTX;
  220. /* In repl5_init.c */
  221. extern int repl5_is_betxn;
  222. char *get_thread_private_agmtname(void);
  223. void set_thread_private_agmtname(const char *agmtname);
  224. void set_thread_primary_csn(const CSN *prim_csn, Replica *repl);
  225. void add_replica_to_primcsn(CSNPL_CTX *prim_csn, Replica *repl);
  226. CSNPL_CTX *get_thread_primary_csn(void);
  227. void *get_thread_private_cache(void);
  228. void set_thread_private_cache(void *buf);
  229. char *get_repl_session_id(Slapi_PBlock *pb, char *id, CSN **opcsn);
  230. /* In repl_extop.c */
  231. int multimaster_extop_StartNSDS50ReplicationRequest(Slapi_PBlock *pb);
  232. int multimaster_extop_EndNSDS50ReplicationRequest(Slapi_PBlock *pb);
  233. int multimaster_extop_cleanruv(Slapi_PBlock *pb);
  234. int multimaster_extop_abort_cleanruv(Slapi_PBlock *pb);
  235. int multimaster_extop_cleanruv_get_maxcsn(Slapi_PBlock *pb);
  236. int multimaster_extop_cleanruv_check_status(Slapi_PBlock *pb);
  237. int extop_noop(Slapi_PBlock *pb);
  238. struct berval *NSDS50StartReplicationRequest_new(const char *protocol_oid,
  239. const char *repl_root,
  240. char **extra_referrals,
  241. CSN *csn);
  242. struct berval *NSDS50EndReplicationRequest_new(char *repl_root);
  243. int decode_repl_ext_response(struct berval *bvdata, int *response_code, struct berval ***ruv_bervals, char **data_guid, struct berval **data);
  244. struct berval *NSDS90StartReplicationRequest_new(const char *protocol_oid,
  245. const char *repl_root,
  246. char **extra_referrals,
  247. CSN *csn,
  248. const char *data_guid,
  249. const struct berval *data);
  250. /* In repl5_total.c */
  251. int multimaster_extop_NSDS50ReplicationEntry(Slapi_PBlock *pb);
  252. /* From repl_globals.c */
  253. extern char *attr_changenumber;
  254. extern char *attr_targetdn;
  255. extern char *attr_changetype;
  256. extern char *attr_newrdn;
  257. extern char *attr_deleteoldrdn;
  258. extern char *attr_changes;
  259. extern char *attr_newsuperior;
  260. extern char *attr_changetime;
  261. extern char *attr_dataversion;
  262. extern char *attr_csn;
  263. extern char *changetype_add;
  264. extern char *changetype_delete;
  265. extern char *changetype_modify;
  266. extern char *changetype_modrdn;
  267. extern char *changetype_moddn;
  268. extern char *type_copyingFrom;
  269. extern char *type_copiedFrom;
  270. extern char *filter_copyingFrom;
  271. extern char *filter_copiedFrom;
  272. extern char *filter_objectclass;
  273. extern char *type_cn;
  274. extern char *type_objectclass;
  275. /* In profile.c */
  276. #ifdef PROFILE
  277. #define PROFILE_POINT \
  278. if (CFG_profile) \
  279. profile_log(__FILE__, __LINE__) /* JCMREPL - Where is the profiling flag stored? */
  280. #else
  281. #define PROFILE_POINT ((void)0)
  282. #endif
  283. /* In repl_controls.c */
  284. int create_NSDS50ReplUpdateInfoControl(const char *uuid,
  285. const char *superior_uuid,
  286. const CSN *csn,
  287. LDAPMod **modify_mods,
  288. LDAPControl **ctrlp);
  289. void destroy_NSDS50ReplUpdateInfoControl(LDAPControl **ctrlp);
  290. int decode_NSDS50ReplUpdateInfoControl(LDAPControl **controlsp,
  291. char **uuid,
  292. char **newsuperior_uuid,
  293. CSN **csn,
  294. LDAPMod ***modrdn_mods);
  295. /* In repl5_replsupplier.c */
  296. typedef struct repl_supplier Repl_Supplier;
  297. Repl_Supplier *replsupplier_init(Slapi_Entry *e);
  298. void replsupplier_configure(Repl_Supplier *rs, Slapi_PBlock *pb);
  299. void replsupplier_start(Repl_Supplier *rs);
  300. void replsupplier_stop(Repl_Supplier *rs);
  301. void replsupplier_destroy(Repl_Supplier **rs);
  302. void replsupplier_notify(Repl_Supplier *rs, PRUint32 eventmask);
  303. PRUint32 replsupplier_get_status(Repl_Supplier *rs);
  304. /* In repl5_plugins.c */
  305. int multimaster_set_local_purl(void);
  306. const char *multimaster_get_local_purl(void);
  307. PRBool multimaster_started(void);
  308. /* In repl5_schedule.c */
  309. typedef struct schedule Schedule;
  310. typedef void (*window_state_change_callback)(void *arg, PRBool opened);
  311. Schedule *schedule_new(window_state_change_callback callback_fn, void *callback_arg, const char *session_id);
  312. void schedule_destroy(Schedule *s);
  313. int schedule_set(Schedule *sch, Slapi_Attr *attr);
  314. char **schedule_get(Schedule *sch);
  315. int schedule_in_window_now(Schedule *sch);
  316. PRTime schedule_next(Schedule *sch);
  317. int schedule_notify(Schedule *sch, Slapi_PBlock *pb);
  318. void schedule_set_priority_attributes(Schedule *sch, char **prio_attrs, int override_schedule);
  319. void schedule_set_startup_delay(Schedule *sch, size_t startup_delay);
  320. void schedule_set_maximum_backlog(Schedule *sch, size_t max_backlog);
  321. void schedule_notify_session(Schedule *sch, PRTime session_end_time, unsigned int flags);
  322. #define REPLICATION_SESSION_SUCCESS 0
  323. /* In repl5_bos.c */
  324. typedef struct repl_bos Repl_Bos;
  325. /* In repl5_agmt.c */
  326. typedef struct repl5agmt Repl_Agmt;
  327. #define TRANSPORT_FLAG_SSL 1
  328. #define TRANSPORT_FLAG_TLS 2
  329. #define BINDMETHOD_SIMPLE_AUTH 1
  330. #define BINDMETHOD_SSL_CLIENTAUTH 2
  331. #define BINDMETHOD_SASL_GSSAPI 3
  332. #define BINDMETHOD_SASL_DIGEST_MD5 4
  333. Repl_Agmt *agmt_new_from_entry(Slapi_Entry *e);
  334. Repl_Agmt *agmt_new_from_pblock(Slapi_PBlock *pb);
  335. void agmt_delete(void **ra);
  336. const Slapi_DN *agmt_get_dn_byref(const Repl_Agmt *ra);
  337. int agmt_get_auto_initialize(const Repl_Agmt *ra);
  338. long agmt_get_timeout(const Repl_Agmt *ra);
  339. long agmt_get_busywaittime(const Repl_Agmt *ra);
  340. long agmt_get_pausetime(const Repl_Agmt *ra);
  341. long agmt_get_flowcontrolwindow(const Repl_Agmt *ra);
  342. long agmt_get_flowcontrolpause(const Repl_Agmt *ra);
  343. long agmt_get_ignoremissing(const Repl_Agmt *ra);
  344. int agmt_start(Repl_Agmt *ra);
  345. int windows_agmt_start(Repl_Agmt *ra);
  346. int agmt_stop(Repl_Agmt *ra);
  347. int agmt_replicate_now(Repl_Agmt *ra);
  348. char *agmt_get_hostname(const Repl_Agmt *ra);
  349. int agmt_get_port(const Repl_Agmt *ra);
  350. PRUint32 agmt_get_transport_flags(const Repl_Agmt *ra);
  351. char *agmt_get_binddn(const Repl_Agmt *ra);
  352. struct berval *agmt_get_credentials(const Repl_Agmt *ra);
  353. int agmt_get_bindmethod(const Repl_Agmt *ra);
  354. Slapi_DN *agmt_get_replarea(const Repl_Agmt *ra);
  355. int agmt_is_fractional(const Repl_Agmt *ra);
  356. int agmt_is_fractional_attr(const Repl_Agmt *ra, const char *attrname);
  357. int agmt_is_fractional_attr_total(const Repl_Agmt *ra, const char *attrname);
  358. int agmt_is_50_mm_protocol(const Repl_Agmt *ra);
  359. int agmt_matches_name(const Repl_Agmt *ra, const Slapi_DN *name);
  360. int agmt_replarea_matches(const Repl_Agmt *ra, const Slapi_DN *name);
  361. int agmt_schedule_in_window_now(const Repl_Agmt *ra);
  362. int agmt_set_schedule_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  363. int agmt_set_timeout_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  364. int agmt_set_flowcontrolwindow_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  365. int agmt_set_flowcontrolpause_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  366. int agmt_set_ignoremissing_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  367. int agmt_set_busywaittime_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  368. int agmt_set_pausetime_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  369. int agmt_set_credentials_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  370. int agmt_set_binddn_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  371. int agmt_set_bind_method_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  372. int agmt_set_transportinfo_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  373. int agmt_set_port_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  374. int agmt_set_host_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  375. const char *agmt_get_long_name(const Repl_Agmt *ra);
  376. int agmt_initialize_replica(const Repl_Agmt *agmt);
  377. void agmt_replica_init_done(const Repl_Agmt *agmt);
  378. void agmt_notify_change(Repl_Agmt *ra, Slapi_PBlock *pb);
  379. Object *agmt_get_consumer_ruv(Repl_Agmt *ra);
  380. ReplicaId agmt_get_consumer_rid(Repl_Agmt *ra, void *conn);
  381. int agmt_set_consumer_ruv(Repl_Agmt *ra, RUV *ruv);
  382. void agmt_update_consumer_ruv(Repl_Agmt *ra);
  383. CSN *agmt_get_consumer_schema_csn(Repl_Agmt *ra);
  384. void agmt_set_consumer_schema_csn(Repl_Agmt *ra, CSN *csn);
  385. void agmt_set_last_update_in_progress(Repl_Agmt *ra, PRBool in_progress);
  386. void agmt_set_last_update_start(Repl_Agmt *ra, time_t start_time);
  387. void agmt_set_last_update_end(Repl_Agmt *ra, time_t end_time);
  388. void agmt_set_last_update_status(Repl_Agmt *ra, int ldaprc, int replrc, const char *msg);
  389. void agmt_set_update_in_progress(Repl_Agmt *ra, PRBool in_progress);
  390. PRBool agmt_get_update_in_progress(const Repl_Agmt *ra);
  391. void agmt_set_last_init_start(Repl_Agmt *ra, time_t start_time);
  392. void agmt_set_last_init_end(Repl_Agmt *ra, time_t end_time);
  393. void agmt_set_last_init_status(Repl_Agmt *ra, int ldaprc, int replrc, int connrc, const char *msg);
  394. void agmt_inc_last_update_changecount(Repl_Agmt *ra, ReplicaId rid, int skipped);
  395. void agmt_get_changecount_string(Repl_Agmt *ra, char *buf, int bufsize);
  396. int agmt_set_replicated_attributes_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  397. int agmt_set_replicated_attributes_total_from_entry(Repl_Agmt *ra, const Slapi_Entry *e);
  398. int agmt_set_replicated_attributes_from_attr(Repl_Agmt *ra, Slapi_Attr *sattr);
  399. int agmt_set_replicated_attributes_total_from_attr(Repl_Agmt *ra, Slapi_Attr *sattr);
  400. char **agmt_get_fractional_attrs(const Repl_Agmt *ra);
  401. char **agmt_get_fractional_attrs_total(const Repl_Agmt *ra);
  402. char **agmt_validate_replicated_attributes(Repl_Agmt *ra, int total);
  403. void *agmt_get_priv(const Repl_Agmt *agmt);
  404. void agmt_set_priv(Repl_Agmt *agmt, void *priv);
  405. int get_agmt_agreement_type(Repl_Agmt *agmt);
  406. void *agmt_get_connection(Repl_Agmt *ra);
  407. int agmt_has_protocol(Repl_Agmt *agmt);
  408. PRBool agmt_is_enabled(Repl_Agmt *ra);
  409. int agmt_set_enabled_from_entry(Repl_Agmt *ra, Slapi_Entry *e, char *returntext);
  410. char **agmt_get_attrs_to_strip(Repl_Agmt *ra);
  411. int agmt_set_attrs_to_strip(Repl_Agmt *ra, Slapi_Entry *e);
  412. int agmt_set_timeout(Repl_Agmt *ra, long timeout);
  413. int agmt_set_ignoremissing(Repl_Agmt *ra, long ignoremissing);
  414. void agmt_update_done(Repl_Agmt *ra, int is_total);
  415. PRUint64 agmt_get_protocol_timeout(Repl_Agmt *agmt);
  416. void agmt_set_protocol_timeout(Repl_Agmt *agmt, PRUint64 timeout);
  417. void agmt_update_maxcsn(Replica *r, Slapi_DN *sdn, int op, LDAPMod **mods, CSN *csn);
  418. void add_agmt_maxcsns(Slapi_Entry *e, Replica *r);
  419. void agmt_remove_maxcsn(Repl_Agmt *ra);
  420. int agmt_maxcsn_to_smod(Replica *r, Slapi_Mod *smod);
  421. int agmt_set_WaitForAsyncResults(Repl_Agmt *ra, const Slapi_Entry *e);
  422. /* In repl5_agmtlist.c */
  423. int agmtlist_config_init(void);
  424. void agmtlist_shutdown(void);
  425. void agmtlist_notify_all(Slapi_PBlock *pb);
  426. Object *agmtlist_get_first_agreement_for_replica(Replica *r);
  427. Object *agmtlist_get_next_agreement_for_replica(Replica *r, Object *prev);
  428. int agmtlist_agmt_exists(const Repl_Agmt *ra);
  429. /* In repl5_backoff.c */
  430. typedef struct backoff_timer Backoff_Timer;
  431. #define BACKOFF_FIXED 1
  432. #define BACKOFF_EXPONENTIAL 2
  433. #define BACKOFF_RANDOM 3
  434. Backoff_Timer *backoff_new(int timer_type, int initial_interval, int max_interval);
  435. time_t backoff_reset(Backoff_Timer *bt, slapi_eq_fn_t callback, void *callback_data);
  436. time_t backoff_step(Backoff_Timer *bt);
  437. int backoff_expired(Backoff_Timer *bt, int margin);
  438. void backoff_delete(Backoff_Timer **btp);
  439. #define REPL_PROTOCOL_UNKNOWN 0
  440. #define REPL_PROTOCOL_50_INCREMENTAL 2
  441. #define REPL_PROTOCOL_50_TOTALUPDATE 3
  442. /* Type of extensions that can be registered */
  443. typedef enum {
  444. REPL_SUP_EXT_OP, /* extension for Operation object, replication supplier */
  445. REPL_SUP_EXT_CONN, /* extension for Connection object, replication supplier */
  446. REPL_CON_EXT_OP, /* extension for Operation object, replication consumer */
  447. REPL_CON_EXT_CONN, /* extension for Connection object, replication consumer */
  448. REPL_CON_EXT_MTNODE, /* extension for mapping_tree_node object, replication consumer */
  449. REPL_EXT_ALL
  450. } ext_type;
  451. /* Operation extension functions - supplier_operation_extension.c */
  452. /* --- supplier operation extension --- */
  453. typedef struct supplier_operation_extension
  454. {
  455. int prevent_recursive_call;
  456. struct slapi_operation_parameters *operation_parameters;
  457. char *repl_gen;
  458. } supplier_operation_extension;
  459. /* extension construct/destructor */
  460. void *supplier_operation_extension_constructor(void *object, void *parent);
  461. void supplier_operation_extension_destructor(void *ext, void *object, void *parent);
  462. /* --- consumer operation extension --- */
  463. typedef struct consumer_operation_extension
  464. {
  465. int has_cf; /* non-zero if the operation contains a copiedFrom/copyingFrom attr */
  466. void *search_referrals;
  467. } consumer_operation_extension;
  468. /* extension construct/destructor */
  469. void *consumer_operation_extension_constructor(void *object, void *parent);
  470. void consumer_operation_extension_destructor(void *ext, void *object, void *parent);
  471. /* Connection extension functions - repl_connext.c */
  472. typedef struct consumer_connection_extension
  473. {
  474. int repl_protocol_version; /* the replication protocol version number the supplier is talking. */
  475. void *replica_acquired; /* Object* for replica */
  476. void *supplier_ruv; /* RUV* */
  477. int isreplicationsession;
  478. Slapi_Connection *connection;
  479. PRLock *lock; /* protects entire structure */
  480. int in_use_opid; /* the id of the operation actively using this, else -1 */
  481. } consumer_connection_extension;
  482. /* extension construct/destructor */
  483. void *consumer_connection_extension_constructor(void *object, void *parent);
  484. void consumer_connection_extension_destructor(void *ext, void *object, void *parent);
  485. /* extension helpers for managing exclusive access */
  486. consumer_connection_extension *consumer_connection_extension_acquire_exclusive_access(void *conn, PRUint64 connid, int opid);
  487. int consumer_connection_extension_relinquish_exclusive_access(void *conn, PRUint64 connid, int opid, PRBool force);
  488. /* mapping tree extension - stores replica object */
  489. typedef struct multimaster_mtnode_extension
  490. {
  491. Object *replica;
  492. } multimaster_mtnode_extension;
  493. void *multimaster_mtnode_extension_constructor(void *object, void *parent);
  494. void multimaster_mtnode_extension_destructor(void *ext, void *object, void *parent);
  495. /* general extension functions - repl_ext.c */
  496. void repl_sup_init_ext(); /* initializes registrations - must be called first */
  497. void repl_con_init_ext(); /* initializes registrations - must be called first */
  498. int repl_sup_register_ext(ext_type type); /* registers an extension of the specified type */
  499. int repl_con_register_ext(ext_type type); /* registers an extension of the specified type */
  500. void *repl_sup_get_ext(ext_type type, void *object); /* retireves the extension from the object */
  501. void *repl_con_get_ext(ext_type type, void *object); /* retireves the extension from the object */
  502. /* In repl5_connection.c
  503. * keep in sync with conn_result2string
  504. */
  505. typedef struct repl_connection Repl_Connection;
  506. typedef enum {
  507. CONN_OPERATION_SUCCESS,
  508. CONN_OPERATION_FAILED,
  509. CONN_NOT_CONNECTED,
  510. CONN_SUPPORTS_DS5_REPL,
  511. CONN_DOES_NOT_SUPPORT_DS5_REPL,
  512. CONN_SCHEMA_UPDATED,
  513. CONN_SCHEMA_NO_UPDATE_NEEDED,
  514. CONN_LOCAL_ERROR,
  515. CONN_BUSY,
  516. CONN_SSL_NOT_ENABLED,
  517. CONN_TIMEOUT,
  518. CONN_SUPPORTS_DS71_REPL,
  519. CONN_DOES_NOT_SUPPORT_DS71_REPL,
  520. CONN_IS_READONLY,
  521. CONN_IS_NOT_READONLY,
  522. CONN_SUPPORTS_DIRSYNC,
  523. CONN_DOES_NOT_SUPPORT_DIRSYNC,
  524. CONN_IS_WIN2K3,
  525. CONN_NOT_WIN2K3,
  526. CONN_SUPPORTS_DS90_REPL,
  527. CONN_DOES_NOT_SUPPORT_DS90_REPL
  528. } ConnResult;
  529. char *conn_result2string(int result);
  530. Repl_Connection *conn_new(Repl_Agmt *agmt);
  531. ConnResult conn_connect(Repl_Connection *conn);
  532. void conn_disconnect(Repl_Connection *conn);
  533. void conn_delete(Repl_Connection *conn);
  534. void conn_get_error(Repl_Connection *conn, int *operation, int *error);
  535. void conn_get_error_ex(Repl_Connection *conn, int *operation, int *error, char **error_string);
  536. ConnResult conn_send_add(Repl_Connection *conn, const char *dn, LDAPMod **attrs, LDAPControl *update_control, int *message_id);
  537. ConnResult conn_send_delete(Repl_Connection *conn, const char *dn, LDAPControl *update_control, int *message_id);
  538. ConnResult conn_send_modify(Repl_Connection *conn, const char *dn, LDAPMod **mods, LDAPControl *update_control, int *message_id);
  539. ConnResult conn_send_rename(Repl_Connection *conn, const char *dn, const char *newrdn, const char *newparent, int deleteoldrdn, LDAPControl *update_control, int *message_id);
  540. ConnResult conn_send_extended_operation(Repl_Connection *conn, const char *extop_oid, struct berval *payload, LDAPControl *update_control, int *message_id);
  541. const char *conn_get_status(Repl_Connection *conn);
  542. void conn_start_linger(Repl_Connection *conn);
  543. void conn_cancel_linger(Repl_Connection *conn);
  544. ConnResult conn_replica_supports_ds5_repl(Repl_Connection *conn);
  545. ConnResult conn_replica_supports_ds71_repl(Repl_Connection *conn);
  546. ConnResult conn_replica_supports_ds90_repl(Repl_Connection *conn);
  547. ConnResult conn_replica_is_readonly(Repl_Connection *conn);
  548. ConnResult conn_read_entry_attribute(Repl_Connection *conn, const char *dn, char *type, struct berval ***returned_bvals);
  549. ConnResult conn_push_schema(Repl_Connection *conn, CSN **remotecsn);
  550. void conn_set_timeout(Repl_Connection *conn, long timeout);
  551. long conn_get_timeout(Repl_Connection *conn);
  552. void conn_set_agmt_changed(Repl_Connection *conn);
  553. ConnResult conn_read_result(Repl_Connection *conn, int *message_id);
  554. ConnResult conn_read_result_ex(Repl_Connection *conn, char **retoidp, struct berval **retdatap, LDAPControl ***returned_controls, int send_msgid, int *resp_msgid, int noblock);
  555. LDAP *conn_get_ldap(Repl_Connection *conn);
  556. void conn_lock(Repl_Connection *conn);
  557. void conn_unlock(Repl_Connection *conn);
  558. void conn_delete_internal_ext(Repl_Connection *conn);
  559. const char *conn_get_bindmethod(Repl_Connection *conn);
  560. void conn_set_tot_update_cb(Repl_Connection *conn, void *cb_data);
  561. void conn_set_tot_update_cb_nolock(Repl_Connection *conn, void *cb_data);
  562. void conn_get_tot_update_cb(Repl_Connection *conn, void **cb_data);
  563. void conn_get_tot_update_cb_nolock(Repl_Connection *conn, void **cb_data);
  564. /* In repl5_protocol.c */
  565. typedef struct repl_protocol Repl_Protocol;
  566. Repl_Protocol *prot_new(Repl_Agmt *agmt, int protocol_state);
  567. void prot_start(Repl_Protocol *rp);
  568. Repl_Agmt *prot_get_agreement(Repl_Protocol *rp);
  569. /* initiate total protocol */
  570. void prot_initialize_replica(Repl_Protocol *rp);
  571. /* stop protocol session in progress */
  572. void prot_stop(Repl_Protocol *rp);
  573. void prot_delete(Repl_Protocol **rpp);
  574. void prot_free(Repl_Protocol **rpp);
  575. PRBool prot_set_active_protocol(Repl_Protocol *rp, PRBool total);
  576. void prot_clear_active_protocol(Repl_Protocol *rp);
  577. Repl_Connection *prot_get_connection(Repl_Protocol *rp);
  578. void prot_resume(Repl_Protocol *rp, int wakeup_action);
  579. void prot_notify_update(Repl_Protocol *rp);
  580. void prot_notify_agmt_changed(Repl_Protocol *rp, char *agmt_name);
  581. void prot_notify_window_opened(Repl_Protocol *rp);
  582. void prot_notify_window_closed(Repl_Protocol *rp);
  583. Object *prot_get_replica_object(Repl_Protocol *rp);
  584. void prot_replicate_now(Repl_Protocol *rp);
  585. Repl_Protocol *agmt_get_protocol(Repl_Agmt *ra);
  586. /* In repl5_replica.c */
  587. typedef enum {
  588. REPLICA_TYPE_UNKNOWN,
  589. REPLICA_TYPE_PRIMARY,
  590. REPLICA_TYPE_READONLY,
  591. REPLICA_TYPE_UPDATABLE,
  592. REPLICA_TYPE_END
  593. } ReplicaType;
  594. #define RUV_STORAGE_ENTRY_UNIQUEID "ffffffff-ffffffff-ffffffff-ffffffff"
  595. #define START_ITERATION_ENTRY_UNIQUEID "00000000-00000000-00000000-00000000"
  596. #define START_ITERATION_ENTRY_DN "cn=start iteration"
  597. typedef int (*FNEnumReplica)(Replica *r, void *arg);
  598. /* this function should be called to construct the replica object
  599. from the data already in the DIT */
  600. Replica *replica_new(const Slapi_DN *root);
  601. Replica *windows_replica_new(const Slapi_DN *root);
  602. /* this function should be called to construct the replica object
  603. during addition of the replica over LDAP */
  604. Replica *replica_new_from_entry(Slapi_Entry *e, char *errortext, PRBool is_add_operation);
  605. void replica_destroy(void **arg);
  606. int replica_subentry_update(Slapi_DN *repl_root, ReplicaId rid);
  607. int replica_subentry_check(Slapi_DN *repl_root, ReplicaId rid);
  608. PRBool replica_get_exclusive_access(Replica *r, PRBool *isInc, PRUint64 connid, int opid, const char *locking_purl, char **current_purl);
  609. void replica_relinquish_exclusive_access(Replica *r, PRUint64 connid, int opid);
  610. PRBool replica_get_tombstone_reap_active(const Replica *r);
  611. const Slapi_DN *replica_get_root(const Replica *r);
  612. const char *replica_get_name(const Replica *r);
  613. uint64_t replica_get_locking_conn(const Replica *r);
  614. ReplicaId replica_get_rid(const Replica *r);
  615. void replica_set_rid(Replica *r, ReplicaId rid);
  616. PRBool replica_is_initialized(const Replica *r);
  617. Object *replica_get_ruv(const Replica *r);
  618. /* replica now owns the RUV */
  619. void replica_set_ruv(Replica *r, RUV *ruv);
  620. Object *replica_get_csngen(const Replica *r);
  621. ReplicaType replica_get_type(const Replica *r);
  622. void replica_set_type(Replica *r, ReplicaType type);
  623. PRBool replica_is_updatedn(Replica *r, const Slapi_DN *sdn);
  624. void replica_set_updatedn(Replica *r, const Slapi_ValueSet *vs, int mod_op);
  625. void replica_set_groupdn(Replica *r, const Slapi_ValueSet *vs, int mod_op);
  626. char *replica_get_generation(const Replica *r);
  627. /* currently supported flags */
  628. #define REPLICA_LOG_CHANGES 0x1 /* enable change logging */
  629. PRBool replica_is_flag_set(const Replica *r, PRUint32 flag);
  630. void replica_set_flag(Replica *r, PRUint32 flag, PRBool clear);
  631. void replica_replace_flags(Replica *r, PRUint32 flags);
  632. void replica_dump(Replica *r);
  633. void replica_set_enabled(Replica *r, PRBool enable);
  634. Object *replica_get_replica_from_dn(const Slapi_DN *dn);
  635. int replica_update_ruv(Replica *replica, const CSN *csn, const char *replica_purl);
  636. Object *replica_get_replica_for_op(Slapi_PBlock *pb);
  637. /* the functions below manipulate replica hash */
  638. int replica_init_name_hash(void);
  639. void replica_destroy_name_hash(void);
  640. int replica_add_by_name(const char *name, Object *replica);
  641. int replica_delete_by_name(const char *name);
  642. Object *replica_get_by_name(const char *name);
  643. void replica_flush(Replica *r);
  644. void replica_set_csn_assigned(Replica *r);
  645. void replica_get_referrals(const Replica *r, char ***referrals);
  646. void replica_set_referrals(Replica *r, const Slapi_ValueSet *vs);
  647. int replica_update_csngen_state(Replica *r, const RUV *ruv);
  648. int replica_update_csngen_state_ext(Replica *r, const RUV *ruv, const CSN *extracsn);
  649. CSN *replica_get_purge_csn(const Replica *r);
  650. int replica_log_ruv_elements(const Replica *r);
  651. void replica_enumerate_replicas(FNEnumReplica fn, void *arg);
  652. int replica_reload_ruv(Replica *r);
  653. int replica_check_for_data_reload(Replica *r, void *arg);
  654. /* the functions below manipulate replica dn hash */
  655. int replica_init_dn_hash(void);
  656. void replica_destroy_dn_hash(void);
  657. int replica_add_by_dn(const char *dn);
  658. int replica_delete_by_dn(const char *dn);
  659. int replica_is_being_configured(const char *dn);
  660. void consumer5_set_mapping_tree_state_for_replica(const Replica *r, RUV *supplierRuv);
  661. Object *replica_get_for_backend(const char *be_name);
  662. void replica_set_purge_delay(Replica *r, PRUint32 purge_delay);
  663. void replica_set_tombstone_reap_interval(Replica *r, long interval);
  664. void replica_update_ruv_consumer(Replica *r, RUV *supplier_ruv);
  665. void replica_set_ruv_dirty(Replica *r);
  666. Slapi_Entry *get_in_memory_ruv(Slapi_DN *suffix_sdn);
  667. int replica_write_ruv(Replica *r);
  668. char *replica_get_dn(Replica *r);
  669. void replica_check_for_tasks(Replica *r, Slapi_Entry *e);
  670. void replica_update_state(time_t when, void *arg);
  671. void replica_reset_csn_pl(Replica *r);
  672. PRUint64 replica_get_protocol_timeout(Replica *r);
  673. void replica_set_protocol_timeout(Replica *r, PRUint64 timeout);
  674. PRUint64 replica_get_release_timeout(Replica *r);
  675. void replica_set_release_timeout(Replica *r, PRUint64 timeout);
  676. void replica_set_groupdn_checkinterval(Replica *r, int timeout);
  677. PRUint64 replica_get_backoff_min(Replica *r);
  678. PRUint64 replica_get_backoff_max(Replica *r);
  679. void replica_set_backoff_min(Replica *r, PRUint64 min);
  680. void replica_set_backoff_max(Replica *r, PRUint64 max);
  681. int replica_get_agmt_count(Replica *r);
  682. void replica_incr_agmt_count(Replica *r);
  683. void replica_decr_agmt_count(Replica *r);
  684. PRUint64 replica_get_precise_purging(Replica *r);
  685. void replica_set_precise_purging(Replica *r, PRUint64 on_off);
  686. PRBool ignore_error_and_keep_going(int error);
  687. void replica_check_release_timeout(Replica *r, Slapi_PBlock *pb);
  688. void replica_lock_replica(Replica *r);
  689. void replica_unlock_replica(Replica *r);
  690. /* The functions below handles the state flag */
  691. /* Current internal state flags */
  692. /* The replica can be busy and not other flag,
  693. * it means that the protocol has ended, but the work is not done yet.
  694. * It happens on total protocol, the end protocol has been received,
  695. * and the thread waits for import to finish
  696. */
  697. #define REPLICA_IN_USE 1 /* The replica is busy */
  698. #define REPLICA_INCREMENTAL_IN_PROGRESS 2 /* Set only between start and stop inc */
  699. #define REPLICA_TOTAL_IN_PROGRESS 4 /* Set only between start and stop total */
  700. #define REPLICA_AGREEMENTS_DISABLED 8 /* Replica is offline */
  701. #define REPLICA_TOTAL_EXCL_SEND 16 /* The server is either sending or receiving the total update. Introducing it if SEND
  702. is active, RECV should back off. And vice versa. But SEND can coexist. */
  703. #define REPLICA_TOTAL_EXCL_RECV 32 /* ditto */
  704. PRBool replica_is_state_flag_set(Replica *r, PRInt32 flag);
  705. void replica_set_state_flag(Replica *r, PRUint32 flag, PRBool clear);
  706. void replica_set_tombstone_reap_stop(Replica *r, PRBool val);
  707. void replica_enable_replication(Replica *r);
  708. void replica_disable_replication(Replica *r, Object *r_obj);
  709. int replica_start_agreement(Replica *r, Repl_Agmt *ra);
  710. int windows_replica_start_agreement(Replica *r, Repl_Agmt *ra);
  711. CSN *replica_generate_next_csn(Slapi_PBlock *pb, const CSN *basecsn);
  712. int replica_get_attr(Slapi_PBlock *pb, const char *type, void *value);
  713. /* mapping tree extensions manipulation */
  714. void multimaster_mtnode_extension_init(void);
  715. void multimaster_mtnode_extension_destroy(void);
  716. void multimaster_mtnode_construct_replicas(void);
  717. void multimaster_be_state_change(void *handle, char *be_name, int old_be_state, int new_be_state);
  718. /* In repl5_replica_config.c */
  719. int replica_config_init(void);
  720. void replica_config_destroy(void);
  721. int get_replica_type(Replica *r);
  722. int replica_execute_cleanruv_task_ext(Object *r, ReplicaId rid);
  723. void add_cleaned_rid(ReplicaId rid, Replica *r, char *maxcsn, char *forcing);
  724. int is_cleaned_rid(ReplicaId rid);
  725. int replica_cleanall_ruv_abort(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter, int *returncode, char *returntext, void *arg);
  726. void replica_cleanallruv_thread_ext(void *arg);
  727. void stop_ruv_cleaning(void);
  728. int task_aborted(void);
  729. void replica_abort_task_thread(void *arg);
  730. void remove_cleaned_rid(ReplicaId rid);
  731. int process_repl_agmts(Replica *replica, int *agmt_info, char *oid, Slapi_Task *task, struct berval *payload, int op);
  732. int decode_cleanruv_payload(struct berval *extop_value, char **payload);
  733. struct berval *create_cleanruv_payload(char *value);
  734. void ruv_get_cleaned_rids(RUV *ruv, ReplicaId *rids);
  735. void add_aborted_rid(ReplicaId rid, Replica *r, char *repl_root);
  736. int is_task_aborted(ReplicaId rid);
  737. void delete_aborted_rid(Replica *replica, ReplicaId rid, char *repl_root, int skip);
  738. int is_pre_cleaned_rid(ReplicaId rid);
  739. void set_cleaned_rid(ReplicaId rid);
  740. void cleanruv_log(Slapi_Task *task, int rid, char *task_type, int sev_level, char *fmt, ...);
  741. char *replica_cleanallruv_get_local_maxcsn(ReplicaId rid, char *base_dn);
  742. #define CLEANRIDSIZ 64 /* maximum number for concurrent CLEANALLRUV tasks */
  743. typedef struct _cleanruv_data
  744. {
  745. Object *repl_obj;
  746. Replica *replica;
  747. ReplicaId rid;
  748. Slapi_Task *task;
  749. struct berval *payload;
  750. CSN *maxcsn;
  751. char *repl_root;
  752. Slapi_DN *sdn;
  753. char *certify;
  754. char *force;
  755. } cleanruv_data;
  756. typedef struct _cleanruv_purge_data
  757. {
  758. int cleaned_rid;
  759. const Slapi_DN *suffix_sdn;
  760. char *replName;
  761. char *replGen;
  762. } cleanruv_purge_data;
  763. /* replutil.c */
  764. LDAPControl *create_managedsait_control(void);
  765. LDAPControl *create_backend_control(Slapi_DN *sdn);
  766. void repl_set_mtn_state_and_referrals(const Slapi_DN *sdn, const char *mtn_state, const RUV *ruv, char **ruv_referrals, char **other_referrals);
  767. void repl_set_repl_plugin_path(const char *path);
  768. /* repl5_updatedn_list.c */
  769. typedef void *ReplicaUpdateDNList;
  770. typedef int (*FNEnumDN)(Slapi_DN *dn, void *arg);
  771. ReplicaUpdateDNList replica_updatedn_list_new(const Slapi_Entry *entry);
  772. Slapi_ValueSet *replica_updatedn_group_new(const Slapi_Entry *entry);
  773. ReplicaUpdateDNList replica_groupdn_list_new(const Slapi_ValueSet *vs);
  774. void replica_updatedn_list_free(ReplicaUpdateDNList list);
  775. void replica_updatedn_list_replace(ReplicaUpdateDNList list, const Slapi_ValueSet *vs);
  776. void replica_updatedn_list_group_replace(ReplicaUpdateDNList list, const Slapi_ValueSet *vs);
  777. void replica_updatedn_list_delete(ReplicaUpdateDNList list, const Slapi_ValueSet *vs);
  778. void replica_updatedn_list_add(ReplicaUpdateDNList list, const Slapi_ValueSet *vs);
  779. void replica_updatedn_list_add_ext(ReplicaUpdateDNList list, const Slapi_ValueSet *vs, int group_update);
  780. PRBool replica_updatedn_list_ismember(ReplicaUpdateDNList list, const Slapi_DN *dn);
  781. char *replica_updatedn_list_to_string(ReplicaUpdateDNList list, const char *delimiter);
  782. void replica_updatedn_list_enumerate(ReplicaUpdateDNList list, FNEnumDN fn, void *arg);
  783. /* enabling developper traces for MMR to understand the total/inc protocol state machines */
  784. #ifdef DEV_DEBUG
  785. #define SLAPI_LOG_DEV_DEBUG SLAPI_LOG_DEBUG
  786. #define dev_debug(a) slapi_log_err(SLAPI_LOG_DEV_DEBUG, "DEV_DEBUG", "%s\n", a)
  787. #else
  788. #define dev_debug(a)
  789. #endif
  790. void repl5_set_debug_timeout(const char *val);
  791. /* temp hack XXX */
  792. ReplicaId agmt_get_consumerRID(Repl_Agmt *ra);
  793. /* For replica release tuning */
  794. int agmt_get_WaitForAsyncResults(Repl_Agmt *ra);
  795. PRBool ldif_dump_is_running(void);
  796. void windows_init_agreement_from_entry(Repl_Agmt *ra, Slapi_Entry *e);
  797. int windows_handle_modify_agreement(Repl_Agmt *ra, const char *type, Slapi_Entry *e);
  798. void windows_agreement_delete(Repl_Agmt *ra);
  799. Repl_Connection *windows_conn_new(Repl_Agmt *agmt);
  800. void windows_conn_delete(Repl_Connection *conn);
  801. void windows_update_done(Repl_Agmt *ra, int is_total);
  802. /* repl_session_plugin.c */
  803. void repl_session_plugin_init(void);
  804. void repl_session_plugin_call_agmt_init_cb(Repl_Agmt *ra);
  805. int repl_session_plugin_call_pre_acquire_cb(const Repl_Agmt *ra, int is_total, char **data_guid, struct berval **data);
  806. int repl_session_plugin_call_post_acquire_cb(const Repl_Agmt *ra, int is_total, const char *data_guid, const struct berval *data);
  807. int repl_session_plugin_call_recv_acquire_cb(const char *repl_area, int is_total, const char *data_guid, const struct berval *data);
  808. int repl_session_plugin_call_reply_acquire_cb(const char *repl_area, int is_total, char **data_guid, struct berval **data);
  809. void repl_session_plugin_call_destroy_agmt_cb(const Repl_Agmt *ra);
  810. #endif /* _REPL5_H_ */