Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe 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. Default route per interface ([email protected])
   2. [PATCH 1/2] added default configuration capability by identifier or 
interface name.
      (Damien LEFEVRE)
   3. [PATCH 2/2] added ability to set the MTU from settings file.
      (Damien LEFEVRE)
   4. High Speed Flexo Printer Slotter Die Cutter Stacker
      ([email protected])


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

Date: Fri, 11 Sep 2020 09:01:32 +0200
From: <[email protected]>
Subject: Default route per interface
To: <[email protected]>
Message-ID: <D2A18EC4B4B243ED85565F822BBE3A01@ChrisPC>
Content-Type: text/plain;       format=flowed;  charset="utf-8";
        reply-type=original

We have a setup with a wired and cellular connection. The wired connection 
has access to the internet, the cellular one to a 10.0.0.0/8 network. We 
would like to have both interfaces up at the same time, with the wired 
connection getting the default route and the cellular getting a route to its 
network. But when connman manages both connections, the cellular also gets a 
default route. Is there an easy way to configure a different 'default' route 
per interface? Would the sessions API help here? 

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

Date: Fri, 11 Sep 2020 11:04:34 +0300
From: Damien LEFEVRE <[email protected]>
Subject: [PATCH 1/2] added default configuration capability by
        identifier or interface name.
To: [email protected]
Cc: Damien LEFEVRE <[email protected]>
Message-ID: <[email protected]>

The default configurations go into STORAGEDIR/defaults directory and are named 
after the service file.

Ex for eth0 (00:04:4B:E5:93:6D) interface:
 - STORAGEDIR/defaults/ethernet_eth0_cable with
[ethernet_eth0_cable]
Name=Wired
AutoConnect=true
IPv4.method=manual
IPv6.method=auto
IPv6.privacy=disabled
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.1.100
MTU=9000

will be copied into STORAGEDIR/ethernet_00044be5936d_cable/settings and 
[ethernet_eth0_cable] will be replaced by [ethernet_00044be5936d_cable] as:
[ethernet_00044be5936d_cable]
Name=Wired
AutoConnect=true
IPv4.method=manual
IPv6.method=auto
IPv6.privacy=disabled
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.1.100
MTU=9000

 - STORAGEDIR/defaults/ethernet_00044be5936d_cable with
Name=Wired
AutoConnect=true
IPv4.method=manual
IPv6.method=auto
IPv6.privacy=disabled
IPv4.netmask_prefixlen=24
IPv4.local_address=192.168.1.100
MTU=9000

will be copied to STORAGEDIR/ethernet_00044be5936d_cable/settings and the 
content will not be modified
---
 include/storage.h |   2 +-
 plugins/wifi.c    |   4 +-
 src/dhcpv6.c      |   2 +-
 src/service.c     |  10 ++--
 src/storage.c     | 124 ++++++++++++++++++++++++++++++++++++++++++++--
 5 files changed, 130 insertions(+), 12 deletions(-)

diff --git a/include/storage.h b/include/storage.h
index 4c23a14e..902b9c82 100644
--- a/include/storage.h
+++ b/include/storage.h
@@ -29,7 +29,7 @@ extern "C" {
 #endif
 
 gchar **connman_storage_get_services();
-GKeyFile *connman_storage_load_service(const char *service_id);
+GKeyFile *connman_storage_load_service(const char *service_id, const char 
*ifname);
 
 #ifdef __cplusplus
 }
diff --git a/plugins/wifi.c b/plugins/wifi.c
index f8c22be3..6fda90c5 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1054,7 +1054,7 @@ static int get_hidden_connections(GSupplicantScanParams 
*scan_data)
                if (strncmp(services[i], "wifi_", 5) != 0)
                        continue;
 
-               keyfile = connman_storage_load_service(services[i]);
+               keyfile = connman_storage_load_service(services[i], "");
                if (!keyfile)
                        continue;
 
@@ -1662,7 +1662,7 @@ static int get_latest_connections(int max_ssids,
                if (strncmp(services[i], "wifi_", 5) != 0)
                        continue;
 
-               keyfile = connman_storage_load_service(services[i]);
+               keyfile = connman_storage_load_service(services[i], "");
                if (!keyfile)
                        continue;
 
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 2d5f8f6a..4ad43860 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -198,7 +198,7 @@ static int set_duid(struct connman_service *service,
 
        ident = connman_service_get_identifier(service);
 
-       keyfile = connman_storage_load_service(ident);
+       keyfile = connman_storage_load_service(ident, 
connman_service_get_interface(service));
        if (!keyfile)
                return -EINVAL;
 
diff --git a/src/service.c b/src/service.c
index 3202f26c..f9ac1655 100644
--- a/src/service.c
+++ b/src/service.c
@@ -382,7 +382,7 @@ int __connman_service_load_modifiable(struct 
connman_service *service)
 
        DBG("service %p", service);
 
-       keyfile = connman_storage_load_service(service->identifier);
+       keyfile = connman_storage_load_service(service->identifier, 
connman_service_get_interface(service));
        if (!keyfile)
                return -EIO;
 
@@ -435,7 +435,7 @@ static int service_load(struct connman_service *service)
 
        DBG("service %p", service);
 
-       keyfile = connman_storage_load_service(service->identifier);
+       keyfile = connman_storage_load_service(service->identifier, 
connman_service_get_interface(service));
        if (!keyfile) {
                service->new_service = true;
                return -EIO;
@@ -6858,7 +6858,7 @@ void __connman_service_read_ip4config(struct 
connman_service *service)
        if (!service->ipconfig_ipv4)
                return;
 
-       keyfile = connman_storage_load_service(service->identifier);
+       keyfile = connman_storage_load_service(service->identifier, 
connman_service_get_interface(service));
        if (!keyfile)
                return;
 
@@ -6888,7 +6888,7 @@ void __connman_service_read_ip6config(struct 
connman_service *service)
        if (!service->ipconfig_ipv6)
                return;
 
-       keyfile = connman_storage_load_service(service->identifier);
+       keyfile = connman_storage_load_service(service->identifier, 
connman_service_get_interface(service));
        if (!keyfile)
                return;
 
@@ -7375,7 +7375,7 @@ static void remove_unprovisioned_services(void)
                file = section = NULL;
                keyfile = configkeyfile = NULL;
 
-               keyfile = connman_storage_load_service(services[i]);
+               keyfile = connman_storage_load_service(services[i], "");
                if (!keyfile)
                        continue;
 
diff --git a/src/storage.c b/src/storage.c
index 5e877ef1..f9ad5b1e 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -240,16 +240,134 @@ gchar **connman_storage_get_services(void)
        return services;
 }
 
-GKeyFile *connman_storage_load_service(const char *service_id)
+GKeyFile *connman_storage_load_service(const char *service_id, const char 
*ifname /*= ""*/)
 {
-       gchar *pathname;
+       gchar *pathname = NULL;
        GKeyFile *keyfile = NULL;
 
        pathname = g_strdup_printf("%s/%s/%s", STORAGEDIR, service_id, 
SETTINGS);
        if (!pathname)
                return NULL;
 
-       keyfile =  storage_load(pathname);
+       keyfile = storage_load(pathname);
+       
+       if (!keyfile) {
+               // Try to load default settings with identifier
+               gchar *default_pathname = g_strdup_printf("%s/defaults/%s", 
STORAGEDIR, service_id);
+               if (!default_pathname) {
+                       g_free(pathname);
+                       return NULL;
+               }
+
+               // Check if default file exists
+               if (g_file_test(default_pathname, G_FILE_TEST_EXISTS)) 
+               {
+                       gsize length = 0;
+                       gchar *content = NULL;  
+
+                       // Create settings directory
+                       gchar *dirname = g_strdup_printf("%s/%s", STORAGEDIR, 
service_id);
+                       if (!dirname) {
+                               g_free(default_pathname);
+                               g_free(pathname);
+                               return NULL;
+                       }
+
+                       if (g_mkdir_with_parents(dirname, 0777) < 0) {
+                               g_free(dirname);
+                               g_free(default_pathname);
+                               g_free(pathname);
+                               return NULL;
+                       }
+
+                       // Copy default file to settings folder                 
                
+                       if (g_file_get_contents (default_pathname, &content, 
&length, NULL)) {  
+                               if (g_file_set_contents (pathname, content, 
length, NULL)) {
+                                       DBG("Deploying default configuration 
for %s from %s", service_id, default_pathname);
+                                       DBG("Default content:\n %s", content);
+                                       keyfile = storage_load(pathname);
+                               }
+
+                               g_free(content);
+                       }
+
+                       g_free(dirname);
+               }
+
+               g_free(default_pathname);
+       }
+               
+       if (!keyfile && g_strcmp0(ifname, "") != 0)
+       {       
+               gchar *default_pathname;
+
+               // If we know the interface name and previous failed,
+               // try to find the default config by name                       
+
+               // split service_id to get the ident at split[1]
+               gchar **split = g_strsplit(service_id, "_", -1);
+
+               // Replace ident by interface name
+               gchar **split2 = g_strsplit(service_id, split[1], -1);
+               gchar *default_service = g_strjoinv(ifname, split2);
+
+               g_strfreev(split);
+               g_strfreev(split2);
+
+               // Try to load default settings with interface name
+               default_pathname = g_strdup_printf("%s/defaults/%s", 
STORAGEDIR, default_service);
+               
+               if (!default_pathname) {
+                       g_free(pathname);
+                       return NULL;
+               }
+
+               // Check if default file exists
+               if (g_file_test(default_pathname, G_FILE_TEST_EXISTS)) {
+                       gsize length;
+                       gchar *content = NULL;
+                       gchar *modified_content = NULL;
+
+                       // Create settings directory
+                       gchar *dirname = g_strdup_printf("%s/%s", STORAGEDIR, 
service_id);
+                       if (!dirname) {
+                               g_free(default_pathname);
+                               g_free(pathname);
+                               return NULL;
+                       }
+
+                       if (g_mkdir_with_parents(dirname, 0777) < 0) {
+                               g_free(dirname); 
+                               g_free(default_pathname);
+                               g_free(pathname);
+                               return NULL;
+                       }
+
+                       // Copy default file to settings folder 
+                       if (g_file_get_contents (default_pathname, &content, 
&length, NULL)) {
+                               // replace ifname by ident in the default 
setting 
+                               gchar **split3 = g_strsplit(service_id, "_", 
-1);
+                               gchar **split4 = g_strsplit(content, ifname, 
-1);
+                               modified_content = g_strjoinv(split3[1], 
split4);
+
+                               g_strfreev(split3);
+                               g_strfreev(split4);
+
+                               if (g_file_set_contents (pathname, 
modified_content, strlen(modified_content), NULL)) {
+                                       DBG("Deploying default configuration 
for %s from %s", service_id, default_pathname);
+                                       DBG("Default content:\n %s", 
modified_content);
+                                       keyfile = storage_load(pathname);
+                               }
+
+                               g_free(modified_content);
+                               g_free(content);
+                       }
+
+                       g_free(dirname);
+                       g_free(default_pathname);
+               }
+       }
+
        g_free(pathname);
 
        return keyfile;
-- 
2.17.1

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

Date: Fri, 11 Sep 2020 11:04:35 +0300
From: Damien LEFEVRE <[email protected]>
Subject: [PATCH 2/2] added ability to set the MTU from settings file.
To: [email protected]
Cc: Damien LEFEVRE <[email protected]>
Message-ID: <[email protected]>

---
 src/service.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/service.c b/src/service.c
index f9ac1655..06f19ca5 100644
--- a/src/service.c
+++ b/src/service.c
@@ -605,6 +605,20 @@ static int service_load(struct connman_service *service)
        service->hidden_service = g_key_file_get_boolean(keyfile,
                                        service->identifier, "Hidden", NULL);
 
+    // Set MTU
+    str = g_key_file_get_string(keyfile,
+                                    service->identifier, "MTU", NULL);
+    if (str){
+            int err = 0;
+            int index = -1;
+            char *ifname = connman_service_get_interface(service);
+            index = connman_inet_ifindex(ifname);
+            err = connman_inet_set_mtu(index, atoi(str));
+            DBG("setting MTU %d, error: %d, service: %s, ifname: %s", 
atoi(str), err, service->identifier, ifname);
+    }
+       
+    g_free(str);
+
 done:
        g_key_file_free(keyfile);
 
-- 
2.17.1

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

Date: Fri, 11 Sep 2020 09:58:09 -0000
From: [email protected]
Subject: High Speed Flexo Printer Slotter Die Cutter Stacker
To: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset="utf-8"

Jiangxi Chuangsheng Packaging Machinery Co., Limited is one of the leading 
suppliers of High speed Flexo printer slotter die cutter stacker. The superior 
quality of the print, easy to adjust, simple operation for multicolor are the 
reasons why our products are the trusted ones of the automated printing 
industry.
http://jxcsjx.cn/index.php/product/index/g/c/id/14.html

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

Subject: Digest Footer

_______________________________________________
connman mailing list -- [email protected]
To unsubscribe send an email to [email protected]


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

End of connman Digest, Vol 59, Issue 10
***************************************

Reply via email to