aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_resolver_api.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2010-04-12 10:07:22 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2010-04-12 10:07:22 +0000
commitdca2e627584720657437f519f7d12a5334acc2cc (patch)
tree540dc8e9b58f1dde023c68d2cae47725e35cbb86 /src/util/test_resolver_api.c
parent7439123ffd66a592db3ce48f4c4ddcf788545af9 (diff)
downloadgnunet-dca2e627584720657437f519f7d12a5334acc2cc.tar.gz
gnunet-dca2e627584720657437f519f7d12a5334acc2cc.zip
added function GNUNET_RESOLVER_local_hostname_get to resolve local hostname
Diffstat (limited to 'src/util/test_resolver_api.c')
-rw-r--r--src/util/test_resolver_api.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c
index 3b41477bd..c577222e1 100644
--- a/src/util/test_resolver_api.c
+++ b/src/util/test_resolver_api.c
@@ -128,6 +128,38 @@ check_127(void *cls, const struct sockaddr *sa, socklen_t salen)
128} 128}
129 129
130static void 130static void
131check_local_hostname(void *cls, const char *hostname)
132{
133 int result = 0;
134
135 char own_hostname[GNUNET_OS_get_hostname_max_length() + 1];
136#if DEBUG_RESOLVER
137 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
138 "Hostname resolved here is `%s'.\n", own_hostname);
139 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
140 "Hostname resolved using resolver is `%s'.\n", hostname);
141#endif
142
143 result = gethostname (own_hostname, sizeof (own_hostname) - 1);
144
145 if ( 0 != result )
146 {
147 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
148 "Could not resolve local hostname\n", own_hostname);
149 }
150 GNUNET_assert( 0 == result);
151
152 result = strcmp(hostname, own_hostname);
153 if ( 0 != result )
154 {
155 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
156 "Local resolved and resolver resolved hostnames are not equal\n", own_hostname);
157 }
158 GNUNET_assert( 0 == result);
159}
160
161
162static void
131check_rootserver_ip(void *cls, const struct sockaddr *sa, socklen_t salen) 163check_rootserver_ip(void *cls, const struct sockaddr *sa, socklen_t salen)
132{ 164{
133 int *ok = cls; 165 int *ok = cls;
@@ -198,6 +230,13 @@ run(void *cls, struct GNUNET_SCHEDULER_Handle *sched, char * const *args,
198 sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls); 230 sizeof(struct sockaddr), GNUNET_NO, timeout, &check_localhost_num, cls);
199 GNUNET_RESOLVER_hostname_resolve(sched, cfg, AF_UNSPEC, timeout, 231 GNUNET_RESOLVER_hostname_resolve(sched, cfg, AF_UNSPEC, timeout,
200 &check_hostname, cls); 232 &check_hostname, cls);
233
234 /*
235 * Looking up our own hostname
236 */
237 GNUNET_RESOLVER_local_hostname_get(sched, cfg, &check_local_hostname, cls);
238
239
201 /* 240 /*
202 * Testing non-local DNS resolution 241 * Testing non-local DNS resolution
203 * DNS rootserver to test: a.root-servers.net - 198.41.0.4 242 * DNS rootserver to test: a.root-servers.net - 198.41.0.4