This fix sends the DHCP_REQUESTED_IP option to server.

Fixes BMC #21068
---
 src/dhcp.c |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 20fc599..0f93b95 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -42,6 +42,7 @@ struct connman_dhcp {
        char **nameservers;
        char *timeserver;
        char *pac;
+       char *last_address;
 
        GDHCPClient *dhcp_client;
 };
@@ -53,10 +54,12 @@ static void dhcp_free(struct connman_dhcp *dhcp)
        g_strfreev(dhcp->nameservers);
        g_free(dhcp->timeserver);
        g_free(dhcp->pac);
+       g_free(dhcp->last_address);
 
        dhcp->nameservers = NULL;
        dhcp->timeserver = NULL;
        dhcp->pac = NULL;
+       dhcp->last_address = NULL;
 }
 
 /**
@@ -103,6 +106,10 @@ static void dhcp_invalidate(struct connman_dhcp *dhcp, 
connman_bool_t callback)
                }
        }
 
+       __connman_service_set_dhcp_address(service, dhcp->last_address);
+
+       DBG("last address %s", dhcp->last_address);
+
        __connman_ipconfig_address_remove(ipconfig);
 
        __connman_ipconfig_set_local(ipconfig, NULL);
@@ -204,6 +211,12 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
        address = g_dhcp_client_get_address(dhcp_client);
 
+       g_free(dhcp->last_address);
+       dhcp->last_address = g_strdup(address);
+       __connman_service_set_dhcp_address(service, dhcp->last_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);
@@ -409,7 +422,7 @@ static int dhcp_request(struct connman_dhcp *dhcp)
 
        dhcp->dhcp_client = dhcp_client;
 
-       return g_dhcp_client_start(dhcp_client);
+       return g_dhcp_client_start(dhcp_client, dhcp->last_address);
 }
 
 static int dhcp_release(struct connman_dhcp *dhcp)
@@ -442,6 +455,7 @@ static void remove_network(gpointer user_data)
 int __connman_dhcp_start(struct connman_network *network, dhcp_cb callback)
 {
        struct connman_dhcp *dhcp;
+       struct connman_service *service;
 
        DBG("");
 
@@ -452,6 +466,11 @@ int __connman_dhcp_start(struct connman_network *network, 
dhcp_cb callback)
        dhcp->network = network;
        dhcp->callback = callback;
 
+       service = __connman_service_lookup_from_network(network);
+       dhcp->last_address = __connman_service_get_dhcp_address(service);
+
+       DBG("last address %s", dhcp->last_address);
+
        g_hash_table_replace(network_table, network, dhcp);
 
        return dhcp_request(dhcp);
-- 
1.7.1

_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to