Use explicit error for timeout

This commit is contained in:
Baptiste Wicht 2016-09-08 12:17:32 +02:00
parent ebbc9e63cd
commit 026406da50
2 changed files with 6 additions and 1 deletions

View File

@ -9,6 +9,8 @@
#include <string.hpp>
#include <expected.hpp>
#include "tlib/errors.hpp"
#include "net/arp_cache.hpp"
#include "net/arp_layer.hpp"
@ -181,7 +183,7 @@ std::expected<uint64_t> network::arp::get_mac_force(network::interface_descripto
auto end = timer::milliseconds();
if(start - end > ms){
logging::logf(logging::log_level::TRACE, "arp: reached timeout, exiting\n");
return std::make_expected_from_error<uint64_t, size_t>(0);
return std::make_expected_from_error<uint64_t>(std::ERROR_SOCKET_TIMEOUT);
}
}
}

View File

@ -39,6 +39,7 @@ constexpr const size_t ERROR_SOCKET_UNIMPLEMENTED = 24;
constexpr const size_t ERROR_SOCKET_NO_INTERFACE = 25;
constexpr const size_t ERROR_SOCKET_INVALID_PACKET_FD = 26;
constexpr const size_t ERROR_SOCKET_NOT_LISTEN = 27;
constexpr const size_t ERROR_SOCKET_TIMEOUT = 28;
inline const char* error_message(size_t error){
switch(error){
@ -96,6 +97,8 @@ inline const char* error_message(size_t error){
return "The packet file descriptor is invalid";
case ERROR_SOCKET_NOT_LISTEN:
return "The socket is not configured to listen";
case ERROR_SOCKET_TIMEOUT:
return "Network timeout";
default:
return "Unknonwn error";
}