diff options
author | Christian Grothoff <christian@grothoff.org> | 2009-05-29 00:46:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2009-05-29 00:46:26 +0000 |
commit | 0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9 (patch) | |
tree | 6b552f40eb089db96409a312a98d9b12bd669102 /src/include/gnunet_resolver_service.h | |
download | gnunet-0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9.tar.gz gnunet-0a217a8df1657b4334b55b0e4a6c7837a8dbcfd9.zip |
ng
Diffstat (limited to 'src/include/gnunet_resolver_service.h')
-rw-r--r-- | src/include/gnunet_resolver_service.h | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/src/include/gnunet_resolver_service.h b/src/include/gnunet_resolver_service.h new file mode 100644 index 000000000..ac7aebcc7 --- /dev/null +++ b/src/include/gnunet_resolver_service.h | |||
@@ -0,0 +1,135 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Christian Grothoff (and other contributing authors) | ||
4 | |||
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. | ||
9 | |||
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. | ||
14 | |||
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. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file include/gnunet_resolver_service.h | ||
23 | * @brief functions related to doing DNS lookups | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | |||
27 | #ifndef GNUNET_RESOLVER_SERVICE_H | ||
28 | #define GNUNET_RESOLVER_SERVICE_H | ||
29 | |||
30 | #ifdef __cplusplus | ||
31 | extern "C" | ||
32 | { | ||
33 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
34 | } | ||
35 | #endif | ||
36 | #endif | ||
37 | |||
38 | #include "gnunet_configuration_lib.h" | ||
39 | #include "gnunet_scheduler_lib.h" | ||
40 | #include "gnunet_time_lib.h" | ||
41 | |||
42 | |||
43 | /** | ||
44 | * Function called by the resolver for each address obtained from DNS. | ||
45 | * | ||
46 | * @param cls closure | ||
47 | * @param addr one of the addresses of the host, NULL for the last address | ||
48 | * @param addrlen length of the address | ||
49 | */ | ||
50 | typedef void (*GNUNET_RESOLVER_AddressCallback) (void *cls, | ||
51 | const struct sockaddr * addr, | ||
52 | socklen_t addrlen); | ||
53 | |||
54 | |||
55 | /** | ||
56 | * Convert a string to one or more IP addresses. | ||
57 | * | ||
58 | * @param sched scheduler to use | ||
59 | * @param cfg configuration to use | ||
60 | * @param hostname the hostname to resolve | ||
61 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" | ||
62 | * @param callback function to call with addresses | ||
63 | * @param cls closure for callback | ||
64 | * @param timeout how long to try resolving | ||
65 | */ | ||
66 | void | ||
67 | GNUNET_RESOLVER_ip_get (struct GNUNET_SCHEDULER_Handle *sched, | ||
68 | struct GNUNET_CONFIGURATION_Handle *cfg, | ||
69 | const char *hostname, | ||
70 | int domain, | ||
71 | struct GNUNET_TIME_Relative timeout, | ||
72 | GNUNET_RESOLVER_AddressCallback callback, void *cls); | ||
73 | |||
74 | |||
75 | /** | ||
76 | * Resolve our hostname to an IP address. | ||
77 | * | ||
78 | * @param sched scheduler to use | ||
79 | * @param cfg configuration to use | ||
80 | * @param domain AF_INET or AF_INET6; use AF_UNSPEC for "any" | ||
81 | * @param callback function to call with addresses | ||
82 | * @param cls closure for callback | ||
83 | * @param timeout how long to try resolving | ||
84 | */ | ||
85 | void | ||
86 | GNUNET_RESOLVER_hostname_resolve (struct GNUNET_SCHEDULER_Handle *sched, | ||
87 | struct GNUNET_CONFIGURATION_Handle *cfg, | ||
88 | int domain, | ||
89 | struct GNUNET_TIME_Relative timeout, | ||
90 | GNUNET_RESOLVER_AddressCallback callback, | ||
91 | void *cls); | ||
92 | |||
93 | |||
94 | /** | ||
95 | * Function called by the resolver for each hostname obtained from DNS. | ||
96 | * | ||
97 | * @param cls closure | ||
98 | * @param hostname one of the names for the host, NULL | ||
99 | * on the last call to the callback | ||
100 | */ | ||
101 | typedef void (*GNUNET_RESOLVER_HostnameCallback) (void *cls, | ||
102 | const char *hostname); | ||
103 | |||
104 | |||
105 | /** | ||
106 | * Get an IP address as a string. | ||
107 | * | ||
108 | * @param sched scheduler to use | ||
109 | * @param cfg configuration to use | ||
110 | * @param sa host address | ||
111 | * @param salen length of host address | ||
112 | * @param do_resolve use GNUNET_NO to return numeric hostname | ||
113 | * @param timeout how long to try resolving | ||
114 | * @param callback function to call with hostnames | ||
115 | * @param cls closure for callback | ||
116 | */ | ||
117 | void GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | ||
118 | struct GNUNET_CONFIGURATION_Handle *cfg, | ||
119 | const struct sockaddr *sa, | ||
120 | socklen_t salen, | ||
121 | int do_resolve, | ||
122 | struct GNUNET_TIME_Relative timeout, | ||
123 | GNUNET_RESOLVER_HostnameCallback callback, | ||
124 | void *cls); | ||
125 | |||
126 | #if 0 /* keep Emacsens' auto-indent happy */ | ||
127 | { | ||
128 | #endif | ||
129 | #ifdef __cplusplus | ||
130 | } | ||
131 | #endif | ||
132 | |||
133 | /* ifndef GNUNET_RESOLVER_SERVICE_H */ | ||
134 | #endif | ||
135 | /* end of gnunet_resolver_service.h */ | ||