Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. [PATCH v2 9/9] connman.service: Remove dependencies on
      remote-fs.target (Patrik Flykt)
   2. [PATCH v2 6/9] connmand-wait-online: Add option to ignore
      interfaces (Patrik Flykt)
   3. [PATCH v2 8/9] build: Add connman-wait-online.service
      (Patrik Flykt)
   4. [PATCH v2 7/9] connmand-wait-online: Add timeout option
      (Patrik Flykt)
   5. [PATCH v2 1/9] connmand-wait-online: Add program and initial
      main loop (Patrik Flykt)
   6. [PATCH v2 4/9] connmand-wait-online: Add command line options
      (Patrik Flykt)
   7. [PATCH v2 2/9] connmand-wait-online: Monitor Manager
      PropertyChanged signals (Patrik Flykt)


----------------------------------------------------------------------

Message: 1
Date: Tue,  1 Dec 2015 16:05:42 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 9/9] connman.service: Remove dependencies on
        remote-fs.target
Message-ID:
        <[email protected]>

With a working connmand-wait-online.service, the extra dependency hack on
remote-fs.target can be removed. Make ConnMan start before multi-user.target.
---
 src/connman.service.in | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/connman.service.in b/src/connman.service.in
index 8006a06..2198a19 100644
--- a/src/connman.service.in
+++ b/src/connman.service.in
@@ -4,8 +4,8 @@ DefaultDependencies=false
 Conflicts=shutdown.target
 RequiresMountsFor=@localstatedir@/lib/connman
 After=dbus.service network-pre.target
-Before=network.target shutdown.target remote-fs-pre.target
-Wants=network.target remote-fs-pre.target
+Before=network.target multi-user.target shutdown.target
+Wants=network.target
 
 [Service]
 Type=dbus
-- 
2.1.4



------------------------------

Message: 2
Date: Tue,  1 Dec 2015 16:05:39 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 6/9] connmand-wait-online: Add option to ignore
        interfaces
Message-ID:
        <[email protected]>

Add command line optoin to ignore interfaces. Interfaces are first matched
against the ignored ones, then the expected ones.
---
 src/connmand-wait-online.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/connmand-wait-online.c b/src/connmand-wait-online.c
index fc89df5..5b89b83 100644
--- a/src/connmand-wait-online.c
+++ b/src/connmand-wait-online.c
@@ -38,14 +38,18 @@ static GMainLoop *main_loop;
 
 static gboolean option_version = FALSE;
 static gchar *option_interface = NULL;
+static gchar *option_ignore = NULL;
 
 struct devices {
        char **interface;
+       char **ignore;
 };
 
 static GOptionEntry options[] = {
        { "interface", 'i', 0, G_OPTION_ARG_STRING, &option_interface,
          "Specify networking device or interface", "DEV" },
+       { "ignore", 'I', 0, G_OPTION_ARG_STRING, &option_ignore,
+         "Specify networking device or interface to ignore", "DEV" },
        { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
          "Show version information and exit" },
        { NULL },
@@ -58,6 +62,13 @@ static bool compare_interface(const char *interface, struct 
devices *devices)
        if (!interface || !devices)
                return false;
 
+       for (i = 0; devices->ignore && devices->ignore[i]; i++)
+               if (!strcmp(interface, devices->ignore[i]))
+                       return false;
+
+       if (!devices->interface)
+               return true;
+
        for (i = 0; devices->interface[i]; i++)
                if (!strcmp(interface, devices->interface[i]))
                        return true;
@@ -348,7 +359,7 @@ int main(int argc, char *argv[])
                CONNMAN_MANAGER_INTERFACE "'";
        int err = 0;
        GError *g_err = NULL;
-       struct devices devices = { NULL };
+       struct devices devices = { NULL, NULL };
        DBusError dbus_err;
        GOptionContext *context;
 
@@ -372,6 +383,11 @@ int main(int argc, char *argv[])
                g_free(option_interface);
        }
 
+       if (option_ignore) {
+               devices.ignore = g_strsplit(option_ignore, ",", -1);
+               g_free(option_ignore);
+       }
+
         if (option_version) {
                fprintf(stdout, "%s\n", VERSION);
                goto free;
@@ -417,6 +433,7 @@ fail:
        dbus_error_free(&dbus_err);
 free:
        g_strfreev(devices.interface);
+       g_strfreev(devices.ignore);
 
        return -err;
 }
-- 
2.1.4



------------------------------

Message: 3
Date: Tue,  1 Dec 2015 16:05:41 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 8/9] build: Add connman-wait-online.service
Message-ID:
        <[email protected]>

Add systemd unit connmand-wait-online.service that can be enabled for the
system to wait until a network connection is established. The service follows
systemd-networkd-wait-online behavior and matches systemd network "online"
status with ConnMan service state 'ready' or 'online'.

Fixes CM-683
---
 Makefile.am                        |  6 ++++--
 src/connman-wait-online.service.in | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 src/connman-wait-online.service.in

diff --git a/Makefile.am b/Makefile.am
index 5b0c2de..5f5e282 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -76,10 +76,12 @@ endif
 
 service_files_sources = src/connman.service.in src/net.connman.service.in \
                                vpn/connman-vpn.service.in \
-                               vpn/net.connman.vpn.service.in
+                               vpn/net.connman.vpn.service.in \
+                               src/connman-wait-online.service.in
 service_files = src/connman.service src/net.connman.service \
                                vpn/connman-vpn.service \
-                               vpn/net.connman.vpn.service
+                               vpn/net.connman.vpn.service \
+                               src/connman-wait-online.service
 
 plugin_LTLIBRARIES =
 
diff --git a/src/connman-wait-online.service.in 
b/src/connman-wait-online.service.in
new file mode 100644
index 0000000..c2ad5cc
--- /dev/null
+++ b/src/connman-wait-online.service.in
@@ -0,0 +1,15 @@
+[Unit]
+Description=Wait for network to be configured by ConnMan
+Requisite=connman.service
+After=connman.service
+Before=network-online.target
+DefaultDependencies=no
+Conflicts=shutdown.target
+
+[Service]
+Type=oneshot
+ExecStart=@sbindir@/connmand-wait-online
+RemainAfterExit=yes
+
+[Install]
+WantedBy=network-online.target
-- 
2.1.4



------------------------------

Message: 4
Date: Tue,  1 Dec 2015 16:05:40 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 7/9] connmand-wait-online: Add timeout option
Message-ID:
        <[email protected]>

Add a timeout option in order not to wait forever for networks. The default
timeout is 120 seconds and can be disabled by setting timeout to 0 with the
command line option.
---
 src/connmand-wait-online.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/connmand-wait-online.c b/src/connmand-wait-online.c
index 5b89b83..2711d56 100644
--- a/src/connmand-wait-online.c
+++ b/src/connmand-wait-online.c
@@ -35,10 +35,13 @@
 
 static DBusConnection *connection;
 static GMainLoop *main_loop;
+static int timeout = 0;
+static int exit_value = 0;
 
 static gboolean option_version = FALSE;
 static gchar *option_interface = NULL;
 static gchar *option_ignore = NULL;
+static gint option_timeout = 120;
 
 struct devices {
        char **interface;
@@ -50,6 +53,9 @@ static GOptionEntry options[] = {
          "Specify networking device or interface", "DEV" },
        { "ignore", 'I', 0, G_OPTION_ARG_STRING, &option_ignore,
          "Specify networking device or interface to ignore", "DEV" },
+       { "timeout", 0, 0, G_OPTION_ARG_INT, &option_timeout,
+         "Time to wait for network going online. Default is 120 seconds.",
+         "seconds" },
        { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
          "Show version information and exit" },
        { NULL },
@@ -353,6 +359,15 @@ static DBusHandlerResult 
manager_property_changed(DBusConnection *connection,
        return DBUS_HANDLER_RESULT_HANDLED;
 }
 
+static gboolean timeout_triggered(gpointer user_data)
+{
+       exit_value = -ETIMEDOUT;
+       g_main_loop_quit(main_loop);
+       timeout = 0;
+
+       return FALSE;
+}
+
 int main(int argc, char *argv[])
 {
        const char *filter = "type='signal',interface='"
@@ -417,9 +432,14 @@ int main(int argc, char *argv[])
                goto cleanup;
        }
 
+       if (option_timeout)
+               timeout = g_timeout_add_seconds(option_timeout,
+                                               timeout_triggered, NULL);
+
        manager_get_properties(&devices);
 
        g_main_loop_run(main_loop);
+       err = exit_value;
 
 cleanup:
        dbus_bus_remove_match(connection, filter, NULL);
@@ -434,6 +454,8 @@ fail:
 free:
        g_strfreev(devices.interface);
        g_strfreev(devices.ignore);
+       if (timeout)
+               g_source_remove(timeout);
 
        return -err;
 }
-- 
2.1.4



------------------------------

Message: 5
Date: Tue,  1 Dec 2015 16:05:34 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 1/9] connmand-wait-online: Add program and initial
        main loop
Message-ID:
        <[email protected]>

Add connmand-wait-online program that will return once ConnMan has
a service connected. The return value with a service connected is
zero, on error one of the defined errno values will be returned.
---

v2: Mention return values

Makefile.am                |  7 +++++-
 src/connmand-wait-online.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)
 create mode 100644 src/connmand-wait-online.c

diff --git a/Makefile.am b/Makefile.am
index 95082c1..5b0c2de 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,7 +97,7 @@ unit_objects =
 
 MANUAL_PAGES =
 
-sbin_PROGRAMS = src/connmand
+sbin_PROGRAMS = src/connmand src/connmand-wait-online
 
 src_connmand_SOURCES = $(gdhcp_sources) $(gweb_sources) \
                        $(builtin_sources) $(shared_sources) src/connman.ver \
@@ -125,6 +125,11 @@ src_connmand_LDADD = gdbus/libgdbus-internal.la 
$(builtin_libadd) \
 src_connmand_LDFLAGS = -Wl,--export-dynamic \
                                -Wl,--version-script=$(srcdir)/src/connman.ver
 
+src_connmand_wait_online_SOURCES = src/connmand-wait-online.c
+
+src_connmand_wait_online_LDADD = gdbus/libgdbus-internal.la \
+                       @GLIB_LIBS@ @DBUS_LIBS@
+
 if VPN
 vpn_plugin_LTLIBRARIES =
 
diff --git a/src/connmand-wait-online.c b/src/connmand-wait-online.c
new file mode 100644
index 0000000..bf7c8db
--- /dev/null
+++ b/src/connmand-wait-online.c
@@ -0,0 +1,61 @@
+/*
+ *
+ *  Connection Manager
+ *
+ *  Copyright (C) 2015  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 <stdio.h>
+#include <glib.h>
+#include <errno.h>
+
+#include <gdbus.h>
+
+static DBusConnection *connection;
+static GMainLoop *main_loop;
+
+int main(int argc, char *argv[])
+{
+       int err = 0;
+       DBusError dbus_err;
+
+       dbus_error_init(&dbus_err);
+       connection = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &dbus_err);
+
+       if (dbus_error_is_set(&dbus_err)) {
+               fprintf(stderr, "Error: %s\n", dbus_err.message);
+
+               err = -ENOPROTOOPT;
+               goto fail;
+       }
+
+       main_loop = g_main_loop_new(NULL, FALSE);
+
+       g_main_loop_run(main_loop);
+
+       dbus_connection_unref(connection);
+       g_main_loop_unref(main_loop);
+
+fail:
+       dbus_error_free(&dbus_err);
+
+       return -err;
+}
-- 
2.1.4



------------------------------

Message: 6
Date: Tue,  1 Dec 2015 16:05:37 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 4/9] connmand-wait-online: Add command line options
Message-ID:
        <[email protected]>

Add command line options for the application. Initially add support for
printing the version.
---

v2: removed extra parenthesis and newline

src/connmand-wait-online.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/src/connmand-wait-online.c b/src/connmand-wait-online.c
index 37394dc..9c77801 100644
--- a/src/connmand-wait-online.c
+++ b/src/connmand-wait-online.c
@@ -36,6 +36,14 @@
 static DBusConnection *connection;
 static GMainLoop *main_loop;
 
+static gboolean option_version = FALSE;
+
+static GOptionEntry options[] = {
+       { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
+         "Show version information and exit" },
+       { NULL },
+};
+
 static bool state_online(DBusMessageIter *iter)
 {
        char *str;
@@ -150,7 +158,29 @@ int main(int argc, char *argv[])
        const char *filter = "type='signal',interface='"
                CONNMAN_MANAGER_INTERFACE "'";
        int err = 0;
+       GError *g_err = NULL;
        DBusError dbus_err;
+       GOptionContext *context;
+
+       context = g_option_context_new(NULL);
+       g_option_context_add_main_entries(context, options, NULL);
+
+       if (!g_option_context_parse(context, &argc, &argv, &g_err)) {
+               if (g_err) {
+                       fprintf(stderr, "%s\n", g_err->message);
+                       g_error_free(g_err);
+               } else
+                       fprintf(stderr, "An unknown error occurred\n");
+
+               return EOPNOTSUPP;
+       }
+
+        g_option_context_free(context);
+
+        if (option_version) {
+               fprintf(stdout, "%s\n", VERSION);
+               goto free;
+       }
 
        dbus_error_init(&dbus_err);
        connection = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, &dbus_err);
-- 
2.1.4



------------------------------

Message: 7
Date: Tue,  1 Dec 2015 16:05:35 +0200
From: Patrik Flykt <[email protected]>
To: [email protected]
Subject: [PATCH v2 2/9] connmand-wait-online: Monitor Manager
        PropertyChanged signals
Message-ID:
        <[email protected]>

Consider ConnMan to be "online" in systemd terms when a service gets connected
with 'ready' or 'online' state. Monitor Manager PropertyChanged signals to
notice when this happens.
---
 src/connmand-wait-online.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/src/connmand-wait-online.c b/src/connmand-wait-online.c
index bf7c8db..d572f8c 100644
--- a/src/connmand-wait-online.c
+++ b/src/connmand-wait-online.c
@@ -24,16 +24,67 @@
 #endif
 
 #include <stdio.h>
+#include <string.h>
 #include <glib.h>
 #include <errno.h>
+#include <stdbool.h>
+#include <dbus/dbus.h>
 
 #include <gdbus.h>
+#include <connman/dbus.h>
 
 static DBusConnection *connection;
 static GMainLoop *main_loop;
 
+static bool state_online(DBusMessageIter *iter)
+{
+       char *str;
+       DBusMessageIter variant;
+
+       if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+               return false;
+
+       dbus_message_iter_get_basic(iter, &str);
+       if (strcmp(str, "State"))
+               return false;
+
+       dbus_message_iter_next(iter);
+
+       if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_VARIANT)
+               return false;
+
+       dbus_message_iter_recurse(iter, &variant);
+
+       if (dbus_message_iter_get_arg_type(&variant) != DBUS_TYPE_STRING)
+               return false;
+
+       dbus_message_iter_get_basic(&variant, &str);
+       if (strcmp(str, "ready") && strcmp(str, "online"))
+               return false;
+
+       return true;
+}
+
+static DBusHandlerResult manager_property_changed(DBusConnection *connection,
+                DBusMessage *message, void *user_data)
+{
+       DBusMessageIter iter;
+
+       if (dbus_message_is_signal(message, CONNMAN_MANAGER_INTERFACE,
+                                       "PropertyChanged")) {
+               dbus_message_iter_init(message, &iter);
+
+               if (state_online(&iter))
+                       g_main_loop_quit(main_loop);
+       }
+
+       return DBUS_HANDLER_RESULT_HANDLED;
+}
+
 int main(int argc, char *argv[])
 {
+       const char *filter = "type='signal',interface='"
+               CONNMAN_MANAGER_INTERFACE "'";
        int err = 0;
        DBusError dbus_err;
 
@@ -49,8 +100,25 @@ int main(int argc, char *argv[])
 
        main_loop = g_main_loop_new(NULL, FALSE);
 
+       dbus_connection_add_filter(connection, manager_property_changed,
+                               NULL, NULL);
+
+       dbus_bus_add_match(connection, filter, &dbus_err);
+
+       if (dbus_error_is_set(&dbus_err)) {
+               fprintf(stderr, "Error: %s\n", dbus_err.message);
+
+               err = -ENOPROTOOPT;
+               goto cleanup;
+       }
+
        g_main_loop_run(main_loop);
 
+cleanup:
+       dbus_bus_remove_match(connection, filter, NULL);
+       dbus_connection_remove_filter(connection, manager_property_changed,
+                               NULL);
+
        dbus_connection_unref(connection);
        g_main_loop_unref(main_loop);
 
-- 
2.1.4



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 2, Issue 3
*************************************

Reply via email to