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 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/>.
22 #include "libcli/netlogon.h"
25 a datagram name request
27 struct nbt_dgram_request {
28 struct nbt_dgram_request *next, *prev;
30 /* where to send the request */
31 struct socket_address *dest;
33 /* the encoded request */
38 context structure for operations on dgram packets
40 struct nbt_dgram_socket {
41 struct socket_context *sock;
42 struct event_context *event_ctx;
43 struct smb_iconv_convenience *iconv_convenience;
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 const char *mailslot_name,
74 struct socket_address *src);
76 struct dgram_mailslot_handler {
77 struct dgram_mailslot_handler *next, *prev;
79 struct nbt_dgram_socket *dgmsock;
80 const char *mailslot_name;
82 dgram_mailslot_handler_t handler;
88 NTSTATUS nbt_dgram_send(struct nbt_dgram_socket *dgmsock,
89 struct nbt_dgram_packet *packet,
90 struct socket_address *dest);
91 NTSTATUS dgram_set_incoming_handler(struct nbt_dgram_socket *dgmsock,
92 void (*handler)(struct nbt_dgram_socket *,
93 struct nbt_dgram_packet *,
94 struct socket_address *),
96 struct nbt_dgram_socket *nbt_dgram_socket_init(TALLOC_CTX *mem_ctx,
97 struct event_context *event_ctx,
98 struct smb_iconv_convenience *);
100 const char *dgram_mailslot_name(struct nbt_dgram_packet *packet);
101 struct dgram_mailslot_handler *dgram_mailslot_find(struct nbt_dgram_socket *dgmsock,
102 const char *mailslot_name);
103 struct dgram_mailslot_handler *dgram_mailslot_listen(struct nbt_dgram_socket *dgmsock,
104 const char *mailslot_name,
105 dgram_mailslot_handler_t handler,
107 struct dgram_mailslot_handler *dgram_mailslot_temp(struct nbt_dgram_socket *dgmsock,
108 const char *mailslot_name,
109 dgram_mailslot_handler_t handler,
111 DATA_BLOB dgram_mailslot_data(struct nbt_dgram_packet *dgram);
114 NTSTATUS dgram_mailslot_send(struct nbt_dgram_socket *dgmsock,
115 enum dgram_msg_type msg_type,
116 const char *mailslot_name,
117 struct nbt_name *dest_name,
118 struct socket_address *dest,
119 struct nbt_name *src_name,
122 NTSTATUS dgram_mailslot_netlogon_send(struct nbt_dgram_socket *dgmsock,
123 struct nbt_name *dest_name,
124 struct socket_address *dest,
125 const char *mailslot_name,
126 struct nbt_name *src_name,
127 struct nbt_netlogon_packet *request);
128 NTSTATUS dgram_mailslot_netlogon_reply(struct nbt_dgram_socket *dgmsock,
129 struct nbt_dgram_packet *request,
130 const char *my_netbios_name,
131 const char *mailslot_name,
132 struct nbt_netlogon_response *reply);
133 NTSTATUS dgram_mailslot_netlogon_parse_request(struct dgram_mailslot_handler *dgmslot,
135 struct nbt_dgram_packet *dgram,
136 struct nbt_netlogon_packet *netlogon);
138 NTSTATUS dgram_mailslot_netlogon_parse_response(struct dgram_mailslot_handler *dgmslot,
140 struct nbt_dgram_packet *dgram,
141 struct nbt_netlogon_response *netlogon);
143 NTSTATUS dgram_mailslot_browse_send(struct nbt_dgram_socket *dgmsock,
144 struct nbt_name *dest_name,
145 struct socket_address *dest,
146 struct nbt_name *src_name,
147 struct nbt_browse_packet *request);
149 NTSTATUS dgram_mailslot_browse_reply(struct nbt_dgram_socket *dgmsock,
150 struct nbt_dgram_packet *request,
151 const char *mailslot_name,
152 const char *my_netbios_name,
153 struct nbt_browse_packet *reply);
155 NTSTATUS dgram_mailslot_browse_parse(struct dgram_mailslot_handler *dgmslot,
157 struct nbt_dgram_packet *dgram,
158 struct nbt_browse_packet *pkt);