diff options
author | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-12 10:07:22 +0000 |
---|---|---|
committer | Matthias Wachs <wachs@net.in.tum.de> | 2010-04-12 10:07:22 +0000 |
commit | dca2e627584720657437f519f7d12a5334acc2cc (patch) | |
tree | 540dc8e9b58f1dde023c68d2cae47725e35cbb86 /src/util/resolver_api.c | |
parent | 7439123ffd66a592db3ce48f4c4ddcf788545af9 (diff) | |
download | gnunet-dca2e627584720657437f519f7d12a5334acc2cc.tar.gz gnunet-dca2e627584720657437f519f7d12a5334acc2cc.zip |
added function GNUNET_RESOLVER_local_hostname_get to resolve local hostname
Diffstat (limited to 'src/util/resolver_api.c')
-rw-r--r-- | src/util/resolver_api.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index a35f680d3..96396bfcc 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c | |||
@@ -669,7 +669,39 @@ GNUNET_RESOLVER_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | |||
669 | 669 | ||
670 | 670 | ||
671 | /** | 671 | /** |
672 | * Perform a reverse DNS lookup. | 672 | * Get local hostname |
673 | * | ||
674 | * @param sched scheduler to use | ||
675 | * @param cfg configuration to use | ||
676 | * @param callback function to call with addresses | ||
677 | * @param cls closure for callback | ||
678 | * @return handle that can be used to cancel the request, NULL on error | ||
679 | */ | ||
680 | void | ||
681 | GNUNET_RESOLVER_local_hostname_get (struct GNUNET_SCHEDULER_Handle *sched, | ||
682 | const struct GNUNET_CONFIGURATION_Handle *cfg, | ||
683 | GNUNET_RESOLVER_HostnameCallback callback, | ||
684 | void *cls) | ||
685 | { | ||
686 | |||
687 | char hostname[GNUNET_OS_get_hostname_max_length() + 1]; | ||
688 | |||
689 | check_config (cfg); | ||
690 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) | ||
691 | { | ||
692 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | | ||
693 | GNUNET_ERROR_TYPE_BULK, "gethostname"); | ||
694 | return; | ||
695 | } | ||
696 | #if DEBUG_RESOLVER | ||
697 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
698 | _("Resolving our hostname `%s'\n"), hostname); | ||
699 | #endif | ||
700 | callback (cls, hostname); | ||
701 | } | ||
702 | |||
703 | /** | ||
704 | * Looking our own hostname. | ||
673 | * | 705 | * |
674 | * @param sched scheduler to use | 706 | * @param sched scheduler to use |
675 | * @param cfg configuration to use | 707 | * @param cfg configuration to use |