summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-04-22 21:39:09 +0100
committerMarcel Holtmann <marcel@holtmann.org>2009-04-22 21:39:09 +0100
commitea4b917988a6b7e153e4b03b2444fdb2581bef9b (patch)
tree402fac5d4cd11710504ea23388af33315aec5665
parentc9db6015a16ec048d9ed4b439947a6919af882ce (diff)
downloadconnman-ea4b917988a6b7e153e4b03b2444fdb2581bef9b.tar.gz
connman-ea4b917988a6b7e153e4b03b2444fdb2581bef9b.tar.bz2
connman-ea4b917988a6b7e153e4b03b2444fdb2581bef9b.zip
Read hostname after setting up loopback interface
-rw-r--r--plugins/loopback.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/plugins/loopback.c b/plugins/loopback.c
index 22a61fb9..04b29e1d 100644
--- a/plugins/loopback.c
+++ b/plugins/loopback.c
@@ -25,6 +25,7 @@
#include <errno.h>
#include <unistd.h>
+#include <limits.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
@@ -35,6 +36,22 @@
#include <connman/plugin.h>
#include <connman/log.h>
+static int setup_hostname(void)
+{
+ char name[HOST_NAME_MAX + 1];
+
+ memset(name, 0, sizeof(name));
+
+ if (gethostname(name, HOST_NAME_MAX) < 0) {
+ connman_error("Failed to get current hostname");
+ return -EIO;
+ }
+
+ connman_info("System hostname is %s", name);
+
+ return 0;
+}
+
static int loopback_init(void)
{
struct ifreq ifr;
@@ -98,6 +115,8 @@ static int loopback_init(void)
done:
close(sk);
+ setup_hostname();
+
return err;
}