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 2 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, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "librpc/gen_ndr/ndr_nbt.h"
26 possible states for pending requests
28 enum nbt_request_state {NBT_REQUEST_SEND,
34 /* where to send the request/replies */
35 struct nbt_peer_socket {
43 struct nbt_name_request {
44 struct nbt_name_request *next, *prev;
46 enum nbt_request_state state;
50 /* the socket this was on */
51 struct nbt_name_socket *nbtsock;
53 /* where to send the request */
54 struct nbt_peer_socket dest;
56 /* timeout between retries */
59 /* how many retries to send on timeout */
62 /* whether we have received a WACK */
65 /* the timeout event */
66 struct timed_event *te;
68 /* the name transaction id */
74 /* the encoded request */
77 /* shall we allow multiple replies? */
78 BOOL allow_multiple_replies;
81 struct nbt_name_reply {
82 struct nbt_name_packet *packet;
83 struct nbt_peer_socket dest;
86 /* information on what to do on completion */
88 void (*fn)(struct nbt_name_request *);
96 context structure for operations on name queries
98 struct nbt_name_socket {
99 struct socket_context *sock;
100 struct event_context *event_ctx;
102 /* a queue of requests pending to be sent */
103 struct nbt_name_request *send_queue;
106 struct fd_event *fde;
108 /* mapping from name_trn_id to pending event */
109 struct idr_context *idr;
111 /* how many requests are waiting for a reply */
112 uint16_t num_pending;
114 /* what to do with incoming request packets */
116 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
117 const struct nbt_peer_socket *);
121 /* what to do with unexpected replies */
123 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
124 const struct nbt_peer_socket *);
130 /* a simple name query */
131 struct nbt_name_query {
133 struct nbt_name name;
134 const char *dest_addr;
137 int timeout; /* in seconds */
141 const char *reply_from;
142 struct nbt_name name;
144 const char **reply_addrs;
148 /* a simple name status query */
149 struct nbt_name_status {
151 struct nbt_name name;
152 const char *dest_addr;
153 int timeout; /* in seconds */
157 const char *reply_from;
158 struct nbt_name name;
159 struct nbt_rdata_status status;
163 /* a name registration request */
164 struct nbt_name_register {
166 struct nbt_name name;
167 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;
197 /* wins name register with multiple wins servers to try and multiple
198 addresses to register */
199 struct nbt_name_register_wins {
201 struct nbt_name name;
202 const char **wins_servers;
203 const char **addresses;
208 const char *wins_server;
215 /* a name refresh request */
216 struct nbt_name_refresh {
218 struct nbt_name name;
219 const char *dest_addr;
224 int timeout; /* in seconds */
228 const char *reply_from;
229 struct nbt_name name;
230 const char *reply_addr;
235 /* wins name refresh with multiple wins servers to try and multiple
236 addresses to register */
237 struct nbt_name_refresh_wins {
239 struct nbt_name name;
240 const char **wins_servers;
241 const char **addresses;
246 const char *wins_server;
252 /* a name release request */
253 struct nbt_name_release {
255 struct nbt_name name;
256 const char *dest_addr;
260 int timeout; /* in seconds */
264 const char *reply_from;
265 struct nbt_name name;
266 const char *reply_addr;