Ethernet networks are created once a cable is plugged in, i.e. carrier
is detected. According to the documentation in doc/service-api.txt,
ethernet networks will act as a Connect() D-Bus API call is issued with
the cable plug in.

Fix the code such that all ethernet services are connected at once when
created provided that the network type is autoconnectable either by
default or by explicitely specifying this with the
DefaultAutoConnectTechnologies main.conf variable.

Reported by Mihai Neagu.
---

        Hi,

As described above, this patch should connect all ethernet (and gadget)
networks as they are assumed to appear when a cable is plugged in. In
order not to become too confusing, DefaultAutoConnectTechnologies setting
in main.conf is followed.

Please test, especially Mihai, but also everybody else on ethernet.

Cheers,

        Patrik



 src/service.c | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/service.c b/src/service.c
index 4cc645a..a3105fa 100644
--- a/src/service.c
+++ b/src/service.c
@@ -6742,8 +6742,32 @@ struct connman_service * 
__connman_service_create_from_network(struct connman_ne
 
        if (service->favorite) {
                device = connman_network_get_device(service->network);
-               if (device && !connman_device_get_scanning(device))
-                       
__connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+               if (device && !connman_device_get_scanning(device)) {
+
+                       switch (service->type) {
+                       case CONNMAN_SERVICE_TYPE_UNKNOWN:
+                       case CONNMAN_SERVICE_TYPE_SYSTEM:
+                       case CONNMAN_SERVICE_TYPE_P2P:
+                               break;
+
+                       case CONNMAN_SERVICE_TYPE_GADGET:
+                       case CONNMAN_SERVICE_TYPE_ETHERNET:
+                               if (service->autoconnect) {
+                                       __connman_service_connect(service,
+                                               
CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+                                       break;
+                               }
+
+                               /* fall through */
+                       case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+                       case CONNMAN_SERVICE_TYPE_GPS:
+                       case CONNMAN_SERVICE_TYPE_VPN:
+                       case CONNMAN_SERVICE_TYPE_WIFI:
+                       case CONNMAN_SERVICE_TYPE_CELLULAR:
+                               
__connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+                               break;
+                       }
+               }
        }
 
        __connman_notifier_service_add(service, service->name);
-- 
2.1.4

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

Reply via email to