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.
26 #include "librpc/gen_ndr/nbt.h"
29 possible states for pending requests
31 enum nbt_request_state {NBT_REQUEST_SEND,
40 struct nbt_name_request {
41 struct nbt_name_request *next, *prev;
43 enum nbt_request_state state;
47 /* the socket this was on */
48 struct nbt_name_socket *nbtsock;
50 /* where to send the request */
51 struct socket_address *dest;
53 /* timeout between retries */
56 /* how many retries to send on timeout */
59 /* whether we have received a WACK */
62 /* the timeout event */
63 struct timed_event *te;
65 /* the name transaction id */
71 /* the encoded request */
74 /* shall we allow multiple replies? */
75 BOOL allow_multiple_replies;
77 unsigned int num_replies;
78 struct nbt_name_reply {
79 struct nbt_name_packet *packet;
80 struct socket_address *dest;
83 /* information on what to do on completion */
85 void (*fn)(struct nbt_name_request *);
93 context structure for operations on name queries
95 struct nbt_name_socket {
96 struct socket_context *sock;
97 struct event_context *event_ctx;
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;
134 int timeout; /* in seconds */
138 const char *reply_from;
139 struct nbt_name name;
141 const char **reply_addrs;
145 /* a simple name status query */
146 struct nbt_name_status {
148 struct nbt_name name;
149 const char *dest_addr;
150 int timeout; /* in seconds */
154 const char *reply_from;
155 struct nbt_name name;
156 struct nbt_rdata_status status;
160 /* a name registration request */
161 struct nbt_name_register {
163 struct nbt_name name;
164 const char *dest_addr;
167 BOOL register_demand;
171 int timeout; /* in seconds */
175 const char *reply_from;
176 struct nbt_name name;
177 const char *reply_addr;
182 /* a send 3 times then demand name broadcast name registration */
183 struct nbt_name_register_bcast {
185 struct nbt_name name;
186 const char *dest_addr;
194 /* wins name register with multiple wins servers to try and multiple
195 addresses to register */
196 struct nbt_name_register_wins {
198 struct nbt_name name;
199 const char **wins_servers;
200 const char **addresses;
205 const char *wins_server;
212 /* a name refresh request */
213 struct nbt_name_refresh {
215 struct nbt_name name;
216 const char *dest_addr;
221 int timeout; /* in seconds */
225 const char *reply_from;
226 struct nbt_name name;
227 const char *reply_addr;
232 /* wins name refresh with multiple wins servers to try and multiple
233 addresses to register */
234 struct nbt_name_refresh_wins {
236 struct nbt_name name;
237 const char **wins_servers;
238 const char **addresses;
243 const char *wins_server;
249 /* a name release request */
250 struct nbt_name_release {
252 struct nbt_name name;
253 const char *dest_addr;
257 int timeout; /* in seconds */
261 const char *reply_from;
262 struct nbt_name name;
263 const char *reply_addr;
268 #include "libcli/nbt/nbt_proto.h"
270 #endif /* __LIBNBT_H__ */