2 Unix SMB/CIFS mplementation.
3 DSDB replication service
5 Copyright (C) Stefan Metzmacher 2007
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #ifndef _DSDB_REPL_DREPL_SERVICE_H_
23 #define _DSDB_REPL_DREPL_SERVICE_H_
25 #include "librpc/gen_ndr/ndr_drsuapi_c.h"
27 struct dreplsrv_service
;
28 struct dreplsrv_partition
;
30 struct dreplsrv_drsuapi_connection
{
32 * this pipe pointer is also the indicator
33 * for a valid connection
35 struct dcerpc_pipe
*pipe
;
36 struct dcerpc_binding_handle
*drsuapi_handle
;
38 DATA_BLOB gensec_skey
;
39 struct drsuapi_DsBindInfo28 remote_info28
;
40 struct policy_handle bind_handle
;
43 struct dreplsrv_out_connection
{
44 struct dreplsrv_out_connection
*prev
, *next
;
46 struct dreplsrv_service
*service
;
49 * the binding for the outgoing connection
51 struct dcerpc_binding
*binding
;
53 /* the out going connection to the source dsa */
54 struct dreplsrv_drsuapi_connection
*drsuapi
;
57 struct dreplsrv_partition_source_dsa
{
58 struct dreplsrv_partition_source_dsa
*prev
, *next
;
60 struct dreplsrv_partition
*partition
;
63 * the cached repsFrom value for this source dsa
65 * it needs to be updated after each DsGetNCChanges() call
68 * repsFrom1 == &_repsFromBlob.ctr.ctr1
70 struct repsFromToBlob _repsFromBlob
;
71 struct repsFromTo1
*repsFrom1
;
73 /* the last uSN when we sent a notify */
76 /* the reference to the source_dsa and its outgoing connection */
77 struct dreplsrv_out_connection
*conn
;
80 struct dreplsrv_partition
{
81 struct dreplsrv_partition
*prev
, *next
;
83 struct dreplsrv_service
*service
;
85 /* the dn of the partition */
87 struct drsuapi_DsReplicaObjectIdentifier nc
;
90 * uptodate vector needs to be updated before and after each DsGetNCChanges() call
92 * - before: we need to use our own invocationId together with our highestCommitedUsn
93 * - after: we need to merge in the remote uptodatevector, to avoid reading it again
95 struct replUpToDateVectorCtr2 uptodatevector
;
96 struct drsuapi_DsReplicaCursorCtrEx uptodatevector_ex
;
99 * a linked list of all source dsa's we replicate from
101 struct dreplsrv_partition_source_dsa
*sources
;
104 * a linked list of all source dsa's we will notify,
105 * that are not also in sources
107 struct dreplsrv_partition_source_dsa
*notifies
;
109 bool partial_replica
;
113 typedef void (*dreplsrv_extended_callback_t
)(struct dreplsrv_service
*,
115 enum drsuapi_DsExtendedError
,
118 struct dreplsrv_out_operation
{
119 struct dreplsrv_out_operation
*prev
, *next
;
120 time_t schedule_time
;
122 struct dreplsrv_service
*service
;
124 struct dreplsrv_partition_source_dsa
*source_dsa
;
126 /* replication options - currently used by DsReplicaSync */
128 enum drsuapi_DsExtendedOperation extended_op
;
130 enum drsuapi_DsExtendedError extended_ret
;
131 dreplsrv_extended_callback_t callback
;
135 struct dreplsrv_notify_operation
{
136 struct dreplsrv_notify_operation
*prev
, *next
;
137 time_t schedule_time
;
139 struct dreplsrv_service
*service
;
142 struct dreplsrv_partition_source_dsa
*source_dsa
;
144 uint32_t replica_flags
;
147 struct dreplsrv_service
{
148 /* the whole drepl service is in one task */
149 struct task_server
*task
;
151 /* the time the service was started */
152 struct timeval startup_time
;
155 * system session info
156 * with machine account credentials
158 struct auth_session_info
*system_session_info
;
161 * a connection to the local samdb
163 struct ldb_context
*samdb
;
165 /* the guid of our NTDS Settings object, which never changes! */
166 struct GUID ntds_guid
;
168 * the struct holds the values used for outgoing DsBind() calls,
169 * so that we need to set them up only once
171 struct drsuapi_DsBindInfo28 bind_info28
;
173 /* some stuff for periodic processing */
176 * the interval between to periodic runs
181 * the timestamp for the next event,
182 * this is the timstamp passed to event_add_timed()
184 struct timeval next_event
;
186 /* here we have a reference to the timed event the schedules the periodic stuff */
187 struct tevent_timer
*te
;
190 /* some stuff for running only the pendings ops */
193 * the interval between notify runs
198 * the timestamp for the next event,
199 * this is the timstamp passed to event_add_timed()
201 struct timeval next_event
;
203 /* here we have a reference to the timed event the schedules the notifies */
204 struct tevent_timer
*te
;
207 /* some stuff for notify processing */
210 * the interval between notify runs
215 * the timestamp for the next event,
216 * this is the timstamp passed to event_add_timed()
218 struct timeval next_event
;
220 /* here we have a reference to the timed event the schedules the notifies */
221 struct tevent_timer
*te
;
225 * the list of partitions we need to replicate
227 struct dreplsrv_partition
*partitions
;
230 * the list of cached connections
232 struct dreplsrv_out_connection
*connections
;
235 /* the pointer to the current active operation */
236 struct dreplsrv_out_operation
*current
;
238 /* the list of pending operations */
239 struct dreplsrv_out_operation
*pending
;
241 /* the list of pending notify operations */
242 struct dreplsrv_notify_operation
*notifies
;
244 /* an active notify operation */
245 struct dreplsrv_notify_operation
*n_current
;
248 bool rid_alloc_in_progress
;
253 #include "lib/messaging/irpc.h"
254 #include "dsdb/repl/drepl_out_helpers.h"
255 #include "dsdb/repl/drepl_service_proto.h"
257 #endif /* _DSDB_REPL_DREPL_SERVICE_H_ */