s4-samba-tool: add password verification in change user pass
[Samba/gbeck.git] / source4 / wrepl_server / wrepl_server.h
blobbb6c181040e521695e053632d07d36494f6dcc62
1 /*
2 Unix SMB/CIFS implementation.
4 WINS Replication server
6 Copyright (C) Stefan Metzmacher 2005
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "system/network.h"
24 struct wreplsrv_service;
25 struct wreplsrv_in_connection;
26 struct wreplsrv_out_connection;
27 struct wreplsrv_partner;
29 #define WREPLSRV_VALID_ASSOC_CTX 0x12345678
30 #define WREPLSRV_INVALID_ASSOC_CTX 0x0000000a
33 state of an incoming wrepl call
35 struct wreplsrv_in_call {
36 struct wreplsrv_in_connection *wreplconn;
37 struct wrepl_packet req_packet;
38 struct wrepl_packet rep_packet;
39 bool terminate_after_send;
41 DATA_BLOB in;
42 DATA_BLOB out;
43 struct iovec out_iov[1];
47 state of an incoming wrepl connection
49 struct wreplsrv_in_connection {
50 struct wreplsrv_in_connection *prev,*next;
51 struct stream_connection *conn;
52 struct tstream_context *tstream;
53 struct tevent_queue *send_queue;
55 /* our global service context */
56 struct wreplsrv_service *service;
59 * the partner that connects us,
60 * can be NULL, when we got a connection
61 * from an unknown address
63 struct wreplsrv_partner *partner;
65 /* keep track of the assoc_ctx's */
66 struct {
67 bool stopped;
68 uint32_t our_ctx;
69 uint32_t peer_ctx;
70 } assoc_ctx;
74 state of an outgoing wrepl connection
76 struct wreplsrv_out_connection {
77 /* our global service context */
78 struct wreplsrv_service *service;
81 * the partner we connect
83 struct wreplsrv_partner *partner;
85 /* keep track of the assoc_ctx's */
86 struct {
87 uint32_t our_ctx;
88 uint32_t peer_ctx;
89 uint16_t peer_major;
90 } assoc_ctx;
92 /*
93 * the client socket to the partner,
94 * NULL if not yet connected
96 struct wrepl_socket *sock;
99 enum winsrepl_partner_type {
100 WINSREPL_PARTNER_NONE = 0x0,
101 WINSREPL_PARTNER_PULL = 0x1,
102 WINSREPL_PARTNER_PUSH = 0x2,
103 WINSREPL_PARTNER_BOTH = (WINSREPL_PARTNER_PULL | WINSREPL_PARTNER_PUSH)
106 #define WINSREPL_DEFAULT_PULL_INTERVAL (30*60)
107 #define WINSREPL_DEFAULT_PULL_RETRY_INTERVAL (30)
109 #define WINSREPL_DEFAULT_PUSH_CHANGE_COUNT (0)
112 this represents one of our configured partners
114 struct wreplsrv_partner {
115 struct wreplsrv_partner *prev,*next;
117 /* our global service context */
118 struct wreplsrv_service *service;
120 /* the netbios name of the partner, mostly just for debugging */
121 const char *name;
123 /* the ip-address of the partner */
124 const char *address;
127 * as wins partners identified by ip-address, we need to use a specific source-ip
128 * when we want to connect to the partner
130 const char *our_address;
132 /* the type of the partner, pull, push or both */
133 enum winsrepl_partner_type type;
135 /* pull specific options */
136 struct {
137 /* the interval between 2 pull replications to the partner */
138 uint32_t interval;
140 /* the retry_interval if a pull cycle failed to the partner */
141 uint32_t retry_interval;
143 /* the error count till the last success */
144 uint32_t error_count;
146 /* the status of the last pull cycle */
147 NTSTATUS last_status;
149 /* the timestamp of the next pull try */
150 struct timeval next_run;
152 /* this is a list of each wins_owner the partner knows about */
153 struct wreplsrv_owner *table;
155 /* the outgoing connection to the partner */
156 struct wreplsrv_out_connection *wreplconn;
158 /* the current pending pull cycle request */
159 struct composite_context *creq;
161 /* the pull cycle io params */
162 struct wreplsrv_pull_cycle_io *cycle_io;
164 /* the current timed_event to the next pull cycle */
165 struct tevent_timer *te;
166 } pull;
168 /* push specific options */
169 struct {
170 /* change count till push notification */
171 uint32_t change_count;
173 /* the last wins db maxVersion have reported to the partner */
174 uint64_t maxVersionID;
176 /* we should use WREPL_REPL_INFORM* messages to this partner */
177 bool use_inform;
179 /* the error count till the last success */
180 uint32_t error_count;
182 /* the status of the last push cycle */
183 NTSTATUS last_status;
185 /* the outgoing connection to the partner */
186 struct wreplsrv_out_connection *wreplconn;
188 /* the current push notification */
189 struct composite_context *creq;
191 /* the pull cycle io params */
192 struct wreplsrv_push_notify_io *notify_io;
193 } push;
196 struct wreplsrv_owner {
197 struct wreplsrv_owner *prev,*next;
199 /* this hold the owner_id (address), min_version, max_version and partner_type */
200 struct wrepl_wins_owner owner;
202 /* can be NULL if this owner isn't a configure partner */
203 struct wreplsrv_partner *partner;
207 state of the whole wrepl service
209 struct wreplsrv_service {
210 /* the whole wrepl service is in one task */
211 struct task_server *task;
213 /* the time the service was started */
214 struct timeval startup_time;
216 /* the winsdb handle */
217 struct winsdb_handle *wins_db;
219 /* some configuration */
220 struct {
221 /* the wins config db handle */
222 struct ldb_context *ldb;
224 /* the last wins config db seqnumber we know about */
225 uint64_t seqnumber;
228 * the interval (in secs) till an active record will be marked as RELEASED
230 uint32_t renew_interval;
233 * the interval (in secs) a record remains in RELEASED state,
234 * before it will be marked as TOMBSTONE
235 * (also known as extinction interval)
237 uint32_t tombstone_interval;
240 * the interval (in secs) a record remains in TOMBSTONE state,
241 * before it will be removed from the database.
242 * See also 'tombstone_extra_timeout'.
243 * (also known as extinction timeout)
245 uint32_t tombstone_timeout;
248 * the interval (in secs) a record remains in TOMBSTONE state,
249 * even after 'tombstone_timeout' passes the current timestamp.
250 * this is the minimum uptime of the wrepl service, before
251 * we start delete tombstones. This is to prevent deletion of
252 * tombstones, without replacte them.
254 uint32_t tombstone_extra_timeout;
257 * the interval (in secs) till a replica record will be verified
258 * with the owning wins server
260 uint32_t verify_interval;
263 * the interval (in secs) till a do a database cleanup
265 uint32_t scavenging_interval;
268 * the interval (in secs) to the next periodic processing
269 * (this is the maximun interval)
271 uint32_t periodic_interval;
272 } config;
274 /* all incoming connections */
275 struct wreplsrv_in_connection *in_connections;
277 /* all partners (pull and push) */
278 struct wreplsrv_partner *partners;
281 * this is our local wins_owner entry, this is also in the table list
282 * but we need a pointer to it, because we need to update it on each
283 * query to wreplsrv_find_owner(), as the local records can be added
284 * to the wins.ldb from external tools and the winsserver
286 struct wreplsrv_owner *owner;
288 /* this is a list of each wins_owner we know about in our database */
289 struct wreplsrv_owner *table;
291 /* some stuff for periodic processing */
292 struct {
294 * the timestamp for the next event,
295 * this is the timstamp passed to event_add_timed()
297 struct timeval next_event;
299 /* here we have a reference to the timed event the schedules the periodic stuff */
300 struct tevent_timer *te;
301 } periodic;
303 /* some stuff for scavenging processing */
304 struct {
306 * the timestamp for the next scavenging run,
307 * this is the timstamp passed to event_add_timed()
309 struct timeval next_run;
312 * are we currently inside a scavenging run
314 bool processing;
315 } scavenging;
318 struct socket_context;
319 struct wrepl_name;
320 #include "wrepl_server/wrepl_out_helpers.h"
321 #include "wrepl_server/wrepl_server_proto.h"