source: branches/samba-3.5.x/source4/wrepl_server/wrepl_server.h

Last change on this file was 414, checked in by Herwig Bauernfeind, 15 years ago

Samba 3.5.0: Initial import

File size: 7.8 KB
Line 
1/*
2 Unix SMB/CIFS implementation.
3
4 WINS Replication server
5
6 Copyright (C) Stefan Metzmacher 2005
7
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.
12
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.
17
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/>.
20*/
21
22struct wreplsrv_service;
23struct wreplsrv_in_connection;
24struct wreplsrv_out_connection;
25struct wreplsrv_partner;
26
27#define WREPLSRV_VALID_ASSOC_CTX 0x12345678
28#define WREPLSRV_INVALID_ASSOC_CTX 0x0000000a
29
30/*
31 state of an incoming wrepl call
32*/
33struct 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;
38};
39
40/*
41 state of an incoming wrepl connection
42*/
43struct wreplsrv_in_connection {
44 struct wreplsrv_in_connection *prev,*next;
45 struct stream_connection *conn;
46 struct packet_context *packet;
47
48 /* our global service context */
49 struct wreplsrv_service *service;
50
51 /*
52 * the partner that connects us,
53 * can be NULL, when we got a connection
54 * from an unknown address
55 */
56 struct wreplsrv_partner *partner;
57
58 /* keep track of the assoc_ctx's */
59 struct {
60 bool stopped;
61 uint32_t our_ctx;
62 uint32_t peer_ctx;
63 } assoc_ctx;
64};
65
66/*
67 state of an outgoing wrepl connection
68*/
69struct wreplsrv_out_connection {
70 /* our global service context */
71 struct wreplsrv_service *service;
72
73 /*
74 * the partner we connect
75 */
76 struct wreplsrv_partner *partner;
77
78 /* keep track of the assoc_ctx's */
79 struct {
80 uint32_t our_ctx;
81 uint32_t peer_ctx;
82 uint16_t peer_major;
83 } assoc_ctx;
84
85 /*
86 * the client socket to the partner,
87 * NULL if not yet connected
88 */
89 struct wrepl_socket *sock;
90};
91
92enum winsrepl_partner_type {
93 WINSREPL_PARTNER_NONE = 0x0,
94 WINSREPL_PARTNER_PULL = 0x1,
95 WINSREPL_PARTNER_PUSH = 0x2,
96 WINSREPL_PARTNER_BOTH = (WINSREPL_PARTNER_PULL | WINSREPL_PARTNER_PUSH)
97};
98
99#define WINSREPL_DEFAULT_PULL_INTERVAL (30*60)
100#define WINSREPL_DEFAULT_PULL_RETRY_INTERVAL (30)
101
102#define WINSREPL_DEFAULT_PUSH_CHANGE_COUNT (0)
103
104/*
105 this represents one of our configured partners
106*/
107struct wreplsrv_partner {
108 struct wreplsrv_partner *prev,*next;
109
110 /* our global service context */
111 struct wreplsrv_service *service;
112
113 /* the netbios name of the partner, mostly just for debugging */
114 const char *name;
115
116 /* the ip-address of the partner */
117 const char *address;
118
119 /*
120 * as wins partners identified by ip-address, we need to use a specific source-ip
121 * when we want to connect to the partner
122 */
123 const char *our_address;
124
125 /* the type of the partner, pull, push or both */
126 enum winsrepl_partner_type type;
127
128 /* pull specific options */
129 struct {
130 /* the interval between 2 pull replications to the partner */
131 uint32_t interval;
132
133 /* the retry_interval if a pull cycle failed to the partner */
134 uint32_t retry_interval;
135
136 /* the error count till the last success */
137 uint32_t error_count;
138
139 /* the status of the last pull cycle */
140 NTSTATUS last_status;
141
142 /* the timestamp of the next pull try */
143 struct timeval next_run;
144
145 /* this is a list of each wins_owner the partner knows about */
146 struct wreplsrv_owner *table;
147
148 /* the outgoing connection to the partner */
149 struct wreplsrv_out_connection *wreplconn;
150
151 /* the current pending pull cycle request */
152 struct composite_context *creq;
153
154 /* the pull cycle io params */
155 struct wreplsrv_pull_cycle_io *cycle_io;
156
157 /* the current timed_event to the next pull cycle */
158 struct tevent_timer *te;
159 } pull;
160
161 /* push specific options */
162 struct {
163 /* change count till push notification */
164 uint32_t change_count;
165
166 /* the last wins db maxVersion have reported to the partner */
167 uint64_t maxVersionID;
168
169 /* we should use WREPL_REPL_INFORM* messages to this partner */
170 bool use_inform;
171
172 /* the error count till the last success */
173 uint32_t error_count;
174
175 /* the status of the last push cycle */
176 NTSTATUS last_status;
177
178 /* the outgoing connection to the partner */
179 struct wreplsrv_out_connection *wreplconn;
180
181 /* the current push notification */
182 struct composite_context *creq;
183
184 /* the pull cycle io params */
185 struct wreplsrv_push_notify_io *notify_io;
186 } push;
187};
188
189struct wreplsrv_owner {
190 struct wreplsrv_owner *prev,*next;
191
192 /* this hold the owner_id (address), min_version, max_version and partner_type */
193 struct wrepl_wins_owner owner;
194
195 /* can be NULL if this owner isn't a configure partner */
196 struct wreplsrv_partner *partner;
197};
198
199/*
200 state of the whole wrepl service
201*/
202struct wreplsrv_service {
203 /* the whole wrepl service is in one task */
204 struct task_server *task;
205
206 /* the time the service was started */
207 struct timeval startup_time;
208
209 /* the winsdb handle */
210 struct winsdb_handle *wins_db;
211
212 /* some configuration */
213 struct {
214 /* the wins config db handle */
215 struct ldb_context *ldb;
216
217 /* the last wins config db seqnumber we know about */
218 uint64_t seqnumber;
219
220 /*
221 * the interval (in secs) till an active record will be marked as RELEASED
222 */
223 uint32_t renew_interval;
224
225 /*
226 * the interval (in secs) a record remains in RELEASED state,
227 * before it will be marked as TOMBSTONE
228 * (also known as extinction interval)
229 */
230 uint32_t tombstone_interval;
231
232 /*
233 * the interval (in secs) a record remains in TOMBSTONE state,
234 * before it will be removed from the database.
235 * See also 'tombstone_extra_timeout'.
236 * (also known as extinction timeout)
237 */
238 uint32_t tombstone_timeout;
239
240 /*
241 * the interval (in secs) a record remains in TOMBSTONE state,
242 * even after 'tombstone_timeout' passes the current timestamp.
243 * this is the minimum uptime of the wrepl service, before
244 * we start delete tombstones. This is to prevent deletion of
245 * tombstones, without replacte them.
246 */
247 uint32_t tombstone_extra_timeout;
248
249 /*
250 * the interval (in secs) till a replica record will be verified
251 * with the owning wins server
252 */
253 uint32_t verify_interval;
254
255 /*
256 * the interval (in secs) till a do a database cleanup
257 */
258 uint32_t scavenging_interval;
259
260 /*
261 * the interval (in secs) to the next periodic processing
262 * (this is the maximun interval)
263 */
264 uint32_t periodic_interval;
265 } config;
266
267 /* all incoming connections */
268 struct wreplsrv_in_connection *in_connections;
269
270 /* all partners (pull and push) */
271 struct wreplsrv_partner *partners;
272
273 /*
274 * this is our local wins_owner entry, this is also in the table list
275 * but we need a pointer to it, because we need to update it on each
276 * query to wreplsrv_find_owner(), as the local records can be added
277 * to the wins.ldb from external tools and the winsserver
278 */
279 struct wreplsrv_owner *owner;
280
281 /* this is a list of each wins_owner we know about in our database */
282 struct wreplsrv_owner *table;
283
284 /* some stuff for periodic processing */
285 struct {
286 /*
287 * the timestamp for the next event,
288 * this is the timstamp passed to event_add_timed()
289 */
290 struct timeval next_event;
291
292 /* here we have a reference to the timed event the schedules the periodic stuff */
293 struct tevent_timer *te;
294 } periodic;
295
296 /* some stuff for scavenging processing */
297 struct {
298 /*
299 * the timestamp for the next scavenging run,
300 * this is the timstamp passed to event_add_timed()
301 */
302 struct timeval next_run;
303
304 /*
305 * are we currently inside a scavenging run
306 */
307 bool processing;
308 } scavenging;
309};
310
311struct socket_context;
312struct wrepl_name;
313#include "wrepl_server/wrepl_out_helpers.h"
314#include "wrepl_server/wrepl_server_proto.h"
Note: See TracBrowser for help on using the repository browser.