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;
59 /* keep track of the assoc_ctx's */
68 state of an outcoming wrepl connection
70 struct wreplsrv_out_connection {
71 /* our global service context */
72 struct wreplsrv_service *service;
75 * the partner that connects us,
76 * can be NULL, when we got a connection
77 * from an unknown address
79 struct wreplsrv_partner *partner;
81 /* keep track of the assoc_ctx's */
88 * the client socket to the partner,
89 * NULL if not yet connected
91 struct wrepl_socket *sock;
94 enum winsrepl_partner_type {
95 WINSREPL_PARTNER_NONE = 0x0,
96 WINSREPL_PARTNER_PULL = 0x1,
97 WINSREPL_PARTNER_PUSH = 0x2,
98 WINSREPL_PARTNER_BOTH = (WINSREPL_PARTNER_PULL | WINSREPL_PARTNER_PUSH)
101 #define WINSREPL_DEFAULT_PULL_INTERVAL (30*60)
102 #define WINSREPL_DEFAULT_PULL_RETRY_INTERVAL (30)
104 #define WINSREPL_DEFAULT_PUSH_CHANGE_COUNT (0)
107 this represents one of our configured partners
109 struct wreplsrv_partner {
110 struct wreplsrv_partner *prev,*next;
112 /* our global service context */
113 struct wreplsrv_service *service;
115 /* the netbios name of the partner, mostly just for debugging */
118 /* the ip-address of the partner */
122 * as wins partners identified by ip-address, we need to use a specific source-ip
123 * when we want to connect to the partner
125 const char *our_address;
127 /* the type of the partner, pull, push or both */
128 enum winsrepl_partner_type type;
130 /* pull specific options */
132 /* the interval between 2 pull replications to the partner */
135 /* the retry_interval if a pull cycle failed to the partner */
136 uint32_t retry_interval;
138 /* the error count till the last success */
139 uint32_t error_count;
141 /* the status of the last pull cycle */
142 NTSTATUS last_status;
144 /* the timestamp of the next pull try */
145 struct timeval next_run;
147 /* this is a list of each wins_owner the partner knows about */
148 struct wreplsrv_owner *table;
150 /* the outgoing connection to the partner */
151 struct wreplsrv_out_connection *wreplconn;
153 /* the current pending pull cycle request */
154 struct composite_context *creq;
156 /* the pull cycle io params */
157 struct wreplsrv_pull_cycle_io *cycle_io;
159 /* the current timed_event to the next pull cycle */
160 struct timed_event *te;
163 /* push specific options */
165 /* change count till push notification */
166 uint32_t change_count;
168 /* the last wins db seqnumber we know about */
171 /* we should use WREPL_REPL_INFORM* messages to this partner */
174 /* the error count till the last success */
175 uint32_t error_count;
177 /* the status of the last push cycle */
178 NTSTATUS last_status;
180 /* the outgoing connection to the partner */
181 struct wreplsrv_out_connection *wreplconn;
183 /* the current push notification */
184 struct composite_context *creq;
186 /* the pull cycle io params */
187 struct wreplsrv_push_notify_io *notify_io;
191 struct wreplsrv_owner {
192 struct wreplsrv_owner *prev,*next;
194 /* this hold the owner_id (address), min_version, max_version and partner_type */
195 struct wrepl_wins_owner owner;
197 /* can be NULL if this owner isn't a configure partner */
198 struct wreplsrv_partner *partner;
202 state of the whole wrepl service
204 struct wreplsrv_service {
205 /* the whole wrepl service is in one task */
206 struct task_server *task;
208 /* the time the service was started */
209 struct timeval startup_time;
211 /* the winsdb handle */
212 struct winsdb_handle *wins_db;
214 /* some configuration */
216 /* the wins config db handle */
217 struct ldb_context *ldb;
219 /* the last wins config db seqnumber we know about */
223 * the interval (in secs) till an active record will be marked as RELEASED
225 uint32_t renew_interval;
228 * the interval (in secs) a record remains in RELEASED state,
229 * before it will be marked as TOMBSTONE
230 * (also known as extinction interval)
232 uint32_t tombstone_interval;
235 * the interval (in secs) a record remains in TOMBSTONE state,
236 * before it will be removed from the database.
237 * See also 'tombstone_extra_timeout'.
238 * (also known as extinction timeout)
240 uint32_t tombstone_timeout;
243 * the interval (in secs) a record remains in TOMBSTONE state,
244 * even after 'tombstone_timeout' passes the current timestamp.
245 * this is the minimum uptime of the wrepl service, before
246 * we start delete tombstones. This is to prevent deletion of
247 * tombstones, without replacte them.
249 uint32_t tombstone_extra_timeout;
252 * the interval (in secs) till a replica record will be verified
253 * with the owning wins server
255 uint32_t verify_interval;
258 * the interval (in secs) till a do a database cleanup
260 uint32_t scavenging_interval;
263 * the interval (in secs) to the next periodic processing
264 * (this is the maximun interval)
266 uint32_t periodic_interval;
269 /* all incoming connections */
270 struct wreplsrv_in_connection *in_connections;
272 /* all partners (pull and push) */
273 struct wreplsrv_partner *partners;
276 * this is our local wins_owner entry, this is also in the table list
277 * but we need a pointer to it, because we need to update it on each
278 * query to wreplsrv_find_owner(), as the local records can be added
279 * to the wins.ldb from external tools and the winsserver
281 struct wreplsrv_owner *owner;
283 /* this is a list of each wins_owner we know about in our database */
284 struct wreplsrv_owner *table;
286 /* some stuff for periodic processing */
289 * the timestamp for the next event,
290 * this is the timstamp passed to event_add_timed()
292 struct timeval next_event;
294 /* here we have a reference to the timed event the schedules the periodic stuff */
295 struct timed_event *te;
298 /* some stuff for scavenging processing */
301 * the timestamp for the next scavenging run,
302 * this is the timstamp passed to event_add_timed()
304 struct timeval next_run;
307 * are we currently inside a scavenging run
313 #include "wrepl_server/wrepl_out_helpers.h"
314 #include "wrepl_server/wrepl_server_proto.h"