summaryrefslogtreecommitdiffstats
path: root/ldap/servers/plugins/replication/repl_shared.h
blob: 957fdc7676ff43c59a22fd3a70d848ee898230bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/** BEGIN COPYRIGHT BLOCK
 * This Program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; version 2 of the License.
 * 
 * This Program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA.
 * 
 * In addition, as a special exception, Red Hat, Inc. gives You the additional
 * right to link the code of this Program with code not covered under the GNU
 * General Public License ("Non-GPL Code") and to distribute linked combinations
 * including the two, subject to the limitations in this paragraph. Non-GPL Code
 * permitted under this exception must only link to the code of this Program
 * through those well defined interfaces identified in the file named EXCEPTION
 * found in the source code files (the "Approved Interfaces"). The files of
 * Non-GPL Code may instantiate templates or use macros or inline functions from
 * the Approved Interfaces without causing the resulting work to be covered by
 * the GNU General Public License. Only Red Hat, Inc. may make changes or
 * additions to the list of Approved Interfaces. You must obey the GNU General
 * Public License in all respects for all of the Program code and other code used
 * in conjunction with the Program except the Non-GPL Code covered by this
 * exception. If you modify this file, you may extend this exception to your
 * version of the file, but you are not obligated to do so. If you do not wish to
 * provide this exception without modification, you must delete this exception
 * statement from your version and license this file solely under the GPL without
 * exception. 
 * 
 * 
 * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
 * Copyright (C) 2005 Red Hat, Inc.
 * All rights reserved.
 * END COPYRIGHT BLOCK **/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

/* repl_shared.h - definitions shared between 4.0 and 5.0 replication
				   modules
 */	

#ifndef REPL_SHARED_H
#define REPL_SHARED_H

#include "slapi-private.h"
#include "slapi-plugin.h"
#include "ldif.h" /* GGOODREPL - is this cheating? */

#ifdef _WIN32
#define FILE_PATHSEP '\\'
#else
#define FILE_PATHSEP '/'
#endif

#define	CHANGELOGDB_TRIM_INTERVAL	300 /* 5 minutes */

#define CONFIG_CHANGELOG_DIR_ATTRIBUTE		"nsslapd-changelogdir"
#define CONFIG_CHANGELOG_MAXENTRIES_ATTRIBUTE	"nsslapd-changelogmaxentries"
#define CONFIG_CHANGELOG_MAXAGE_ATTRIBUTE	"nsslapd-changelogmaxage"
/* Changelog Internal Configuration Parameters -> DB related */
#define CONFIG_CHANGELOG_DB_DBCACHESIZE			"nsslapd-dbcachesize"
#define CONFIG_CHANGELOG_DB_DURABLE_TRANSACTIONS	"nsslapd-db-durable-transaction"
#define CONFIG_CHANGELOG_DB_CHECKPOINT_INTERVAL		"nsslapd-db-checkpoint-interval"
#define CONFIG_CHANGELOG_DB_CIRCULAR_LOGGING		"nsslapd-db-circular-logging"
#define CONFIG_CHANGELOG_DB_PAGE_SIZE			"nsslapd-db-page-size"
#define CONFIG_CHANGELOG_DB_LOGFILE_SIZE		"nsslapd-db-logfile-size"
#define CONFIG_CHANGELOG_DB_MAXTXN_SIZE			"nsslapd-db-max-txn"
#define CONFIG_CHANGELOG_DB_VERBOSE			"nsslapd-db-verbose"
#define CONFIG_CHANGELOG_DB_DEBUG			"nsslapd-db-debug"
#define CONFIG_CHANGELOG_DB_TRICKLE_PERCENTAGE		"nsslapd-db-trickle-percentage"
#define CONFIG_CHANGELOG_DB_SPINCOUNT			"nsslapd-db-spin-count"
/* Changelog Internal Configuration Parameters -> Changelog Cache related */
#define CONFIG_CHANGELOG_CACHESIZE			"nsslapd-cachesize"
#define CONFIG_CHANGELOG_CACHEMEMSIZE			"nsslapd-cachememsize"
#define CONFIG_CHANGELOG_NB_LOCK	"nsslapd-db-locks"
#define CONFIG_CHANGELOG_MAX_CONCURRENT_WRITES	"nsslapd-changelogmaxconcurrentwrites"

#define	T_CHANGETYPESTR		"changetype"
#define	T_CHANGETYPE		1
#define	T_TIMESTR		"time"
#define	T_TIME			2
#define	T_DNSTR			"dn"
#define	T_DN			3
#define	T_CHANGESTR		"change"
#define	T_CHANGE		4

#define	T_ADDCTSTR		"add"
#define	T_ADDCT			4
#define	T_MODIFYCTSTR		"modify"
#define	T_MODIFYCT		5
#define	T_DELETECTSTR		"delete"
#define	T_DELETECT		6
#define	T_MODRDNCTSTR		"modrdn"
#define	T_MODRDNCT		7
#define	T_MODDNCTSTR		"moddn"
#define	T_MODDNCT		8

#define	T_MODOPADDSTR		"add"
#define	T_MODOPADD		9
#define	T_MODOPREPLACESTR	"replace"
#define	T_MODOPREPLACE		10
#define	T_MODOPDELETESTR	"delete"
#define	T_MODOPDELETE		11
#define	T_MODSEPSTR		"-"
#define	T_MODSEP		12

#define	T_NEWRDNSTR		"newrdn"
#define T_NEWSUPERIORSTR	ATTR_NEWSUPERIOR
#define	T_DRDNFLAGSTR		"deleteoldrdn"

#define	T_ERR			-1
#define	AWAITING_OP		-1

#define STATE_REFERRAL "referral"
#define STATE_UPDATE_REFERRAL "referral on update"
#define STATE_BACKEND "backend"

#define REPL_PLUGIN_NAME "NSMMReplicationPlugin"
/*
 * Changed version from 1.0 to 2.0 when we switched from libdb32 to libdb33
 * richm 20020708
 * also changed name from REPL_PLUGIN_VERSION to CHANGELOG_DB_VERSION since we use
 * a different version for the plugin itself and this particular version is only
 * used for the changelog database
*/
/*
 * Changed version from 2.0 to 3.0 when we switched from libdb33 to libdb41
 * noriko 20021203
 */
#define CHANGELOG_DB_VERSION_PREV "3.0"
#define CHANGELOG_DB_VERSION "4.0"
extern char *repl_plugin_name;
extern char *windows_repl_plugin_name;
extern char *repl_plugin_name_cl;

/* repl_monitor.c */
int repl_monitor_init();

/* In replutil.c */
char ** get_cleattrs();
unsigned long strntoul( char *from, size_t len, int base );
void freepmods( LDAPMod **pmods );
char *copy_berval (struct berval* from);
void entry_print(Slapi_Entry *e);
int copyfile(char* source, char *destination, int overwrite, int mode);
time_t age_str2time (const char *age);
const char* changeType2Str (int type);
int str2ChangeType (const char *str);
lenstr *make_changes_string(LDAPMod **ldm, char **includeattrs);
Slapi_Mods* parse_changes_string(char *str);
PRBool IsValidOperation (const slapi_operation_parameters *op);
const char *map_repl_root_to_dbid(Slapi_DN *repl_root);
PRBool is_ruv_tombstone_entry (Slapi_Entry *e);

/* replication plugins */
enum {
		PLUGIN_LEGACY_REPLICATION,
		PLUGIN_MULTIMASTER_REPLICATION,
		PLUGIN_MAX
};						

void* repl_get_plugin_identity (int pluginID);
void  repl_set_plugin_identity (int pluginID, void *identity);

#endif