2 This file is part of GNUnet.
3 (C) 2001-2013 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_resolver_service.h
23 * @brief functions related to doing DNS lookups
24 * @author Christian Grothoff
25 * @defgroup resolver asynchronous standard DNS lookups
29 #ifndef GNUNET_RESOLVER_SERVICE_H
30 #define GNUNET_RESOLVER_SERVICE_H
35 #if 0 /* keep Emacsens' auto-indent happy */
40 #include "gnunet_configuration_lib.h"
41 #include "gnunet_scheduler_lib.h"
42 #include "gnunet_time_lib.h"
46 * Function called by the resolver for each address obtained from DNS.
49 * @param addr one of the addresses of the host, NULL for the last address
50 * @param addrlen length of @a addr
52 typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls,
53 const struct sockaddr *addr,
58 * Handle to a request given to the resolver. Can be used to cancel
59 * the request prior to the timeout or successful execution.
61 struct GNUNET_RESOLVER_RequestHandle;
64 * Create the connection to the resolver service.
66 * @param cfg configuration to use
69 GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
73 * Destroy the connection to the resolver service.
76 GNUNET_RESOLVER_disconnect (void);
80 * Convert a string to one or more IP addresses.
82 * @param hostname the hostname to resolve
83 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
84 * @param callback function to call with addresses
85 * @param callback_cls closure for @a callback
86 * @param timeout how long to try resolving
87 * @return handle that can be used to cancel the request, NULL on error
89 struct GNUNET_RESOLVER_RequestHandle *
90 GNUNET_RESOLVER_ip_get (const char *hostname, int af,
91 struct GNUNET_TIME_Relative timeout,
92 GNUNET_RESOLVER_AddressCallback callback,
97 * Resolve our hostname to an IP address.
99 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
100 * @param callback function to call with addresses
101 * @param cls closure for @a callback
102 * @param timeout how long to try resolving
103 * @return handle that can be used to cancel the request, NULL on error
105 struct GNUNET_RESOLVER_RequestHandle *
106 GNUNET_RESOLVER_hostname_resolve (int af,
107 struct GNUNET_TIME_Relative timeout,
108 GNUNET_RESOLVER_AddressCallback callback,
113 * Function called by the resolver for each hostname obtained from DNS.
116 * @param hostname one of the names for the host, NULL
117 * on the last call to the callback
119 typedef void (*GNUNET_RESOLVER_HostnameCallback) (void *cls,
120 const char *hostname);
123 * Get local fully qualified domain name
125 * @return local hostname, caller must free
128 GNUNET_RESOLVER_local_fqdn_get (void);
132 * Perform a reverse DNS lookup.
134 * @param sa host address
135 * @param salen length of @a sa
136 * @param do_resolve use #GNUNET_NO to return numeric hostname
137 * @param timeout how long to try resolving
138 * @param callback function to call with hostnames
139 * @param cls closure for @a callback
140 * @return handle that can be used to cancel the request, NULL on error
142 struct GNUNET_RESOLVER_RequestHandle *
143 GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa, socklen_t salen,
145 struct GNUNET_TIME_Relative timeout,
146 GNUNET_RESOLVER_HostnameCallback callback,
151 * Cancel a request that is still pending with the resolver.
152 * Note that a client MUST NOT cancel a request that has
153 * been completed (i.e, the callback has been called to
154 * signal timeout or the final result).
156 * @param rh handle of request to cancel
159 GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh);
162 #if 0 /* keep Emacsens' auto-indent happy */
169 /** @} */ /* end of group resolver */
171 /* ifndef GNUNET_RESOLVER_SERVICE_H */
173 /* end of gnunet_resolver_service.h */