This email list is read-only. Emails sent to this list will be discarded
----------------------------------
bootstrap-configure | 3 +-
configure.ac | 4 ++
plugins/Makefile.am | 6 +++
plugins/fake.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++++
plugins/ipv4.c | 3 +
src/element.c | 30 +++++++++++-
test/Makefile.am | 5 +-
test/disable-device | 23 +++++++++
test/enable-device | 23 +++++++++
test/monitor-networks | 52 +++++++++++++++++++++
10 files changed, 264 insertions(+), 6 deletions(-)
New commits:
commit 4351a568b74d3ed47ef67582123a70a674126add
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 15:11:56 2008 +0200
Add basic functionality to fake plugin
commit 866c74f98fae4227d26c651bb6adff43f5275498
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 15:08:48 2008 +0200
Update status of Enabled property
commit 6ca9fc9115f323d7358b146096994c7f2ba344b5
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 14:36:57 2008 +0200
Add scripts for enabling/disabling devices
commit 371e8bd67cbeb37695f5b69d964a11bf0cc963b2
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 14:28:19 2008 +0200
Add script for monitoring network changes
commit 8dd59fd33eed869fcb2597b3962b8d3cba9c5efa
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 14:23:28 2008 +0200
Include fake plugin for testing
commit 6fa6bdc6f6a8d239142b32979318245da8941d2b
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 14:21:02 2008 +0200
Fail if address, netmask or gateway are not provided
commit 18886b7ef037884eff0bac7b9de673aa0a058493
Author: Marcel Holtmann <[EMAIL PROTECTED]>
Date: Tue Oct 7 14:19:52 2008 +0200
Use glob pattern matching for interface names
Diff in this email is a maximum of 400 lines.
diff --git a/bootstrap-configure b/bootstrap-configure
index ea6d525..cba03dc 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -15,4 +15,5 @@ fi
--prefix=/usr \
--mandir=/usr/share/man \
--localstatedir=/var \
- --sysconfdir=/etc
+ --sysconfdir=/etc \
+ --enable-fake $*
diff --git a/configure.ac b/configure.ac
index 61e6418..5857197 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,10 @@ PKG_CHECK_MODULES(SQLITE, sqlite3, sqlite_found=yes,
sqlite_found=no)
AC_SUBST(SQLITE_CFLAGS)
AC_SUBST(SQLITE_LIBS)
+AC_ARG_ENABLE(fake, AC_HELP_STRING([--enable-fake],
+ [enable fake plugin]), [enable_fake=${enableval}])
+AM_CONDITIONAL(FAKE, test "${enable_fake}" = "yes")
+
AC_OUTPUT(Makefile gdbus/Makefile include/Makefile src/Makefile doc/Makefile
test/Makefile plugins/Makefile scripts/Makefile scripts/connman
src/connman.service doc/version.xml connman.pc)
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 7c12a8e..a19236c 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -46,6 +46,12 @@ policydir = $(datadir)/PolicyKit/policy
policy_DATA = connman.policy
endif
+if FAKE
+plugin_LTLIBRARIES += fake.la
+
+fake_la_SOURCES = fake.c
+endif
+
AM_LDFLAGS = -no-undefined -module -avoid-version \
-export-symbols-regex connman_plugin_desc
diff --git a/plugins/fake.c b/plugins/fake.c
new file mode 100644
index 0000000..7bd48df
--- /dev/null
+++ b/plugins/fake.c
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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/driver.h>
+#include <connman/element.h>
+#include <connman/log.h>
+
+static void create_network(struct connman_element *parent, const char *name)
+{
+ struct connman_element *element;
+
+ element = connman_element_create(name);
+ element->type = CONNMAN_ELEMENT_TYPE_NETWORK;
+
+ connman_element_register(element, parent);
+ connman_element_unref(element);
+}
+
+static int fake_device_probe(struct connman_element *element)
+{
+ DBG("");
+
+ return 0;
+}
+
+static void fake_device_remove(struct connman_element *element)
+{
+ DBG("");
+}
+
+static int fake_device_update(struct connman_element *element)
+{
+ DBG("");
+
+ create_network(element, "network_new");
+
+ return 0;
+}
+
+static int fake_device_enable(struct connman_element *element)
+{
+ DBG("");
+
+ create_network(element, "network_one");
+ create_network(element, "network_two");
+
+ return 0;
+}
+
+static int fake_device_disable(struct connman_element *element)
+{
+ DBG("");
+
+ connman_element_unregister_children(element);
+
+ return 0;
+}
+
+static struct connman_driver fake_device_driver = {
+ .name = "fake-device",
+ .type = CONNMAN_ELEMENT_TYPE_DEVICE,
+ .priority = CONNMAN_DRIVER_PRIORITY_HIGH,
+ .probe = fake_device_probe,
+ .remove = fake_device_remove,
+ .update = fake_device_update,
+ .enable = fake_device_enable,
+ .disable = fake_device_disable,
+};
+
+static void create_device(const char *name)
+{
+ struct connman_element *element;
+
+ element = connman_element_create(name);
+ element->type = CONNMAN_ELEMENT_TYPE_DEVICE;
+
+ //connman_element_define_properties(element,
+ // CONNMAN_PROPERTY_ID_IPV4_METHOD,
+ // CONNMAN_PROPERTY_ID_INVALID);
+
+ connman_element_register(element, NULL);
+ connman_element_unref(element);
+}
+
+static int fake_init(void)
+{
+ create_device("fakeone");
+ create_device("faketwo");
+
+ return connman_driver_register(&fake_device_driver);
+}
+
+static void fake_exit(void)
+{
+ connman_driver_unregister(&fake_device_driver);
+}
+
+CONNMAN_PLUGIN_DEFINE("fake", "Tesing plugin", VERSION, fake_init, fake_exit)
diff --git a/plugins/ipv4.c b/plugins/ipv4.c
index 0a66a23..67d1ed1 100644
--- a/plugins/ipv4.c
+++ b/plugins/ipv4.c
@@ -192,6 +192,9 @@ static int ipv4_probe(struct connman_element *element)
DBG("netmask %s", netmask);
DBG("gateway %s", gateway);
+ if (address == NULL || netmask == NULL || gateway == NULL)
+ return -EINVAL;
+
memset(&ipv4, 0, sizeof(ipv4));
ipv4.address.s_addr = inet_addr(address);
ipv4.netmask.s_addr = inet_addr(netmask);
diff --git a/src/element.c b/src/element.c
index 9260d16..ff467d5 100644
--- a/src/element.c
+++ b/src/element.c
@@ -359,6 +359,9 @@ static DBusMessage *do_update(DBusConnection *conn,
if (element->driver == NULL)
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ if (element->enabled == FALSE)
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+
if (element->driver->update) {
DBG("Calling update callback");
element->driver->update(element);
@@ -377,9 +380,19 @@ static DBusMessage *do_enable(DBusConnection *conn,
if (element->driver == NULL)
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ if (element->enabled == TRUE)
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+
if (element->driver->enable) {
DBG("Calling enable callback");
- element->driver->enable(element);
+ if (element->driver->enable(element) == 0) {
+ element->enabled = TRUE;
+
+ g_dbus_emit_signal(connection, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "ElementUpdated",
+ DBUS_TYPE_OBJECT_PATH, &element->path,
+ DBUS_TYPE_INVALID);
+ }
}
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -395,9 +408,19 @@ static DBusMessage *do_disable(DBusConnection *conn,
if (element->driver == NULL)
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+ if (element->enabled == FALSE)
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+
if (element->driver->disable) {
DBG("Calling disable callback");
- element->driver->disable(element);
+ if (element->driver->disable(element) == 0) {
+ element->enabled = FALSE;
+
+ g_dbus_emit_signal(connection, CONNMAN_MANAGER_PATH,
+ CONNMAN_MANAGER_INTERFACE, "ElementUpdated",
+ DBUS_TYPE_OBJECT_PATH, &element->path,
+ DBUS_TYPE_INVALID);
+ }
}
return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
@@ -953,7 +976,8 @@ int connman_element_register(struct connman_element
*element,
DBG("element %p name %s parent %p", element, element->name, parent);
if (device_filter && element->type == CONNMAN_ELEMENT_TYPE_DEVICE) {
- if (g_str_equal(device_filter, element->name) == FALSE) {
+ if (g_pattern_match_simple(device_filter,
+ element->name) == FALSE) {
DBG("ignoring %s device", element->name);
return -EPERM;
}
diff --git a/test/Makefile.am b/test/Makefile.am
index 9b640ea..fe11939 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,6 +1,7 @@
EXTRA_DIST = list-profiles list-elements monitor-elements monitor-state \
- start-scanning select-network disable-network simple-agent \
- get-state show-introspection test-compat test-supplicant
+ get-state select-network disable-network monitor-networks \
+ enable-device disable-device start-scanning simple-agent \
+ show-introspection test-compat test-supplicant
MAINTAINERCLEANFILES = Makefile.in
diff --git a/test/disable-device b/test/disable-device
new file mode 100755
index 0000000..ac55e77
--- /dev/null
+++ b/test/disable-device
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+
+import dbus
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
+ 'org.moblin.connman.Manager')
+
+elements = manager.ListElements()
+
+for path in elements:
+ element = dbus.Interface(bus.get_object('org.moblin.connman', path),
+ 'org.moblin.connman.Element')
+
+ properties = element.GetProperties()
+
+ if (properties["Type"] != "device"):
+ continue
+
+ print "[ %s ]" % (path)
+
+ element.Disable()
diff --git a/test/enable-device b/test/enable-device
new file mode 100755
index 0000000..55bd1f1
--- /dev/null
+++ b/test/enable-device
@@ -0,0 +1,23 @@
+#!/usr/bin/python
+
+import dbus
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.moblin.connman', "/"),
+ 'org.moblin.connman.Manager')
+
+elements = manager.ListElements()
+
+for path in elements:
+ element = dbus.Interface(bus.get_object('org.moblin.connman', path),
+ 'org.moblin.connman.Element')
+
+ properties = element.GetProperties()
+
+ if (properties["Type"] != "device"):
+ continue
+
+ print "[ %s ]" % (path)
+
+ element.Enable()
diff --git a/test/monitor-networks b/test/monitor-networks
new file mode 100755
index 0000000..ce817ef
--- /dev/null
+++ b/test/monitor-networks
@@ -0,0 +1,52 @@
+#!/usr/bin/python
+
+import gobject
+
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+
+def element_print(action, path):
+ print "%s [ %s ]" % (action, path)
+
+ if (action == "-"):
+ return
+
+ element = dbus.Interface(bus.get_object("org.moblin.connman", path),
+ "org.moblin.connman.Element")
+
+ properties = element.GetProperties()
+ if (properties["Type"] != "network"):
+ return
+
+ for key in properties.keys():
+ print " %s = %s" % (key, properties[key])
+
+def element_added(path):
+ element_print("+", path)
+
+def element_updated(path):
+ element_print("*", path)
+
+def element_removed(path):
+ element_print("-", path)
+
+if __name__ == '__main__':
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SystemBus()
+
+ bus.add_signal_receiver(element_added,
+ dbus_interface = "org.moblin.connman.Manager",
+ signal_name = "ElementAdded")
+
+ bus.add_signal_receiver(element_updated,
+ dbus_interface = "org.moblin.connman.Manager",
+ signal_name = "ElementUpdated")
+
+ bus.add_signal_receiver(element_removed,
+ dbus_interface = "org.moblin.connman.Manager",
+ signal_name = "ElementRemoved")
+
+ mainloop = gobject.MainLoop()
+ mainloop.run()
_______________________________________________
Commits mailing list
[email protected]
https://lists.moblin.org/mailman/listinfo/commits