In g_dhcp_client_start, DHCP discovery is skipped and do start_request when
dhcp server address provided
---
gdhcp/client.c | 20 +++++++++++++++++---
gdhcp/gdhcp.h | 3 ++-
src/dhcp.c | 3 ++-
src/dhcpv6.c | 22 +++++++++++-----------
tools/dhcp-test.c | 2 +-
5 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 05e425c..3e498a6 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -1365,7 +1365,8 @@ static void restart_dhcp(GDHCPClient *dhcp_client, int
retry_times)
dhcp_client->state = INIT_SELECTING;
switch_listening_mode(dhcp_client, L2);
- g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
+ g_dhcp_client_start(dhcp_client, dhcp_client->last_address,
+ dhcp_client->last_server_address);
}
static gboolean start_rebound_timeout(gpointer user_data)
@@ -2116,7 +2117,7 @@ static gboolean discover_timeout(gpointer user_data)
* if the server is non-authoritative it will ignore the request if
the
* option is present.
*/
- g_dhcp_client_start(dhcp_client, NULL);
+ g_dhcp_client_start(dhcp_client, NULL, NULL);
return FALSE;
}
@@ -2182,7 +2183,8 @@ static gboolean ipv4ll_probe_timeout(gpointer
dhcp_data)
return FALSE;
}
-int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address)
+int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address,
+ const char *last_server_address)
{
int re;
uint32_t addr;
@@ -2281,6 +2283,18 @@ int g_dhcp_client_start(GDHCPClient *dhcp_client,
const char *last_address)
dhcp_client->last_address = g_strdup(last_address);
}
}
+
+ if (last_server_address != NULL && strlen(last_server_address) > 0)
{
+ dhcp_client->last_server_address =
+ g_strdup(last_server_address);
+ dhcp_client->server_ip = inet_addr(last_server_address);
+ dhcp_client->requested_ip = addr;
+
+ start_request(dhcp_client);
+
+ return 0;
+ }
+
send_discover(dhcp_client, addr);
dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index d531b5d..4478362 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -107,7 +107,8 @@ typedef void (*GDHCPDebugFunc)(const char *str, gpointer
user_data);
GDHCPClient *g_dhcp_client_new(GDHCPType type, int index,
GDHCPClientError *error);
-int g_dhcp_client_start(GDHCPClient *client, const char *last_address);
+int g_dhcp_client_start(GDHCPClient *client, const char *last_address,
+ const char *last_server_address);
void g_dhcp_client_stop(GDHCPClient *client);
GDHCPClient *g_dhcp_client_ref(GDHCPClient *client);
diff --git a/src/dhcp.c b/src/dhcp.c
index fa2a408..e5627eb 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -455,7 +455,8 @@ static int dhcp_request(struct connman_dhcp *dhcp)
ipconfig = __connman_service_get_ip4config(service);
return g_dhcp_client_start(dhcp_client,
-
__connman_ipconfig_get_dhcp_address(ipconfig));
+ __connman_ipconfig_get_dhcp_address(ipconfig),
+
__connman_ipconfig_get_dhcp_server_address(ipconfig));
}
static int dhcp_release(struct connman_dhcp *dhcp)
diff --git a/src/dhcpv6.c b/src/dhcpv6.c
index 574b19e..5f6b5c3 100644
--- a/src/dhcpv6.c
+++ b/src/dhcpv6.c
@@ -379,7 +379,7 @@ static int dhcpv6_info_request(struct connman_dhcpv6
*dhcp)
dhcp->dhcp_client = dhcp_client;
- return g_dhcp_client_start(dhcp_client, NULL);
+ return g_dhcp_client_start(dhcp_client, NULL, NULL);
}
static int check_ipv6_addr_prefix(GSList *prefixes, char *address)
@@ -603,7 +603,7 @@ static int dhcpv6_rebind(struct connman_dhcpv6 *dhcp)
dhcp->dhcp_client = dhcp_client;
- return g_dhcp_client_start(dhcp_client, NULL);
+ return g_dhcp_client_start(dhcp_client, NULL, NULL);
}
static gboolean dhcpv6_restart(gpointer user_data)
@@ -652,7 +652,7 @@ static gboolean timeout_rebind(gpointer user_data)
dhcp->timeout = g_timeout_add(dhcp->RT, timeout_rebind, dhcp);
- g_dhcp_client_start(dhcp->dhcp_client, NULL);
+ g_dhcp_client_start(dhcp->dhcp_client, NULL, NULL);
return FALSE;
}
@@ -712,7 +712,7 @@ static int dhcpv6_request(struct connman_dhcpv6 *dhcp,
dhcp->dhcp_client = dhcp_client;
- return g_dhcp_client_start(dhcp_client, NULL);
+ return g_dhcp_client_start(dhcp_client, NULL, NULL);
}
static gboolean timeout_request(gpointer user_data)
@@ -733,7 +733,7 @@ static gboolean timeout_request(gpointer user_data)
DBG("request RT timeout %d msec", dhcp->RT);
dhcp->timeout = g_timeout_add(dhcp->RT, timeout_request, dhcp);
- g_dhcp_client_start(dhcp->dhcp_client, NULL);
+ g_dhcp_client_start(dhcp->dhcp_client, NULL, NULL);
return FALSE;
}
@@ -779,7 +779,7 @@ static int dhcpv6_renew(struct connman_dhcpv6 *dhcp)
dhcp->dhcp_client = dhcp_client;
- return g_dhcp_client_start(dhcp_client, NULL);
+ return g_dhcp_client_start(dhcp_client, NULL, NULL);
}
static gboolean timeout_renew(gpointer user_data)
@@ -795,7 +795,7 @@ static gboolean timeout_renew(gpointer user_data)
dhcp->timeout = g_timeout_add(dhcp->RT, timeout_renew, dhcp);
- g_dhcp_client_start(dhcp->dhcp_client, NULL);
+ g_dhcp_client_start(dhcp->dhcp_client, NULL, NULL);
return FALSE;
}
@@ -936,7 +936,7 @@ int __connman_dhcpv6_start_release(struct
connman_network *network,
dhcp->dhcp_client = dhcp_client;
- return g_dhcp_client_start(dhcp_client, NULL);
+ return g_dhcp_client_start(dhcp_client, NULL, NULL);
}
static int dhcpv6_release(struct connman_dhcpv6 *dhcp)
@@ -979,7 +979,7 @@ static gboolean timeout_info_req(gpointer user_data)
dhcp->timeout = g_timeout_add(dhcp->RT, timeout_info_req, dhcp);
- g_dhcp_client_start(dhcp->dhcp_client, NULL);
+ g_dhcp_client_start(dhcp->dhcp_client, NULL, NULL);
return FALSE;
}
@@ -1082,7 +1082,7 @@ static gboolean timeout_solicitation(gpointer
user_data)
dhcp->timeout = g_timeout_add(dhcp->RT, timeout_solicitation, dhcp);
- g_dhcp_client_start(dhcp->dhcp_client, NULL);
+ g_dhcp_client_start(dhcp->dhcp_client, NULL, NULL);
return FALSE;
}
@@ -1149,7 +1149,7 @@ static int dhcpv6_solicitation(struct connman_dhcpv6
*dhcp)
dhcp->dhcp_client = dhcp_client;
- return g_dhcp_client_start(dhcp_client, NULL);
+ return g_dhcp_client_start(dhcp_client, NULL, NULL);
}
static gboolean start_solicitation(gpointer user_data)
diff --git a/tools/dhcp-test.c b/tools/dhcp-test.c
index 284656b..c2a1ebd 100644
--- a/tools/dhcp-test.c
+++ b/tools/dhcp-test.c
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
timer = g_timer_new();
- g_dhcp_client_start(dhcp_client, NULL);
+ g_dhcp_client_start(dhcp_client, NULL, NULL);
memset(&sa, 0, sizeof(sa));
sa.sa_handler = sig_term;
--
1.7.9.5
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman