1/* 2 Unix SMB/CIFS mplementation. 3 DSDB replication service 4 5 Copyright (C) Stefan Metzmacher 2007 6 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. 11 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. 16 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/>. 19 20*/ 21 22#ifndef _DSDB_REPL_DREPL_SERVICE_H_ 23#define _DSDB_REPL_DREPL_SERVICE_H_ 24 25#include "librpc/gen_ndr/ndr_drsuapi_c.h" 26 27struct dreplsrv_service; 28struct dreplsrv_partition; 29 30struct dreplsrv_drsuapi_connection { 31 /* 32 * this pipe pointer is also the indicator 33 * for a valid connection 34 */ 35 struct dcerpc_pipe *pipe; 36 37 DATA_BLOB gensec_skey; 38 struct drsuapi_DsBindInfo28 remote_info28; 39 struct policy_handle bind_handle; 40}; 41 42struct dreplsrv_out_connection { 43 struct dreplsrv_out_connection *prev, *next; 44 45 struct dreplsrv_service *service; 46 47 /* 48 * the binding for the outgoing connection 49 */ 50 struct dcerpc_binding *binding; 51 52 /* the out going connection to the source dsa */ 53 struct dreplsrv_drsuapi_connection *drsuapi; 54}; 55 56struct dreplsrv_partition_source_dsa { 57 struct dreplsrv_partition_source_dsa *prev, *next; 58 59 struct dreplsrv_partition *partition; 60 61 /* 62 * the cached repsFrom value for this source dsa 63 * 64 * it needs to be updated after each DsGetNCChanges() call 65 * to the source dsa 66 * 67 * repsFrom1 == &_repsFromBlob.ctr.ctr1 68 */ 69 struct repsFromToBlob _repsFromBlob; 70 struct repsFromTo1 *repsFrom1; 71 72 /* the last uSN when we sent a notify */ 73 uint64_t notify_uSN; 74 75 /* the reference to the source_dsa and its outgoing connection */ 76 struct dreplsrv_out_connection *conn; 77}; 78 79struct dreplsrv_partition { 80 struct dreplsrv_partition *prev, *next; 81 82 struct dreplsrv_service *service; 83 84 /* the dn of the partition */ 85 struct ldb_dn *dn; 86 struct drsuapi_DsReplicaObjectIdentifier nc; 87 88 /* 89 * uptodate vector needs to be updated before and after each DsGetNCChanges() call 90 * 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 93 */ 94 struct replUpToDateVectorCtr2 uptodatevector; 95 struct drsuapi_DsReplicaCursorCtrEx uptodatevector_ex; 96 97 /* 98 * a linked list of all source dsa's we replicate from 99 */ 100 struct dreplsrv_partition_source_dsa *sources; 101}; 102 103struct dreplsrv_out_operation { 104 struct dreplsrv_out_operation *prev, *next; 105 106 struct dreplsrv_service *service; 107 108 struct dreplsrv_partition_source_dsa *source_dsa; 109 110 struct composite_context *creq; 111}; 112 113struct dreplsrv_notify_operation { 114 struct dreplsrv_notify_operation *prev, *next; 115 116 struct dreplsrv_service *service; 117 uint64_t uSN; 118 119 struct dreplsrv_partition_source_dsa *source_dsa; 120 121 struct composite_context *creq; 122}; 123 124struct dreplsrv_service { 125 /* the whole drepl service is in one task */ 126 struct task_server *task; 127 128 /* the time the service was started */ 129 struct timeval startup_time; 130 131 /* 132 * system session info 133 * with machine account credentials 134 */ 135 struct auth_session_info *system_session_info; 136 137 /* 138 * a connection to the local samdb 139 */ 140 struct ldb_context *samdb; 141 142 /* the guid of our NTDS Settings object, which never changes! */ 143 struct GUID ntds_guid; 144 /* 145 * the struct holds the values used for outgoing DsBind() calls, 146 * so that we need to set them up only once 147 */ 148 struct drsuapi_DsBindInfo28 bind_info28; 149 150 /* some stuff for periodic processing */ 151 struct { 152 /* 153 * the interval between to periodic runs 154 */ 155 uint32_t interval; 156 157 /* 158 * the timestamp for the next event, 159 * this is the timstamp passed to event_add_timed() 160 */ 161 struct timeval next_event; 162 163 /* here we have a reference to the timed event the schedules the periodic stuff */ 164 struct tevent_timer *te; 165 } periodic; 166 167 /* some stuff for notify processing */ 168 struct { 169 /* 170 * the interval between notify runs 171 */ 172 uint32_t interval; 173 174 /* 175 * the timestamp for the next event, 176 * this is the timstamp passed to event_add_timed() 177 */ 178 struct timeval next_event; 179 180 /* here we have a reference to the timed event the schedules the notifies */ 181 struct tevent_timer *te; 182 } notify; 183 184 /* 185 * the list of partitions we need to replicate 186 */ 187 struct dreplsrv_partition *partitions; 188 189 /* 190 * the list of cached connections 191 */ 192 struct dreplsrv_out_connection *connections; 193 194 struct { 195 /* the pointer to the current active operation */ 196 struct dreplsrv_out_operation *current; 197 198 /* the list of pending operations */ 199 struct dreplsrv_out_operation *pending; 200 201 /* the list of pending notify operations */ 202 struct dreplsrv_notify_operation *notifies; 203 204 /* an active notify operation */ 205 struct dreplsrv_notify_operation *n_current; 206 } ops; 207}; 208 209#include "dsdb/repl/drepl_out_helpers.h" 210#include "dsdb/repl/drepl_service_proto.h" 211 212#endif /* _DSDB_REPL_DREPL_SERVICE_H_ */ 213