gdhcp: Set client state to INIT_SELECTING on restart
[platform/upstream/connman.git] / gdhcp / client.c
index a51857f..cf04ced 100644 (file)
@@ -1361,6 +1361,7 @@ static void restart_dhcp(GDHCPClient *dhcp_client, int retry_times)
 
        dhcp_client->retry_times = retry_times;
        dhcp_client->requested_ip = 0;
+       dhcp_client->state = INIT_SELECTING;
        switch_listening_mode(dhcp_client, L2);
 
        g_dhcp_client_start(dhcp_client, dhcp_client->last_address);
@@ -1665,7 +1666,7 @@ static GList *get_addresses(GDHCPClient *dhcp_client,
 
        if (addr_count > 0 && st == 0) {
                /* We only support one address atm */
-               char str[INET6_ADDRSTRLEN + 1];
+               char addr_str[INET6_ADDRSTRLEN + 1];
 
                if (preferred > valid)
                        /* RFC 3315, 22.6 */
@@ -1674,11 +1675,11 @@ static GList *get_addresses(GDHCPClient *dhcp_client,
                dhcp_client->T1 = T1;
                dhcp_client->T2 = T2;
 
-               inet_ntop(AF_INET6, &addr, str, INET6_ADDRSTRLEN);
+               inet_ntop(AF_INET6, &addr, addr_str, INET6_ADDRSTRLEN);
                debug(dhcp_client, "count %d addr %s T1 %u T2 %u",
-                       addr_count, str, T1, T2);
+                       addr_count, addr_str, T1, T2);
 
-               list = g_list_append(list, g_strdup(str));
+               list = g_list_append(list, g_strdup(addr_str));
 
                if (code == G_DHCPV6_IA_NA)
                        memcpy(&dhcp_client->ia_na, &addr,
@@ -1865,6 +1866,9 @@ static gboolean listener_event(GIOChannel *channel, GIOCondition condition,
                return TRUE;
 
        if (dhcp_client->type == G_DHCP_IPV6) {
+               if (packet6 == NULL)
+                       return TRUE;
+
                count = 0;
                client_id = dhcpv6_get_option(packet6, pkt_len,
                                G_DHCPV6_CLIENTID, &option_len, &count);