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 it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your 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 Affero General Public License for more details.
15 You should have received a copy of the GNU Affero General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * @author Christian Grothoff
23 * Functions related to doing DNS lookups
25 * @defgroup resolver Resolver service
26 * Asynchronous standard DNS lookups
30 #ifndef GNUNET_RESOLVER_SERVICE_H
31 #define GNUNET_RESOLVER_SERVICE_H
36 #if 0 /* keep Emacsens' auto-indent happy */
41 #include "gnunet_configuration_lib.h"
42 #include "gnunet_scheduler_lib.h"
43 #include "gnunet_time_lib.h"
47 * Function called by the resolver for each address obtained from DNS.
50 * @param addr one of the addresses of the host, NULL for the last address
51 * @param addrlen length of @a addr
54 (*GNUNET_RESOLVER_AddressCallback) (void *cls,
55 const struct sockaddr *addr,
60 * Handle to a request given to the resolver. Can be used to cancel
61 * the request prior to the timeout or successful execution.
63 struct GNUNET_RESOLVER_RequestHandle;
66 * Create the connection to the resolver service.
68 * @param cfg configuration to use
71 GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
75 * Destroy the connection to the resolver service.
78 GNUNET_RESOLVER_disconnect (void);
82 * Convert a string to one or more IP addresses.
84 * @param hostname the hostname to resolve
85 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
86 * @param callback function to call with addresses
87 * @param callback_cls closure for @a callback
88 * @param timeout how long to try resolving
89 * @return handle that can be used to cancel the request, NULL on error
91 struct GNUNET_RESOLVER_RequestHandle *
92 GNUNET_RESOLVER_ip_get (const char *hostname,
94 struct GNUNET_TIME_Relative timeout,
95 GNUNET_RESOLVER_AddressCallback callback,
100 * Resolve our hostname to an IP address.
102 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
103 * @param callback function to call with addresses
104 * @param cls closure for @a callback
105 * @param timeout how long to try resolving
106 * @return handle that can be used to cancel the request, NULL on error
108 struct GNUNET_RESOLVER_RequestHandle *
109 GNUNET_RESOLVER_hostname_resolve (int af,
110 struct GNUNET_TIME_Relative timeout,
111 GNUNET_RESOLVER_AddressCallback callback,
116 * Function called by the resolver for each hostname obtained from DNS.
119 * @param hostname one of the names for the host, NULL
120 * on the last call to the callback
123 (*GNUNET_RESOLVER_HostnameCallback) (void *cls,
124 const char *hostname);
127 * Get local fully qualified domain name
129 * @return local hostname, caller must free
132 GNUNET_RESOLVER_local_fqdn_get (void);
136 * Perform a reverse DNS lookup.
138 * @param sa host address
139 * @param salen length of @a sa
140 * @param do_resolve use #GNUNET_NO to return numeric hostname
141 * @param timeout how long to try resolving
142 * @param callback function to call with hostnames
143 * @param cls closure for @a callback
144 * @return handle that can be used to cancel the request, NULL on error
146 struct GNUNET_RESOLVER_RequestHandle *
147 GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
150 struct GNUNET_TIME_Relative timeout,
151 GNUNET_RESOLVER_HostnameCallback callback,
156 * Cancel a request that is still pending with the resolver.
157 * Note that a client MUST NOT cancel a request that has
158 * been completed (i.e, the callback has been called to
159 * signal timeout or the final result).
161 * @param rh handle of request to cancel
164 GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh);
167 #if 0 /* keep Emacsens' auto-indent happy */
174 /* ifndef GNUNET_RESOLVER_SERVICE_H */
177 /** @} */ /* end of group resolver */
179 /* end of gnunet_resolver_service.h */