10#include <linux/neighbour.h>
11#include <linux/rtnetlink.h>
19 enum class Type : uint16_t {
51 if (std::to_underlying(
state) == NUD_NONE) {
57 std::string_view name;
60 static constexpr std::array<StateName, 8> state_names{{
61 {NUD_INCOMPLETE,
"NUD_INCOMPLETE"},
62 {NUD_REACHABLE,
"NUD_REACHABLE"},
63 {NUD_STALE,
"NUD_STALE"},
64 {NUD_DELAY,
"NUD_DELAY"},
65 {NUD_PROBE,
"NUD_PROBE"},
66 {NUD_FAILED,
"NUD_FAILED"},
67 {NUD_NOARP,
"NUD_NOARP"},
68 {NUD_PERMANENT,
"NUD_PERMANENT"},
72 for (
const auto& entry : state_names) {
73 if ((std::to_underlying(
state) & entry.mask) != 0U) {
74 if (!result.empty()) {
77 result.append(entry.name);
81 return result.empty() ?
"UNKNOWN" : result;
Definition nl_common.hxx:21
std::pmr::vector< NeighborEvent > NeighborEventList
Definition nl_neighbor_event.hxx:88
Definition nl_common.hxx:20
Definition nl_neighbor_event.hxx:18
std::string lladdr
Definition nl_neighbor_event.hxx:44
auto state_to_string() const -> std::string
Convert the Neighbor state enum to a readable string.
Definition nl_neighbor_event.hxx:50
Type type
Definition nl_neighbor_event.hxx:37
Type
Definition nl_neighbor_event.hxx:19
@ UNKNOWN
Definition nl_neighbor_event.hxx:20
@ NEW_NEIGHBOR
Definition nl_neighbor_event.hxx:21
@ DELETE_NEIGHBOR
Definition nl_neighbor_event.hxx:22
int index
Definition nl_neighbor_event.hxx:38
uint8_t flags
Definition nl_neighbor_event.hxx:41
State
Definition nl_neighbor_event.hxx:25
@ INCOMPLETE
Definition nl_neighbor_event.hxx:27
@ STALE
Definition nl_neighbor_event.hxx:29
@ PERMANENT
Definition nl_neighbor_event.hxx:34
@ NOARP
Definition nl_neighbor_event.hxx:33
@ PROBE
Definition nl_neighbor_event.hxx:31
@ DELAY
Definition nl_neighbor_event.hxx:30
@ NONE
Definition nl_neighbor_event.hxx:26
@ FAILED
Definition nl_neighbor_event.hxx:32
@ REACHABLE
Definition nl_neighbor_event.hxx:28
static auto from_nlmsghdr(const nlmsghdr &header) -> NeighborEvent
Parse a NeighborEvent from a netlink message header.
Definition nl_neighbor_event.cxx:12
uint8_t neighbor_type
Definition nl_neighbor_event.hxx:42
std::string address
Definition nl_neighbor_event.hxx:43
uint8_t family
Definition nl_neighbor_event.hxx:39
State state
Definition nl_neighbor_event.hxx:40