*
* Connection Manager
*
- * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2009 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
#include <config.h>
#endif
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
+
#include "connman.h"
struct entry_data {
DBG("interface %s domain %s server %s", interface, domain, server);
+ if (server == NULL)
+ return -EINVAL;
+
entry = g_try_new0(struct entry_data, 1);
if (entry == NULL)
return -ENOMEM;
return 0;
}
+
+static int resolvfile_append(const char *interface, const char *domain,
+ const char *server)
+{
+ char *cmd;
+ int fd, len, err;
+
+ DBG("interface %s server %s", interface, server);
+
+ fd = open("/etc/resolv.conf", O_RDWR | O_CREAT,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd < 0)
+ return -errno;
+
+ err = ftruncate(fd, 0);
+
+ cmd = g_strdup_printf("# Generated by Connection Manager\n"
+ "nameserver %s\n", server);
+
+ len = write(fd, cmd, strlen(cmd));
+
+ g_free(cmd);
+
+ close(fd);
+
+ return 0;
+}
+
+static int resolvfile_remove(const char *interface, const char *domain,
+ const char *server)
+{
+ DBG("interface %s server %s", interface, server);
+
+ return 0;
+}
+
+static struct connman_resolver resolvfile_resolver = {
+ .name = "resolvfile",
+ .priority = CONNMAN_RESOLVER_PRIORITY_LOW,
+ .append = resolvfile_append,
+ .remove = resolvfile_remove,
+};
+
+int __connman_resolver_init(void)
+{
+ DBG("");
+
+ return connman_resolver_register(&resolvfile_resolver);
+}
+
+void __connman_resolver_cleanup(void)
+{
+ DBG("");
+
+ connman_resolver_unregister(&resolvfile_resolver);
+}