#include <RouteTable.h>
Public Member Functions | |
RouteTable (const std::string &router_name) | |
Constructor. | |
virtual | ~RouteTable () |
Destructor. | |
bool | add_entry (RouteEntry *entry) |
Add a route entry. | |
bool | del_entry (const EndpointIDPattern &dest, const LinkRef &next_hop) |
Remove a route entry. | |
template<typename Predicate > | |
size_t | del_matching_entries (Predicate test) |
Remove entries that match the given predicate. | |
size_t | del_entries (const EndpointIDPattern &dest) |
Remove all entries to the given endpoint id pattern. | |
size_t | del_entries_for_nexthop (const LinkRef &next_hop) |
Remove all entries that rely on the given next_hop link. | |
void | clear () |
Clear the whole route table. | |
size_t | get_matching (const EndpointID &eid, const LinkRef &next_hop, RouteEntryVec *entry_vec) const |
Fill in the entry_vec with the list of all entries whose patterns match the given eid and next hop. | |
size_t | get_matching (const EndpointID &eid, RouteEntryVec *entry_vec) const |
Syntactic sugar to call get_matching for all links. | |
void | dump (oasys::StringBuffer *buf) const |
Dump a string representation of the routing table. | |
int | size () |
Return the size of the table. | |
const RouteEntryVec * | route_table () |
Return the routing table. | |
oasys::Lock * | lock () |
Accessor for the RouteTable internal lock. | |
Protected Member Functions | |
size_t | get_matching_helper (const EndpointID &eid, const LinkRef &next_hop, RouteEntryVec *entry_vec, bool *loop, int level) const |
Helper function for get_matching. | |
Protected Attributes | |
RouteEntryVec | route_table_ |
The routing table itself. | |
oasys::SpinLock | lock_ |
Lock to protect internal data structures. |
Definition at line 34 of file RouteTable.h.
dtn::RouteTable::RouteTable | ( | const std::string & | router_name | ) |
dtn::RouteTable::~RouteTable | ( | ) | [virtual] |
bool dtn::RouteTable::add_entry | ( | RouteEntry * | entry | ) |
Add a route entry.
Definition at line 39 of file RouteTable.cc.
References lock_, and route_table_.
Referenced by dtn::TableBasedRouter::add_route(), dtn::TableBasedRouter::add_subscriber(), dtn::TcaRouter::create_route(), and dtn::DTLSRRouter::recompute_routes().
void dtn::RouteTable::clear | ( | ) |
Clear the whole route table.
Definition at line 94 of file RouteTable.cc.
References lock_, and route_table_.
size_t dtn::RouteTable::del_entries | ( | const EndpointIDPattern & | dest | ) |
Remove all entries to the given endpoint id pattern.
Definition at line 78 of file RouteTable.cc.
References del_matching_entries(), and lock_.
Referenced by dtn::TableBasedRouter::del_route(), and dtn::TcaRouter::handle_del_route().
size_t dtn::RouteTable::del_entries_for_nexthop | ( | const LinkRef & | next_hop | ) |
Remove all entries that rely on the given next_hop link.
Definition at line 86 of file RouteTable.cc.
References del_matching_entries(), and lock_.
Referenced by dtn::TableBasedRouter::handle_link_deleted().
bool dtn::RouteTable::del_entry | ( | const EndpointIDPattern & | dest, | |
const LinkRef & | next_hop | |||
) |
Remove a route entry.
Definition at line 52 of file RouteTable.cc.
References dtn::EndpointID::c_str(), dtn::RouteEntry::dest_pattern(), dtn::EndpointID::equals(), dtn::RouteEntry::link(), lock_, and route_table_.
size_t dtn::RouteTable::del_matching_entries | ( | Predicate | test | ) | [inline] |
Remove entries that match the given predicate.
Definition at line 144 of file RouteTable.h.
References lock_, and route_table_.
Referenced by del_entries(), del_entries_for_nexthop(), and dtn::DTLSRRouter::recompute_routes().
void dtn::RouteTable::dump | ( | oasys::StringBuffer * | buf | ) | const |
Dump a string representation of the routing table.
Definition at line 176 of file RouteTable.cc.
References dtn::RouteEntry::dest_pattern(), dtn::RouteEntry::dump_header(), dtn::EndpointID::length(), dtn::RouteEntry::link(), lock_, route_table_, dtn::RouteEntry::route_to(), and dtn::RouteEntry::source_pattern().
Referenced by dtn::TableBasedRouter::get_routing_state().
size_t dtn::RouteTable::get_matching | ( | const EndpointID & | eid, | |
RouteEntryVec * | entry_vec | |||
) | const [inline] |
Syntactic sugar to call get_matching for all links.
Definition at line 96 of file RouteTable.h.
References get_matching().
size_t dtn::RouteTable::get_matching | ( | const EndpointID & | eid, | |
const LinkRef & | next_hop, | |||
RouteEntryVec * | entry_vec | |||
) | const |
Fill in the entry_vec with the list of all entries whose patterns match the given eid and next hop.
If the next hop is NULL, it is ignored.
Definition at line 107 of file RouteTable.cc.
References dtn::EndpointID::c_str(), get_matching_helper(), and lock_.
Referenced by dtn::TableBasedRouter::add_nexthop_route(), dtn::TableBasedRouter::find_session_upstream(), dtn::TcaRouter::fwd_to_all(), dtn::TcaRouter::fwd_to_matching_r(), get_matching(), dtn::TcaRouter::handle_get_routes(), and dtn::TableBasedRouter::route_bundle().
size_t dtn::RouteTable::get_matching_helper | ( | const EndpointID & | eid, | |
const LinkRef & | next_hop, | |||
RouteEntryVec * | entry_vec, | |||
bool * | loop, | |||
int | level | |||
) | const [protected] |
Helper function for get_matching.
Definition at line 126 of file RouteTable.cc.
References ASSERT, dtn::EndpointID::c_str(), dtn::BundleRouter::config_, count, dtn::RouteEntry::dest_pattern(), dtn::EndpointID::length(), dtn::RouteEntry::link(), dtn::EndpointIDPattern::match(), route_table_, and dtn::RouteEntry::route_to().
Referenced by get_matching().
oasys::Lock* dtn::RouteTable::lock | ( | ) | [inline] |
Accessor for the RouteTable internal lock.
Definition at line 122 of file RouteTable.h.
References lock_.
Referenced by dtn::TableBasedRouter::tcl_dump_state().
const RouteEntryVec * dtn::RouteTable::route_table | ( | ) |
Return the routing table.
Asserts that the RouteTable spin lock is held by the caller.
Definition at line 225 of file RouteTable.cc.
References lock_, and route_table_.
Referenced by dtn::TableBasedRouter::tcl_dump_state().
int dtn::RouteTable::size | ( | ) | [inline] |
oasys::SpinLock dtn::RouteTable::lock_ [mutable, protected] |
Lock to protect internal data structures.
Definition at line 138 of file RouteTable.h.
Referenced by add_entry(), clear(), del_entries(), del_entries_for_nexthop(), del_entry(), del_matching_entries(), dump(), get_matching(), lock(), and route_table().
RouteEntryVec dtn::RouteTable::route_table_ [protected] |
The routing table itself.
Definition at line 133 of file RouteTable.h.
Referenced by add_entry(), clear(), del_entry(), del_matching_entries(), dump(), get_matching_helper(), route_table(), and size().