047e5d21c88fe48a48778236bbc17e56d288f06d
[amitay/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    Copyright (C) Stefan Metzmacher 2005-2010
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "librpc/gen_ndr/nbt.h"
24 #include "librpc/gen_ndr/winsrepl.h"
25
26 struct wrepl_request;
27
28 /*
29   main context structure for the wins replication client library
30 */
31 struct wrepl_socket {
32         struct socket_context *sock;
33         struct packet_context *packet;
34
35         struct {
36                 struct tevent_context *ctx;
37                 struct tevent_fd *fde;
38         } event;
39
40         /* a queue of replies waiting to be received */
41         struct wrepl_request *recv_queue;
42
43         /* the default timeout for requests, 0 means no timeout */
44 #define WREPL_SOCKET_REQUEST_TIMEOUT    (60)
45         uint32_t request_timeout;
46
47         /* counter for request timeouts, after 2 timeouts the socket is marked as dead */
48         uint32_t timeout_count;
49
50         /* remember is the socket is dead */
51         bool dead;
52
53         /* remember if we need to free the wrepl_socket at the end of wrepl_socket_dead() */
54         bool free_skipped;
55
56         struct smb_iconv_convenience *iconv_convenience;
57 };
58
59 struct wrepl_send_ctrl {
60         bool send_only;
61         bool disconnect_after_send;
62 };
63
64 /*
65   setup an association
66 */
67 struct wrepl_associate {
68         struct {
69                 uint32_t assoc_ctx;
70                 uint16_t major_version;
71         } out;
72 };
73
74 /*
75   setup an association
76 */
77 struct wrepl_associate_stop {
78         struct {
79                 uint32_t assoc_ctx;
80                 uint32_t reason;
81         } in;
82 };
83
84 /*
85   pull the partner table
86 */
87 struct wrepl_pull_table {
88         struct {
89                 uint32_t assoc_ctx;
90         } in;
91         struct {
92                 uint32_t num_partners;
93                 struct wrepl_wins_owner *partners;
94         } out;
95 };
96
97 #define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
98 #define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
99 #define WREPL_NAME_NODE(flags) ((flags & WREPL_FLAGS_NODE_TYPE)>>5)
100 #define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?true:false)
101
102 #define WREPL_NAME_FLAGS(type, state, node, is_static) \
103         (type | (state << 2) | (node << 5) | \
104          (is_static ? WREPL_FLAGS_IS_STATIC : 0))
105
106 struct wrepl_address {
107         const char *owner;
108         const char *address;
109 };
110
111 struct wrepl_name {
112         struct nbt_name name;
113         enum wrepl_name_type type;
114         enum wrepl_name_state state;
115         enum wrepl_name_node node;
116         bool is_static;
117         uint32_t raw_flags;
118         uint64_t version_id;
119         const char *owner;
120         uint32_t num_addresses;
121         struct wrepl_address *addresses;
122 };
123
124 /*
125   a full pull replication
126 */
127 struct wrepl_pull_names {
128         struct {
129                 uint32_t assoc_ctx;
130                 struct wrepl_wins_owner partner;
131         } in;
132         struct {
133                 uint32_t num_names;
134                 struct wrepl_name *names;
135         } out;
136 };
137
138 struct resolve_context;
139
140 #include "libcli/wrepl/winsrepl_proto.h"