From 7f30feb2513f6a1609f291e4e9c647a08434d2c2 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 1 Sep 2008 21:12:59 +0200 Subject: [PATCH] Fixup resolver plugins to use INET helpers --- plugins/resolvconf.c | 29 ++++++++++++++++++++--------- plugins/resolvfile.c | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/plugins/resolvconf.c b/plugins/resolvconf.c index 779c68f3..814bbeb7 100644 --- a/plugins/resolvconf.c +++ b/plugins/resolvconf.c @@ -30,13 +30,15 @@ #include #include +#include "inet.h" + #define RESOLVCONF "/sbin/resolvconf" static int resolvconf_probe(struct connman_element *element) { const char *nameserver = NULL; struct connman_element *internet; - gchar *cmd; + gchar *cmd, *name; int err; DBG("element %p name %s", element, element->name); @@ -45,22 +47,26 @@ static int resolvconf_probe(struct connman_element *element) return -errno; connman_element_get_value(element, - CONNMAN_PROPERTY_TYPE_IPV4_NAMESERVER, &nameserver); + CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver); if (nameserver == NULL) return -EINVAL; + name = inet_index2name(element->index); + cmd = g_strdup_printf("echo \"nameserver %s\" | %s -a %s", - nameserver, RESOLVCONF, - element->netdev.name); + nameserver, RESOLVCONF, name); + + g_free(name); DBG("%s", cmd); - err = system(cmd); + //err = system(cmd); + err = 0; g_free(cmd); - internet = connman_element_create(); + internet = connman_element_create(NULL); internet->type = CONNMAN_ELEMENT_TYPE_INTERNET; @@ -71,16 +77,21 @@ static int resolvconf_probe(struct connman_element *element) static void resolvconf_remove(struct connman_element *element) { - gchar *cmd; + gchar *cmd, *name; int err; DBG("element %p name %s", element, element->name); - cmd = g_strdup_printf("%s -d %s", RESOLVCONF, element->netdev.name); + name = inet_index2name(element->index); + + cmd = g_strdup_printf("%s -d %s", RESOLVCONF, name); + + g_free(name); DBG("%s", cmd); - err = system(cmd); + //err = system(cmd); + err = 0; g_free(cmd); } diff --git a/plugins/resolvfile.c b/plugins/resolvfile.c index 5ea3422d..0920441c 100644 --- a/plugins/resolvfile.c +++ b/plugins/resolvfile.c @@ -43,7 +43,7 @@ static int resolvfile_probe(struct connman_element *element) DBG("element %p name %s", element, element->name); connman_element_get_value(element, - CONNMAN_PROPERTY_TYPE_IPV4_NAMESERVER, &nameserver); + CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver); if (nameserver == NULL) return -EINVAL; @@ -63,7 +63,7 @@ static int resolvfile_probe(struct connman_element *element) close(fd); - internet = connman_element_create(); + internet = connman_element_create(NULL); internet->type = CONNMAN_ELEMENT_TYPE_INTERNET; -- 2.34.1