2 This file is part of GNUnet.
3 Copyright (C) 2001-2013 GNUnet e.V.
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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
22 * @author Christian Grothoff
25 * Functions related to doing DNS lookups
27 * @defgroup resolver Resolver service
28 * Asynchronous standard DNS lookups
32 #ifndef GNUNET_RESOLVER_SERVICE_H
33 #define GNUNET_RESOLVER_SERVICE_H
38 #if 0 /* keep Emacsens' auto-indent happy */
43 #include "gnunet_configuration_lib.h"
44 #include "gnunet_scheduler_lib.h"
45 #include "gnunet_time_lib.h"
49 * Function called by the resolver for each address obtained from DNS.
52 * @param addr one of the addresses of the host, NULL for the last address
53 * @param addrlen length of @a addr
56 (*GNUNET_RESOLVER_AddressCallback) (void *cls,
57 const struct sockaddr *addr,
62 * Handle to a request given to the resolver. Can be used to cancel
63 * the request prior to the timeout or successful execution.
65 struct GNUNET_RESOLVER_RequestHandle;
68 * Create the connection to the resolver service.
70 * @param cfg configuration to use
73 GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
77 * Destroy the connection to the resolver service.
80 GNUNET_RESOLVER_disconnect (void);
84 * Convert a string to one or more IP addresses.
86 * @param hostname the hostname to resolve
87 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
88 * @param callback function to call with addresses
89 * @param callback_cls closure for @a callback
90 * @param timeout how long to try resolving
91 * @return handle that can be used to cancel the request, NULL on error
93 struct GNUNET_RESOLVER_RequestHandle *
94 GNUNET_RESOLVER_ip_get (const char *hostname,
96 struct GNUNET_TIME_Relative timeout,
97 GNUNET_RESOLVER_AddressCallback callback,
102 * Resolve our hostname to an IP address.
104 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
105 * @param callback function to call with addresses
106 * @param cls closure for @a callback
107 * @param timeout how long to try resolving
108 * @return handle that can be used to cancel the request, NULL on error
110 struct GNUNET_RESOLVER_RequestHandle *
111 GNUNET_RESOLVER_hostname_resolve (int af,
112 struct GNUNET_TIME_Relative timeout,
113 GNUNET_RESOLVER_AddressCallback callback,
118 * Function called by the resolver for each hostname obtained from DNS.
121 * @param hostname one of the names for the host, NULL
122 * on the last call to the callback
125 (*GNUNET_RESOLVER_HostnameCallback) (void *cls,
126 const char *hostname);
129 * Get local fully qualified domain name
131 * @return local hostname, caller must free
134 GNUNET_RESOLVER_local_fqdn_get (void);
138 * Perform a reverse DNS lookup.
140 * @param sa host address
141 * @param salen length of @a sa
142 * @param do_resolve use #GNUNET_NO to return numeric hostname
143 * @param timeout how long to try resolving
144 * @param callback function to call with hostnames
145 * @param cls closure for @a callback
146 * @return handle that can be used to cancel the request, NULL on error
148 struct GNUNET_RESOLVER_RequestHandle *
149 GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
152 struct GNUNET_TIME_Relative timeout,
153 GNUNET_RESOLVER_HostnameCallback callback,
158 * Cancel a request that is still pending with the resolver.
159 * Note that a client MUST NOT cancel a request that has
160 * been completed (i.e, the callback has been called to
161 * signal timeout or the final result).
163 * @param rh handle of request to cancel
166 GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh);
169 #if 0 /* keep Emacsens' auto-indent happy */
176 /* ifndef GNUNET_RESOLVER_SERVICE_H */
179 /** @} */ /* end of group resolver */
181 /* end of gnunet_resolver_service.h */