2007-01-23 19:06:47 +03:00
/*
Unix SMB / CIFS mplementation .
DSDB replication service
Copyright ( C ) Stefan Metzmacher 2007
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
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2007-01-23 19:06:47 +03:00
( at your option ) any later version .
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
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2007-01-23 19:06:47 +03:00
*/
# ifndef _DSDB_REPL_DREPL_SERVICE_H_
# define _DSDB_REPL_DREPL_SERVICE_H_
2007-04-23 04:43:47 +04:00
# include "librpc/gen_ndr/ndr_drsuapi_c.h"
struct dreplsrv_service ;
struct dreplsrv_partition ;
struct dreplsrv_drsuapi_connection {
/*
* this pipe pointer is also the indicator
* for a valid connection
*/
struct dcerpc_pipe * pipe ;
2010-03-08 18:23:17 +03:00
struct dcerpc_binding_handle * drsuapi_handle ;
2007-04-23 04:43:47 +04:00
DATA_BLOB gensec_skey ;
struct drsuapi_DsBindInfo28 remote_info28 ;
struct policy_handle bind_handle ;
} ;
struct dreplsrv_out_connection {
struct dreplsrv_out_connection * prev , * next ;
struct dreplsrv_service * service ;
/*
* the binding for the outgoing connection
*/
struct dcerpc_binding * binding ;
/* the out going connection to the source dsa */
struct dreplsrv_drsuapi_connection * drsuapi ;
} ;
struct dreplsrv_partition_source_dsa {
struct dreplsrv_partition_source_dsa * prev , * next ;
struct dreplsrv_partition * partition ;
/*
* the cached repsFrom value for this source dsa
*
* it needs to be updated after each DsGetNCChanges ( ) call
* to the source dsa
*
* repsFrom1 = = & _repsFromBlob . ctr . ctr1
*/
struct repsFromToBlob _repsFromBlob ;
struct repsFromTo1 * repsFrom1 ;
2009-09-13 12:16:13 +04:00
/* the last uSN when we sent a notify */
uint64_t notify_uSN ;
2007-04-23 04:43:47 +04:00
/* the reference to the source_dsa and its outgoing connection */
struct dreplsrv_out_connection * conn ;
} ;
struct dreplsrv_partition {
struct dreplsrv_partition * prev , * next ;
struct dreplsrv_service * service ;
/* the dn of the partition */
struct ldb_dn * dn ;
struct drsuapi_DsReplicaObjectIdentifier nc ;
/*
* uptodate vector needs to be updated before and after each DsGetNCChanges ( ) call
*
2016-12-01 13:49:07 +03:00
* - before : we need to use our own invocationId together with our highestCommittedUSN
2007-04-23 04:43:47 +04:00
* - after : we need to merge in the remote uptodatevector , to avoid reading it again
*/
struct replUpToDateVectorCtr2 uptodatevector ;
struct drsuapi_DsReplicaCursorCtrEx uptodatevector_ex ;
/*
* a linked list of all source dsa ' s we replicate from
*/
struct dreplsrv_partition_source_dsa * sources ;
2010-08-25 06:32:48 +04:00
2010-11-08 09:14:09 +03:00
/*
* a linked list of all source dsa ' s we will notify ,
* that are not also in sources
*/
struct dreplsrv_partition_source_dsa * notifies ;
2011-09-21 02:52:14 +04:00
bool partial_replica ;
2011-10-06 04:14:13 +04:00
bool rodc_replica ;
2007-04-23 04:43:47 +04:00
} ;
2010-09-15 12:59:17 +04:00
typedef void ( * dreplsrv_extended_callback_t ) ( struct dreplsrv_service * ,
WERROR ,
enum drsuapi_DsExtendedError ,
void * cb_data ) ;
2010-01-06 09:16:58 +03:00
2007-04-23 04:43:47 +04:00
struct dreplsrv_out_operation {
struct dreplsrv_out_operation * prev , * next ;
2010-11-17 15:12:10 +03:00
time_t schedule_time ;
2007-04-23 04:43:47 +04:00
struct dreplsrv_service * service ;
struct dreplsrv_partition_source_dsa * source_dsa ;
2011-02-26 21:36:19 +03:00
/* replication options - currently used by DsReplicaSync */
uint32_t options ;
2010-01-06 06:54:12 +03:00
enum drsuapi_DsExtendedOperation extended_op ;
2010-01-06 09:16:58 +03:00
uint64_t fsmo_info ;
2010-07-08 18:20:11 +04:00
enum drsuapi_DsExtendedError extended_ret ;
2010-09-15 12:59:17 +04:00
dreplsrv_extended_callback_t callback ;
2010-08-31 01:01:25 +04:00
void * cb_data ;
2007-04-23 04:43:47 +04:00
} ;
2009-09-13 12:16:13 +04:00
struct dreplsrv_notify_operation {
struct dreplsrv_notify_operation * prev , * next ;
2010-11-17 15:12:10 +03:00
time_t schedule_time ;
2009-09-13 12:16:13 +04:00
struct dreplsrv_service * service ;
uint64_t uSN ;
struct dreplsrv_partition_source_dsa * source_dsa ;
2010-01-21 14:20:44 +03:00
bool is_urgent ;
2010-10-02 06:07:01 +04:00
uint32_t replica_flags ;
2009-09-13 12:16:13 +04:00
} ;
2007-01-23 19:06:47 +03:00
struct dreplsrv_service {
/* the whole drepl service is in one task */
struct task_server * task ;
/* the time the service was started */
struct timeval startup_time ;
/*
* system session info
* with machine account credentials
*/
struct auth_session_info * system_session_info ;
/*
* a connection to the local samdb
*/
struct ldb_context * samdb ;
2007-04-23 04:43:47 +04:00
/* the guid of our NTDS Settings object, which never changes! */
struct GUID ntds_guid ;
/*
* the struct holds the values used for outgoing DsBind ( ) calls ,
* so that we need to set them up only once
*/
struct drsuapi_DsBindInfo28 bind_info28 ;
2007-01-23 19:06:47 +03:00
/* some stuff for periodic processing */
struct {
/*
* the interval between to periodic runs
*/
uint32_t interval ;
/*
* the timestamp for the next event ,
* this is the timstamp passed to event_add_timed ( )
*/
struct timeval next_event ;
/* here we have a reference to the timed event the schedules the periodic stuff */
2008-12-29 22:24:57 +03:00
struct tevent_timer * te ;
2007-01-23 19:06:47 +03:00
} periodic ;
2017-07-21 08:52:04 +03:00
/* some stuff for running only the incoming notify ops */
2013-05-15 15:46:33 +04:00
struct {
2017-07-21 08:52:04 +03:00
/*
* here we have a reference to the immidicate event that was
* scheduled from the DsReplicaSync
2013-05-15 15:46:33 +04:00
*/
2017-07-21 08:52:04 +03:00
struct tevent_immediate * im ;
2013-05-15 15:46:33 +04:00
} pending ;
2009-09-13 12:16:13 +04:00
/* some stuff for notify processing */
struct {
/*
* the interval between notify runs
*/
uint32_t interval ;
/*
* the timestamp for the next event ,
* this is the timstamp passed to event_add_timed ( )
*/
struct timeval next_event ;
/* here we have a reference to the timed event the schedules the notifies */
struct tevent_timer * te ;
} notify ;
2007-04-23 04:43:47 +04:00
/*
* the list of partitions we need to replicate
*/
struct dreplsrv_partition * partitions ;
/*
* the list of cached connections
*/
struct dreplsrv_out_connection * connections ;
struct {
/* the pointer to the current active operation */
struct dreplsrv_out_operation * current ;
/* the list of pending operations */
struct dreplsrv_out_operation * pending ;
2009-09-13 12:16:13 +04:00
/* the list of pending notify operations */
struct dreplsrv_notify_operation * notifies ;
/* an active notify operation */
struct dreplsrv_notify_operation * n_current ;
2007-04-23 04:43:47 +04:00
} ops ;
2010-01-06 06:54:12 +03:00
2010-09-15 10:15:12 +04:00
bool rid_alloc_in_progress ;
2010-04-27 06:17:08 +04:00
2010-09-15 14:24:50 +04:00
bool am_rodc ;
2007-01-23 19:06:47 +03:00
} ;
2010-11-28 13:53:48 +03:00
# include "lib/messaging/irpc.h"
2007-04-23 04:43:47 +04:00
# include "dsdb/repl/drepl_out_helpers.h"
2007-01-23 19:06:47 +03:00
# include "dsdb/repl/drepl_service_proto.h"
# endif /* _DSDB_REPL_DREPL_SERVICE_H_ */