ndn-embeds 0.1.0
Lightweight NDN protocol stack for embedded systems
Loading...
Searching...
No Matches
ndn::Fib Class Reference

Forwarding Information Base. More...

#include <ndn/fib.hpp>

Public Member Functions

Route management
Error addRoute (const Name &prefix, FaceId faceId, uint8_t cost=0)
 Add a route.
 
void removeRoute (const Name &prefix, FaceId faceId)
 Remove a specific next-hop.
 
void removeRoute (const Name &prefix)
 Remove all routes for a prefix.
 
void removeFace (FaceId faceId)
 Remove a specified Face from all entries.
 
Lookup
const FibEntryfindLongestMatch (const Name &name) const
 Look up using Longest Prefix Match.
 
const FibEntryfindExact (const Name &prefix) const
 Look up using exact match.
 
FibEntryfindExact (const Name &prefix)
 Look up using exact match (non-const version)
 
Statistics
size_t size () const
 Get the current number of entries.
 
size_t capacity () const
 Get the maximum number of entries.
 

Detailed Description

Forwarding Information Base.

One of the core components of the forwarder. Determines which Face to forward Interests to. Uses Longest Prefix Match for forwarding lookups.

Fib fib;
// Add a route
Name prefix;
prefix.appendComponent("sensor");
fib.addRoute(prefix, espNowFaceId, 10); // Cost 10
// Look up forwarding destination (Longest Prefix Match)
Name interestName;
interestName.appendComponent("sensor");
interestName.appendComponent("temperature");
if (auto* entry = fib.findLongestMatch(interestName)) {
for (size_t i = 0; i < entry->nexthopCount(); i++) {
forwardTo(entry->nexthop(i).faceId, interest);
}
}
Forwarding Information Base.
Definition fib.hpp:119
const FibEntry * findLongestMatch(const Name &name) const
Look up using Longest Prefix Match.
Definition fib.cpp:117
Error addRoute(const Name &prefix, FaceId faceId, uint8_t cost=0)
Add a route.
Definition fib.cpp:56
NDN Name class.
Definition name.hpp:64
Error appendComponent(std::string_view comp)
Append a string component.
Definition name.cpp:228

Definition at line 119 of file fib.hpp.

Member Function Documentation

◆ addRoute()

Error ndn::Fib::addRoute ( const Name prefix,
FaceId  faceId,
uint8_t  cost = 0 
)

Add a route.

Registers a forwarding destination for the specified prefix. If the prefix already exists, adds a next-hop.

Parameters
prefixName prefix
faceIdNext-hop Face ID
costCost (default: 0)
Returns
Error::Success on success, Error::Full when table is full

Definition at line 56 of file fib.cpp.

References ndn::FibEntry::addNexthop(), and findExact().

Referenced by ndn::Forwarder::addRoute(), ndn::Forwarder::addRoute(), and ndn::Forwarder::registerPrefix().

◆ capacity()

size_t ndn::Fib::capacity ( ) const
inline

Get the maximum number of entries.

Returns
Maximum number of entries

Definition at line 205 of file fib.hpp.

References ndn::FIB_MAX_ENTRIES.

◆ findExact() [1/2]

FibEntry * ndn::Fib::findExact ( const Name prefix)

Look up using exact match (non-const version)

Parameters
prefixPrefix to search for
Returns
Pointer to the entry if found, nullptr otherwise

Definition at line 143 of file fib.cpp.

◆ findExact() [2/2]

const FibEntry * ndn::Fib::findExact ( const Name prefix) const

Look up using exact match.

Parameters
prefixPrefix to search for
Returns
Const pointer to the entry if found, nullptr otherwise

Definition at line 134 of file fib.cpp.

Referenced by addRoute(), removeRoute(), and removeRoute().

◆ findLongestMatch()

const FibEntry * ndn::Fib::findLongestMatch ( const Name name) const

Look up using Longest Prefix Match.

Returns the entry with the longest prefix that matches the given Name.

Parameters
nameName to search for
Returns
Pointer to the entry if found, nullptr otherwise

Definition at line 117 of file fib.cpp.

References ndn::Name::componentCount().

◆ removeFace()

void ndn::Fib::removeFace ( FaceId  faceId)

Remove a specified Face from all entries.

Call this when a Face is disconnected.

Parameters
faceIdFace ID to remove

Definition at line 105 of file fib.cpp.

Referenced by ndn::Forwarder::removeFace().

◆ removeRoute() [1/2]

void ndn::Fib::removeRoute ( const Name prefix)

Remove all routes for a prefix.

Parameters
prefixName prefix

Definition at line 96 of file fib.cpp.

References findExact().

◆ removeRoute() [2/2]

void ndn::Fib::removeRoute ( const Name prefix,
FaceId  faceId 
)

Remove a specific next-hop.

Parameters
prefixName prefix
faceIdFace ID to remove

Definition at line 81 of file fib.cpp.

References findExact(), and ndn::FibEntry::removeNexthop().

Referenced by ndn::Forwarder::unregisterPrefix().

◆ size()

size_t ndn::Fib::size ( ) const
inline

Get the current number of entries.

Returns
Number of entries

Definition at line 199 of file fib.hpp.


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