From 5b875e36444979b36170cf7074fb3e0f5b970a3e Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 28 Jul 2011 13:20:28 +0300 Subject: dhcp: Try to reuse the IP address we had last time. This fix will cause the DHCP_REQUESTED_IP option to be sent to the server. Fixes BMC #21068 --- src/dhcp.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/dhcp.c') diff --git a/src/dhcp.c b/src/dhcp.c index 39f4eeb5..10e14031 100644 --- a/src/dhcp.c +++ b/src/dhcp.c @@ -103,6 +103,10 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, connman_bool_t callback) } } + __connman_ipconfig_set_dhcp_address(ipconfig, + __connman_ipconfig_get_local(ipconfig)); + DBG("last address %s", __connman_ipconfig_get_dhcp_address(ipconfig)); + __connman_ipconfig_address_remove(ipconfig); __connman_ipconfig_set_local(ipconfig, NULL); @@ -205,6 +209,9 @@ static void lease_available_cb(GDHCPClient *dhcp_client, gpointer user_data) address = g_dhcp_client_get_address(dhcp_client); + __connman_ipconfig_set_dhcp_address(ipconfig, address); + DBG("last address %s", address); + option = g_dhcp_client_get_option(dhcp_client, G_DHCP_SUBNET); if (option != NULL) netmask = g_strdup(option->data); @@ -365,6 +372,8 @@ static void dhcp_debug(const char *str, void *data) static int dhcp_request(struct connman_dhcp *dhcp) { + struct connman_service *service; + struct connman_ipconfig *ipconfig; GDHCPClient *dhcp_client; GDHCPClientError error; const char *hostname; @@ -412,7 +421,11 @@ static int dhcp_request(struct connman_dhcp *dhcp) dhcp->dhcp_client = dhcp_client; - return g_dhcp_client_start(dhcp_client); + service = __connman_service_lookup_from_network(dhcp->network); + ipconfig = __connman_service_get_ip4config(service); + + return g_dhcp_client_start(dhcp_client, + __connman_ipconfig_get_dhcp_address(ipconfig)); } static int dhcp_release(struct connman_dhcp *dhcp) -- cgit v1.2.3