From: Daniel Wagner <[email protected]>
---
Hi,
It seems we having the same problems for internal project. In our
case the router starts slower than the embedded board. ConnMan
falls back to IPv4LL because the router does not answer the DHCP request.
This patch here is completely untested but I think you get the idea :)
cheers,
daniel
src/dhcp.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/dhcp.c b/src/dhcp.c
index f32bfae..c84e67c 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -45,6 +45,8 @@ struct connman_dhcp {
char *pac;
GDHCPClient *dhcp_client;
+
+ int timeout;
};
static GHashTable *network_table;
@@ -198,6 +200,11 @@ static void lease_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
DBG("Lease available");
+ if (dhcp->timeout > 0) {
+ g_source_remove(dhcp->timeout);
+ dhcp->timeout = 0;
+ }
+
service = connman_service_lookup_from_network(dhcp->network);
if (service == NULL) {
connman_error("Can not lookup service");
@@ -354,6 +361,22 @@ static void lease_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
g_free(hostname);
}
+static int dhcp_request(struct connman_dhcp *dhcp);
+
+static gboolean dhcp_retry(gpointer user_data)
+{
+ struct connman_dhcp *dhcp = user_data;
+
+ dhcp_request(dhcp);
+
+ return TRUE;
+}
+
+static void dhcp_request_retry_start(struct connman_dhcp *dhcp)
+{
+ dhcp->timeout = g_timeout_add_seconds(5, dhcp_retry, dhcp);
+}
+
static void ipv4ll_available_cb(GDHCPClient *dhcp_client, gpointer user_data)
{
struct connman_dhcp *dhcp = user_data;
@@ -386,6 +409,8 @@ static void ipv4ll_available_cb(GDHCPClient *dhcp_client,
gpointer user_data)
g_free(address);
g_free(netmask);
+
+ dhcp_request_retry_start(dhcp);
}
static void dhcp_debug(const char *str, void *data)
@@ -466,6 +491,11 @@ static int dhcp_release(struct connman_dhcp *dhcp)
if (dhcp->dhcp_client == NULL)
return 0;
+ if (dhcp->timeout > 0) {
+ g_source_remove(dhcp->timeout);
+ dhcp->timeout = 0;
+ }
+
g_dhcp_client_stop(dhcp->dhcp_client);
g_dhcp_client_unref(dhcp->dhcp_client);
--
1.8.2.rc3.16.gce432ca
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman