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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 struct wreplsrv_service;
24 struct wreplsrv_in_connection;
25 struct wreplsrv_out_connection;
26 struct wreplsrv_partner;
28 #define WREPLSRV_VALID_ASSOC_CTX 0x12345678
29 #define WREPLSRV_INVALID_ASSOC_CTX 0x0000000a
32 state of an incoming wrepl call
34 struct wreplsrv_in_call {
35 struct wreplsrv_in_connection *wreplconn;
36 struct wrepl_packet req_packet;
37 struct wrepl_packet rep_packet;
38 BOOL terminate_after_send;
42 state of an incoming wrepl connection
44 struct wreplsrv_in_connection {
45 struct wreplsrv_in_connection *prev,*next;
46 struct stream_connection *conn;
47 struct packet_context *packet;
49 /* our global service context */
50 struct wreplsrv_service *service;
53 * the partner that connects us,
54 * can be NULL, when we got a connection
55 * from an unknown address
57 struct wreplsrv_partner *partner;
60 * we need to take care of our own ip address,
61 * as this is the WINS-Owner ID the peer expect
66 /* keep track of the assoc_ctx's */
75 state of an outcoming wrepl connection
77 struct wreplsrv_out_connection {
78 /* our global service context */
79 struct wreplsrv_service *service;
82 * the partner that connects us,
83 * can be NULL, when we got a connection
84 * from an unknown address
86 struct wreplsrv_partner *partner;
88 /* keep track of the assoc_ctx's */
95 * the client socket to the partner,
96 * NULL if not yet connected
98 struct wrepl_socket *sock;
101 enum winsrepl_partner_type {
102 WINSREPL_PARTNER_NONE = 0x0,
103 WINSREPL_PARTNER_PULL = 0x1,
104 WINSREPL_PARTNER_PUSH = 0x2,
105 WINSREPL_PARTNER_BOTH = (WINSREPL_PARTNER_PULL | WINSREPL_PARTNER_PUSH)
108 #define WINSREPL_DEFAULT_PULL_INTERVAL (30*60)
109 #define WINSREPL_DEFAULT_PULL_RETRY_INTERVAL (30)
111 #define WINSREPL_DEFAULT_PUSH_CHANGE_COUNT (0)
114 this represents one of our configured partners
116 struct wreplsrv_partner {
117 struct wreplsrv_partner *prev,*next;
119 /* our global service context */
120 struct wreplsrv_service *service;
122 /* the netbios name of the partner, mostly just for debugging */
125 /* the ip-address of the partner */
129 * as wins partners identified by ip-address, we need to use a specific source-ip
130 * when we want to connect to the partner
132 const char *our_address;
134 /* the type of the partner, pull, push or both */
135 enum winsrepl_partner_type type;
137 /* pull specific options */
139 /* the interval between 2 pull replications to the partner */
142 /* the retry_interval if a pull cycle failed to the partner */
143 uint32_t retry_interval;
145 /* the error count till the last success */
146 uint32_t error_count;
148 /* the status of the last pull cycle */
149 NTSTATUS last_status;
151 /* the timestamp of the next pull try */
152 struct timeval next_run;
154 /* this is a list of each wins_owner the partner knows about */
155 struct wreplsrv_owner *table;
157 /* the outgoing connection to the partner */
158 struct wreplsrv_out_connection *wreplconn;
160 /* the current pending pull cycle request */
161 struct composite_context *creq;
163 /* the pull cycle io params */
164 struct wreplsrv_pull_cycle_io *cycle_io;
166 /* the current timed_event to the next pull cycle */
167 struct timed_event *te;
170 /* push specific options */
172 /* change count till push notification */
173 uint32_t change_count;
175 /* we should use WREPL_REPL_INFORM* messages to this partner */
178 /* the error count till the last success */
179 uint32_t error_count;
181 /* the status of the last push cycle */
182 NTSTATUS last_status;
184 /* the outgoing connection to the partner */
185 struct wreplsrv_out_connection *wreplconn;
187 /* the current push notification */
188 struct composite_context *creq;
190 /* the pull cycle io params */
191 struct wreplsrv_push_notify_io *notify_io;
195 struct wreplsrv_owner {
196 struct wreplsrv_owner *prev,*next;
198 /* this hold the owner_id (address), min_version, max_version and partner_type */
199 struct wrepl_wins_owner owner;
201 /* can be NULL if this owner isn't a configure partner */
202 struct wreplsrv_partner *partner;
206 state of the whole wrepl service
208 struct wreplsrv_service {
209 /* the whole wrepl service is in one task */
210 struct task_server *task;
212 /* the time the service was started */
213 struct timeval startup_time;
215 /* the winsdb handle */
216 struct winsdb_handle *wins_db;
218 /* some configuration */
220 /* the wins config db handle */
221 struct ldb_context *ldb;
224 * the interval (in secs) till an active record will be marked as RELEASED
226 uint32_t renew_interval;
229 * the interval (in secs) a record remains in RELEASED state,
230 * before it will be marked as TOMBSTONE
231 * (also known as extinction interval)
233 uint32_t tombstone_interval;
236 * the interval (in secs) a record remains in TOMBSTONE state,
237 * before it will be removed from the database.
238 * See also 'tombstone_extra_timeout'.
239 * (also known as extinction timeout)
241 uint32_t tombstone_timeout;
244 * the interval (in secs) a record remains in TOMBSTONE state,
245 * even after 'tombstone_timeout' passes the current timestamp.
246 * this is the minimum uptime of the wrepl service, before
247 * we start delete tombstones. This is to prevent deletion of
248 * tombstones, without replacte them.
250 uint32_t tombstone_extra_timeout;
253 * the interval (in secs) till a replica record will be verified
254 * with the owning wins server
256 uint32_t verify_interval;
259 * the interval (in secs) till a do a database cleanup
261 uint32_t scavenging_interval;
264 * the interval (in secs) to the next periodic processing
265 * (this is the maximun interval)
267 uint32_t periodic_interval;
270 /* all incoming connections */
271 struct wreplsrv_in_connection *in_connections;
273 /* all partners (pull and push) */
274 struct wreplsrv_partner *partners;
276 /* this is a list of each wins_owner we know about in our database */
277 struct wreplsrv_owner *table;
279 /* some stuff for periodic processing */
282 * the timestamp for the next event,
283 * this is the timstamp passed to event_add_timed()
285 struct timeval next_event;
287 /* here we have a reference to the timed event the schedules the periodic stuff */
288 struct timed_event *te;
291 /* some stuff for scavenging processing */
294 * the timestamp for the next scavenging run,
295 * this is the timstamp passed to event_add_timed()
297 struct timeval next_run;
300 * are we currently inside a scavenging run
306 #include "wrepl_server/wrepl_server_proto.h"