NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.0: NDN, CCN, CCNx, content centric networks
API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
fib-entry.cpp
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26
#include "
fib-entry.hpp
"
27
28
namespace
nfd {
29
namespace
fib {
30
31
Entry::Entry
(
const
Name
& prefix)
32
: m_prefix(prefix)
33
{
34
}
35
36
NextHopList::iterator
37
Entry::findNextHop(
Face
& face)
38
{
39
return
std::find_if(m_nextHops.begin(), m_nextHops.end(),
40
[&face] (
const
NextHop
& nexthop) {
41
return
nexthop.getFace().get() == &face;
42
});
43
}
44
45
bool
46
Entry::hasNextHop
(shared_ptr<Face> face)
const
47
{
48
return
const_cast<
Entry
*
>
(
this
)->findNextHop(*face) != m_nextHops.end();
49
}
50
51
void
52
Entry::addNextHop
(shared_ptr<Face> face, uint64_t cost)
53
{
54
auto
it = this->findNextHop(*face);
55
if
(it == m_nextHops.end()) {
56
m_nextHops.push_back(
fib::NextHop
(face));
57
it = m_nextHops.end();
58
--it;
59
}
60
// now it refers to the NextHop for face
61
62
it->setCost(cost);
63
64
this->sortNextHops();
65
}
66
67
void
68
Entry::removeNextHop
(shared_ptr<Face> face)
69
{
70
auto
it = this->findNextHop(*face);
71
if
(it != m_nextHops.end()) {
72
m_nextHops.erase(it);
73
}
74
}
75
76
void
77
Entry::sortNextHops()
78
{
79
std::sort(m_nextHops.begin(), m_nextHops.end(),
80
[] (
const
NextHop
& a,
const
NextHop
& b) {
return
a.
getCost
() < b.getCost(); });
81
}
82
83
84
}
// namespace fib
85
}
// namespace nfd
nfd::fib::Entry::addNextHop
void addNextHop(shared_ptr< Face > face, uint64_t cost)
adds a NextHop record
Definition:
fib-entry.cpp:52
nfd::fib::NextHop::getCost
uint64_t getCost() const
Definition:
fib-nexthop.cpp:50
fib-entry.hpp
nfd::fib::Entry::removeNextHop
void removeNextHop(shared_ptr< Face > face)
removes a NextHop record
Definition:
fib-entry.cpp:68
nfd::fib::Entry
represents a FIB entry
Definition:
fib-entry.hpp:53
nfd::fib::Entry::hasNextHop
bool hasNextHop(shared_ptr< Face > face) const
Definition:
fib-entry.cpp:46
nfd::Face
represents a face
Definition:
face.hpp:59
nfd::fib::Entry::Entry
Entry(const Name &prefix)
Definition:
fib-entry.cpp:31
ns3::ndn::Name
Name
Definition:
ndn-common.cpp:25
nfd::fib::NextHop
represents a nexthop record in FIB entry
Definition:
fib-nexthop.hpp:38
ndnSIM
NFD
daemon
table
fib-entry.cpp
Generated on Wed Feb 18 2015 16:31:16 for ndnSIM by
1.8.7