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,
37 struct nbt_name_request {
38 struct nbt_name_request *next, *prev;
40 enum nbt_request_state state;
44 /* the socket this was on */
45 struct nbt_name_socket *nbtsock;
47 /* where to send the request */
48 const char *dest_addr;
51 /* timeout between retries */
54 /* how many retries to send on timeout */
57 /* whether we have received a WACK */
60 /* the timeout event */
61 struct timed_event *te;
63 /* the name transaction id */
69 /* the encoded request */
72 /* shall we allow multiple replies? */
73 BOOL allow_multiple_replies;
76 struct nbt_name_reply {
77 struct nbt_name_packet *packet;
78 const char *reply_addr;
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;
98 /* a queue of requests pending to be sent */
99 struct nbt_name_request *send_queue;
102 struct fd_event *fde;
104 /* mapping from name_trn_id to pending event */
105 struct idr_context *idr;
107 /* how many requests are waiting for a reply */
108 uint16_t num_pending;
110 /* what to do with incoming request packets */
112 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
117 /* what to do with unexpected replies */
119 void (*handler)(struct nbt_name_socket *, struct nbt_name_packet *,
126 /* a simple name query */
127 struct nbt_name_query {
129 struct nbt_name name;
130 const char *dest_addr;
133 int timeout; /* in seconds */
137 const char *reply_from;
138 struct nbt_name name;
140 const char **reply_addrs;
144 /* a simple name status query */
145 struct nbt_name_status {
147 struct nbt_name name;
148 const char *dest_addr;
149 int timeout; /* in seconds */
153 const char *reply_from;
154 struct nbt_name name;
155 struct nbt_rdata_status status;
159 /* a name registration request */
160 struct nbt_name_register {
162 struct nbt_name name;
163 const char *dest_addr;
166 BOOL register_demand;
170 int timeout; /* in seconds */
174 const char *reply_from;
175 struct nbt_name name;
176 const char *reply_addr;
181 /* a send 3 times then demand name broadcast name registration */
182 struct nbt_name_register_bcast {
184 struct nbt_name name;
185 const char *dest_addr;
193 /* wins name register with multiple wins servers to try and multiple
194 addresses to register */
195 struct nbt_name_register_wins {
197 struct nbt_name name;
198 const char **wins_servers;
199 const char **addresses;
204 const char *wins_server;
211 /* a name refresh request */
212 struct nbt_name_refresh {
214 struct nbt_name name;
215 const char *dest_addr;
220 int timeout; /* in seconds */
224 const char *reply_from;
225 struct nbt_name name;
226 const char *reply_addr;
231 /* wins name refresh with multiple wins servers to try and multiple
232 addresses to register */
233 struct nbt_name_refresh_wins {
235 struct nbt_name name;
236 const char **wins_servers;
237 const char **addresses;
242 const char *wins_server;
248 /* a name release request */
249 struct nbt_name_release {
251 struct nbt_name name;
252 const char *dest_addr;
256 int timeout; /* in seconds */
260 const char *reply_from;
261 struct nbt_name name;
262 const char *reply_addr;