llmx-rtaco 0.0.1
RTNL-only netlink control-plane library for Linux (C++23).
Loading...
Searching...
No Matches
nl_route_event.hxx
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7#include <linux/rtnetlink.h>
8
10
11struct nlmsghdr;
12
13namespace llmx {
14namespace rtaco {
15
16struct RouteEvent {
17 enum class Type : uint16_t {
19 NEW_ROUTE = RTM_NEWROUTE,
20 DELETE_ROUTE = RTM_DELROUTE,
21 };
22
23 enum class Flags : uint32_t {
24 NONE = 0,
25 NOTIFY = (1u << 8), // 0x100 Notify user of route change
26 CLONED = (1u << 9), // 0x200 This route is cloned
27 EQUALIZE = (1u << 10), // 0x400 Multipath equalizer / equalized route
28 PREFIX = (1u << 11), // 0x800 Prefix addresses
29 LOOKUP_TABLE = (1u << 12), // 0x1000 set rtm_table to FIB lookup result
30 FIB_MATCH = (1u << 13), // 0x2000 return full fib lookup match
31 OFFLOAD = (1u << 14), // 0x4000 route is offloaded
32 TRAP = (1u << 15), // 0x8000 route is trapping packets
33 OFFLOAD_FAILED = (1u << 29), // 0x20000000 route offload failed
34 };
35
37 uint8_t family{0};
38 uint8_t dst_prefix_len{0};
39 uint8_t src_prefix_len{0};
40 uint8_t scope{0};
41 uint8_t protocol{0};
42 uint8_t route_type{0};
44 uint32_t table{0};
45 uint32_t priority{0};
46 uint32_t oif_index{0};
47 std::string dst{};
48 std::string src{};
49 std::string gateway{};
50 std::string prefsrc{};
51 std::string oif{};
52
57 static auto from_nlmsghdr(const nlmsghdr& header) -> RouteEvent;
58};
59
60using RouteEventList = std::pmr::vector<RouteEvent>;
61
62template<>
63struct enable_bitmask_operators<RouteEvent::Flags> : std::true_type {};
64
65} // namespace rtaco
66} // namespace llmx
Definition nl_common.hxx:21
std::pmr::vector< RouteEvent > RouteEventList
Definition nl_route_event.hxx:60
Definition nl_common.hxx:20
Definition nl_route_event.hxx:16
uint8_t protocol
Definition nl_route_event.hxx:41
Type type
Definition nl_route_event.hxx:36
std::string prefsrc
Definition nl_route_event.hxx:50
std::string src
Definition nl_route_event.hxx:48
uint32_t oif_index
Definition nl_route_event.hxx:46
std::string dst
Definition nl_route_event.hxx:47
static auto from_nlmsghdr(const nlmsghdr &header) -> RouteEvent
Parse a RouteEvent from a netlink message header.
Definition nl_route_event.cxx:12
uint8_t route_type
Definition nl_route_event.hxx:42
Type
Definition nl_route_event.hxx:17
@ NEW_ROUTE
Definition nl_route_event.hxx:19
@ UNKNOWN
Definition nl_route_event.hxx:18
@ DELETE_ROUTE
Definition nl_route_event.hxx:20
uint8_t family
Definition nl_route_event.hxx:37
std::string oif
Definition nl_route_event.hxx:51
uint8_t src_prefix_len
Definition nl_route_event.hxx:39
std::string gateway
Definition nl_route_event.hxx:49
uint8_t scope
Definition nl_route_event.hxx:40
uint8_t dst_prefix_len
Definition nl_route_event.hxx:38
Flags
Definition nl_route_event.hxx:23
@ LOOKUP_TABLE
Definition nl_route_event.hxx:29
@ TRAP
Definition nl_route_event.hxx:32
@ OFFLOAD_FAILED
Definition nl_route_event.hxx:33
@ PREFIX
Definition nl_route_event.hxx:28
@ FIB_MATCH
Definition nl_route_event.hxx:30
@ EQUALIZE
Definition nl_route_event.hxx:27
@ NOTIFY
Definition nl_route_event.hxx:25
@ NONE
Definition nl_route_event.hxx:24
@ OFFLOAD
Definition nl_route_event.hxx:31
@ CLONED
Definition nl_route_event.hxx:26
uint32_t table
Definition nl_route_event.hxx:44
Flags flags
Definition nl_route_event.hxx:43
uint32_t priority
Definition nl_route_event.hxx:45
Enable bitwise operators for an enum class.
Definition nl_utils.hxx:26