From 9b44548e78c312d3fb25fd06b43ed2fe6c762f4c Mon Sep 17 00:00:00 2001
From: Luc Saillard <luc@saillard.org>
Date: Wed, 24 Jun 2009 19:20:28 +0200
Subject: [PATCH 2/2] Allow loading/saving ipv4 configuration for device

---
 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

