17 #ifndef __LINUX_ROUTING_INTERNAL_HPP__ 18 #define __LINUX_ROUTING_INTERNAL_HPP__ 20 #include <netlink/cache.h> 21 #include <netlink/errno.h> 22 #include <netlink/netlink.h> 23 #include <netlink/socket.h> 39 inline void cleanup(
struct nl_cache* cache)
63 explicit Netlink(T*
object) : data(new Data(object)) {}
65 T*
get()
const {
return data->object; }
70 explicit Data(T* _object) : object(_object) {}
74 if (
object !=
nullptr) {
82 std::shared_ptr<Data> data;
93 struct nl_sock* s = nl_socket_alloc();
95 return Error(
"Failed to allocate netlink socket");
100 int error = nl_connect(sock.
get(), protocol);
103 "Failed to connect to netlink protocol: " +
104 std::string(nl_geterror(error)));
112 #endif // __LINUX_ROUTING_INTERNAL_HPP__ Definition: errorbase.hpp:36
Netlink(T *object)
Definition: internal.hpp:63
T * get() const
Definition: internal.hpp:65
Definition: internal.hpp:60
std::string error(const std::string &msg, uint32_t code)
Definition: diagnosis.hpp:30
void cleanup(struct rtnl_cls *cls)
Definition: internal.hpp:64
Try< Netlink< struct nl_sock > > socket(int protocol=NETLINK_ROUTE)
Definition: internal.hpp:91