Add last dhcp server address in connman_ipconfig, and with
ipconfig_load/save
---
src/connman.h | 3 +++
src/ipconfig.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/connman.h b/src/connman.h
index 6726078..c865f65 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -350,6 +350,9 @@ const char
*__connman_ipconfig_get_proxy_autoconfig(struct connman_ipconfig *ipc
void __connman_ipconfig_set_dhcp_address(struct connman_ipconfig *ipconfig,
const char *address);
char *__connman_ipconfig_get_dhcp_address(struct connman_ipconfig
*ipconfig);
+void __connman_ipconfig_set_dhcp_server_address(struct connman_ipconfig
*ipconfig,
+ const char *address);
+char *__connman_ipconfig_get_dhcp_server_address(struct connman_ipconfig
*ipconfig);
int __connman_ipconfig_load(struct connman_ipconfig *ipconfig,
GKeyFile *keyfile, const char *identifier, const char
*prefix);
diff --git a/src/ipconfig.c b/src/ipconfig.c
index 5e34ac0..7dd9c0e 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -56,6 +56,7 @@ struct connman_ipconfig {
int ipv6_privacy_config;
char *last_dhcp_address;
+ char *last_dhcp_server_address;
};
struct connman_ipdevice {
@@ -1367,6 +1368,7 @@ void __connman_ipconfig_unref_debug(struct
connman_ipconfig *ipconfig,
connman_ipaddress_free(ipconfig->system);
connman_ipaddress_free(ipconfig->address);
g_free(ipconfig->last_dhcp_address);
+ g_free(ipconfig->last_dhcp_server_address);
g_free(ipconfig);
}
@@ -1616,6 +1618,24 @@ char *__connman_ipconfig_get_dhcp_address(struct
connman_ipconfig *ipconfig)
return ipconfig->last_dhcp_address;
}
+void __connman_ipconfig_set_dhcp_server_address(struct connman_ipconfig
*ipconfig,
+ const char *address)
+{
+ if (ipconfig == NULL)
+ return;
+
+ g_free(ipconfig->last_dhcp_server_address);
+ ipconfig->last_dhcp_server_address = g_strdup(address);
+}
+
+char *__connman_ipconfig_get_dhcp_server_address(struct connman_ipconfig
*ipconfig)
+{
+ if (ipconfig == NULL)
+ return NULL;
+
+ return ipconfig->last_dhcp_server_address;
+}
+
static void disable_ipv6(struct connman_ipconfig *ipconfig)
{
struct connman_ipdevice *ipdevice;
@@ -2298,6 +2318,14 @@ int __connman_ipconfig_load(struct connman_ipconfig
*ipconfig,
}
g_free(key);
+ key = g_strdup_printf("%sDHCP.LastServerAddress", prefix);
+ str = g_key_file_get_string(keyfile, identifier, key, NULL);
+ if (str != NULL) {
+ g_free(ipconfig->last_dhcp_server_address);
+ ipconfig->last_dhcp_server_address = str;
+ }
+ g_free(key);
+
return 0;
}
@@ -2336,6 +2364,16 @@ int __connman_ipconfig_save(struct connman_ipconfig
*ipconfig,
else
g_key_file_remove_key(keyfile, identifier, key,
NULL);
g_free(key);
+
+ key = g_strdup_printf("%sDHCP.LastServerAddress", prefix);
+ if (ipconfig->last_dhcp_server_address != NULL &&
+ strlen(ipconfig->last_dhcp_server_address) >
0)
+ g_key_file_set_string(keyfile, identifier, key,
+ ipconfig->last_dhcp_server_address);
+ else
+ g_key_file_remove_key(keyfile, identifier, key,
NULL);
+ g_free(key);
+
/* fall through */
case CONNMAN_IPCONFIG_METHOD_UNKNOWN:
case CONNMAN_IPCONFIG_METHOD_OFF:
--
1.7.9.5
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman