summaryrefslogtreecommitdiff
path: root/gdhcp
diff options
context:
space:
mode:
authorNiraj Kumar Goit <niraj.g@samsung.com>2016-06-10 17:47:15 +0530
committerNiraj Kumar Goit <niraj.g@samsung.com>2016-06-10 21:37:36 +0530
commit1a1a27626501580e4d6e0490cdd1bd39653a753e (patch)
tree5c86d5a5b90659dd6a207fdc0474778b041b6adf /gdhcp
parent0c5ab2959c0a22bbc2843d9c8c4a4c2e8040c3ad (diff)
downloadconnman-1a1a27626501580e4d6e0490cdd1bd39653a753e.tar.gz
connman-1a1a27626501580e4d6e0490cdd1bd39653a753e.tar.bz2
connman-1a1a27626501580e4d6e0490cdd1bd39653a753e.zip
[SPIN] Restart dhcp as soon as INIT-REBOOT has been failed
desc: Start DHCPDISCOVERY when DHCPREQUEST of INIT-REBOOT has failed. Change-Id: I7c6de8a3b397765cd0173a5b18c0c926a5ce29a4 Signed-off-by: Niraj Kumar Goit <niraj.g@samsung.com>
Diffstat (limited to 'gdhcp')
-rwxr-xr-xgdhcp/client.c49
-rwxr-xr-xgdhcp/gdhcp.h4
2 files changed, 53 insertions, 0 deletions
diff --git a/gdhcp/client.c b/gdhcp/client.c
index 2c442e59..9b2de9db 100755
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -156,6 +156,9 @@ struct _GDHCPClient {
bool retransmit;
struct timeval start_time;
bool request_bcast;
+#if defined TIZEN_EXT
+ gboolean init_reboot;
+#endif
};
static inline void debug(GDHCPClient *client, const char *format, ...)
@@ -480,6 +483,9 @@ static int send_request(GDHCPClient *dhcp_client)
init_packet(dhcp_client, &packet, DHCPREQUEST);
packet.xid = dhcp_client->xid;
+#if defined TIZEN_EXT
+ if (dhcp_client->init_reboot != TRUE)
+#endif
packet.secs = dhcp_attempt_secs(dhcp_client);
if (dhcp_client->state == REQUESTING || dhcp_client->state == REBOOTING)
@@ -1513,6 +1519,21 @@ static gboolean request_timeout(gpointer user_data)
{
GDHCPClient *dhcp_client = user_data;
+#if defined TIZEN_EXT
+ if (dhcp_client->init_reboot) {
+ 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);
@@ -2362,6 +2383,18 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
remove_timeouts(dhcp_client);
+#if defined TIZEN_EXT
+ if (dhcp_client->init_reboot) {
+ g_dhcp_client_set_address_known(dhcp_client, FALSE);
+ dhcp_client->timeout = g_idle_add_full(
+ G_PRIORITY_HIGH,
+ restart_dhcp_timeout,
+ dhcp_client,
+ NULL);
+
+ break;
+ }
+#endif
dhcp_client->timeout = g_timeout_add_seconds_full(
G_PRIORITY_HIGH, 3,
restart_dhcp_timeout,
@@ -3205,3 +3238,19 @@ GSList *g_dhcpv6_copy_prefixes(GSList *prefixes)
return copy;
}
+
+#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 22fa9f4b..59b562bf 100755
--- a/gdhcp/gdhcp.h
+++ b/gdhcp/gdhcp.h
@@ -238,6 +238,10 @@ void g_dhcp_server_set_save_ack_lease(GDHCPServer *dhcp_server,
int dhcp_get_random(uint64_t *val);
void dhcp_cleanup_random(void);
+#if defined TIZEN_EXT
+void g_dhcp_client_set_address_known(GDHCPClient *client, gboolean known);
+#endif
+
#ifdef __cplusplus
}
#endif