From 4b819888f4556ed4b4633f7f14a9265a2f478896 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 17 Aug 2010 12:42:54 +0200 Subject: Add more debug statements to DHCP library --- gdhcp/client.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gdhcp') diff --git a/gdhcp/client.c b/gdhcp/client.c index a7bd88a5..430ecc86 100644 --- a/gdhcp/client.c +++ b/gdhcp/client.c @@ -600,6 +600,9 @@ static gboolean request_timeout(gpointer user_data) { GDHCPClient *dhcp_client = user_data; + debug(dhcp_client, "request timeout (retries %d)", + dhcp_client->retry_times); + dhcp_client->retry_times++; start_request(dhcp_client); @@ -616,6 +619,9 @@ static int switch_listening_mode(GDHCPClient *dhcp_client, GIOChannel *listener_channel; int listener_sockfd; + debug(dhcp_client, "switch listening mode (%d ==> %d)", + dhcp_client->listen_mode, listen_mode); + if (dhcp_client->listen_mode == listen_mode) return 0; @@ -665,6 +671,9 @@ static int switch_listening_mode(GDHCPClient *dhcp_client, static void start_request(GDHCPClient *dhcp_client) { + debug(dhcp_client, "start request (retries %d)", + dhcp_client->retry_times); + if (dhcp_client->retry_times == REQUEST_RETRIES) { dhcp_client->state = INIT_SELECTING; @@ -710,6 +719,8 @@ static uint32_t get_lease(struct dhcp_packet *packet) static void restart_dhcp(GDHCPClient *dhcp_client, int retry_times) { + debug(dhcp_client, "restart DHCP (retries %d)", retry_times); + if (dhcp_client->timeout > 0) { g_source_remove(dhcp_client->timeout); dhcp_client->timeout = 0; @@ -726,6 +737,8 @@ static gboolean start_rebound_timeout(gpointer user_data) { GDHCPClient *dhcp_client = user_data; + debug(dhcp_client, "start rebound timeout"); + switch_listening_mode(dhcp_client, L2); dhcp_client->lease_seconds >>= 1; @@ -755,6 +768,8 @@ static gboolean start_rebound_timeout(gpointer user_data) static void start_rebound(GDHCPClient *dhcp_client) { + debug(dhcp_client, "start rebound"); + dhcp_client->state = REBINDING; dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH, @@ -768,6 +783,8 @@ static gboolean start_renew_timeout(gpointer user_data) { GDHCPClient *dhcp_client = user_data; + debug(dhcp_client, "start renew timeout"); + dhcp_client->state = RENEWING; dhcp_client->lease_seconds >>= 1; @@ -791,6 +808,8 @@ static gboolean start_renew_timeout(gpointer user_data) static void start_bound(GDHCPClient *dhcp_client) { + debug(dhcp_client, "start bound"); + dhcp_client->state = BOUND; dhcp_client->timeout = g_timeout_add_seconds_full(G_PRIORITY_HIGH, @@ -803,6 +822,8 @@ static gboolean restart_dhcp_timeout(gpointer user_data) { GDHCPClient *dhcp_client = user_data; + debug(dhcp_client, "restart DHCP timeout"); + dhcp_client->ack_retry_times++; restart_dhcp(dhcp_client, dhcp_client->ack_retry_times); -- cgit v1.2.3