static sd_dhcp_client *client_stop(sd_dhcp_client *client, int error) {
assert_return(client, NULL);
- log_dhcp_client(client, "STOPPED %d", error);
+ log_dhcp_client(client, "STOPPED: %s", strerror(-error));
client = client_notify(client, error);
if (r < 0)
return r;
- log_dhcp_client(client, "REQUEST");
+ switch (client->state) {
+ case DHCP_STATE_REQUESTING:
+ log_dhcp_client(client, "REQUEST (requesting)");
+ break;
+ case DHCP_STATE_INIT_REBOOT:
+ log_dhcp_client(client, "REQUEST (init-reboot)");
+ break;
+ case DHCP_STATE_RENEWING:
+ log_dhcp_client(client, "REQUEST (renewing)");
+ break;
+ case DHCP_STATE_REBINDING:
+ log_dhcp_client(client, "REQUEST (rebinding)");
+ break;
+ default:
+ log_dhcp_client(client, "REQUEST (invalid)");
+ break;
+ }
return 0;
}
if (r < 0)
goto error;
- return client_start(client);
-
- break;
+ r = client_start(client);
+ if (r < 0)
+ goto error;
+ else {
+ log_dhcp_client(client, "REBOOTED");
+ return 0;
+ }
case DHCP_STATE_INIT:
case DHCP_STATE_INIT_REBOOT:
client->secs = 0;
}
- log_dhcp_client(client, "STARTED");
-
return client_initialize_events(client, client_receive_message_raw);
}
r = client_start(client);
if (r < 0)
goto error;
+
+ log_dhcp_client(client, "REBOOTED");
}
goto error;
if (client->last_addr)
client->state = DHCP_STATE_INIT_REBOOT;
- return client_start(client);
+ r = client_start(client);
+ if (r >= 0)
+ log_dhcp_client(client, "STARTED");
+
+ return r;
}
int sd_dhcp_client_stop(sd_dhcp_client *client) {