This email list is read-only. Emails sent to this list will be discarded
----------------------------------
configure.ac | 2 +-
include/Makefile.am | 4 +-
plugins/Makefile.am | 4 ++-
plugins/hal.c | 2 +-
plugins/resolvconf.c | 13 +++++++--
plugins/resolvfile.c | 22 ++++++++++++----
plugins/rtnllink.c | 40 ++++++++++++++++++++++++++++++
plugins/wifi.c | 2 +-
src/Makefile.am | 2 +-
src/main.c | 4 +++
src/rtnl.c | 66 +++----------------------------------------------
11 files changed, 83 insertions(+), 78 deletions(-)
New commits:
commit bcb649ac5e1814b1ef4516229c0be8695adf9055
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Aug 9 05:41:14 2008 +0200
Plugin names should be all lower-case
commit 8de5c2bce2ab02078646be19b2f7402760d76394
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Aug 9 05:40:22 2008 +0200
Add skeleton for RTNL link detection plugin
commit a89cdde4c815684b9a39ffac745f093a31df4dea
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Aug 9 05:26:46 2008 +0200
Don't optimize when debug is enabled
commit 4658b59abd4e0fc58821a67e6847667c1bab33ca
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Aug 9 04:59:25 2008 +0200
Write /etc/resolv.conf file directly
commit 6232321cbe36b7ddaa3f6946a8c562a32d25845e
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Aug 9 04:39:52 2008 +0200
Check if resolvconf is actually installed
commit 51818dc258152d9578c78219eb6fe32e5e94c84e
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Sat Aug 9 04:30:21 2008 +0200
Add basics for a global RTNL engine
Diff in this email is a maximum of 400 lines.
diff --git a/configure.ac b/configure.ac
index 64196c9..6508cd4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,7 +28,7 @@ AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug],
[enable compiling with debugging information]), [
if (test "${enableval}" = "yes" &&
test "${ac_cv_prog_cc_g}" = "yes"); then
- CFLAGS="$CFLAGS -g"
+ CFLAGS="$CFLAGS -g -O0"
fi
])
diff --git a/include/Makefile.am b/include/Makefile.am
index 70c39d2..1844d98 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,9 +1,9 @@
includedir = @includedir@/connman
-include_HEADERS = log.h plugin.h driver.h element.h property.h dbus.h
+include_HEADERS = log.h plugin.h driver.h element.h property.h rtnl.h dbus.h
-noinst_HEADERS = iface.h rtnl.h dhcp.h resolver.h
+noinst_HEADERS = iface.h dhcp.h resolver.h
MAINTAINERCLEANFILES = Makefile.in
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index ea85755..780dc1a 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,13 +1,15 @@
plugindir = $(libdir)/connman/plugins
-plugin_LTLIBRARIES = hal.la ethernet.la wifi.la bluetooth.la \
+plugin_LTLIBRARIES = hal.la rtnllink.la ethernet.la wifi.la bluetooth.la \
dhclient.la ipv4.la resolvconf.la resolvfile.la
hal_la_SOURCES = hal.c
hal_la_LIBADD = @HAL_LIBS@
hal_la_CFLAGS = @GLIB_CFLAGS@ @HAL_CFLAGS@
+rtnllink_la_SOURCES = rtnllink.c
+
ethernet_la_SOURCES = ethernet.c
wifi_la_SOURCES = wifi.c supplicant.h supplicant.c
diff --git a/plugins/hal.c b/plugins/hal.c
index 3b990c3..2afe856 100644
--- a/plugins/hal.c
+++ b/plugins/hal.c
@@ -290,5 +290,5 @@ static void hal_exit(void)
dbus_connection_unref(conn);
}
-CONNMAN_PLUGIN_DEFINE("HAL", "Hardware detection plugin", VERSION,
+CONNMAN_PLUGIN_DEFINE("hal", "Hardware detection plugin", VERSION,
hal_init, hal_exit)
diff --git a/plugins/resolvconf.c b/plugins/resolvconf.c
index 1d4927b..b065060 100644
--- a/plugins/resolvconf.c
+++ b/plugins/resolvconf.c
@@ -23,12 +23,15 @@
#include <config.h>
#endif
+#include <unistd.h>
#include <stdlib.h>
#include <connman/plugin.h>
#include <connman/driver.h>
#include <connman/log.h>
+#define RESOLVCONF "/sbin/resolvconf"
+
static int resolvconf_probe(struct connman_element *element)
{
const char *nameserver = NULL;
@@ -38,14 +41,18 @@ static int resolvconf_probe(struct connman_element *element)
DBG("element %p name %s", element, element->name);
+ if (access(RESOLVCONF, X_OK) < 0)
+ return -errno;
+
connman_element_get_value(element,
CONNMAN_PROPERTY_TYPE_IPV4_NAMESERVER, &nameserver);
if (nameserver == NULL)
return -EINVAL;
- cmd = g_strdup_printf("echo \"nameserver %s\" | resolvconf -a %s",
- nameserver, element->netdev.name);
+ cmd = g_strdup_printf("echo \"nameserver %s\" | %s -a %s",
+ RESOLVCONF, nameserver,
+ element->netdev.name);
DBG("%s", cmd);
@@ -78,7 +85,7 @@ static void resolvconf_remove(struct connman_element *element)
connman_element_unref(internet);
- cmd = g_strdup_printf("resolvconf -d %s", element->netdev.name);
+ cmd = g_strdup_printf("%s -d %s", RESOLVCONF, element->netdev.name);
DBG("%s", cmd);
diff --git a/plugins/resolvfile.c b/plugins/resolvfile.c
index d39b2e1..bf48081 100644
--- a/plugins/resolvfile.c
+++ b/plugins/resolvfile.c
@@ -23,7 +23,11 @@
#include <config.h>
#endif
-#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
#include <connman/plugin.h>
#include <connman/driver.h>
@@ -34,7 +38,7 @@ static int resolvfile_probe(struct connman_element *element)
const char *nameserver = NULL;
struct connman_element *internet;
gchar *cmd;
- int err;
+ int fd, len, err;
DBG("element %p name %s", element, element->name);
@@ -44,15 +48,21 @@ static int resolvfile_probe(struct connman_element *element)
if (nameserver == NULL)
return -EINVAL;
- cmd = g_strdup_printf("echo \"nameserver %s\" > /etc/resolv.conf",
- nameserver);
+ fd = open("/etc/resolv.conf", O_RDWR | O_CREAT,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd < 0)
+ return errno;
- DBG("%s", cmd);
+ err = ftruncate(fd, 0);
- err = system(cmd);
+ cmd = g_strdup_printf("nameserver %s\n", nameserver);
+
+ len = write(fd, cmd, strlen(cmd));
g_free(cmd);
+ close(fd);
+
internet = connman_element_create();
internet->type = CONNMAN_ELEMENT_TYPE_INTERNET;
diff --git a/plugins/rtnllink.c b/plugins/rtnllink.c
new file mode 100644
index 0000000..07f969e
--- /dev/null
+++ b/plugins/rtnllink.c
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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/element.h>
+#include <connman/log.h>
+
+static int rtnllink_init(void)
+{
+ return 0;
+}
+
+static void rtnllink_exit(void)
+{
+}
+
+CONNMAN_PLUGIN_DEFINE("rtnllink", "RTNL link detection plugin", VERSION,
+ rtnllink_init, rtnllink_exit)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index b4a3b8f..640b708 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -313,5 +313,5 @@ static void wifi_exit(void)
connman_driver_unregister(&wifi_driver);
}
-CONNMAN_PLUGIN_DEFINE("WiFi", "WiFi interface plugin", VERSION,
+CONNMAN_PLUGIN_DEFINE("wifi", "WiFi interface plugin", VERSION,
wifi_init, wifi_exit)
diff --git a/src/Makefile.am b/src/Makefile.am
index e4ad954..f959379 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@ DISTCLEANFILES = $(service_DATA)
sbin_PROGRAMS = connmand
connmand_SOURCES = main.c connman.h log.c plugin.c profile.c element.c \
- storage.c manager.c agent.c
+ storage.c manager.c agent.c rtnl.c
connmand_LDADD = @SQLITE_LIBS@ @GDBUS_LIBS@ @GMODULE_LIBS@ @GTHREAD_LIBS@
diff --git a/src/main.c b/src/main.c
index 5f8b487..77dff01 100644
--- a/src/main.c
+++ b/src/main.c
@@ -146,6 +146,8 @@ int main(int argc, char *argv[])
__connman_profile_init(conn);
+ __connman_rtnl_init();
+
__connman_plugin_init();
g_free(option_device);
@@ -157,6 +159,8 @@ int main(int argc, char *argv[])
g_main_loop_run(main_loop);
+ __connman_rtnl_cleanup();
+
__connman_agent_cleanup();
__connman_element_cleanup();
diff --git a/src/rtnl.c b/src/rtnl.c
index f100c21..491f190 100644
--- a/src/rtnl.c
+++ b/src/rtnl.c
@@ -36,21 +36,6 @@
#include "connman.h"
-struct rtnl_data {
- unsigned ifi_flags;
-};
-
-static struct rtnl_data *get_rtnl_data(struct connman_iface *iface)
-{
- if ((iface->flags & CONNMAN_IFACE_FLAG_RTNL) == 0)
- return NULL;
-
- if (iface->rtnl_data == NULL)
- iface->rtnl_data = g_try_new0(struct rtnl_data, 1);
-
- return iface->rtnl_data;
-}
-
static inline void print_inet(struct rtattr *attr, const char *name, int
family)
{
if (family == AF_INET) {
@@ -85,8 +70,6 @@ static inline void print_attr(struct rtattr *attr, const char
*name)
static void rtnl_link(struct nlmsghdr *hdr)
{
- struct connman_iface *iface;
- struct rtnl_data *data;
struct ifinfomsg *msg;
struct rtattr *attr;
int bytes;
@@ -96,34 +79,6 @@ static void rtnl_link(struct nlmsghdr *hdr)
DBG("ifi_index %d ifi_flags 0x%04x", msg->ifi_index, msg->ifi_flags);
- iface = __connman_iface_find(msg->ifi_index);
- if (iface == NULL)
- return;
-
- data = get_rtnl_data(iface);
- if (data == NULL)
- return;
-
- if ((data->ifi_flags & IFF_RUNNING) != (msg->ifi_flags & IFF_RUNNING)) {
- if (!(iface->flags & CONNMAN_IFACE_FLAG_NOCARRIER)) {
- if (msg->ifi_flags & IFF_RUNNING)
- connman_iface_indicate_carrier_on(iface);
- else
- connman_iface_indicate_carrier_off(iface);
- }
- }
-
- if ((data->ifi_flags & IFF_UP) != (msg->ifi_flags & IFF_UP)) {
- if (msg->ifi_flags & IFF_UP)
- connman_iface_indicate_ifup(iface);
- else
- connman_iface_indicate_ifdown(iface);
- }
-
- data->ifi_flags = msg->ifi_flags;
-
- return;
-
for (attr = IFLA_RTA(msg); RTA_OK(attr, bytes);
attr = RTA_NEXT(attr, bytes)) {
switch (attr->rta_type) {
@@ -158,9 +113,7 @@ static void rtnl_link(struct nlmsghdr *hdr)
print_attr(attr, "master");
break;
case IFLA_WIRELESS:
- if (iface->driver->rtnl_wireless)
- iface->driver->rtnl_wireless(iface,
- RTA_DATA(attr), RTA_PAYLOAD(attr));
+ print_attr(attr, "wireless");
break;
case IFLA_PROTINFO:
print_attr(attr, "protinfo");
@@ -189,8 +142,6 @@ static void rtnl_link(struct nlmsghdr *hdr)
static void rtnl_addr(struct nlmsghdr *hdr)
{
- struct connman_iface *iface;
- struct rtnl_data *data;
struct ifaddrmsg *msg;
struct rtattr *attr;
int bytes;
@@ -200,14 +151,6 @@ static void rtnl_addr(struct nlmsghdr *hdr)
DBG("ifa_family %d ifa_index %d", msg->ifa_family, msg->ifa_index);
- iface = __connman_iface_find(msg->ifa_index);
- if (iface == NULL)
- return;
-
- data = get_rtnl_data(iface);
- if (data == NULL)
- return;
-
for (attr = IFA_RTA(msg); RTA_OK(attr, bytes);
attr = RTA_NEXT(attr, bytes)) {
switch (attr->rta_type) {
@@ -406,7 +349,7 @@ int __connman_rtnl_init(void)
memset(&addr, 0, sizeof(addr));
addr.nl_family = AF_NETLINK;
- addr.nl_groups = RTMGRP_LINK;
+ //addr.nl_groups = RTMGRP_LINK;
//addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR;
//addr.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV4_ROUTE;
@@ -418,9 +361,8 @@ int __connman_rtnl_init(void)
channel = g_io_channel_unix_new(sk);
g_io_channel_set_close_on_unref(channel, TRUE);
- g_io_add_watch(channel,
- G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
- netlink_event, NULL);
+ g_io_add_watch(channel, G_IO_IN | G_IO_NVAL | G_IO_HUP | G_IO_ERR,
+ netlink_event, NULL);
return 0;
}
_______________________________________________
Commits mailing list
[email protected]
https://www.moblin.org/mailman/listinfo/commits