summaryrefslogtreecommitdiff
path: root/plugins/resolvfile.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-12-13 19:50:01 +0100
committerMarcel Holtmann <marcel@holtmann.org>2008-12-13 19:50:01 +0100
commit212ac19139a303448076d3699428c375c5439e19 (patch)
treeb5ae813acacbcd2367382e5c82bd30b614ea469e /plugins/resolvfile.c
parent4cc7b22fe12f12d2ded7aaa78c9887f53a5133fe (diff)
downloadconnman-212ac19139a303448076d3699428c375c5439e19.tar.gz
connman-212ac19139a303448076d3699428c375c5439e19.tar.bz2
connman-212ac19139a303448076d3699428c375c5439e19.zip
Convert IPv4 setting to use new resolver framework
Diffstat (limited to 'plugins/resolvfile.c')
-rw-r--r--plugins/resolvfile.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/plugins/resolvfile.c b/plugins/resolvfile.c
index deb39c94..440656af 100644
--- a/plugins/resolvfile.c
+++ b/plugins/resolvfile.c
@@ -24,29 +24,25 @@
#endif
#include <stdio.h>
+#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/stat.h>
#include <connman/plugin.h>
-#include <connman/driver.h>
+#include <connman/resolver.h>
#include <connman/log.h>
-static int resolvfile_probe(struct connman_element *element)
+#include <glib.h>
+
+static int resolvfile_append(const char *interface, const char *domain,
+ const char *server)
{
- const char *nameserver = NULL;
- struct connman_element *internet;
- gchar *cmd;
+ char *cmd;
int fd, len, err;
- DBG("element %p name %s", element, element->name);
-
- connman_element_get_value(element,
- CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver);
-
- if (nameserver == NULL)
- return -EINVAL;
+ DBG("server %s", server);
fd = open("/etc/resolv.conf", O_RDWR | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
@@ -55,7 +51,7 @@ static int resolvfile_probe(struct connman_element *element)
err = ftruncate(fd, 0);
- cmd = g_strdup_printf("nameserver %s\n", nameserver);
+ cmd = g_strdup_printf("nameserver %s\n", server);
len = write(fd, cmd, strlen(cmd));
@@ -63,36 +59,32 @@ static int resolvfile_probe(struct connman_element *element)
close(fd);
- internet = connman_element_create(NULL);
-
- internet->type = CONNMAN_ELEMENT_TYPE_CONNECTION;
-
- connman_element_register(internet, element);
-
return 0;
}
-static void resolvfile_remove(struct connman_element *element)
+static int resolvfile_remove(const char *interface, const char *domain,
+ const char *server)
{
- DBG("element %p name %s", element, element->name);
+ DBG("server %s", server);
+
+ return 0;
}
-static struct connman_driver resolvfile_driver = {
- .name = "resolvconf",
- .type = CONNMAN_ELEMENT_TYPE_RESOLVER,
- .priority = CONNMAN_DRIVER_PRIORITY_LOW,
- .probe = resolvfile_probe,
+static struct connman_resolver resolvfile_resolver = {
+ .name = "resolvfile",
+ .priority = CONNMAN_RESOLVER_PRIORITY_LOW,
+ .append = resolvfile_append,
.remove = resolvfile_remove,
};
static int resolvfile_init(void)
{
- return connman_driver_register(&resolvfile_driver);
+ return connman_resolver_register(&resolvfile_resolver);
}
static void resolvfile_exit(void)
{
- connman_driver_unregister(&resolvfile_driver);
+ connman_resolver_unregister(&resolvfile_resolver);
}
CONNMAN_PLUGIN_DEFINE(resolvfile, "Name resolver plugin", VERSION,