Routing table

The routing table contains all routes known to the networking within the NetworkManager of given module. The table itself manages underlying lwip’s forwarding table (an addition of the RoFI platform) which should be left intact by the user.

class RoutingTable

Class representing routing table of the platform.

This class also manages the underlying lwip library, therefore users should not interfere and manage the forwarding table in lwip themselves.

Public Types

using Cost = int
using Records = std::vector<Record>

Public Functions

inline std::size_t size() const

Get the count of records (number of known networks).

inline bool empty() const

Check if the table contains any record.

Returns:

true if there are no records.

inline Record *find(const Ip6Addr &ip, uint8_t mask)

Find a record for given network.

inline bool add(const Record &r, const Protocol *learnedFrom = nullptr)

Add a new network to the table.

If the record exists, it merges gateways of both records.

Returns:

true if a record was added or (in case it exists) merging added a new gateway.

inline bool add(const Ip6Addr &ip, uint8_t mask, const Interface::Name &n, Cost c, const Protocol *learned = nullptr)

Overloaded version of add.

inline bool remove(const Record &r)

Remove given record.

Returns:

true if record was removed.

inline bool remove(const Ip6Addr &ip, uint8_t mask, const Gateway &gw)

Remove all gateways from the given network record with given Gateways.

inline bool removeNetwork(const Ip6Addr &ip, uint8_t mask)

Removes record for given network with all of its gateways.

inline bool removeInterface(const Ip6Addr &ip, uint8_t mask, const Interface::Name &gwn)

Remove all gateways from the given network record with given output interface.

inline void purge(const Interface::Name &n)

Remove all gateways using given interface as the output.

Removes records that would end up empty (i.e., without any gateway).

inline Records recordsLearnedFrom(const Protocol &proto) const

Function for getting all records learned through given protocol.

Friends

friend std::ostream &operator<<(std::ostream&, const RoutingTable&)
class Gateway

Class representing single gateway with its cost, output interface, and protocol via witch the gateway was discovered.

Public Functions

inline Gateway(const Interface::Name &i, Cost c)
inline Gateway(const Interface::Name &i, Cost c, const Protocol *learnedFrom)
inline Cost cost() const
inline Interface::Name name() const
inline const Protocol *learnedFrom() const
inline bool improveCost(Cost c)

Update the cost with a new value, if the new value is lower.

Returns:

true if the cost changed, false otherwise

auto operator<=>(const Gateway&) const = default
class Record

Class representing a record of the routing table.

Each network (i.e., ip + mask) has its own record.

Public Functions

inline Record(const Ip6Addr &ip, uint8_t mask)
inline Record(const Ip6Addr &ip, uint8_t mask, const Interface::Name &n, Cost c, const Protocol *from = nullptr)
inline bool addGateway(const Interface::Name &n, Cost c)

Add a new gateway for the given record.

Returns:

true if the gateway was added.

inline bool addGateway(Interface::Name n, Cost c, const Protocol *learnedFrom)

Overloaded version of the previous function.

inline bool removeGateway(const Gateway &gw)

Remove given gateway.

Returns:

true if the gateway was succesfully removed.

inline bool removeGateway(const Interface::Name &n, Cost c, const Protocol *learnedFrom = nullptr)

Overloaded version of removeGateway.

inline bool removeGateway(const Interface::Name &n)

Remove all gateways from the record with given interface name.

inline Ip6Addr ip() const

Get Record’s IP.

inline uint8_t mask() const

Get Record’s mask.

inline std::size_t size() const

Get number of gateways.

inline std::optional<Gateway> best() const

Get the best (with the lowest cost) gateway for given network if it exists.

inline bool contains(const Gateway &gw) const

Check if a given gateway is present in the record.

inline auto gateways() const

Get iterable range of Record’s gateways.

inline bool compareNetworks(const Record &r) const
inline bool compareNetworks(const Ip6Addr &ip, uint8_t mask) const
auto operator<=>(const Record&) const = default