s4 dns: Add a simple async client library
[obnox/samba/samba-obnox.git] / libcli / dns / libdns.h
1 /*
2    Unix SMB/CIFS implementation.
3
4    Small async DNS library for Samba with socketwrapper support
5
6    Copyright (C) 2012 Kai Blin  <kai@samba.org>
7
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.
12
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.
17
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/>.
20 */
21
22 #ifndef __LIBDNS_H__
23 #define __LIBDNS_H__
24
25 /** Send an dns request to a dns server using UDP
26  *
27  *@param mem_ctx        talloc memory context to use
28  *@param ev             tevent context to use
29  *@param server_address address of the server as a string
30  *@param query          dns query to send
31  *@param query_len      length of the query
32  *@return tevent_req with the active request or NULL on out-of-memory
33  */
34 struct tevent_req *dns_udp_request_send(TALLOC_CTX *mem_ctx,
35                                         struct tevent_context *ev,
36                                         const char *server_address,
37                                         const uint8_t *query,
38                                         size_t query_len);
39
40 /** Get the dns response from a dns server via UDP
41  *
42  *@param req       tevent_req struct returned from dns_request_send
43  *@param mem_ctx   talloc memory context to use for the reply string
44  *@param reply     buffer that will be allocated and filled with the dns reply
45  *@param reply_len length of the reply buffer
46  *@return WERROR code depending on the async request result
47  */
48 WERROR dns_udp_request_recv(struct tevent_req *req,
49                             TALLOC_CTX *mem_ctx,
50                             uint8_t **reply,
51                             size_t *reply_len);
52
53 #endif /*__LIBDNS_H__*/