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 struct wreplsrv_service;
23 struct wreplsrv_in_connection;
24 struct wreplsrv_out_connection;
25 struct wreplsrv_partner;
27 #define WREPLSRV_VALID_ASSOC_CTX 0x12345678
28 #define WREPLSRV_INVALID_ASSOC_CTX 0x0000000a
31 state of an incoming wrepl call
33 struct wreplsrv_in_call {
34 struct wreplsrv_in_connection *wreplconn;
35 struct wrepl_packet req_packet;
36 struct wrepl_packet rep_packet;
37 bool terminate_after_send;
41 state of an incoming wrepl connection
43 struct wreplsrv_in_connection {
44 struct wreplsrv_in_connection *prev,*next;
45 struct stream_connection *conn;
46 struct packet_context *packet;
48 /* our global service context */
49 struct wreplsrv_service *service;
52 * the partner that connects us,
53 * can be NULL, when we got a connection
54 * from an unknown address
56 struct wreplsrv_partner *partner;
58 /* keep track of the assoc_ctx's */
67 state of an outgoing wrepl connection
69 struct wreplsrv_out_connection {
70 /* our global service context */
71 struct wreplsrv_service *service;
74 * the partner we connect
76 struct wreplsrv_partner *partner;
78 /* keep track of the assoc_ctx's */
85 * the client socket to the partner,
86 * NULL if not yet connected
88 struct wrepl_socket *sock;
91 enum winsrepl_partner_type {
92 WINSREPL_PARTNER_NONE = 0x0,
93 WINSREPL_PARTNER_PULL = 0x1,
94 WINSREPL_PARTNER_PUSH = 0x2,
95 WINSREPL_PARTNER_BOTH = (WINSREPL_PARTNER_PULL | WINSREPL_PARTNER_PUSH)
98 #define WINSREPL_DEFAULT_PULL_INTERVAL (30*60)
99 #define WINSREPL_DEFAULT_PULL_RETRY_INTERVAL (30)
101 #define WINSREPL_DEFAULT_PUSH_CHANGE_COUNT (0)
104 this represents one of our configured partners
106 struct wreplsrv_partner {
107 struct wreplsrv_partner *prev,*next;
109 /* our global service context */
110 struct wreplsrv_service *service;
112 /* the netbios name of the partner, mostly just for debugging */
115 /* the ip-address of the partner */
119 * as wins partners identified by ip-address, we need to use a specific source-ip
120 * when we want to connect to the partner
122 const char *our_address;
124 /* the type of the partner, pull, push or both */
125 enum winsrepl_partner_type type;
127 /* pull specific options */
129 /* the interval between 2 pull replications to the partner */
132 /* the retry_interval if a pull cycle failed to the partner */
133 uint32_t retry_interval;
135 /* the error count till the last success */
136 uint32_t error_count;
138 /* the status of the last pull cycle */
139 NTSTATUS last_status;
141 /* the timestamp of the next pull try */
142 struct timeval next_run;
144 /* this is a list of each wins_owner the partner knows about */
145 struct wreplsrv_owner *table;
147 /* the outgoing connection to the partner */
148 struct wreplsrv_out_connection *wreplconn;
150 /* the current pending pull cycle request */
151 struct composite_context *creq;
153 /* the pull cycle io params */
154 struct wreplsrv_pull_cycle_io *cycle_io;
156 /* the current timed_event to the next pull cycle */
157 struct tevent_timer *te;
160 /* push specific options */
162 /* change count till push notification */
163 uint32_t change_count;
165 /* the last wins db maxVersion have reported to the partner */
166 uint64_t maxVersionID;
168 /* we should use WREPL_REPL_INFORM* messages to this partner */
171 /* the error count till the last success */
172 uint32_t error_count;
174 /* the status of the last push cycle */
175 NTSTATUS last_status;
177 /* the outgoing connection to the partner */
178 struct wreplsrv_out_connection *wreplconn;
180 /* the current push notification */
181 struct composite_context *creq;
183 /* the pull cycle io params */
184 struct wreplsrv_push_notify_io *notify_io;
188 struct wreplsrv_owner {
189 struct wreplsrv_owner *prev,*next;
191 /* this hold the owner_id (address), min_version, max_version and partner_type */
192 struct wrepl_wins_owner owner;
194 /* can be NULL if this owner isn't a configure partner */
195 struct wreplsrv_partner *partner;
199 state of the whole wrepl service
201 struct wreplsrv_service {
202 /* the whole wrepl service is in one task */
203 struct task_server *task;
205 /* the time the service was started */
206 struct timeval startup_time;
208 /* the winsdb handle */
209 struct winsdb_handle *wins_db;
211 /* some configuration */
213 /* the wins config db handle */
214 struct ldb_context *ldb;
216 /* the last wins config db seqnumber we know about */
220 * the interval (in secs) till an active record will be marked as RELEASED
222 uint32_t renew_interval;
225 * the interval (in secs) a record remains in RELEASED state,
226 * before it will be marked as TOMBSTONE
227 * (also known as extinction interval)
229 uint32_t tombstone_interval;
232 * the interval (in secs) a record remains in TOMBSTONE state,
233 * before it will be removed from the database.
234 * See also 'tombstone_extra_timeout'.
235 * (also known as extinction timeout)
237 uint32_t tombstone_timeout;
240 * the interval (in secs) a record remains in TOMBSTONE state,
241 * even after 'tombstone_timeout' passes the current timestamp.
242 * this is the minimum uptime of the wrepl service, before
243 * we start delete tombstones. This is to prevent deletion of
244 * tombstones, without replacte them.
246 uint32_t tombstone_extra_timeout;
249 * the interval (in secs) till a replica record will be verified
250 * with the owning wins server
252 uint32_t verify_interval;
255 * the interval (in secs) till a do a database cleanup
257 uint32_t scavenging_interval;
260 * the interval (in secs) to the next periodic processing
261 * (this is the maximun interval)
263 uint32_t periodic_interval;
266 /* all incoming connections */
267 struct wreplsrv_in_connection *in_connections;
269 /* all partners (pull and push) */
270 struct wreplsrv_partner *partners;
273 * this is our local wins_owner entry, this is also in the table list
274 * but we need a pointer to it, because we need to update it on each
275 * query to wreplsrv_find_owner(), as the local records can be added
276 * to the wins.ldb from external tools and the winsserver
278 struct wreplsrv_owner *owner;
280 /* this is a list of each wins_owner we know about in our database */
281 struct wreplsrv_owner *table;
283 /* some stuff for periodic processing */
286 * the timestamp for the next event,
287 * this is the timstamp passed to event_add_timed()
289 struct timeval next_event;
291 /* here we have a reference to the timed event the schedules the periodic stuff */
292 struct tevent_timer *te;
295 /* some stuff for scavenging processing */
298 * the timestamp for the next scavenging run,
299 * this is the timstamp passed to event_add_timed()
301 struct timeval next_run;
304 * are we currently inside a scavenging run
310 struct socket_context;
312 #include "wrepl_server/wrepl_out_helpers.h"
313 #include "wrepl_server/wrepl_server_proto.h"