| 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 tevent_context *ctx;
|
|---|
| 34 | struct tevent_fd *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 | struct smb_iconv_convenience *iconv_convenience;
|
|---|
| 54 | };
|
|---|
| 55 |
|
|---|
| 56 | struct wrepl_send_ctrl {
|
|---|
| 57 | bool send_only;
|
|---|
| 58 | bool disconnect_after_send;
|
|---|
| 59 | };
|
|---|
| 60 |
|
|---|
| 61 | enum wrepl_request_state {
|
|---|
| 62 | WREPL_REQUEST_INIT = 0,
|
|---|
| 63 | WREPL_REQUEST_RECV = 1,
|
|---|
| 64 | WREPL_REQUEST_DONE = 2,
|
|---|
| 65 | WREPL_REQUEST_ERROR = 3
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | /*
|
|---|
| 69 | a WINS replication request
|
|---|
| 70 | */
|
|---|
| 71 | struct wrepl_request {
|
|---|
| 72 | struct wrepl_request *next, *prev;
|
|---|
| 73 | struct wrepl_socket *wrepl_socket;
|
|---|
| 74 |
|
|---|
| 75 | enum wrepl_request_state state;
|
|---|
| 76 | bool trigger;
|
|---|
| 77 | NTSTATUS status;
|
|---|
| 78 |
|
|---|
| 79 | struct tevent_timer *te;
|
|---|
| 80 |
|
|---|
| 81 | struct wrepl_packet *packet;
|
|---|
| 82 |
|
|---|
| 83 | struct {
|
|---|
| 84 | void (*fn)(struct wrepl_request *);
|
|---|
| 85 | void *private_data;
|
|---|
| 86 | } async;
|
|---|
| 87 | };
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 | /*
|
|---|
| 91 | setup an association
|
|---|
| 92 | */
|
|---|
| 93 | struct wrepl_associate {
|
|---|
| 94 | struct {
|
|---|
| 95 | uint32_t assoc_ctx;
|
|---|
| 96 | uint16_t major_version;
|
|---|
| 97 | } out;
|
|---|
| 98 | };
|
|---|
| 99 |
|
|---|
| 100 | /*
|
|---|
| 101 | setup an association
|
|---|
| 102 | */
|
|---|
| 103 | struct wrepl_associate_stop {
|
|---|
| 104 | struct {
|
|---|
| 105 | uint32_t assoc_ctx;
|
|---|
| 106 | uint32_t reason;
|
|---|
| 107 | } in;
|
|---|
| 108 | };
|
|---|
| 109 |
|
|---|
| 110 | /*
|
|---|
| 111 | pull the partner table
|
|---|
| 112 | */
|
|---|
| 113 | struct wrepl_pull_table {
|
|---|
| 114 | struct {
|
|---|
| 115 | uint32_t assoc_ctx;
|
|---|
| 116 | } in;
|
|---|
| 117 | struct {
|
|---|
| 118 | uint32_t num_partners;
|
|---|
| 119 | struct wrepl_wins_owner *partners;
|
|---|
| 120 | } out;
|
|---|
| 121 | };
|
|---|
| 122 |
|
|---|
| 123 | #define WREPL_NAME_TYPE(flags) (flags & WREPL_FLAGS_RECORD_TYPE)
|
|---|
| 124 | #define WREPL_NAME_STATE(flags) ((flags & WREPL_FLAGS_RECORD_STATE)>>2)
|
|---|
| 125 | #define WREPL_NAME_NODE(flags) ((flags & WREPL_FLAGS_NODE_TYPE)>>5)
|
|---|
| 126 | #define WREPL_NAME_IS_STATIC(flags) ((flags & WREPL_FLAGS_IS_STATIC)?true:false)
|
|---|
| 127 |
|
|---|
| 128 | #define WREPL_NAME_FLAGS(type, state, node, is_static) \
|
|---|
| 129 | (type | (state << 2) | (node << 5) | \
|
|---|
| 130 | (is_static ? WREPL_FLAGS_IS_STATIC : 0))
|
|---|
| 131 |
|
|---|
| 132 | /*
|
|---|
| 133 | a full pull replication
|
|---|
| 134 | */
|
|---|
| 135 | struct wrepl_pull_names {
|
|---|
| 136 | struct {
|
|---|
| 137 | uint32_t assoc_ctx;
|
|---|
| 138 | struct wrepl_wins_owner partner;
|
|---|
| 139 | } in;
|
|---|
| 140 | struct {
|
|---|
| 141 | uint32_t num_names;
|
|---|
| 142 | struct wrepl_name {
|
|---|
| 143 | struct nbt_name name;
|
|---|
| 144 | enum wrepl_name_type type;
|
|---|
| 145 | enum wrepl_name_state state;
|
|---|
| 146 | enum wrepl_name_node node;
|
|---|
| 147 | bool is_static;
|
|---|
| 148 | uint32_t raw_flags;
|
|---|
| 149 | uint64_t version_id;
|
|---|
| 150 | const char *owner;
|
|---|
| 151 | uint32_t num_addresses;
|
|---|
| 152 | struct wrepl_address {
|
|---|
| 153 | const char *owner;
|
|---|
| 154 | const char *address;
|
|---|
| 155 | } *addresses;
|
|---|
| 156 | } *names;
|
|---|
| 157 | } out;
|
|---|
| 158 | };
|
|---|
| 159 |
|
|---|
| 160 | struct resolve_context;
|
|---|
| 161 |
|
|---|
| 162 | #include "libcli/wrepl/winsrepl_proto.h"
|
|---|