r10530: - fix some crash bugs when we lost the connection...
[samba.git] / source4 / libcli / wrepl / winsrepl.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    structures for WINS replication client library
5
6    Copyright (C) Andrew Tridgell 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 #include "librpc/gen_ndr/ndr_nbt.h"
24 #include "librpc/gen_ndr/ndr_winsrepl.h"
25
26 /*
27   main context structure for the wins replication client library
28 */
29 struct wrepl_socket {
30         struct socket_context *sock;
31         struct event_context *event_ctx;
32
33         /* a queue of requests pending to be sent */
34         struct wrepl_request *send_queue;
35
36         /* a queue of replies waiting to be received */
37         struct wrepl_request *recv_queue;
38
39         /* the fd event */
40         struct fd_event *fde;
41
42         /* remember is the socket is dead */
43         BOOL dead;
44 };
45
46 enum wrepl_request_state {
47         WREPL_REQUEST_SEND  = 0,
48         WREPL_REQUEST_RECV  = 1,
49         WREPL_REQUEST_DONE  = 2,
50         WREPL_REQUEST_ERROR = 3
51 };
52
53 /*
54   a WINS replication request
55 */
56 struct wrepl_request {
57         struct wrepl_request *next, *prev;
58         struct wrepl_socket *wrepl_socket;
59
60         enum wrepl_request_state state;
61         NTSTATUS status;
62
63         DATA_BLOB buffer;
64
65         size_t num_read;
66
67         struct wrepl_packet *packet;
68
69         struct {
70                 void (*fn)(struct wrepl_request *);
71                 void *private;
72         } async;
73 };
74
75
76 /*
77   setup an association
78 */
79 struct wrepl_associate {
80         struct {
81                 uint32_t assoc_ctx;
82         } out;
83 };
84
85 /*
86   pull the partner table
87 */
88 struct wrepl_pull_table {
89         struct {
90                 uint32_t assoc_ctx;
91         } in;
92         struct {
93                 uint32_t num_partners;
94                 struct wrepl_wins_owner *partners;
95         } out;
96 };
97
98 /*
99   a full pull replication
100 */
101 struct wrepl_pull_names {
102         struct {
103                 uint32_t assoc_ctx;
104                 struct wrepl_wins_owner partner;
105         } in;
106         struct {
107                 uint32_t num_names;
108                 struct wrepl_name {
109                         struct nbt_name name;
110                         uint32_t num_addresses;
111                         struct wrepl_address {
112                                 const char *owner;
113                                 const char *address;
114                         } *addresses;
115                 } *names;
116         } out;
117 };