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