r10569: add all info that we have to wrepl_name, as we need it for replication :-)
[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         /* the default timeout for requests, 0 means no timeout */
43 #define WREPL_SOCKET_REQUEST_TIMEOUT    (60)
44         uint32_t request_timeout;
45
46         /* counter for request timeouts, after 2 timeouts the socket is marked as dead */
47         uint32_t timeout_count;
48
49         /* remember is the socket is dead */
50         BOOL dead;
51 };
52
53 enum wrepl_request_state {
54         WREPL_REQUEST_SEND  = 0,
55         WREPL_REQUEST_RECV  = 1,
56         WREPL_REQUEST_DONE  = 2,
57         WREPL_REQUEST_ERROR = 3
58 };
59
60 /*
61   a WINS replication request
62 */
63 struct wrepl_request {
64         struct wrepl_request *next, *prev;
65         struct wrepl_socket *wrepl_socket;
66
67         enum wrepl_request_state state;
68         NTSTATUS status;
69
70         DATA_BLOB buffer;
71
72         size_t num_read;
73
74         struct timed_event *te;
75
76         struct wrepl_packet *packet;
77
78         struct {
79                 void (*fn)(struct wrepl_request *);
80                 void *private;
81         } async;
82 };
83
84
85 /*
86   setup an association
87 */
88 struct wrepl_associate {
89         struct {
90                 uint32_t assoc_ctx;
91         } out;
92 };
93
94 /*
95   pull the partner table
96 */
97 struct wrepl_pull_table {
98         struct {
99                 uint32_t assoc_ctx;
100         } in;
101         struct {
102                 uint32_t num_partners;
103                 struct wrepl_wins_owner *partners;
104         } out;
105 };
106
107 /*
108   a full pull replication
109 */
110 struct wrepl_pull_names {
111         struct {
112                 uint32_t assoc_ctx;
113                 struct wrepl_wins_owner partner;
114         } in;
115         struct {
116                 uint32_t num_names;
117                 struct wrepl_name {
118                         struct nbt_name name;
119                         uint32_t flags;
120                         uint32_t group_flag;
121                         uint64_t version_id;
122                         const char *owner;
123                         uint32_t num_addresses;
124                         struct wrepl_address {
125                                 const char *owner;
126                                 const char *address;
127                         } *addresses;
128                 } *names;
129         } out;
130 };