NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
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
, m_nameTreeEntry(nullptr)
34
{
35
}
36
37
NextHopList::iterator
38
Entry::findNextHop(
const
Face
&
face
)
39
{
40
return
std::find_if(m_nextHops.begin(), m_nextHops.end(),
41
[&
face
] (
const
NextHop
& nexthop) {
42
return
&nexthop.getFace() == &
face
;
43
});
44
}
45
46
bool
47
Entry::hasNextHop
(
const
Face
&
face
)
const
48
{
49
return
const_cast<
Entry
*
>
(
this
)->findNextHop(
face
) != m_nextHops.end();
50
}
51
52
void
53
Entry::addNextHop
(
Face
&
face
, uint64_t cost)
54
{
55
auto
it = this->findNextHop(
face
);
56
if
(it == m_nextHops.end()) {
57
m_nextHops.emplace_back(
face
);
58
it = std::prev(m_nextHops.end());
59
}
60
61
it->setCost(cost);
62
this->sortNextHops();
63
}
64
65
void
66
Entry::removeNextHop
(
const
Face
&
face
)
67
{
68
auto
it = this->findNextHop(
face
);
69
if
(it != m_nextHops.end()) {
70
m_nextHops.erase(it);
71
}
72
}
73
74
void
75
Entry::sortNextHops()
76
{
77
std::sort(m_nextHops.begin(), m_nextHops.end(),
78
[] (
const
NextHop
& a,
const
NextHop
& b) {
return
a.
getCost
() < b.getCost(); });
79
}
80
81
}
// namespace fib
82
}
// namespace nfd
nfd::fib::NextHop::getCost
uint64_t getCost() const
Definition:
fib-nexthop.hpp:51
nfd::face::Face
generalization of a network interface
Definition:
face.hpp:67
nfd::fib::Entry
represents a FIB entry
Definition:
fib-entry.hpp:51
nfd::fib::Entry::addNextHop
void addNextHop(Face &face, uint64_t cost)
adds a NextHop record
Definition:
fib-entry.cpp:53
nfd::fib::Entry::Entry
Entry(const Name &prefix)
Definition:
fib-entry.cpp:31
nfd::cs::iterator
Table::const_iterator iterator
Definition:
cs-internal.hpp:41
nfd::fib::Entry::removeNextHop
void removeNextHop(const Face &face)
removes a NextHop record
Definition:
fib-entry.cpp:66
nfd
Copyright (c) 2011-2015 Regents of the University of California.
Definition:
ndn-common.hpp:40
face
ndn::Name
Represents an absolute name.
Definition:
name.hpp:42
fib-entry.hpp
nfd::fib::NextHop
represents a nexthop record in FIB entry
Definition:
fib-nexthop.hpp:38
nfd::fib::Entry::hasNextHop
bool hasNextHop(const Face &face) const
Definition:
fib-entry.cpp:47
ndnSIM
NFD
daemon
table
fib-entry.cpp
Generated on Sun Feb 25 2018 13:27:06 for ndnSIM by
1.8.14