join 1.0
lightweight network framework library
Loading...
Searching...
No Matches
join::Route Class Reference

class representing a single kernel routing table entry. More...

#include <route.hpp>

Public Types

using Ptr = std::shared_ptr<Route>
 
using List = std::vector<Ptr>
 

Public Member Functions

 Route ()=delete
 create instance.
 
 ~Route ()=default
 destroy instance.
 
uint32_t index () const noexcept
 get interface index.
 
const IpAddressdest () const noexcept
 get the destination network address.
 
uint32_t prefix () const noexcept
 get the prefix length.
 
IpAddress gateway () const
 get the gateway address.
 
uint32_t metric () const
 get the route metric.
 
uint8_t type () const
 get the route type.
 
uint8_t scope () const
 get the route scope.
 
uint8_t protocol () const
 get the route protocol.
 
bool isUnicast () const noexcept
 check if route is a standard unicast route.
 
bool isBlackhole () const noexcept
 check if route silently drops packets.
 
bool isUnreachable () const noexcept
 check if route returns ICMP unreachable.
 
bool isProhibit () const noexcept
 check if route returns ICMP prohibited.
 
bool isLocal () const noexcept
 check if route is a local route.
 
bool isScopeUniverse () const noexcept
 check if route is universe-scoped.
 
bool isScopeLink () const noexcept
 check if route is link-scoped.
 
bool isScopeHost () const noexcept
 check if route is host-scoped.
 
bool isStatic () const noexcept
 check if route was added statically.
 
bool isKernel () const noexcept
 check if route was added by the kernel.
 
bool isDhcp () const noexcept
 check if route was added by a DHCP client.
 
bool isBoot () const noexcept
 check if route was added at boot time.
 
int set (const IpAddress &gateway, uint32_t metric=0, bool sync=false) const
 update this route entry in the kernel table.
 
int remove (bool sync=false) const
 remove this route entry from the kernel table.
 

Friends

class RouteManager
 
bool operator== (const Route::Ptr &lhs, const Route::Ptr &rhs)
 compare if two routes are equal.
 
bool operator< (const Route::Ptr &lhs, const Route::Ptr &rhs)
 compare two routes for ordering.
 

Detailed Description

class representing a single kernel routing table entry.

Member Typedef Documentation

◆ List

using join::Route::List = std::vector<Ptr>

◆ Ptr

using join::Route::Ptr = std::shared_ptr<Route>

Constructor & Destructor Documentation

◆ Route()

join::Route::Route ( )
delete

create instance.

◆ ~Route()

join::Route::~Route ( )
default

destroy instance.

Member Function Documentation

◆ dest()

const IpAddress & Route::dest ( ) const
noexcept

get the destination network address.

Returns
destination IP address.

◆ gateway()

IpAddress Route::gateway ( ) const

get the gateway address.

Returns
gateway IP address.

◆ index()

uint32_t Route::index ( ) const
noexcept

get interface index.

Returns
interface index.

◆ isBlackhole()

bool Route::isBlackhole ( ) const
noexcept

check if route silently drops packets.

Returns
true if type is RTN_BLACKHOLE.

◆ isBoot()

bool Route::isBoot ( ) const
noexcept

check if route was added at boot time.

Returns
true if protocol is RTPROT_BOOT.

◆ isDhcp()

bool Route::isDhcp ( ) const
noexcept

check if route was added by a DHCP client.

Returns
true if protocol is RTPROT_DHCP.

◆ isKernel()

bool Route::isKernel ( ) const
noexcept

check if route was added by the kernel.

Returns
true if protocol is RTPROT_KERNEL.

◆ isLocal()

bool Route::isLocal ( ) const
noexcept

check if route is a local route.

Returns
true if type is RTN_LOCAL.

◆ isProhibit()

bool Route::isProhibit ( ) const
noexcept

check if route returns ICMP prohibited.

Returns
true if type is RTN_PROHIBIT.

◆ isScopeHost()

bool Route::isScopeHost ( ) const
noexcept

check if route is host-scoped.

Returns
true if scope is RT_SCOPE_HOST.

◆ isScopeLink()

bool Route::isScopeLink ( ) const
noexcept

check if route is link-scoped.

Returns
true if scope is RT_SCOPE_LINK.

◆ isScopeUniverse()

bool Route::isScopeUniverse ( ) const
noexcept

check if route is universe-scoped.

Returns
true if scope is RT_SCOPE_UNIVERSE.

◆ isStatic()

bool Route::isStatic ( ) const
noexcept

check if route was added statically.

Returns
true if protocol is RTPROT_STATIC.

◆ isUnicast()

bool Route::isUnicast ( ) const
noexcept

check if route is a standard unicast route.

Returns
true if type is RTN_UNICAST.

◆ isUnreachable()

bool Route::isUnreachable ( ) const
noexcept

check if route returns ICMP unreachable.

Returns
true if type is RTN_UNREACHABLE.

◆ metric()

uint32_t Route::metric ( ) const

get the route metric.

Returns
metric value.

◆ prefix()

uint32_t Route::prefix ( ) const
noexcept

get the prefix length.

Returns
prefix length.

◆ protocol()

uint8_t Route::protocol ( ) const

get the route protocol.

Returns
route protocol.

◆ remove()

int Route::remove ( bool sync = false) const

remove this route entry from the kernel table.

Parameters
syncwait for operation completion if true.
Returns
0 on success, -1 on failure.

◆ scope()

uint8_t Route::scope ( ) const

get the route scope.

Returns
route scope.

◆ set()

int Route::set ( const IpAddress & gateway,
uint32_t metric = 0,
bool sync = false ) const

update this route entry in the kernel table.

Parameters
gatewaynew gateway address.
metricnew metric value.
syncwait for operation completion if true.
Returns
0 on success, -1 on failure.

◆ type()

uint8_t Route::type ( ) const

get the route type.

Returns
route type.

Friends And Related Symbol Documentation

◆ operator<

bool operator< ( const Route::Ptr & lhs,
const Route::Ptr & rhs )
friend

compare two routes for ordering.

Parameters
lhsleft side route.
rhsright side route.
Returns
true if lhs is less than rhs.

◆ operator==

bool operator== ( const Route::Ptr & lhs,
const Route::Ptr & rhs )
friend

compare if two routes are equal.

Parameters
lhsleft side route.
rhsright side route.
Returns
true if both are equal.

◆ RouteManager

friend class RouteManager
friend

The documentation for this class was generated from the following files: