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;
41 state of an incoming wrepl connection
43 struct wreplsrv_in_connection {
44 struct wreplsrv_in_connection *prev,*next;
45 struct stream_connection *conn;
47 /* our global service context */
48 struct wreplsrv_service *service;
51 * the partner that connects us,
52 * can be NULL, when we got a connection
53 * from an unknown address
55 struct wreplsrv_partner *partner;
58 * we need to take care of our own ip address,
59 * as this is the WINS-Owner ID the peer expect
64 /* keep track of the assoc_ctx's */
71 /* the partial input on the connection */
76 * are we currently processing a request?
77 * this prevents loops, with half async code
82 * if this is set we no longer accept incoming packets
83 * and terminate the connection after we have send all packets
87 /* the list of outgoing DATA_BLOB's that needs to be send */
88 struct data_blob_list_item *send_queue;
92 state of an outcoming wrepl connection
94 struct wreplsrv_out_connection {
95 /* our global service context */
96 struct wreplsrv_service *service;
99 * the partner that connects us,
100 * can be NULL, when we got a connection
101 * from an unknown address
103 struct wreplsrv_partner *partner;
105 /* keep track of the assoc_ctx's */
112 * the client socket to the partner,
113 * NULL if not yet connected
115 struct wrepl_socket *sock;
118 enum winsrepl_partner_type {
119 WINSREPL_PARTNER_NONE = 0x0,
120 WINSREPL_PARTNER_PULL = 0x1,
121 WINSREPL_PARTNER_PUSH = 0x2,
122 WINSREPL_PARTNER_BOTH = (WINSREPL_PARTNER_PULL | WINSREPL_PARTNER_PUSH)
125 #define WINSREPL_DEFAULT_PULL_INTERVAL (30*60)
126 #define WINSREPL_DEFAULT_PULL_RETRY_INTERVAL (30)
129 this represents one of our configured partners
131 struct wreplsrv_partner {
132 struct wreplsrv_partner *prev,*next;
134 /* our global service context */
135 struct wreplsrv_service *service;
137 /* the netbios name of the partner, mostly just for debugging */
140 /* the ip-address of the partner */
144 * as wins partners identified by ip-address, we need to use a specific source-ip
145 * when we want to connect to the partner
147 const char *our_address;
149 /* the type of the partner, pull, push or both */
150 enum winsrepl_partner_type type;
152 /* pull specific options */
154 /* the interval between 2 pull replications to the partner */
157 /* the retry_interval if a pull cycle failed to the partner */
158 uint32_t retry_interval;
160 /* the error count till the last success */
161 uint32_t error_count;
163 /* the status of the last pull cycle */
164 NTSTATUS last_status;
166 /* this is a list of each wins_owner the partner knows about */
167 struct wreplsrv_owner *table;
169 /* the outgoing connection to the partner */
170 struct wreplsrv_out_connection *wreplconn;
172 /* the current pending pull cycle request */
173 struct composite_context *creq;
175 /* the pull cycle io params */
176 struct wreplsrv_pull_cycle_io *cycle_io;
178 /* the current timed_event to the next pull cycle */
179 struct timed_event *te;
182 /* push specific options */
184 /* change count till push notification */
185 uint32_t change_count;
187 /* the status of the last push cycle */
188 NTSTATUS last_status;
190 /* the outgoing connection to the partner */
191 struct wreplsrv_out_connection *wreplconn;
193 /* the current push notification */
194 struct composite_context *creq;
196 /* the pull cycle io params */
197 struct wreplsrv_push_notify_io *notify_io;
199 /* the current timed_event to the next push notify */
200 struct timed_event *te;
204 struct wreplsrv_owner {
205 struct wreplsrv_owner *prev,*next;
207 /* this hold the owner_id (address), min_version, max_version and partner_type */
208 struct wrepl_wins_owner owner;
210 /* can be NULL if this owner isn't a configure partner */
211 struct wreplsrv_partner *partner;
215 state of the whole wrepl service
217 struct wreplsrv_service {
218 /* the whole wrepl service is in one task */
219 struct task_server *task;
221 /* the winsdb handle */
222 struct ldb_context *wins_db;
224 /* all incoming connections */
225 struct wreplsrv_in_connection *in_connections;
227 /* all partners (pull and push) */
228 struct wreplsrv_partner *partners;
230 /* this is a list of each wins_owner we know about in our database */
231 struct wreplsrv_owner *table;