aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_resolver_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-04-22 11:18:48 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-04-22 11:18:48 +0000
commit5a85013ee94a838a2438a3bd1dedec1b78cc68a6 (patch)
tree47f009c75f8ca6c2310971962bbb01aa72b5dcf2 /src/util/test_resolver_api.c
parent01a4013c9f1bca74ae784b3508b67be32d9b33db (diff)
downloadgnunet-5a85013ee94a838a2438a3bd1dedec1b78cc68a6.tar.gz
gnunet-5a85013ee94a838a2438a3bd1dedec1b78cc68a6.zip
Diffstat (limited to 'src/util/test_resolver_api.c')
-rw-r--r--src/util/test_resolver_api.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c
index af8ecdeec..d0831bf49 100644
--- a/src/util/test_resolver_api.c
+++ b/src/util/test_resolver_api.c
@@ -128,6 +128,44 @@ check_127(void *cls, const struct sockaddr *sa, socklen_t salen)
128} 128}
129 129
130static void 130static void
131check_local_fqdn(void *cls, const char *gnunet_fqdn)
132{
133 int result = 0;
134
135 struct hostent *host;
136 char hostname[GNUNET_OS_get_hostname_max_length() + 1];
137
138 if (0 != gethostname (hostname, sizeof (hostname) - 1))
139 {
140 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR |
141 GNUNET_ERROR_TYPE_BULK, "gethostname");
142 return NULL;
143 }
144#if DEBUG_RESOLVER
145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
146 _("Resolving our FQDN `%s'\n"), hostname);
147#endif
148 host = gethostbyname ( hostname );
149 if ( NULL == host)
150 {
151 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
152 _("Could not resolve our FQDN : %s %u\n"),
153 hstrerror (h_errno), h_errno);
154 return NULL;
155 }
156
157 GNUNET_assert( 0 != host);
158
159 result = strcmp(host->h_name, gnunet_fqdn);
160 if ( 0 != result )
161 {
162 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
163 "Local resolved and resolver resolved fqdns are not equal\n");
164 }
165 GNUNET_assert( 0 == result);
166}
167
168static void
131check_local_hostname(void *cls, const char *hostname) 169check_local_hostname(void *cls, const char *hostname)
132{ 170{
133 int result = 0; 171 int result = 0;
@@ -219,6 +257,7 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args,
219 GNUNET_TIME_UNIT_MILLISECONDS, 2500); 257 GNUNET_TIME_UNIT_MILLISECONDS, 2500);
220 int count_ips = 0; 258 int count_ips = 0;
221 char * own_hostname; 259 char * own_hostname;
260 char * own_fqdn;
222 261
223 memset(&sa, 0, sizeof(sa)); 262 memset(&sa, 0, sizeof(sa));
224 sa.sin_family = AF_INET; 263 sa.sin_family = AF_INET;
@@ -240,6 +279,13 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args,
240 GNUNET_free (own_hostname); 279 GNUNET_free (own_hostname);
241 280
242 /* 281 /*
282 * Looking up our own fqdn
283 */
284 own_fqdn = GNUNET_RESOLVER_local_fqdn_get();
285 check_local_fqdn( NULL, own_fqdn);
286 GNUNET_free_non_null (own_fqdn);
287
288 /*
243 * Testing non-local DNS resolution 289 * Testing non-local DNS resolution
244 * DNS rootserver to test: a.root-servers.net - 198.41.0.4 290 * DNS rootserver to test: a.root-servers.net - 198.41.0.4
245 */ 291 */