2 This file is part of GNUnet.
3 (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 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 2, 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
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 the address
50 typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls,
51 const struct sockaddr * addr,
56 * Handle to a request given to the resolver. Can be used to cancel
57 * the request prior to the timeout or successful execution.
59 struct GNUNET_RESOLVER_RequestHandle;
63 * Convert a string to one or more IP addresses.
65 * @param sched scheduler to use
66 * @param cfg configuration to use
67 * @param hostname the hostname to resolve
68 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
69 * @param callback function to call with addresses
70 * @param callback_cls closure for callback
71 * @param timeout how long to try resolving
72 * @return handle that can be used to cancel the request, NULL on error
74 struct GNUNET_RESOLVER_RequestHandle *
75 GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched,
76 const struct GNUNET_CONFIGURATION_Handle *cfg,
79 struct GNUNET_TIME_Relative timeout,
80 GNUNET_RESOLVER_AddressCallback callback,
85 * Resolve our hostname to an IP address.
87 * @param sched scheduler to use
88 * @param cfg configuration to use
89 * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any"
90 * @param callback function to call with addresses
91 * @param cls closure for callback
92 * @param timeout how long to try resolving
93 * @return handle that can be used to cancel the request, NULL on error
95 struct GNUNET_RESOLVER_RequestHandle *
96 GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched,
97 const struct GNUNET_CONFIGURATION_Handle *cfg,
99 struct GNUNET_TIME_Relative timeout,
100 GNUNET_RESOLVER_AddressCallback callback,
105 * Function called by the resolver for each hostname obtained from DNS.
108 * @param hostname one of the names for the host, NULL
109 * on the last call to the callback
111 typedef void (*GNUNET_RESOLVER_HostnameCallback) (void *cls,
112 const char *hostname);
116 * Perform a reverse DNS lookup.
118 * @param sched scheduler to use
119 * @param cfg configuration to use
120 * @param sa host address
121 * @param salen length of host address
122 * @param do_resolve use GNUNET_NO to return numeric hostname
123 * @param timeout how long to try resolving
124 * @param callback function to call with hostnames
125 * @param cls closure for callback
126 * @return handle that can be used to cancel the request, NULL on error
128 struct GNUNET_RESOLVER_RequestHandle *
129 GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched,
130 const struct GNUNET_CONFIGURATION_Handle *cfg,
131 const struct sockaddr *sa,
134 struct GNUNET_TIME_Relative timeout,
135 GNUNET_RESOLVER_HostnameCallback callback,
140 * Cancel a request that is still pending with the resolver.
141 * Note that a client MUST NOT cancel a request that has
142 * been completed (i.e, the callback has been called to
143 * signal timeout or the final result).
145 * @param h handle of request to cancel
148 GNUNET_RESOLVER_request_cancel (struct GNUNET_RESOLVER_RequestHandle *h);
151 #if 0 /* keep Emacsens' auto-indent happy */
158 /* ifndef GNUNET_RESOLVER_SERVICE_H */
160 /* end of gnunet_resolver_service.h */