summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArron Wang <arron.wang@intel.com>2012-10-12 14:29:29 +0800
committerZhang zhengguang <zhengguang.zhang@intel.com>2013-07-01 11:04:43 +0800
commite151cda8b88a2e3f697180a8d00f02a31e4c3213 (patch)
tree503fe42110abbd436676ea057466c297165e7d2a
parenta5eded6f3a9cff14ab19ee696ce27cedd633cca3 (diff)
downloadconnman-e151cda8b88a2e3f697180a8d00f02a31e4c3213.tar.gz
connman-e151cda8b88a2e3f697180a8d00f02a31e4c3213.tar.bz2
connman-e151cda8b88a2e3f697180a8d00f02a31e4c3213.zip
Tizen: Add last known address in DHCP discovery request
-rw-r--r--gdhcp/client.c51
-rw-r--r--gdhcp/gdhcp.h4
-rw-r--r--src/dhcp.c12
3 files changed, 67 insertions, 0 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index a41e1678..c64d7130 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -149,6 +149,9 @@ struct _GDHCPClient {
time_t expire;
gboolean retransmit;
struct timeval start_time;
+#if defined TIZEN_EXT
+ gboolean init_reboot;
+#endif
};
static inline void debug(GDHCPClient *client, const char *format, ...)
@@ -436,6 +439,9 @@ static int send_select(GDHCPClient *dhcp_client)
dhcp_add_option_uint32(&packet, DHCP_REQUESTED_IP,
dhcp_client->requested_ip);
+#if defined TIZEN_EXT
+ if (dhcp_client->init_reboot != TRUE)
+#endif
dhcp_add_option_uint32(&packet, DHCP_SERVER_ID,
dhcp_client->server_ip);
@@ -1322,6 +1328,21 @@ static gboolean request_timeout(gpointer user_data)
{
GDHCPClient *dhcp_client = user_data;
+#if defined TIZEN_EXT
+ if (dhcp_client->init_reboot == TRUE) {
+ debug(dhcp_client, "DHCPREQUEST of INIT-REBOOT has failed");
+
+ /* Start DHCPDISCOVERY when DHCPREQUEST of INIT-REBOOT has failed */
+ g_dhcp_client_set_address_known(dhcp_client, FALSE);
+
+ dhcp_client->retry_times = 0;
+ dhcp_client->requested_ip = 0;
+
+ g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
+
+ return FALSE;
+ }
+#endif
debug(dhcp_client, "request timeout (retries %d)",
dhcp_client->retry_times);
@@ -2041,6 +2062,9 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
dhcp_client->lease_seconds = get_lease(&packet);
+#if defined TIZEN_EXT
+ debug(dhcp_client, "lease %d secs", dhcp_client->lease_seconds);
+#endif
get_request(dhcp_client, &packet);
switch_listening_mode(dhcp_client, L_NONE);
@@ -2060,6 +2084,9 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
if (dhcp_client->timeout > 0)
g_source_remove(dhcp_client->timeout);
+#if defined TIZEN_EXT
+ g_dhcp_client_set_address_known(dhcp_client, FALSE);
+#endif
dhcp_client->timeout = g_timeout_add_seconds_full(
G_PRIORITY_HIGH, 3,
restart_dhcp_timeout,
@@ -2410,6 +2437,15 @@ int g_dhcp_client_start(GDHCPClient *dhcp_client, const char *last_address)
dhcp_client->last_address = g_strdup(last_address);
}
}
+#if defined TIZEN_EXT
+ if (dhcp_client->init_reboot == TRUE) {
+ dhcp_client->requested_ip = addr;
+
+ start_request(dhcp_client);
+
+ return 0;
+ }
+#endif
send_discover(dhcp_client, addr);
dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH,
@@ -2789,3 +2825,18 @@ void g_dhcp_client_set_debug(GDHCPClient *dhcp_client,
dhcp_client->debug_func = func;
dhcp_client->debug_data = user_data;
}
+#if defined TIZEN_EXT
+void g_dhcp_client_set_address_known(GDHCPClient *dhcp_client, gboolean known)
+{
+ /* DHCPREQUEST during INIT-REBOOT state (rfc2131)
+ * 4.4.3 Initialization with known network address
+ * 4.3.2 DHCPREQUEST generated during INIT-REBOOT state
+ */
+ debug(dhcp_client, "known network address (%d)", known);
+
+ if (dhcp_client->init_reboot == known)
+ return;
+
+ dhcp_client->init_reboot = known;
+}
+#endif
diff --git a/gdhcp/gdhcp.h b/gdhcp/gdhcp.h
index ba47eaff..71431f5a 100644
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -197,6 +197,10 @@ void g_dhcp_server_set_lease_time(GDHCPServer *dhcp_server,
unsigned int lease_time);
void g_dhcp_server_set_save_lease(GDHCPServer *dhcp_server,
GDHCPSaveLeaseFunc func, gpointer user_data);
+#if defined TIZEN_EXT
+void g_dhcp_client_set_address_known(GDHCPClient *client, gboolean known);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/src/dhcp.c b/src/dhcp.c
index c5c14a8a..028035cf 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -412,6 +412,9 @@ static int dhcp_request(struct connman_dhcp *dhcp)
GDHCPClientError error;
const char *hostname;
int index;
+#if defined TIZEN_EXT
+ const char *last_address;
+#endif
DBG("dhcp %p", dhcp);
@@ -460,6 +463,14 @@ static int dhcp_request(struct connman_dhcp *dhcp)
service = connman_service_lookup_from_network(dhcp->network);
ipconfig = __connman_service_get_ip4config(service);
+#if defined TIZEN_EXT
+ last_address = __connman_ipconfig_get_dhcp_address(ipconfig);
+
+ if (last_address != NULL && strlen(last_address) > 0)
+ g_dhcp_client_set_address_known(dhcp_client, TRUE);
+
+ return g_dhcp_client_start(dhcp_client, last_address);
+#else
/*
* Clear the addresses at startup so that lease callback will
* take the lease and set ip address properly.
@@ -468,6 +479,7 @@ static int dhcp_request(struct connman_dhcp *dhcp)
return g_dhcp_client_start(dhcp_client,
__connman_ipconfig_get_dhcp_address(ipconfig));
+#endif
}
static int dhcp_release(struct connman_dhcp *dhcp)