nlsr::NamePrefixTable Class Reference

#include <name-prefix-table.hpp>

Public Types

using const_iterator = NptEntryList::const_iterator
 
using NptEntryList = std::list< std::shared_ptr< NamePrefixTableEntry > >
 
using RoutingTableEntryPool = std::unordered_map< ndn::Name, std::shared_ptr< RoutingTablePoolEntry > >
 

Public Member Functions

 NamePrefixTable (const ndn::Name &ownRouterName, Fib &fib, RoutingTable &routingTable, AfterRoutingChange &afterRoutingChangeSignal, Lsdb::AfterLsdbModified &afterLsdbModifiedSignal)
 
 ~NamePrefixTable ()
 
void addEntry (const ndn::Name &name, const ndn::Name &destRouter)
 Adds a destination to the specified name prefix. More...
 
std::shared_ptr< RoutingTablePoolEntryaddRtpeToPool (RoutingTablePoolEntry &rtpe)
 Adds a pool entry to the pool. More...
 
const_iterator begin () const
 
void deleteRtpeFromPool (std::shared_ptr< RoutingTablePoolEntry > rtpePtr)
 Removes a pool entry from the pool. More...
 
const_iterator end () const
 
void removeEntry (const ndn::Name &name, const ndn::Name &destRouter)
 Removes a destination from a name prefix table entry. More...
 
void updateFromLsdb (std::shared_ptr< Lsa > lsa, LsdbUpdate updateType, const std::list< ndn::Name > &namesToAdd, const std::list< ndn::Name > &namesToRemove)
 Add, update, or remove Names according to the Lsdb update. More...
 
void updateWithNewRoute (const std::list< RoutingTableEntry > &entries)
 Updates all routing information in the NPT. More...
 
void writeLog ()
 

Detailed Description

Definition at line 37 of file name-prefix-table.hpp.

Member Typedef Documentation

◆ const_iterator

using nlsr::NamePrefixTable::const_iterator = NptEntryList::const_iterator

Definition at line 43 of file name-prefix-table.hpp.

◆ NptEntryList

using nlsr::NamePrefixTable::NptEntryList = std::list<std::shared_ptr<NamePrefixTableEntry> >

Definition at line 42 of file name-prefix-table.hpp.

◆ RoutingTableEntryPool

using nlsr::NamePrefixTable::RoutingTableEntryPool = std::unordered_map<ndn::Name, std::shared_ptr<RoutingTablePoolEntry> >

Definition at line 40 of file name-prefix-table.hpp.

Constructor & Destructor Documentation

◆ NamePrefixTable()

nlsr::NamePrefixTable::NamePrefixTable ( const ndn::Name &  ownRouterName,
Fib fib,
RoutingTable routingTable,
AfterRoutingChange afterRoutingChangeSignal,
Lsdb::AfterLsdbModified afterLsdbModifiedSignal 
)

Definition at line 36 of file name-prefix-table.cpp.

◆ ~NamePrefixTable()

nlsr::NamePrefixTable::~NamePrefixTable ( )

Definition at line 57 of file name-prefix-table.cpp.

Member Function Documentation

◆ addEntry()

void nlsr::NamePrefixTable::addEntry ( const ndn::Name &  name,
const ndn::Name &  destRouter 
)

Adds a destination to the specified name prefix.

Parameters
nameThe name prefix
destRouterThe destination router prefix

This method adds a router to a name prefix table entry. If the name prefix table entry does not exist, it is created. The method will first look through its local pool of cached entries to find the routing information for destRouter. If it is not found there, it will construct one and fill it with information from an appropriate RoutingTableEntry in the routing table. If there isn't a match, it will instantiate it with no next hops. The FIB will be notified of the change to the NPT entry, too.

Definition at line 116 of file name-prefix-table.cpp.

◆ addRtpeToPool()

std::shared_ptr< RoutingTablePoolEntry > nlsr::NamePrefixTable::addRtpeToPool ( RoutingTablePoolEntry rtpe)

Adds a pool entry to the pool.

Parameters
rtpeThe entry.
Returns
A shared_ptr to the entry, now in the pool.

Adds a RoutingTablePoolEntry to the NPT's local pool. Shared pointers are used because it eliminates complicated hacks to deal with lifetime issues, and to simplify memory management.

Definition at line 304 of file name-prefix-table.cpp.

◆ begin()

NamePrefixTable::const_iterator nlsr::NamePrefixTable::begin ( ) const
inline

Definition at line 149 of file name-prefix-table.hpp.

◆ deleteRtpeFromPool()

void nlsr::NamePrefixTable::deleteRtpeFromPool ( std::shared_ptr< RoutingTablePoolEntry rtpePtr)

Removes a pool entry from the pool.

Parameters
rtpePtrThe shared_ptr to the entry.

Removes a pool entry from the pool. Comparing these shared_ptrs should not be a problem, because the same pointer is moved around, all sourced from this central location. A more robust solution is certainly possible, though.

Definition at line 318 of file name-prefix-table.cpp.

◆ end()

NamePrefixTable::const_iterator nlsr::NamePrefixTable::end ( ) const
inline

Definition at line 155 of file name-prefix-table.hpp.

◆ removeEntry()

void nlsr::NamePrefixTable::removeEntry ( const ndn::Name &  name,
const ndn::Name &  destRouter 
)

Removes a destination from a name prefix table entry.

Parameters
nameThe name prefix
destRouterThe destination.

This method removes a destination from an entry. It will not fail if an invalid name/destination pair are passed. After removal, if the RoutingTablePoolEntry has a use count of 0, it is deleted from the table. Additionally, if the name prefix has no routing table entries associated with it, it is deleted from the NPT. In any case, the FIB is informed of the changes.

Definition at line 200 of file name-prefix-table.cpp.

◆ updateFromLsdb()

void nlsr::NamePrefixTable::updateFromLsdb ( std::shared_ptr< Lsa lsa,
LsdbUpdate  updateType,
const std::list< ndn::Name > &  namesToAdd,
const std::list< ndn::Name > &  namesToRemove 
)

Add, update, or remove Names according to the Lsdb update.

Parameters
lsaThe LSA class pointer
updateTypeUpdate type from Lsdb (INSTALLED, UPDATED, REMOVED)
namesToAddIf LSA is UPDATED, then these are the names to add
namesToRemoveIf LSA is UPDATED, then these are the names to remove

Definition at line 64 of file name-prefix-table.cpp.

◆ updateWithNewRoute()

void nlsr::NamePrefixTable::updateWithNewRoute ( const std::list< RoutingTableEntry > &  entries)

Updates all routing information in the NPT.

Takes in a list of entries that are assumed to be exhaustive, and updates each pool entry with the next hop information contained in the corresponding entry in entries. If no entry is found, it is assumed that the destination for that pool entry is inaccessible, and its next hop information is deleted.

Definition at line 264 of file name-prefix-table.cpp.

◆ writeLog()

void nlsr::NamePrefixTable::writeLog ( )

Definition at line 328 of file name-prefix-table.cpp.