diff options
author | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-09-08 12:33:09 +0000 |
commit | d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch) | |
tree | 9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/util/test_resolver_api.c | |
parent | a0fce305c565c0937d917a92712f15e9c5736260 (diff) | |
download | gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip |
uncrustify as demanded.
Diffstat (limited to 'src/util/test_resolver_api.c')
-rw-r--r-- | src/util/test_resolver_api.c | 421 |
1 files changed, 210 insertions, 211 deletions
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index f4184aa84..ea26c4ee6 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c | |||
@@ -1,19 +1,19 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | Copyright (C) 2009 GNUnet e.V. | 3 | Copyright (C) 2009 GNUnet e.V. |
4 | 4 | ||
5 | GNUnet is free software: you can redistribute it and/or modify it | 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 | 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, | 7 | by the Free Software Foundation, either version 3 of the License, |
8 | or (at your option) any later version. | 8 | or (at your option) any later version. |
9 | 9 | ||
10 | GNUnet is distributed in the hope that it will be useful, but | 10 | GNUnet is distributed in the hope that it will be useful, but |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 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/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
@@ -36,308 +36,307 @@ static int disable_rootserver_check; | |||
36 | * For more information have a look at IANA's website http://www.root-servers.org/ | 36 | * For more information have a look at IANA's website http://www.root-servers.org/ |
37 | */ | 37 | */ |
38 | #define ROOTSERVER_NAME "a.root-servers.net" | 38 | #define ROOTSERVER_NAME "a.root-servers.net" |
39 | #define ROOTSERVER_IP "198.41.0.4" | 39 | #define ROOTSERVER_IP "198.41.0.4" |
40 | 40 | ||
41 | 41 | ||
42 | static void | 42 | static void |
43 | check_hostname (void *cls, | 43 | check_hostname(void *cls, |
44 | const struct sockaddr *sa, | 44 | const struct sockaddr *sa, |
45 | socklen_t salen) | 45 | socklen_t salen) |
46 | { | 46 | { |
47 | int *ok = cls; | 47 | int *ok = cls; |
48 | 48 | ||
49 | if (0 == salen) | 49 | if (0 == salen) |
50 | { | 50 | { |
51 | (*ok) &= ~8; | 51 | (*ok) &= ~8; |
52 | return; | 52 | return; |
53 | } | 53 | } |
54 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 54 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
55 | "Got IP address `%s' for our host.\n", | 55 | "Got IP address `%s' for our host.\n", |
56 | GNUNET_a2s (sa, salen)); | 56 | GNUNET_a2s(sa, salen)); |
57 | } | 57 | } |
58 | 58 | ||
59 | 59 | ||
60 | static void | 60 | static void |
61 | check_localhost_num (void *cls, | 61 | check_localhost_num(void *cls, |
62 | const char *hostname) | 62 | const char *hostname) |
63 | { | 63 | { |
64 | int *ok = cls; | 64 | int *ok = cls; |
65 | 65 | ||
66 | if (hostname == NULL) | 66 | if (hostname == NULL) |
67 | return; | 67 | return; |
68 | if (0 == strcmp (hostname, "127.0.0.1")) | 68 | if (0 == strcmp(hostname, "127.0.0.1")) |
69 | { | 69 | { |
70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 70 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
71 | "Received correct hostname `%s'.\n", | 71 | "Received correct hostname `%s'.\n", |
72 | hostname); | 72 | hostname); |
73 | (*ok) &= ~4; | 73 | (*ok) &= ~4; |
74 | } | 74 | } |
75 | else | 75 | else |
76 | { | 76 | { |
77 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 77 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
78 | "Received invalid hostname `%s'.\n", | 78 | "Received invalid hostname `%s'.\n", |
79 | hostname); | 79 | hostname); |
80 | GNUNET_break (0); | 80 | GNUNET_break(0); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | 84 | ||
85 | static void | 85 | static void |
86 | check_localhost (void *cls, | 86 | check_localhost(void *cls, |
87 | const char *hostname) | 87 | const char *hostname) |
88 | { | 88 | { |
89 | int *ok = cls; | 89 | int *ok = cls; |
90 | 90 | ||
91 | if (NULL == hostname) | 91 | if (NULL == hostname) |
92 | return; | 92 | return; |
93 | if (0 == strcmp (hostname, "localhost")) | 93 | if (0 == strcmp(hostname, "localhost")) |
94 | { | 94 | { |
95 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 95 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
96 | "Received correct hostname `%s'.\n", | 96 | "Received correct hostname `%s'.\n", |
97 | hostname); | 97 | hostname); |
98 | (*ok) &= ~2; | 98 | (*ok) &= ~2; |
99 | } | 99 | } |
100 | else | 100 | else |
101 | { | 101 | { |
102 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 102 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
103 | "Received unexpected hostname `%s', expected `localhost' (this could be OK).\n", | 103 | "Received unexpected hostname `%s', expected `localhost' (this could be OK).\n", |
104 | hostname); | 104 | hostname); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
109 | static void | 109 | static void |
110 | check_127 (void *cls, const struct sockaddr *sa, socklen_t salen) | 110 | check_127(void *cls, const struct sockaddr *sa, socklen_t salen) |
111 | { | 111 | { |
112 | int *ok = cls; | 112 | int *ok = cls; |
113 | const struct sockaddr_in *sai = (const struct sockaddr_in *) sa; | 113 | const struct sockaddr_in *sai = (const struct sockaddr_in *)sa; |
114 | 114 | ||
115 | if (NULL == sa) | 115 | if (NULL == sa) |
116 | return; | 116 | return; |
117 | GNUNET_assert (sizeof (struct sockaddr_in) == salen); | 117 | GNUNET_assert(sizeof(struct sockaddr_in) == salen); |
118 | if (sai->sin_addr.s_addr == htonl (INADDR_LOOPBACK)) | 118 | if (sai->sin_addr.s_addr == htonl(INADDR_LOOPBACK)) |
119 | { | 119 | { |
120 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 120 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
121 | "Received correct address.\n"); | 121 | "Received correct address.\n"); |
122 | (*ok) &= ~1; | 122 | (*ok) &= ~1; |
123 | } | 123 | } |
124 | else | 124 | else |
125 | { | 125 | { |
126 | char buf[INET_ADDRSTRLEN]; | 126 | char buf[INET_ADDRSTRLEN]; |
127 | 127 | ||
128 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 128 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
129 | "Received incorrect address `%s'.\n", | 129 | "Received incorrect address `%s'.\n", |
130 | inet_ntop (AF_INET, | 130 | inet_ntop(AF_INET, |
131 | &sai->sin_addr, | 131 | &sai->sin_addr, |
132 | buf, | 132 | buf, |
133 | sizeof (buf))); | 133 | sizeof(buf))); |
134 | GNUNET_break (0); | 134 | GNUNET_break(0); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | static void | 139 | static void |
140 | check_rootserver_ip (void *cls, const struct sockaddr *sa, socklen_t salen) | 140 | check_rootserver_ip(void *cls, const struct sockaddr *sa, socklen_t salen) |
141 | { | 141 | { |
142 | int *ok = cls; | 142 | int *ok = cls; |
143 | const struct sockaddr_in *sai = (const struct sockaddr_in *) sa; | 143 | const struct sockaddr_in *sai = (const struct sockaddr_in *)sa; |
144 | 144 | ||
145 | if (NULL == sa) | 145 | if (NULL == sa) |
146 | return; | 146 | return; |
147 | GNUNET_assert (sizeof (struct sockaddr_in) == salen); | 147 | GNUNET_assert(sizeof(struct sockaddr_in) == salen); |
148 | 148 | ||
149 | if (0 == strcmp (inet_ntoa (sai->sin_addr), ROOTSERVER_IP)) | 149 | if (0 == strcmp(inet_ntoa(sai->sin_addr), ROOTSERVER_IP)) |
150 | { | 150 | { |
151 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 151 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
152 | "Received correct rootserver ip address.\n"); | 152 | "Received correct rootserver ip address.\n"); |
153 | (*ok) &= ~1; | 153 | (*ok) &= ~1; |
154 | } | 154 | } |
155 | else | 155 | else |
156 | { | 156 | { |
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 157 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
158 | "Received incorrect rootserver ip address.\n"); | 158 | "Received incorrect rootserver ip address.\n"); |
159 | GNUNET_break (0); | 159 | GNUNET_break(0); |
160 | } | 160 | } |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | static void | 164 | static void |
165 | check_rootserver_name (void *cls, | 165 | check_rootserver_name(void *cls, |
166 | const char *hostname) | 166 | const char *hostname) |
167 | { | 167 | { |
168 | int *ok = cls; | 168 | int *ok = cls; |
169 | 169 | ||
170 | if (NULL == hostname) | 170 | if (NULL == hostname) |
171 | return; | 171 | return; |
172 | 172 | ||
173 | if (0 == strcmp (hostname, ROOTSERVER_NAME)) | 173 | if (0 == strcmp(hostname, ROOTSERVER_NAME)) |
174 | { | 174 | { |
175 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 175 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
176 | "Received correct rootserver hostname `%s'.\n", | 176 | "Received correct rootserver hostname `%s'.\n", |
177 | hostname); | 177 | hostname); |
178 | (*ok) &= ~2; | 178 | (*ok) &= ~2; |
179 | } | 179 | } |
180 | else | 180 | else |
181 | { | 181 | { |
182 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 182 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
183 | "Received invalid rootserver hostname `%s', expected `%s'\n", | 183 | "Received invalid rootserver hostname `%s', expected `%s'\n", |
184 | hostname, | 184 | hostname, |
185 | ROOTSERVER_NAME); | 185 | ROOTSERVER_NAME); |
186 | GNUNET_break (disable_rootserver_check); | 186 | GNUNET_break(disable_rootserver_check); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
191 | static void | 191 | static void |
192 | run (void *cls, char *const *args, const char *cfgfile, | 192 | run(void *cls, char *const *args, const char *cfgfile, |
193 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 193 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
194 | { | 194 | { |
195 | int *ok = cls; | 195 | int *ok = cls; |
196 | struct sockaddr_in sa; | 196 | struct sockaddr_in sa; |
197 | struct GNUNET_TIME_Relative timeout = | 197 | struct GNUNET_TIME_Relative timeout = |
198 | GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30); | 198 | GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 30); |
199 | int count_ips = 0; | 199 | int count_ips = 0; |
200 | char *own_fqdn; | 200 | char *own_fqdn; |
201 | const char *rootserver_name = ROOTSERVER_NAME; | 201 | const char *rootserver_name = ROOTSERVER_NAME; |
202 | struct hostent *rootserver; | 202 | struct hostent *rootserver; |
203 | struct in_addr rootserver_addr; | 203 | struct in_addr rootserver_addr; |
204 | 204 | ||
205 | memset (&sa, 0, sizeof (sa)); | 205 | memset(&sa, 0, sizeof(sa)); |
206 | sa.sin_family = AF_INET; | 206 | sa.sin_family = AF_INET; |
207 | #if HAVE_SOCKADDR_IN_SIN_LEN | 207 | #if HAVE_SOCKADDR_IN_SIN_LEN |
208 | sa.sin_len = (u_char) sizeof (sa); | 208 | sa.sin_len = (u_char)sizeof(sa); |
209 | #endif | 209 | #endif |
210 | sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 210 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
211 | 211 | ||
212 | /* | 212 | /* |
213 | * Looking up our own fqdn | 213 | * Looking up our own fqdn |
214 | */ | 214 | */ |
215 | own_fqdn = GNUNET_RESOLVER_local_fqdn_get (); | 215 | own_fqdn = GNUNET_RESOLVER_local_fqdn_get(); |
216 | /* can't really check, only thing we can safely | 216 | /* can't really check, only thing we can safely |
217 | compare against is our own identical logic... */ | 217 | compare against is our own identical logic... */ |
218 | GNUNET_free_non_null (own_fqdn); | 218 | GNUNET_free_non_null(own_fqdn); |
219 | 219 | ||
220 | /* | 220 | /* |
221 | * Testing non-local DNS resolution | 221 | * Testing non-local DNS resolution |
222 | * DNS rootserver to test: a.root-servers.net - 198.41.0.4 | 222 | * DNS rootserver to test: a.root-servers.net - 198.41.0.4 |
223 | */ | 223 | */ |
224 | 224 | ||
225 | rootserver = gethostbyname (rootserver_name); | 225 | rootserver = gethostbyname(rootserver_name); |
226 | if (NULL == rootserver) | 226 | if (NULL == rootserver) |
227 | { | 227 | { |
228 | /* Error: resolving ip addresses does not work */ | 228 | /* Error: resolving ip addresses does not work */ |
229 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 229 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
230 | _("gethostbyname() could not lookup IP address: %s\n"), | 230 | _("gethostbyname() could not lookup IP address: %s\n"), |
231 | hstrerror (h_errno)); | 231 | hstrerror(h_errno)); |
232 | fprintf (stderr, | 232 | fprintf(stderr, |
233 | "%s", | 233 | "%s", |
234 | "System seems to be off-line, will not run all DNS tests\n"); | 234 | "System seems to be off-line, will not run all DNS tests\n"); |
235 | *ok = 0; /* mark test as passing anyway */ | 235 | *ok = 0; /* mark test as passing anyway */ |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | 238 | ||
239 | /* Counting returned IP addresses */ | 239 | /* Counting returned IP addresses */ |
240 | while (NULL != rootserver->h_addr_list[count_ips]) | 240 | while (NULL != rootserver->h_addr_list[count_ips]) |
241 | count_ips++; | 241 | count_ips++; |
242 | if (count_ips > 1) | 242 | if (count_ips > 1) |
243 | { | 243 | { |
244 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 244 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
245 | "IP received range for root name server, but a root name server has only 1 IP\n"); | 245 | "IP received range for root name server, but a root name server has only 1 IP\n"); |
246 | GNUNET_break (0); | 246 | GNUNET_break(0); |
247 | } | 247 | } |
248 | 248 | ||
249 | /* Comparing to resolved address to the address the root name server should have */ | 249 | /* Comparing to resolved address to the address the root name server should have */ |
250 | if (0 != | 250 | if (0 != |
251 | strcmp (inet_ntoa (*(struct in_addr *) rootserver->h_addr_list[0]), | 251 | strcmp(inet_ntoa(*(struct in_addr *)rootserver->h_addr_list[0]), |
252 | ROOTSERVER_IP)) | 252 | ROOTSERVER_IP)) |
253 | { | 253 | { |
254 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 254 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, |
255 | "IP received and IP for root name server differ\n"); | 255 | "IP received and IP for root name server differ\n"); |
256 | GNUNET_break (0); | 256 | GNUNET_break(0); |
257 | } | 257 | } |
258 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 258 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
259 | "System's own forward name resolution is working\n"); | 259 | "System's own forward name resolution is working\n"); |
260 | /* Resolve the same using GNUNET */ | 260 | /* Resolve the same using GNUNET */ |
261 | GNUNET_RESOLVER_ip_get (ROOTSERVER_NAME, AF_INET, timeout, | 261 | GNUNET_RESOLVER_ip_get(ROOTSERVER_NAME, AF_INET, timeout, |
262 | &check_rootserver_ip, cls); | 262 | &check_rootserver_ip, cls); |
263 | GNUNET_RESOLVER_ip_get (ROOTSERVER_NAME, AF_INET, timeout, | 263 | GNUNET_RESOLVER_ip_get(ROOTSERVER_NAME, AF_INET, timeout, |
264 | &check_rootserver_ip, cls); | 264 | &check_rootserver_ip, cls); |
265 | 265 | ||
266 | /* | 266 | /* |
267 | * Success: forward lookups work as expected | 267 | * Success: forward lookups work as expected |
268 | * Next step: reverse lookups | 268 | * Next step: reverse lookups |
269 | */ | 269 | */ |
270 | if (1 != inet_pton (AF_INET, | 270 | if (1 != inet_pton(AF_INET, |
271 | ROOTSERVER_IP, | 271 | ROOTSERVER_IP, |
272 | &rootserver_addr)) | 272 | &rootserver_addr)) |
273 | { | 273 | { |
274 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 274 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
275 | "Could not transform root name server IP address\n"); | 275 | "Could not transform root name server IP address\n"); |
276 | GNUNET_break (0); | 276 | GNUNET_break(0); |
277 | } | 277 | } |
278 | 278 | ||
279 | rootserver = | 279 | rootserver = |
280 | gethostbyaddr ((const void *) &rootserver_addr, | 280 | gethostbyaddr((const void *)&rootserver_addr, |
281 | sizeof (rootserver_addr), | 281 | sizeof(rootserver_addr), |
282 | AF_INET); | 282 | AF_INET); |
283 | if (NULL == rootserver) | 283 | if (NULL == rootserver) |
284 | { | ||
285 | /* Error: resolving IP addresses does not work */ | ||
286 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
287 | "gethostbyaddr() could not lookup hostname: %s\n", | ||
288 | hstrerror (h_errno)); | ||
289 | disable_rootserver_check = GNUNET_YES; | ||
290 | } | ||
291 | else | ||
292 | { | ||
293 | if (0 != strcmp (rootserver->h_name, | ||
294 | ROOTSERVER_NAME)) | ||
295 | { | 284 | { |
296 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 285 | /* Error: resolving IP addresses does not work */ |
297 | "Received hostname and hostname for root name server differ\n"); | 286 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
287 | "gethostbyaddr() could not lookup hostname: %s\n", | ||
288 | hstrerror(h_errno)); | ||
298 | disable_rootserver_check = GNUNET_YES; | 289 | disable_rootserver_check = GNUNET_YES; |
299 | } | 290 | } |
300 | } | 291 | else |
292 | { | ||
293 | if (0 != strcmp(rootserver->h_name, | ||
294 | ROOTSERVER_NAME)) | ||
295 | { | ||
296 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
297 | "Received hostname and hostname for root name server differ\n"); | ||
298 | disable_rootserver_check = GNUNET_YES; | ||
299 | } | ||
300 | } | ||
301 | 301 | ||
302 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 302 | GNUNET_log(GNUNET_ERROR_TYPE_INFO, |
303 | "System's own reverse name resolution is working\n"); | 303 | "System's own reverse name resolution is working\n"); |
304 | /* Resolve the same using GNUNET */ | 304 | /* Resolve the same using GNUNET */ |
305 | memset (&sa, 0, sizeof (sa)); | 305 | memset(&sa, 0, sizeof(sa)); |
306 | sa.sin_family = AF_INET; | 306 | sa.sin_family = AF_INET; |
307 | #if HAVE_SOCKADDR_IN_SIN_LEN | 307 | #if HAVE_SOCKADDR_IN_SIN_LEN |
308 | sa.sin_len = (u_char) sizeof (sa); | 308 | sa.sin_len = (u_char)sizeof(sa); |
309 | #endif | 309 | #endif |
310 | #ifndef MINGW | 310 | #ifndef MINGW |
311 | inet_aton (ROOTSERVER_IP, &sa.sin_addr); | 311 | inet_aton(ROOTSERVER_IP, &sa.sin_addr); |
312 | #else | 312 | #else |
313 | sa.sin_addr.S_un.S_addr = inet_addr (ROOTSERVER_IP); | 313 | sa.sin_addr.S_un.S_addr = inet_addr(ROOTSERVER_IP); |
314 | #endif | 314 | #endif |
315 | GNUNET_RESOLVER_hostname_get ((const struct sockaddr *) &sa, | 315 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *)&sa, |
316 | sizeof (struct sockaddr), GNUNET_YES, timeout, | 316 | sizeof(struct sockaddr), GNUNET_YES, timeout, |
317 | &check_rootserver_name, cls); | 317 | &check_rootserver_name, cls); |
318 | 318 | ||
319 | memset (&sa, 0, sizeof (sa)); | 319 | memset(&sa, 0, sizeof(sa)); |
320 | sa.sin_family = AF_INET; | 320 | sa.sin_family = AF_INET; |
321 | #if HAVE_SOCKADDR_IN_SIN_LEN | 321 | #if HAVE_SOCKADDR_IN_SIN_LEN |
322 | sa.sin_len = (u_char) sizeof (sa); | 322 | sa.sin_len = (u_char)sizeof(sa); |
323 | #endif | 323 | #endif |
324 | sa.sin_addr.s_addr = htonl (INADDR_LOOPBACK); | 324 | sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); |
325 | |||
326 | GNUNET_RESOLVER_ip_get ("localhost", AF_INET, timeout, &check_127, cls); | ||
327 | GNUNET_RESOLVER_hostname_get ((const struct sockaddr *) &sa, | ||
328 | sizeof (struct sockaddr), GNUNET_YES, timeout, | ||
329 | &check_localhost, cls); | ||
330 | 325 | ||
331 | GNUNET_RESOLVER_hostname_get ((const struct sockaddr *) &sa, | 326 | GNUNET_RESOLVER_ip_get("localhost", AF_INET, timeout, &check_127, cls); |
332 | sizeof (struct sockaddr), GNUNET_NO, timeout, | 327 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *)&sa, |
333 | &check_localhost_num, cls); | 328 | sizeof(struct sockaddr), GNUNET_YES, timeout, |
334 | GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, timeout, &check_hostname, cls); | 329 | &check_localhost, cls); |
335 | 330 | ||
331 | GNUNET_RESOLVER_hostname_get((const struct sockaddr *)&sa, | ||
332 | sizeof(struct sockaddr), GNUNET_NO, timeout, | ||
333 | &check_localhost_num, cls); | ||
334 | GNUNET_RESOLVER_hostname_resolve(AF_UNSPEC, timeout, &check_hostname, cls); | ||
336 | } | 335 | } |
337 | 336 | ||
338 | 337 | ||
339 | int | 338 | int |
340 | main (int argc, char *argv[]) | 339 | main(int argc, char *argv[]) |
341 | { | 340 | { |
342 | int ok = 1 + 2 + 4 + 8; | 341 | int ok = 1 + 2 + 4 + 8; |
343 | char *fn; | 342 | char *fn; |
@@ -346,34 +345,34 @@ main (int argc, char *argv[]) | |||
346 | "test-resolver-api", "-c", "test_resolver_api_data.conf", NULL | 345 | "test-resolver-api", "-c", "test_resolver_api_data.conf", NULL |
347 | }; | 346 | }; |
348 | struct GNUNET_GETOPT_CommandLineOption options[] = | 347 | struct GNUNET_GETOPT_CommandLineOption options[] = |
349 | { GNUNET_GETOPT_OPTION_END }; | 348 | { GNUNET_GETOPT_OPTION_END }; |
350 | 349 | ||
351 | GNUNET_log_setup ("test-resolver-api", | 350 | GNUNET_log_setup("test-resolver-api", |
352 | "WARNING", | 351 | "WARNING", |
353 | NULL); | 352 | NULL); |
354 | fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); | 353 | fn = GNUNET_OS_get_libexec_binary_path("gnunet-service-resolver"); |
355 | proc = GNUNET_OS_start_process (GNUNET_YES, | 354 | proc = GNUNET_OS_start_process(GNUNET_YES, |
356 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 355 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
357 | NULL, NULL, NULL, | 356 | NULL, NULL, NULL, |
358 | fn, | 357 | fn, |
359 | "gnunet-service-resolver", | 358 | "gnunet-service-resolver", |
360 | "-c", "test_resolver_api_data.conf", NULL); | 359 | "-c", "test_resolver_api_data.conf", NULL); |
361 | GNUNET_assert (NULL != proc); | 360 | GNUNET_assert(NULL != proc); |
362 | GNUNET_free (fn); | 361 | GNUNET_free(fn); |
363 | GNUNET_assert (GNUNET_OK == | 362 | GNUNET_assert(GNUNET_OK == |
364 | GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1, | 363 | GNUNET_PROGRAM_run((sizeof(argvx) / sizeof(char *)) - 1, |
365 | argvx, "test-resolver-api", "nohelp", | 364 | argvx, "test-resolver-api", "nohelp", |
366 | options, &run, &ok)); | 365 | options, &run, &ok)); |
367 | if (0 != GNUNET_OS_process_kill (proc, GNUNET_TERM_SIG)) | 366 | if (0 != GNUNET_OS_process_kill(proc, GNUNET_TERM_SIG)) |
368 | { | 367 | { |
369 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); | 368 | GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill"); |
370 | ok = 1; | 369 | ok = 1; |
371 | } | 370 | } |
372 | GNUNET_OS_process_wait (proc); | 371 | GNUNET_OS_process_wait(proc); |
373 | GNUNET_OS_process_destroy (proc); | 372 | GNUNET_OS_process_destroy(proc); |
374 | proc = NULL; | 373 | proc = NULL; |
375 | if (0 != ok) | 374 | if (0 != ok) |
376 | fprintf (stderr, "Missed some resolutions: %u\n", ok); | 375 | fprintf(stderr, "Missed some resolutions: %u\n", ok); |
377 | return ok; | 376 | return ok; |
378 | } | 377 | } |
379 | 378 | ||