summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Xu <martin.xu@intel.com>2010-02-09 10:29:55 +0100
committerMarcel Holtmann <marcel@holtmann.org>2010-02-11 05:31:34 +0100
commite78dd7a43a9484882ff4edb3cbd89a0e56f9f63e (patch)
tree914ba6bf09d7c44b6b98701ecceb235cecddac22
parentb78879268663e2d98851d62588c172a776354ceb (diff)
downloadconnman-e78dd7a43a9484882ff4edb3cbd89a0e56f9f63e.tar.gz
connman-e78dd7a43a9484882ff4edb3cbd89a0e56f9f63e.tar.bz2
connman-e78dd7a43a9484882ff4edb3cbd89a0e56f9f63e.zip
Load and save ipconfig settings
-rw-r--r--src/ipconfig.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 5d626e2f..9e1dbf48 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -1231,16 +1231,76 @@ void __connman_ipconfig_append_ethernet(struct connman_ipconfig *ipconfig,
int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix)
{
+ const char *method;
+ char *key;
+
DBG("ipconfig %p identifier %s", ipconfig, identifier);
+ key = g_strdup_printf("%smethod", prefix);
+ method = g_key_file_get_string(keyfile, identifier, key, NULL);
+ ipconfig->method = __connman_ipconfig_string2method(method);
+ g_free(key);
+
+ key = g_strdup_printf("%snetmask_prefixlen", prefix);
+ ipconfig->address->prefixlen = g_key_file_get_integer(
+ keyfile, identifier, key, NULL);
+ g_free(key);
+
+ key = g_strdup_printf("%slocal_address", prefix);
+ ipconfig->address->local = g_key_file_get_string(
+ keyfile, identifier, key, NULL);
+ g_free(key);
+
+ key = g_strdup_printf("%speer_address", prefix);
+ ipconfig->address->peer = g_key_file_get_string(
+ keyfile, identifier, key, NULL);
+ g_free(key);
+
+ key = g_strdup_printf("%sbroadcast_address", prefix);
+ ipconfig->address->broadcast = g_key_file_get_string(
+ keyfile, identifier, key, NULL);
+ g_free(key);
+
return 0;
}
int __connman_ipconfig_save(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char *prefix)
{
+ const char *method;
+ char *key;
+
DBG("ipconfig %p identifier %s", ipconfig, identifier);
+ method = __connman_ipconfig_method2string(ipconfig->method);
+
+ key = g_strdup_printf("%smethod", prefix);
+ g_key_file_set_string(keyfile, identifier, key, method);
+ g_free(key);
+
+ key = g_strdup_printf("%snetmask_prefixlen", prefix);
+ g_key_file_set_integer(keyfile, identifier,
+ key, ipconfig->address->prefixlen);
+ g_free(key);
+
+ key = g_strdup_printf("%slocal_address", prefix);
+ if (ipconfig->address->local != NULL)
+ g_key_file_set_string(keyfile, identifier,
+ key, ipconfig->address->local);
+ g_free(key);
+
+ key = g_strdup_printf("%speer_address", prefix);
+ if (ipconfig->address->peer != NULL)
+ g_key_file_set_string(keyfile, identifier,
+ key, ipconfig->address->peer);
+ g_free(key);
+
+ key = g_strdup_printf("%sbroadcast_address", prefix);
+ if (ipconfig->address->broadcast != NULL)
+ g_key_file_set_string(keyfile, identifier,
+ "broadcast_address", ipconfig->address->broadcast);
+ g_free(key);
+
return 0;
}