r11014: r10139@SERNOX: metze | 2005-09-10 10:32:36 +0200
[kai/samba-autobuild/.git] / source4 / wrepl_server / wrepl_server.h
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 2 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, write to the Free Software
20    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23 struct wreplsrv_service;
24 struct wreplsrv_in_connection;
25 struct wreplsrv_out_connection;
26 struct wreplsrv_partner;
27 struct wreplsrv_pull_partner_item;
28 struct wreplsrv_push_partner_item;
29
30 #define WREPLSRV_VALID_ASSOC_CTX        0x12345678
31 #define WREPLSRV_INVALID_ASSOC_CTX      0x0000000a
32
33 /*
34   state of an incoming wrepl call
35 */
36 struct wreplsrv_in_call {
37         struct wreplsrv_in_connection *wreplconn;
38         struct wrepl_packet req_packet;
39         struct wrepl_packet rep_packet;
40 };
41
42 /*
43   state of an incoming wrepl connection
44 */
45 struct wreplsrv_in_connection {
46         struct wreplsrv_in_connection *prev,*next;
47         struct stream_connection *conn;
48
49         /* our global service context */
50         struct wreplsrv_service *service;
51
52         /*
53          * the partner that connects us,
54          * can be NULL, when we got a connection
55          * from an unknown address
56          */
57         struct wreplsrv_partner *partner;
58
59         /*
60          * we need to take care of our own ip address,
61          * as this is the WINS-Owner ID the peer expect
62          * from us.
63          */
64         const char *our_ip;
65
66         /* keep track of the assoc_ctx's */
67         struct {
68                 BOOL stopped;
69                 uint32_t our_ctx;
70                 uint32_t peer_ctx;
71         } assoc_ctx;
72
73         /* the partial input on the connection */
74         DATA_BLOB partial;
75         size_t partial_read;
76
77         /*
78          * are we currently processing a request?
79          * this prevents loops, with half async code
80          */
81         BOOL processing;
82
83         /*
84          * if this is set we no longer accept incoming packets
85          * and terminate the connection after we have send all packets
86          */
87         BOOL terminate;
88
89         /* the list of outgoing DATA_BLOB's that needs to be send */
90         struct data_blob_list_item *send_queue;
91 };
92
93 /*
94   state of an outcoming wrepl connection
95 */
96 struct wreplsrv_out_connection {
97         struct wreplsrv_partner *partner;
98 };
99
100 /*
101   state of the whole wrepl service
102 */
103 struct wreplsrv_service {
104         /* the whole wrepl service is in one task */
105         struct task_server *task;
106
107         /* all incoming connections */
108         struct wreplsrv_in_connection *in_connections;
109
110         /* all partners (pull and push) */
111         struct wreplsrv_partner *partners;
112
113         /* all pull partners */
114         struct wreplsrv_pull_partner *pull_partners;
115
116         /* all push partners */
117         struct wreplsrv_push_partner *push_partners;
118 };