2 Unix SMB/CIFS implementation.
4 a raw async NBT library
6 Copyright (C) Andrew Tridgell 2005
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.
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.
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/>.
25 #include "librpc/gen_ndr/nbt.h"
28 possible states for pending requests
30 enum nbt_request_state {NBT_REQUEST_SEND,
39 struct nbt_name_request {
40 struct nbt_name_request *next, *prev;
42 enum nbt_request_state state;
46 /* the socket this was on */
47 struct nbt_name_socket *nbtsock;
49 /* where to send the request */
50 struct socket_address *dest;
52 /* timeout between retries */
55 /* how many retries to send on timeout */
58 /* whether we have received a WACK */
61 /* the timeout event */
62 struct timed_event *te;
64 /* the name transaction id */
70 /* the encoded request */
73 /* shall we allow multiple replies? */
74 bool allow_multiple_replies;
76 unsigned int num_replies;
77 struct nbt_name_reply {
78 struct nbt_name_packet *packet;
79 struct socket_address *dest;
82 /* information on what to do on completion */
84 void (*fn)(struct nbt_name_request *);
92 context structure for operations on name queries
94 struct nbt_name_socket {
95 struct socket_context *sock;
96 struct event_context *event_ctx;
97 struct smb_iconv_convenience *iconv_convenience;
99 /* a queue of requests pending to be sent */
100 struct nbt_name_request *send_queue;
103 struct fd_event *fde;
105 /* mapping from name_trn_id to pending event */
106 struct idr_context *idr;
108 /* how many requests are waiting for a reply */
109 uint16_t num_pending;
111 /* what to do with incoming request packets */
113 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
114 struct socket_address *);
118 /* what to do with unexpected replies */
120 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
121 struct socket_address *);
127 /* a simple name query */
128 struct nbt_name_query {
130 struct nbt_name name;
131 const char *dest_addr;
135 int timeout; /* in seconds */
139 const char *reply_from;
140 struct nbt_name name;
142 const char **reply_addrs;
146 /* a simple name status query */
147 struct nbt_name_status {
149 struct nbt_name name;
150 const char *dest_addr;
152 int timeout; /* in seconds */
156 const char *reply_from;
157 struct nbt_name name;
158 struct nbt_rdata_status status;
162 /* a name registration request */
163 struct nbt_name_register {
165 struct nbt_name name;
166 const char *dest_addr;
170 bool register_demand;
174 int timeout; /* in seconds */
178 const char *reply_from;
179 struct nbt_name name;
180 const char *reply_addr;
185 /* a send 3 times then demand name broadcast name registration */
186 struct nbt_name_register_bcast {
188 struct nbt_name name;
189 const char *dest_addr;
198 /* wins name register with multiple wins servers to try and multiple
199 addresses to register */
200 struct nbt_name_register_wins {
202 struct nbt_name name;
203 const char **wins_servers;
205 const char **addresses;
210 const char *wins_server;
217 /* a name refresh request */
218 struct nbt_name_refresh {
220 struct nbt_name name;
221 const char *dest_addr;
227 int timeout; /* in seconds */
231 const char *reply_from;
232 struct nbt_name name;
233 const char *reply_addr;
238 /* wins name refresh with multiple wins servers to try and multiple
239 addresses to register */
240 struct nbt_name_refresh_wins {
242 struct nbt_name name;
243 const char **wins_servers;
245 const char **addresses;
250 const char *wins_server;
256 /* a name release request */
257 struct nbt_name_release {
259 struct nbt_name name;
260 const char *dest_addr;
265 int timeout; /* in seconds */
269 const char *reply_from;
270 struct nbt_name name;
271 const char *reply_addr;
276 #include "libcli/nbt/nbt_proto.h"
278 #endif /* __LIBNBT_H__ */