Send connman mailing list submissions to
        connman@lists.01.org

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
        connman-requ...@lists.01.org

You can reach the person managing the list at
        connman-ow...@lists.01.org

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


Today's Topics:

   1. Re: [PATCH] service: Enhance
      __connman_service_iterate_services() (Slava Monich)
   2. [PATCH 00/10] Disconnect VPN provider when transport is gone
      (Slava Monich)
   3. [PATCH 01/10] include: Add connman_service_iterate_services()
      prototype (Slava Monich)
   4. [PATCH 02/10] service: Implement
      connman_service_iterate_services() (Slava Monich)
   5. [PATCH 03/10] include: Add connman_service_get_default()
      prototype (Slava Monich)
   6. [PATCH 04/10] service: Expose default service to plugin
      (Slava Monich)
   7. [PATCH 05/10] include: Add connman_service_get_state()
      prototype (Slava Monich)
   8. [PATCH 06/10] service: Expose service state to plugins
      (Slava Monich)


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

Message: 1
Date: Mon, 17 Sep 2018 19:39:49 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: Re: [PATCH] service: Enhance
        __connman_service_iterate_services()
Message-ID: <c7212890-5c83-1282-710e-6b5880bec...@jolla.com>
Content-Type: text/plain; charset=utf-8; format=flowed

On 14/09/18 16:11, Slava Monich wrote:
> Let the callback to break the loop by returning non-zero value.
> ---
>   src/connman.h |  3 ++-
>   src/service.c | 10 ++++------
>   2 files changed, 6 insertions(+), 7 deletions(-)

Please ignore this patch, I'm planning to submit a patch set which will 
supersede this one.

Sorry about the noise.

Cheers,
-Slava


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

Message: 2
Date: Mon, 17 Sep 2018 19:48:31 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 00/10] Disconnect VPN provider when transport is gone
Message-ID: <1537202921-30124-1-git-send-email-slava.mon...@jolla.com>

The purpose of this patchset is to make sure that VPN provider
gets disconnected after switching between WiFi and mobile data.
See the last patch for details.

Slava Monich (10):
  include: Add connman_service_iterate_services() prototype
  service: Implement connman_service_iterate_services()
  include: Add connman_service_get_default() prototype
  service: Expose default service to plugin
  include: Add connman_service_get_state() prototype
  service: Expose service state to plugins
  include: Add connman_service_get_identifier() prototype
  service: Expose service identifier to plugins
  service: Remove __connman_service_lookup_from_ident()
  vpn: Disconnect VPN provider when transport is gone

 include/service.h |   9 ++++
 plugins/vpn.c     | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
 src/config.c      |   6 +--
 src/connection.c  |   2 +-
 src/connman.h     |   9 ----
 src/dhcpv6.c      |   2 +-
 src/ipv6pd.c      |   8 ++--
 src/provider.c    |   2 +-
 src/service.c     |  46 +++++++++----------
 src/session.c     |   8 ++--
 src/stats.c       |   6 +--
 src/timeserver.c  |   4 +-
 12 files changed, 172 insertions(+), 59 deletions(-)

-- 
1.9.1



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

Message: 3
Date: Mon, 17 Sep 2018 19:48:32 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 01/10] include: Add connman_service_iterate_services()
        prototype
Message-ID: <1537202921-30124-2-git-send-email-slava.mon...@jolla.com>

---
 include/service.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/service.h b/include/service.h
index c958375..6652bae 100644
--- a/include/service.h
+++ b/include/service.h
@@ -130,6 +130,12 @@ const char *connman_service_get_proxy_autoconfig(struct 
connman_service *service
 bool connman_service_get_favorite(struct connman_service *service);
 bool connman_service_get_autoconnect(struct connman_service *service);
 
+/* Return non-zero value to terminate the loop, zero to continue */
+typedef int (* connman_service_iterate_cb) (struct connman_service *service,
+                                                       void *user_data);
+int connman_service_iterate_services(connman_service_iterate_cb cb,
+                                                       void *user_data);
+
 struct connman_service *connman_service_lookup_from_network(struct 
connman_network *network);
 struct connman_service *connman_service_lookup_from_identifier(const char* 
identifier);
 
-- 
1.9.1



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

Message: 4
Date: Mon, 17 Sep 2018 19:48:33 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 02/10] service: Implement
        connman_service_iterate_services()
Message-ID: <1537202921-30124-3-git-send-email-slava.mon...@jolla.com>

Internal function __connman_service_iterate_services() is not being
used and can be safely cannibalized.
---
 src/connman.h |  5 -----
 src/service.c | 13 ++++++-------
 2 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index aeead52..8a69b35 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -849,11 +849,6 @@ int __connman_peer_service_unregister(const char *owner,
 
 #include <connman/session.h>
 
-typedef void (* service_iterate_cb) (struct connman_service *service,
-                                       void *user_data);
-
-int __connman_service_iterate_services(service_iterate_cb cb, void *user_data);
-
 void __connman_service_mark_dirty();
 void __connman_service_save(struct connman_service *service);
 
diff --git a/src/service.c b/src/service.c
index 35251fd..25a4b71 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2401,17 +2401,16 @@ void __connman_service_counter_unregister(const char 
*counter)
        counter_list = g_slist_remove(counter_list, counter);
 }
 
-int __connman_service_iterate_services(service_iterate_cb cb, void *user_data)
+int connman_service_iterate_services(connman_service_iterate_cb cb,
+                                                       void *user_data)
 {
        GList *list;
+       int ret = 0;
 
-       for (list = service_list; list; list = list->next) {
-               struct connman_service *service = list->data;
+       for (list = service_list; list && ret == 0; list = list->next)
+               ret = cb((struct connman_service *)list->data, user_data);
 
-               cb(service, user_data);
-       }
-
-       return 0;
+       return ret;
 }
 
 static void append_properties(DBusMessageIter *dict, dbus_bool_t limited,
-- 
1.9.1



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

Message: 5
Date: Mon, 17 Sep 2018 19:48:34 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 03/10] include: Add connman_service_get_default()
        prototype
Message-ID: <1537202921-30124-4-git-send-email-slava.mon...@jolla.com>

---
 include/service.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/service.h b/include/service.h
index 6652bae..2c3fe3d 100644
--- a/include/service.h
+++ b/include/service.h
@@ -136,6 +136,7 @@ typedef int (* connman_service_iterate_cb) (struct 
connman_service *service,
 int connman_service_iterate_services(connman_service_iterate_cb cb,
                                                        void *user_data);
 
+struct connman_service *connman_service_get_default(void);
 struct connman_service *connman_service_lookup_from_network(struct 
connman_network *network);
 struct connman_service *connman_service_lookup_from_identifier(const char* 
identifier);
 
-- 
1.9.1



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

Message: 6
Date: Mon, 17 Sep 2018 19:48:35 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 04/10] service: Expose default service to plugin
Message-ID: <1537202921-30124-5-git-send-email-slava.mon...@jolla.com>

Public connman_service_get_default() can be called by plugins
and replaces internal __connman_service_get_default().
---
 src/connection.c |  2 +-
 src/connman.h    |  1 -
 src/ipv6pd.c     |  8 ++++----
 src/service.c    | 18 +++++++++---------
 src/timeserver.c |  4 ++--
 5 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 582f34d..7a1fbce 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -561,7 +561,7 @@ static struct gateway_data *find_default_gateway(void)
 {
        struct connman_service *service;
 
-       service = __connman_service_get_default();
+       service = connman_service_get_default();
        if (!service)
                return NULL;
 
diff --git a/src/connman.h b/src/connman.h
index 8a69b35..7a8eff0 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -679,7 +679,6 @@ struct connman_service 
*__connman_service_lookup_from_ident(const char *identifi
 struct connman_service *__connman_service_create_from_network(struct 
connman_network *network);
 struct connman_service *__connman_service_create_from_provider(struct 
connman_provider *provider);
 bool __connman_service_index_is_default(int index);
-struct connman_service *__connman_service_get_default(void);
 void __connman_service_update_from_network(struct connman_network *network);
 void __connman_service_remove_from_network(struct connman_network *network);
 void __connman_service_read_ip4config(struct connman_service *service);
diff --git a/src/ipv6pd.c b/src/ipv6pd.c
index 87da3d8..a70de3f 100644
--- a/src/ipv6pd.c
+++ b/src/ipv6pd.c
@@ -138,7 +138,7 @@ static gboolean do_setup(gpointer data)
        if (!default_interface)
                DBG("No uplink connection, retrying prefix delegation");
 
-       ret = setup_prefix_delegation(__connman_service_get_default());
+       ret = setup_prefix_delegation(connman_service_get_default());
        if (ret < 0 && ret != -EINPROGRESS)
                return TRUE; /* delegation error, try again */
 
@@ -154,7 +154,7 @@ static void dhcpv6_renew_callback(struct connman_network 
*network,
        if (status == CONNMAN_DHCPV6_STATUS_SUCCEED)
                dhcpv6_callback(network, status, data);
        else
-               setup_prefix_delegation(__connman_service_get_default());
+               setup_prefix_delegation(connman_service_get_default());
 }
 
 static void cleanup(void)
@@ -262,7 +262,7 @@ static void update_default_interface(struct connman_service 
*service)
 static void update_ipconfig(struct connman_service *service,
                                struct connman_ipconfig *ipconfig)
 {
-       if (!service || service != __connman_service_get_default())
+       if (!service || service != connman_service_get_default())
                return;
 
        if (ipconfig != __connman_service_get_ip6config(service))
@@ -326,7 +326,7 @@ int __connman_ipv6pd_setup(const char *bridge)
                DBG("Cannot receive router solicitation %d/%s",
                        err, strerror(-err));
 
-       service = __connman_service_get_default();
+       service = connman_service_get_default();
        if (service) {
                /*
                 * We have an uplink connection already, try to use it.
diff --git a/src/service.c b/src/service.c
index 25a4b71..df280bf 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1391,7 +1391,7 @@ static void address_updated(struct connman_service 
*service,
                        enum connman_ipconfig_type type)
 {
        if (is_connected(service->state) &&
-                       service == __connman_service_get_default()) {
+                       service == connman_service_get_default()) {
                nameserver_remove_all(service, type);
                nameserver_add_all(service, type);
 
@@ -1487,7 +1487,7 @@ static void reset_stats(struct connman_service *service)
        g_timer_reset(service->stats_roaming.timer);
 }
 
-struct connman_service *__connman_service_get_default(void)
+struct connman_service *connman_service_get_default(void)
 {
        struct connman_service *service;
 
@@ -1509,14 +1509,14 @@ bool __connman_service_index_is_default(int index)
        if (index < 0)
                return false;
 
-       service = __connman_service_get_default();
+       service = connman_service_get_default();
 
        return __connman_service_get_index(service) == index;
 }
 
 static void default_changed(void)
 {
-       struct connman_service *service = __connman_service_get_default();
+       struct connman_service *service = connman_service_get_default();
 
        if (service == current_default)
                return;
@@ -3606,7 +3606,7 @@ static DBusMessage *set_property(DBusConnection *conn,
                service_save(service);
                timeservers_configuration_changed(service);
 
-               if (service == __connman_service_get_default())
+               if (service == connman_service_get_default())
                        __connman_timeserver_sync(service);
 
        } else if (g_str_equal(name, "Domains.Configuration")) {
@@ -4459,7 +4459,7 @@ static void apply_relevant_default_downgrade(struct 
connman_service *service)
 {
        struct connman_service *def_service;
 
-       def_service = __connman_service_get_default();
+       def_service = connman_service_get_default();
        if (!def_service)
                return;
 
@@ -5647,7 +5647,7 @@ static int service_indicate_state(struct connman_service 
*service)
        if (old_state == new_state)
                return -EALREADY;
 
-       def_service = __connman_service_get_default();
+       def_service = connman_service_get_default();
 
        if (new_state == CONNMAN_SERVICE_STATE_ONLINE) {
                result = service_update_preferred_order(def_service,
@@ -5718,7 +5718,7 @@ static int service_indicate_state(struct connman_service 
*service)
 
                default_changed();
 
-               def_service = __connman_service_get_default();
+               def_service = connman_service_get_default();
 
                service_update_preferred_order(def_service, service, new_state);
 
@@ -5770,7 +5770,7 @@ static int service_indicate_state(struct connman_service 
*service)
 
                reply_pending(service, ECONNABORTED);
 
-               def_service = __connman_service_get_default();
+               def_service = connman_service_get_default();
 
                if (!__connman_notifier_is_connected() &&
                        def_service &&
diff --git a/src/timeserver.c b/src/timeserver.c
index 4752aa3..48f026c 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -299,7 +299,7 @@ static gboolean ts_recheck(gpointer user_data)
 {
        GSList *ts;
 
-       ts = __connman_timeserver_get_all(__connman_service_get_default());
+       ts = __connman_timeserver_get_all(connman_service_get_default());
 
        if (!ts) {
                DBG("timeservers disabled");
@@ -365,7 +365,7 @@ int __connman_timeserver_sync(struct connman_service 
*default_service)
        if (default_service)
                service = default_service;
        else
-               service = __connman_service_get_default();
+               service = connman_service_get_default();
 
        if (!service)
                return -EINVAL;
-- 
1.9.1



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

Message: 7
Date: Mon, 17 Sep 2018 19:48:36 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 05/10] include: Add connman_service_get_state()
        prototype
Message-ID: <1537202921-30124-6-git-send-email-slava.mon...@jolla.com>

---
 include/service.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/service.h b/include/service.h
index 2c3fe3d..443099e 100644
--- a/include/service.h
+++ b/include/service.h
@@ -114,6 +114,7 @@ void connman_service_unref_debug(struct connman_service 
*service,
                        const char *file, int line, const char *caller);
 
 enum connman_service_type connman_service_get_type(struct connman_service 
*service);
+enum connman_service_state connman_service_get_state(struct connman_service 
*service);
 char *connman_service_get_interface(struct connman_service *service);
 
 const char *connman_service_get_domainname(struct connman_service *service);
-- 
1.9.1



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

Message: 8
Date: Mon, 17 Sep 2018 19:48:37 +0300
From: Slava Monich <slava.mon...@jolla.com>
To: connman@lists.01.org
Subject: [PATCH 06/10] service: Expose service state to plugins
Message-ID: <1537202921-30124-7-git-send-email-slava.mon...@jolla.com>

Public connman_service_get_state() can be called by plugins
and replaces internal __connman_service_get_state().
---
 src/connman.h | 1 -
 src/service.c | 4 ++--
 src/session.c | 8 +++-----
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index 7a8eff0..2782269 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -699,7 +699,6 @@ bool __connman_service_is_connected_state(struct 
connman_service *service,
 const char *__connman_service_get_ident(struct connman_service *service);
 const char *__connman_service_get_path(struct connman_service *service);
 const char *__connman_service_get_name(struct connman_service *service);
-enum connman_service_state __connman_service_get_state(struct connman_service 
*service);
 struct connman_network *__connman_service_get_network(struct connman_service 
*service);
 enum connman_service_security __connman_service_get_security(struct 
connman_service *service);
 const char *__connman_service_get_phase2(struct connman_service *service);
diff --git a/src/service.c b/src/service.c
index df280bf..fdb0a52 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6971,9 +6971,9 @@ const char *__connman_service_get_name(struct 
connman_service *service)
        return service->name;
 }
 
-enum connman_service_state __connman_service_get_state(struct connman_service 
*service)
+enum connman_service_state connman_service_get_state(struct connman_service 
*service)
 {
-       return service->state;
+       return service ? service->state : CONNMAN_SERVICE_STATE_UNKNOWN;
 }
 
 static enum connman_service_type convert_network_type(struct connman_network 
*network)
diff --git a/src/session.c b/src/session.c
index 59a01c0..3ef7bf5 100644
--- a/src/session.c
+++ b/src/session.c
@@ -28,8 +28,6 @@
 
 #include <gdbus.h>
 
-#include <connman/session.h>
-
 #include "connman.h"
 
 static DBusConnection *connection;
@@ -1717,7 +1715,7 @@ static void update_session_state(struct connman_session 
*session)
        enum connman_session_state state = CONNMAN_SESSION_STATE_DISCONNECTED;
 
        if (session->service) {
-               service_state = __connman_service_get_state(session->service);
+               service_state = connman_service_get_state(session->service);
                state = service_to_session_state(service_state);
                session->info->state = state;
        }
@@ -1812,7 +1810,7 @@ static void session_activate(struct connman_session 
*session)
 
                while (g_hash_table_iter_next(&iter, &key, &value)) {
                        struct connman_service_info *info = value;
-                       state = __connman_service_get_state(info->service);
+                       state = connman_service_get_state(info->service);
 
                        if (is_session_connected(session, state))
                                service_list = g_slist_prepend(service_list,
@@ -1841,7 +1839,7 @@ static void session_activate(struct connman_session 
*session)
                struct connman_service_info *info = value;
                enum connman_service_state state;
 
-               state = __connman_service_get_state(info->service);
+               state = connman_service_get_state(info->service);
 
                if (is_session_connected(session, state) &&
                                session_match_service(session, info->service)) {
-- 
1.9.1



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

Subject: Digest Footer

_______________________________________________
connman mailing list
connman@lists.01.org
https://lists.01.org/mailman/listinfo/connman


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

End of connman Digest, Vol 35, Issue 4
**************************************

Reply via email to