5 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #include <connman/plugin.h>
29 #include <connman/driver.h>
30 #include <connman/log.h>
32 static int resolvconf_probe(struct connman_element *element)
34 const char *nameserver = NULL;
35 struct connman_element *internet;
39 DBG("element %p name %s", element, element->name);
41 connman_element_get_value(element,
42 CONNMAN_PROPERTY_TYPE_IPV4_NAMESERVER, &nameserver);
44 if (nameserver == NULL)
47 cmd = g_strdup_printf("echo \"nameserver %s\" | resolvconf -a %s",
48 nameserver, element->netdev.name);
56 internet = connman_element_create();
58 internet->type = CONNMAN_ELEMENT_TYPE_INTERNET;
60 connman_element_set_data(element, internet);
62 connman_element_register(internet, element);
67 static void resolvconf_remove(struct connman_element *element)
69 struct connman_element *internet = connman_element_get_data(element);
73 DBG("element %p name %s", element, element->name);
75 DBG("element %p name %s", element, element->name);
77 connman_element_set_data(element, NULL);
79 connman_element_unregister(internet);
81 connman_element_unref(internet);
83 cmd = g_strdup_printf("resolvconf -d %s", element->netdev.name);
92 static struct connman_driver resolvconf_driver = {
94 .type = CONNMAN_ELEMENT_TYPE_RESOLVER,
95 .probe = resolvconf_probe,
96 .remove = resolvconf_remove,
99 static int resolvconf_init(void)
101 return connman_driver_register(&resolvconf_driver);
104 static void resolvconf_exit(void)
106 connman_driver_unregister(&resolvconf_driver);
109 CONNMAN_PLUGIN_DEFINE("resolvconf", "Name resolver plugin", VERSION,
110 resolvconf_init, resolvconf_exit)