gpointer address_conflict_data;
GDHCPDebugFunc debug_func;
gpointer debug_data;
+ char *last_address;
};
static inline void debug(GDHCPClient *client, const char *format, ...)
dhcp_client->requested_ip = 0;
switch_listening_mode(dhcp_client, L2);
- g_dhcp_client_start(dhcp_client);
+ g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
}
static gboolean start_rebound_timeout(gpointer user_data)
dhcp_client->retry_times++;
- g_dhcp_client_start(dhcp_client);
+ /*
+ * We do not send the REQUESTED IP option if we are retrying because
+ * if the server is non-authoritative it will ignore the request if the
+ * option is present.
+ */
+ g_dhcp_client_start(dhcp_client, NULL);
return FALSE;
}
return FALSE;
}
-int g_dhcp_client_start(GDHCPClient *dhcp_client)
+int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address)
{
int re;
+ uint32_t addr;
if (dhcp_client->retry_times == DISCOVER_RETRIES) {
ipv4ll_start(dhcp_client);
dhcp_client->xid = rand();
}
- send_discover(dhcp_client, 0);
+ if (last_address == NULL) {
+ addr = 0;
+ } else {
+ addr = inet_addr(last_address);
+ if (addr == 0xFFFFFFFF) {
+ addr = 0;
+ } else {
+ g_free(dhcp_client->last_address);
+ dhcp_client->last_address = g_strdup(last_address);
+ }
+ }
+ send_discover(dhcp_client, addr);
dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
DISCOVER_TIMEOUT,
g_free(dhcp_client->interface);
g_free(dhcp_client->assigned_ip);
+ g_free(dhcp_client->last_address);
g_list_free(dhcp_client->request_list);
g_list_free(dhcp_client->require_list);
GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
GDHCPClientError *error);
-int g_dhcp_client_start(GDHCPClient *client);
+int g_dhcp_client_start(GDHCPClient *client, const char *last_address);
void g_dhcp_client_stop(GDHCPClient *client);
GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
}
}
+ __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);
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);
static int dhcp_request(struct connman_dhcp *dhcp)
{
+ struct connman_service *service;
+ struct connman_ipconfig *ipconfig;
GDHCPClient *dhcp_client;
GDHCPClientError error;
const char *hostname;
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)
timer = g_timer_new();
- g_dhcp_client_start(dhcp_client);
+ g_dhcp_client_start(dhcp_client, NULL);
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sig_term;