2fea11bd63a69718d6ddfc085e301a98d4bd02de
[garming/samba-autobuild/.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 packet_context *packet;
32
33         struct {
34                 struct event_context *ctx;
35                 struct fd_event *fde;
36         } event;
37
38         /* a queue of replies waiting to be received */
39         struct wrepl_request *recv_queue;
40
41         /* the default timeout for requests, 0 means no timeout */
42 #define WREPL_SOCKET_REQUEST_TIMEOUT    (60)
43         uint32_t request_timeout;
44
45         /* counter for request timeouts, after 2 timeouts the socket is marked as dead */
46         uint32_t timeout_count;
47
48         /* remember is the socket is dead */
49         BOOL dead;
50
51         /* remember if we need to free the wrepl_socket at the end of wrepl_socket_dead() */
52         BOOL free_skipped;
53 };
54
55 struct wrepl_send_ctrl {
56         BOOL send_only;
57         BOOL disconnect_after_send;
58 };
59
60 enum wrepl_request_state {
61         WREPL_REQUEST_INIT  = 0,
62         WREPL_REQUEST_RECV  = 1,
63         WREPL_REQUEST_DONE  = 2,
64         WREPL_REQUEST_ERROR = 3
65 };
66
67 /*
68   a WINS replication request
69 */
70 struct wrepl_request {
71         struct wrepl_request *next, *prev;
72         struct wrepl_socket *wrepl_socket;
73
74         enum wrepl_request_state state;
75         BOOL trigger;
76         NTSTATUS status;
77
78         struct timed_event *te;
79
80         struct wrepl_packet *packet;
81
82         struct {
83                 void (*fn)(struct wrepl_request *);
84                 void *private;
85         } async;
86 };
87
88
89 /*
90   setup an association
91 */
92 struct wrepl_associate {
93         struct {
94                 uint32_t assoc_ctx;
95         } out;
96 };
97
98 /*
99   setup an association
100 */
101 struct wrepl_associate_stop {
102         struct {
103                 uint32_t assoc_ctx;
104                 uint32_t reason;
105         } in;
106 };
107
108 /*
109   pull the partner table
110 */
111 struct wrepl_pull_table {
112         struct {
113                 uint32_t assoc_ctx;
114         } in;
115         struct {
116                 uint32_t num_partners;
117                 struct wrepl_wins_owner *partners;
118         } out;
119 };
120
121 #define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
122 #define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
123 #define WREPL_NAME_NODE(flags) ((flags & WREPL_FLAGS_NODE_TYPE)>>5)
124 #define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?True:False)
125
126 #define WREPL_NAME_FLAGS(type, state, node, is_static) \
127         (type | (state << 2) | (node << 5) | \
128          (is_static ? WREPL_FLAGS_IS_STATIC : 0))
129
130 /*
131   a full pull replication
132 */
133 struct wrepl_pull_names {
134         struct {
135                 uint32_t assoc_ctx;
136                 struct wrepl_wins_owner partner;
137         } in;
138         struct {
139                 uint32_t num_names;
140                 struct wrepl_name {
141                         struct nbt_name name;
142                         enum wrepl_name_type type;
143                         enum wrepl_name_state state;
144                         enum wrepl_name_node node;
145                         BOOL is_static;
146                         uint32_t raw_flags;
147                         uint64_t version_id;
148                         const char *owner;
149                         uint32_t num_addresses;
150                         struct wrepl_address {
151                                 const char *owner;
152                                 const char *address;
153                         } *addresses;
154                 } *names;
155         } out;
156 };
157
158 #include "libcli/wrepl/winsrepl_proto.h"