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 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.
17 * @author Christian Grothoff
20 * Functions related to doing DNS lookups
22 * @defgroup resolver Resolver service
23 * Asynchronous standard DNS lookups
27 #ifndef GNUNET_RESOLVER_SERVICE_H
28 #define GNUNET_RESOLVER_SERVICE_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_configuration_lib.h"
39 #include "gnunet_scheduler_lib.h"
40 #include "gnunet_time_lib.h"
44 * Function called by the resolver for each address obtained from DNS.
47 * @param addr one of the addresses of the host, NULL for the last address
48 * @param addrlen length of @a addr
51 (*GNUNET_RESOLVER_AddressCallback) (void *cls,
52 const struct sockaddr *addr,
57 * Handle to a request given to the resolver. Can be used to cancel
58 * the request prior to the timeout or successful execution.
60 struct GNUNET_RESOLVER_RequestHandle;
63 * Create the connection to the resolver service.
65 * @param cfg configuration to use
68 GNUNET_RESOLVER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
72 * Destroy the connection to the resolver service.
75 GNUNET_RESOLVER_disconnect (void);
79 * Convert a string to one or more IP addresses.
81 * @param hostname the hostname to resolve
82 * @param af AF_INET or AF_INET6; use AF_UNSPEC for "any"
83 * @param callback function to call with addresses
84 * @param callback_cls closure for @a callback
85 * @param timeout how long to try resolving
86 * @return handle that can be used to cancel the request, NULL on error
88 struct GNUNET_RESOLVER_RequestHandle *
89 GNUNET_RESOLVER_ip_get (const char *hostname,
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
120 (*GNUNET_RESOLVER_HostnameCallback) (void *cls,
121 const char *hostname);
124 * Get local fully qualified domain name
126 * @return local hostname, caller must free
129 GNUNET_RESOLVER_local_fqdn_get (void);
133 * Perform a reverse DNS lookup.
135 * @param sa host address
136 * @param salen length of @a sa
137 * @param do_resolve use #GNUNET_NO to return numeric hostname
138 * @param timeout how long to try resolving
139 * @param callback function to call with hostnames
140 * @param cls closure for @a callback
141 * @return handle that can be used to cancel the request, NULL on error
143 struct GNUNET_RESOLVER_RequestHandle *
144 GNUNET_RESOLVER_hostname_get (const struct sockaddr *sa,
147 struct GNUNET_TIME_Relative timeout,
148 GNUNET_RESOLVER_HostnameCallback callback,
153 * Cancel a request that is still pending with the resolver.
154 * Note that a client MUST NOT cancel a request that has
155 * been completed (i.e, the callback has been called to
156 * signal timeout or the final result).
158 * @param rh handle of request to cancel
161 GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *rh);
164 #if 0 /* keep Emacsens' auto-indent happy */
171 /* ifndef GNUNET_RESOLVER_SERVICE_H */
174 /** @} */ /* end of group resolver */
176 /* end of gnunet_resolver_service.h */