This email list is read-only.  Emails sent to this list will be discarded
----------------------------------
 include/element.h    |    1 -
 include/resolver.h   |   13 ++++
 plugins/Makefile.am  |   12 ++--
 plugins/dnsproxy.c   |   64 ++++++++++++++++++
 plugins/ipv4.c       |   25 +++++--
 plugins/resolvconf.c |   60 ++++++-----------
 plugins/resolvfile.c |   48 ++++++--------
 plugins/wifi.c       |   76 ++++++++++++++++------
 src/Makefile.am      |    6 +-
 src/connman.h        |    4 +
 src/element.c        |    2 -
 src/main.c           |   11 +++
 src/resolver.c       |  177 +++++++++++++++++++++++++++++++++++++++++++++++++-
 src/selftest.c       |   43 ++++++++++++
 14 files changed, 435 insertions(+), 107 deletions(-)

New commits:
commit 2f74c0693e5f374778e5f5d329e742c390e84d37
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 20:04:06 2008 +0100

    Add skeleton for DNS proxy resolver plugin

commit c45047df7b35f3d4802cedf8fe21e2a2f8610935
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:56:05 2008 +0100

    Restart scanning after disconnecting

commit 67e4d9d3cc18b494eb07639eb33e29342100ca7b
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:52:10 2008 +0100

    Remove deprecated resolver element type

commit 947c603d03e65b8343fb83a06b81fd52702081e7
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:50:53 2008 +0100

    Remove linkage of unused functions

commit 212ac19139a303448076d3699428c375c5439e19
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:50:01 2008 +0100

    Convert IPv4 setting to use new resolver framework

commit 4cc7b22fe12f12d2ded7aaa78c9887f53a5133fe
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:33:05 2008 +0100

    Remove unused variable and fix another variable name

commit aad2c32df36c15ccafaadd5c0f7f71aff4c21995
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:25:04 2008 +0100

    Add improved resolver framework

commit 1854341db894fd9efc8aa5eabe32b3a101ec605c
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 19:15:04 2008 +0100

    Add small self testing framework

commit 2f09e0d729845dd47373c9c7e70b8aad566ebf14
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 16:01:18 2008 +0100

    Add support for sorting resolvers by priority

commit 16d4c499a52e8e8116015be66c86e15bb82f96be
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 15:53:37 2008 +0100

    Remove misuse of parent element parameter name

commit 06c0b8a9158bd5b0aad93dd9100ec0606ea894ac
Author: Marcel Holtmann <[email protected]>
Date:   Sat Dec 13 15:50:25 2008 +0100

    Add support for inactive and cleanup timers


Diff in this email is a maximum of 400 lines.
diff --git a/include/element.h b/include/element.h
index e56f669..466f46b 100644
--- a/include/element.h
+++ b/include/element.h
@@ -64,7 +64,6 @@ enum connman_element_type {
        CONNMAN_ELEMENT_TYPE_DHCP       = 8,
        CONNMAN_ELEMENT_TYPE_BOOTP      = 9,
        CONNMAN_ELEMENT_TYPE_ZEROCONF   = 10,
-       CONNMAN_ELEMENT_TYPE_RESOLVER   = 11,
 
        CONNMAN_ELEMENT_TYPE_CONNECTION = 42,
 };
diff --git a/include/resolver.h b/include/resolver.h
index 77a95cf..d849e08 100644
--- a/include/resolver.h
+++ b/include/resolver.h
@@ -32,13 +32,26 @@ extern "C" {
  * @short_description: Functions for registering resolver modules
  */
 
+#define CONNMAN_RESOLVER_PRIORITY_LOW      -100
+#define CONNMAN_RESOLVER_PRIORITY_DEFAULT     0
+#define CONNMAN_RESOLVER_PRIORITY_HIGH      100
+
 struct connman_resolver {
        const char *name;
+       int priority;
+       int (*append) (const char *interface, const char *domain,
+                                                       const char *server);
+       int (*remove) (const char *interface, const char *domain,
+                                                       const char *server);
 };
 
 extern int connman_resolver_register(struct connman_resolver *resolver);
 extern void connman_resolver_unregister(struct connman_resolver *resolver);
 
+extern int connman_resolver_append(const char *interface, const char *domain,
+                                                       const char *server);
+extern int connman_resolver_remove_all(const char *interface);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index b9011f9..41f20bd 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -2,8 +2,8 @@
 plugindir = $(libdir)/connman/plugins
 
 plugin_LTLIBRARIES = loopback.la ethernet.la wifi.la bluetooth.la \
-                               netdev.la dhclient.la ipv4.la \
-                               resolvconf.la resolvfile.la rtnllink.la
+                               netdev.la dhclient.la ipv4.la rtnllink.la \
+                               dnsproxy.la resolvconf.la resolvfile.la
 
 loopback_la_SOURCES = loopback.c
 
@@ -23,11 +23,13 @@ dhclient_la_CFLAGS = @GLIB_CFLAGS@ @GDBUS_CFLAGS@ 
-DDHCLIENT=\"@dhcli...@\" \
 
 ipv4_la_SOURCES = ipv4.c
 
-resolvconf_la_SOURCES = resolvconf.c inet.h inet.c
+rtnllink_la_SOURCES = rtnllink.c inet.h inet.c
 
-resolvfile_la_SOURCES = resolvfile.c
+dnsproxy_la_SOURCES = dnsproxy.c
 
-rtnllink_la_SOURCES = rtnllink.c inet.h inet.c
+resolvconf_la_SOURCES = resolvconf.c
+
+resolvfile_la_SOURCES = resolvfile.c
 
 if POLKIT
 plugin_LTLIBRARIES += polkit.la
diff --git a/plugins/dnsproxy.c b/plugins/dnsproxy.c
new file mode 100644
index 0000000..419d33d
--- /dev/null
+++ b/plugins/dnsproxy.c
@@ -0,0 +1,64 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2007-2008  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
+ *  published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <connman/plugin.h>
+#include <connman/resolver.h>
+#include <connman/log.h>
+
+static int dnsproxy_append(const char *interface, const char *domain,
+                                                       const char *server)
+{
+       DBG("server %s", server);
+
+       return -1;
+}
+
+static int dnsproxy_remove(const char *interface, const char *domain,
+                                                       const char *server)
+{
+       DBG("server %s", server);
+
+       return 0;
+}
+
+static struct connman_resolver dnsproxy_resolver = {
+       .name           = "dnsproxy",
+       .priority       = CONNMAN_RESOLVER_PRIORITY_HIGH,
+       .append         = dnsproxy_append,
+       .remove         = dnsproxy_remove,
+};
+
+static int dnsproxy_init(void)
+{
+       return connman_resolver_register(&dnsproxy_resolver);
+}
+
+static void dnsproxy_exit(void)
+{
+       connman_resolver_unregister(&dnsproxy_resolver);
+}
+
+CONNMAN_PLUGIN_DEFINE(dnsproxy, "DNS proxy resolver plugin", VERSION,
+                                       dnsproxy_init, dnsproxy_exit)
diff --git a/plugins/ipv4.c b/plugins/ipv4.c
index 173c691..ddff153 100644
--- a/plugins/ipv4.c
+++ b/plugins/ipv4.c
@@ -37,8 +37,11 @@
 
 #include <connman/plugin.h>
 #include <connman/driver.h>
+#include <connman/resolver.h>
 #include <connman/log.h>
 
+#include "inet.h"
+
 enum connman_ipv4_method {
        CONNMAN_IPV4_METHOD_UNKNOWN = 0,
        CONNMAN_IPV4_METHOD_OFF     = 1,
@@ -57,7 +60,7 @@ struct connman_ipv4 {
 };
 
 static int set_ipv4(struct connman_element *element,
-                                               struct connman_ipv4 *ipv4)
+                       struct connman_ipv4 *ipv4, const char *nameserver)
 {
        struct ifreq ifr;
        struct rtentry rt;
@@ -131,6 +134,8 @@ static int set_ipv4(struct connman_element *element,
                return -1;
        }
 
+       connman_resolver_append(ifr.ifr_name, NULL, nameserver);
+
        return 0;
 }
 
@@ -156,6 +161,8 @@ static int clear_ipv4(struct connman_element *element)
 
        DBG("ifname %s", ifr.ifr_name);
 
+       connman_resolver_remove_all(ifr.ifr_name);
+
        addr = (struct sockaddr_in *) &ifr.ifr_addr;
        addr->sin_family = AF_INET;
        addr->sin_addr.s_addr = INADDR_ANY;
@@ -175,9 +182,10 @@ static int clear_ipv4(struct connman_element *element)
 
 static int ipv4_probe(struct connman_element *element)
 {
-       struct connman_element *resolver;
+       struct connman_element *connection;
        struct connman_ipv4 ipv4;
        const char *address = NULL, *netmask = NULL, *gateway = NULL;
+       const char *nameserver = NULL;
 
        DBG("element %p name %s", element, element->name);
 
@@ -188,6 +196,9 @@ static int ipv4_probe(struct connman_element *element)
        connman_element_get_value(element,
                                CONNMAN_PROPERTY_ID_IPV4_GATEWAY, &gateway);
 
+       connman_element_get_value(element,
+                       CONNMAN_PROPERTY_ID_IPV4_NAMESERVER, &nameserver);
+
        DBG("address %s", address);
        DBG("netmask %s", netmask);
        DBG("gateway %s", gateway);
@@ -200,14 +211,14 @@ static int ipv4_probe(struct connman_element *element)
        ipv4.netmask.s_addr = inet_addr(netmask);
        ipv4.gateway.s_addr = inet_addr(gateway);
 
-       set_ipv4(element, &ipv4);
+       set_ipv4(element, &ipv4, nameserver);
 
-       resolver = connman_element_create(NULL);
+       connection = connman_element_create(NULL);
 
-       resolver->type = CONNMAN_ELEMENT_TYPE_RESOLVER;
-       resolver->index = element->index;
+       connection->type = CONNMAN_ELEMENT_TYPE_CONNECTION;
+       connection->index = element->index;
 
-       connman_element_register(resolver, element);
+       connman_element_register(connection, element);
 
        return 0;
 }
diff --git a/plugins/resolvconf.c b/plugins/resolvconf.c
index e1d5337..41f649c 100644
--- a/plugins/resolvconf.c
+++ b/plugins/resolvconf.c
@@ -23,41 +23,31 @@
 #include <config.h>
 #endif
 
+#include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
 
 #include <connman/plugin.h>
-#include <connman/driver.h>
+#include <connman/resolver.h>
 #include <connman/log.h>
 
-#include "inet.h"
+#include <glib.h>
 
 #define RESOLVCONF "/sbin/resolvconf"
 
-static int resolvconf_probe(struct connman_element *element)
+static int resolvconf_append(const char *interface, const char *domain,
+                                                       const char *server)
 {
-       const char *nameserver = NULL;
-       struct connman_element *internet;
-       gchar *cmd, *name;
+       char *cmd;
        int err;
 
-       DBG("element %p name %s", element, element->name);
+       DBG("interface %s server %s", interface, server);
 
        if (access(RESOLVCONF, X_OK) < 0)
                return -errno;
 
-       connman_element_get_value(element,
-                       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, name);
-
-       g_free(name);
+                                               server, RESOLVCONF, interface);
 
        DBG("%s", cmd);
 
@@ -66,27 +56,18 @@ static int resolvconf_probe(struct connman_element *element)
 
        g_free(cmd);
 
-       internet = connman_element_create(NULL);
-
-       internet->type = CONNMAN_ELEMENT_TYPE_CONNECTION;
-
-       connman_element_register(internet, element);
-
-       return 0;
+       return err;
 }
 
-static void resolvconf_remove(struct connman_element *element)
+static int resolvconf_remove(const char *interface, const char *domain,
+                                                       const char *server)
 {
-       gchar *cmd, *name;
+       char *cmd;
        int err;
 
-       DBG("element %p name %s", element, element->name);
-
-       name = inet_index2name(element->index);
+       DBG("interface %s server %s", interface, server);
 
-       cmd = g_strdup_printf("%s -d %s", RESOLVCONF, name);
-
-       g_free(name);
+       cmd = g_strdup_printf("%s -d %s", RESOLVCONF, interface);
 
        DBG("%s", cmd);
 
@@ -94,24 +75,25 @@ static void resolvconf_remove(struct connman_element 
*element)
        err = 0;
 
        g_free(cmd);
+
+       return err;
 }
 
-static struct connman_driver resolvconf_driver = {
+static struct connman_resolver resolvconf_resolver = {
        .name           = "resolvconf",
-       .type           = CONNMAN_ELEMENT_TYPE_RESOLVER,
-       .priority       = CONNMAN_DRIVER_PRIORITY_HIGH,
-       .probe          = resolvconf_probe,
+       .priority       = CONNMAN_RESOLVER_PRIORITY_DEFAULT,
+       .append         = resolvconf_append,
        .remove         = resolvconf_remove,
 };
 
 static int resolvconf_init(void)
 {
-       return connman_driver_register(&resolvconf_driver);
+       return connman_resolver_register(&resolvconf_resolver);
 }
 
 static void resolvconf_exit(void)
 {
-       connman_driver_unregister(&resolvconf_driver);
+       connman_resolver_unregister(&resolvconf_resolver);
 }
 
 CONNMAN_PLUGIN_DEFINE(resolvconf, "Name resolver plugin", VERSION,
diff --git a/plugins/resolvfile.c b/plugins/resolvfile.c
index deb39c9..440656a 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));
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits

Reply via email to