-
Notifications
You must be signed in to change notification settings - Fork 0
/
dhcp_error.hpp
60 lines (51 loc) · 1.67 KB
/
dhcp_error.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef NDHCPD_DHCP_ERROR_HPP
#define NDHCPD_DHCP_ERROR_HPP
#include <system_error>
enum class dhcp_error {
ok = 0,
invalid_packet = 512,
invalid_hwtype,
unexpected_packet_type,
unexpected_message_type,
no_more_leases,
no_ip_requested
};
class dhcp_category_impl
: public std::error_category
{
public:
const char *name() const noexcept override { return "dhcp"; }
bool equivalent( const std::error_code& code, int condition) const noexcept override { return false; }
std::string message(int ev) const noexcept override
{
switch (dhcp_error(ev)) {
case dhcp_error::ok:
return "no error";
case dhcp_error::invalid_packet:
return "Invalid DHCP packet";
case dhcp_error::invalid_hwtype:
return "Unsupported hardware type in DHCP packet";
case dhcp_error::unexpected_packet_type:
return "Unexpected DHCP packet type";
case dhcp_error::unexpected_message_type:
return "Unexpected DHCP packet message type";
case dhcp_error::no_more_leases:
return "No leases available for client";
case dhcp_error::no_ip_requested:
return "DHCP Request packet without ip address";
default:
return "Unknown DHCP error";
}
}
};
const std::error_category& dhcp_category();
std::error_condition make_error_condition(dhcp_error e);
std::error_code make_error_code(dhcp_error e);
namespace std
{
template <> struct is_error_condition_enum<dhcp_error>
: public true_type {};
template <> struct is_error_code_enum<dhcp_error>
: public true_type {};
}
#endif//NDHCPD_DHCP_ERROR_HPP