---
src/connman.h |3 +++
src/service.c | 36
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/src/connman.h b/src/connman.h
index 408b809..e687502 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -552,6 +552,9 @@ void __connman_service_notify(struct connman_service
*service,
int __connman_service_counter_register(const char *counter);
void __connman_service_counter_unregister(const char *counter);
+void __connman_service_set_dhcp_address(struct connman_service *service,
+ const char *address);
+char *__connman_service_get_dhcp_address(struct connman_service *service);
struct connman_session;
struct service_entry;
diff --git a/src/service.c b/src/service.c
index b8f6aac..72e08a7 100644
--- a/src/service.c
+++ b/src/service.c
@@ -108,6 +108,7 @@ struct connman_service {
char **excludes;
char *pac;
connman_bool_t wps;
+ char *last_dynamic_ip_address;
};
static void append_path(gpointer value, gpointer user_data)
@@ -3005,6 +3006,7 @@ static void service_free(gpointer user_data)
g_free(service->private_key_file);
g_free(service->private_key_passphrase);
g_free(service->phase2);
+ g_free(service->last_dynamic_ip_address);
if (service->stats.timer != NULL)
g_timer_destroy(service->stats.timer);
@@ -5003,6 +5005,24 @@ __connman_service_create_from_provider(struct
connman_provider *provider)
return service;
}
+void __connman_service_set_dhcp_address(struct connman_service *service,
+ const char *address)
+{
+ if (service == NULL)
+ return;
+
+ g_free(service->last_dynamic_ip_address);
+ service->last_dynamic_ip_address = g_strdup(address);
+}
+
+char *__connman_service_get_dhcp_address(struct connman_service *service)
+{
+ if (service == NULL)
+ return NULL;
+
+ return g_strdup(service->last_dynamic_ip_address);
+}
+
static int service_load(struct connman_service *service)
{
const char *ident = service->profile;
@@ -5186,6 +5206,13 @@ static int service_load(struct connman_service *service)
service->pac = str;
}
+ str = g_key_file_get_string(keyfile,
+ service->identifier, "DHCP.LastAddress", NULL);
+ if (str != NULL) {
+ g_free(service->last_dynamic_ip_address);
+ service->last_dynamic_ip_address = str;
+ }
+
done:
g_key_file_free(keyfile);
@@ -5366,6 +5393,15 @@ update:
g_key_file_remove_key(keyfile, service->identifier,
"Proxy.URL", NULL);
+ if (service->last_dynamic_ip_address != NULL &&
+ strlen(service->last_dynamic_ip_address) > 0)
+ g_key_file_set_string(keyfile, service->identifier,
+ "DHCP.LastAddress",
+ service->last_dynamic_ip_address);
+ else
+ g_key_file_remove_key(keyfile, service->identifier,
+ "DHCP.LastAddress", NULL);
+
data = g_key_file_to_data(keyfile, &length, NULL);
if (g_file_set_contents(pathname, data, length, NULL) == FALSE)
--
1.7.1
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman