On Fri, Jun 26, 2009 at 02:15:46PM +0200, Marcel Holtmann wrote:
> Hi Sven,
> 
> > we're using connman (latest GIT version) with an embedded Linux System and 
> > we need to set a static IP configuration.  
>    
> you would need to set the static IP details on the device or network
> interface. When the connection interface is present, then it is already
> to late for that, because DHCP already have been executed.
> 

I've made a patch for saving/loading ip static configuration. I don't known
if it's the right things to do in device_save() device_load(), but it's
working with the patch send two days ago from  Fate <[email protected]>
This only works on ethernet device, for wifi this need a new patch.

---
 src/device.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/src/device.c b/src/device.c
index cd9105d..a65bba4 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1905,6 +1905,18 @@ static int device_load(struct connman_device *device)
        switch (device->mode) {
        case CONNMAN_DEVICE_MODE_UNKNOWN:
        case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
+               str = g_key_file_get_string(keyfile, identifier, "IPv4.Method", 
NULL);
+               if (str != NULL) {
+                       device->element.ipv4.method = 
__connman_ipv4_string2method(str);
+                       g_free(str);
+               }
+               if (device->element.ipv4.method == CONNMAN_IPV4_METHOD_STATIC) {
+                       device->element.ipv4.address = 
g_key_file_get_string(keyfile, identifier, "IPv4.Address", NULL);
+                       device->element.ipv4.netmask = 
g_key_file_get_string(keyfile, identifier, "IPv4.Netmask", NULL);
+                       device->element.ipv4.gateway = 
g_key_file_get_string(keyfile, identifier, "IPv4.Gateway", NULL);
+                       device->element.ipv4.broadcast = 
g_key_file_get_string(keyfile, identifier, "IPv4.Broadcast", NULL);
+                       device->element.ipv4.nameserver = 
g_key_file_get_string(keyfile, identifier, "IPv4.Nameserver", NULL);
+               }
                break;
        case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
        case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
@@ -1961,8 +1973,31 @@ update:
 
        switch (device->mode) {
        case CONNMAN_DEVICE_MODE_UNKNOWN:
+               break;
+
        case CONNMAN_DEVICE_MODE_TRANSPORT_IP:
+               str = __connman_ipv4_method2string(device->element.ipv4.method);
+               if (str != NULL)
+                       g_key_file_set_string(keyfile, identifier, 
"IPv4.Method", str);
+               if (device->element.ipv4.method == CONNMAN_IPV4_METHOD_STATIC) {
+                       str = device->element.ipv4.address;
+                       if (str)
+                               g_key_file_set_string(keyfile, identifier, 
"IPv4.Address", str);
+                       str = device->element.ipv4.netmask;
+                       if (str)
+                               g_key_file_set_string(keyfile, identifier, 
"IPv4.Netmask", str);
+                       str = device->element.ipv4.gateway;
+                       if (str)
+                               g_key_file_set_string(keyfile, identifier, 
"IPv4.Gateway", str);
+                       str = device->element.ipv4.broadcast;
+                       if (str)
+                               g_key_file_set_string(keyfile, identifier, 
"IPv4.Broadcast", str);
+                       str = device->element.ipv4.nameserver;
+                       if (str)
+                               g_key_file_set_string(keyfile, identifier, 
"IPv4.Nameserver", str);
+               }
                break;
+
        case CONNMAN_DEVICE_MODE_NETWORK_SINGLE:
        case CONNMAN_DEVICE_MODE_NETWORK_MULTIPLE:
                if (device->scan_interval > 0)
-- 
1.6.3.1

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

Reply via email to