2 Unix SMB/CIFS implementation.
4 a raw async NBT DGRAM 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/nbt.h"
26 a datagram name request
28 struct nbt_dgram_request {
29 struct nbt_dgram_request *next, *prev;
31 /* where to send the request */
32 struct socket_address *dest;
34 /* the encoded request */
39 context structure for operations on dgram packets
41 struct nbt_dgram_socket {
42 struct socket_context *sock;
43 struct event_context *event_ctx;
48 /* a queue of outgoing requests */
49 struct nbt_dgram_request *send_queue;
51 /* a list of mailslot handlers */
52 struct dgram_mailslot_handler *mailslot_handlers;
54 /* what to do with incoming request packets */
56 void (*handler)(struct nbt_dgram_socket *, struct nbt_dgram_packet *,
57 struct socket_address *src);
64 the mailslot code keeps a list of mailslot handlers. A mailslot
65 handler is a function that receives incoming packets for a specific
66 mailslot name. When a caller needs to send a mailslot and wants to
67 get a reply then it needs to register itself as listening for
68 incoming packets on the reply mailslot
71 typedef void (*dgram_mailslot_handler_t)(struct dgram_mailslot_handler *,
72 struct nbt_dgram_packet *,
73 struct socket_address *src);
75 struct dgram_mailslot_handler {
76 struct dgram_mailslot_handler *next, *prev;
78 struct nbt_dgram_socket *dgmsock;
79 const char *mailslot_name;
81 dgram_mailslot_handler_t handler;
87 NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock,
88 struct nbt_dgram_packet *packet,
89 struct socket_address *dest);
90 NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock,
91 void (*handler)(struct nbt_dgram_socket *,
92 struct nbt_dgram_packet *,
93 struct socket_address *),
95 struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
96 struct event_context *event_ctx);
98 const char *dgram_mailslot_name(struct nbt_dgram_packet *packet);
99 struct dgram_mailslot_handler *dgram_mailslot_find(struct nbt_dgram_socket *dgmsock,
100 const char *mailslot_name);
101 struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dgmsock,
102 const char *mailslot_name,
103 dgram_mailslot_handler_t handler,
105 struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgmsock,
106 const char *mailslot_name,
107 dgram_mailslot_handler_t handler,
109 DATA_BLOB dgram_mailslot_data(struct nbt_dgram_packet *dgram);
112 NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
113 enum dgram_msg_type msg_type,
114 const char *mailslot_name,
115 struct nbt_name *dest_name,
116 struct socket_address *dest,
117 struct nbt_name *src_name,
120 NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
121 struct nbt_name *dest_name,
122 struct socket_address *dest,
123 struct nbt_name *src_name,
124 struct nbt_netlogon_packet *request);
125 NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
126 struct nbt_dgram_packet *request,
127 const char *mailslot_name,
128 struct nbt_netlogon_packet *reply);
129 NTSTATUS dgram_mailslot_netlogon_parse(struct dgram_mailslot_handler *dgmslot,
131 struct nbt_dgram_packet *dgram,
132 struct nbt_netlogon_packet *netlogon);
134 NTSTATUS dgram_mailslot_ntlogon_send(struct nbt_dgram_socket *dgmsock,
135 enum dgram_msg_type msg_type,
136 struct nbt_name *dest_name,
137 struct socket_address *dest,
138 struct nbt_name *src_name,
139 struct nbt_ntlogon_packet *request);
140 NTSTATUS dgram_mailslot_ntlogon_reply(struct nbt_dgram_socket *dgmsock,
141 struct nbt_dgram_packet *request,
142 const char *mailslot_name,
143 struct nbt_ntlogon_packet *reply);
144 NTSTATUS dgram_mailslot_ntlogon_parse(struct dgram_mailslot_handler *dgmslot,
146 struct nbt_dgram_packet *dgram,
147 struct nbt_ntlogon_packet *ntlogon);
149 NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
150 struct nbt_name *dest_name,
151 struct socket_address *dest,
152 struct nbt_name *src_name,
153 struct nbt_browse_packet *request);
155 NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
156 struct nbt_dgram_packet *request,
157 const char *mailslot_name,
158 struct nbt_browse_packet *reply);
160 NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot,
162 struct nbt_dgram_packet *dgram,
163 struct nbt_browse_packet *pkt);