s4:dsdb/repl: convert dreplsrv_op_pull_source_send/recv to tevent_req
[Samba/gbeck.git] / source4 / dsdb / repl / drepl_service.h
blob0a0d721d5c2805a6b1fd9a60c3abb3e4d5fbf3c8
1 /*
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;
37 DATA_BLOB gensec_skey;
38 struct drsuapi_DsBindInfo28 remote_info28;
39 struct policy_handle bind_handle;
42 struct dreplsrv_out_connection {
43 struct dreplsrv_out_connection *prev, *next;
45 struct dreplsrv_service *service;
48 * the binding for the outgoing connection
50 struct dcerpc_binding *binding;
52 /* the out going connection to the source dsa */
53 struct dreplsrv_drsuapi_connection *drsuapi;
56 struct dreplsrv_partition_source_dsa {
57 struct dreplsrv_partition_source_dsa *prev, *next;
59 struct dreplsrv_partition *partition;
62 * the cached repsFrom value for this source dsa
64 * it needs to be updated after each DsGetNCChanges() call
65 * to the source dsa
67 * repsFrom1 == &_repsFromBlob.ctr.ctr1
69 struct repsFromToBlob _repsFromBlob;
70 struct repsFromTo1 *repsFrom1;
72 /* the last uSN when we sent a notify */
73 uint64_t notify_uSN;
75 /* the reference to the source_dsa and its outgoing connection */
76 struct dreplsrv_out_connection *conn;
79 struct dreplsrv_partition {
80 struct dreplsrv_partition *prev, *next;
82 struct dreplsrv_service *service;
84 /* the dn of the partition */
85 struct ldb_dn *dn;
86 struct drsuapi_DsReplicaObjectIdentifier nc;
88 /*
89 * uptodate vector needs to be updated before and after each DsGetNCChanges() call
91 * - before: we need to use our own invocationId together with our highestCommitedUsn
92 * - after: we need to merge in the remote uptodatevector, to avoid reading it again
94 struct replUpToDateVectorCtr2 uptodatevector;
95 struct drsuapi_DsReplicaCursorCtrEx uptodatevector_ex;
98 * a linked list of all source dsa's we replicate from
100 struct dreplsrv_partition_source_dsa *sources;
103 typedef void (*dreplsrv_fsmo_callback_t)(struct dreplsrv_service *, WERROR );
105 struct dreplsrv_out_operation {
106 struct dreplsrv_out_operation *prev, *next;
108 struct dreplsrv_service *service;
110 struct dreplsrv_partition_source_dsa *source_dsa;
112 enum drsuapi_DsExtendedOperation extended_op;
113 uint64_t fsmo_info;
114 dreplsrv_fsmo_callback_t callback;
117 struct dreplsrv_notify_operation {
118 struct dreplsrv_notify_operation *prev, *next;
120 struct dreplsrv_service *service;
121 uint64_t uSN;
123 struct dreplsrv_partition_source_dsa *source_dsa;
125 struct composite_context *creq;
128 struct dreplsrv_service {
129 /* the whole drepl service is in one task */
130 struct task_server *task;
132 /* the time the service was started */
133 struct timeval startup_time;
136 * system session info
137 * with machine account credentials
139 struct auth_session_info *system_session_info;
142 * a connection to the local samdb
144 struct ldb_context *samdb;
146 /* the guid of our NTDS Settings object, which never changes! */
147 struct GUID ntds_guid;
149 * the struct holds the values used for outgoing DsBind() calls,
150 * so that we need to set them up only once
152 struct drsuapi_DsBindInfo28 bind_info28;
154 /* some stuff for periodic processing */
155 struct {
157 * the interval between to periodic runs
159 uint32_t interval;
162 * the timestamp for the next event,
163 * this is the timstamp passed to event_add_timed()
165 struct timeval next_event;
167 /* here we have a reference to the timed event the schedules the periodic stuff */
168 struct tevent_timer *te;
169 } periodic;
171 /* some stuff for notify processing */
172 struct {
174 * the interval between notify runs
176 uint32_t interval;
179 * the timestamp for the next event,
180 * this is the timstamp passed to event_add_timed()
182 struct timeval next_event;
184 /* here we have a reference to the timed event the schedules the notifies */
185 struct tevent_timer *te;
186 } notify;
189 * the list of partitions we need to replicate
191 struct dreplsrv_partition *partitions;
194 * the list of cached connections
196 struct dreplsrv_out_connection *connections;
198 struct {
199 /* the pointer to the current active operation */
200 struct dreplsrv_out_operation *current;
202 /* the list of pending operations */
203 struct dreplsrv_out_operation *pending;
205 /* the list of pending notify operations */
206 struct dreplsrv_notify_operation *notifies;
208 /* an active notify operation */
209 struct dreplsrv_notify_operation *n_current;
210 } ops;
212 struct {
213 bool in_progress;
214 struct dreplsrv_partition_source_dsa *rid_manager_source_dsa;
215 } ridalloc;
218 #include "dsdb/repl/drepl_out_helpers.h"
219 #include "dsdb/repl/drepl_service_proto.h"
221 #endif /* _DSDB_REPL_DREPL_SERVICE_H_ */