Loading...
Searching...
No Matches
fib-entry.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2024, Regents of the University of California,
4 * Arizona Board of Regents,
5 * Colorado State University,
6 * University Pierre & Marie Curie, Sorbonne University,
7 * Washington University in St. Louis,
8 * Beijing Institute of Technology,
9 * The University of Memphis.
10 *
11 * This file is part of NFD (Named Data Networking Forwarding Daemon).
12 * See AUTHORS.md for complete list of NFD authors and contributors.
13 *
14 * NFD is free software: you can redistribute it and/or modify it under the terms
15 * of the GNU General Public License as published by the Free Software Foundation,
16 * either version 3 of the License, or (at your option) any later version.
17 *
18 * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
19 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20 * PURPOSE. See the GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License along with
23 * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
24 */
25
26#ifndef NFD_DAEMON_TABLE_FIB_ENTRY_HPP
27#define NFD_DAEMON_TABLE_FIB_ENTRY_HPP
28
29#include "core/common.hpp"
30
31namespace nfd {
32
33namespace face {
34class Face;
35} // namespace face
36using face::Face;
37
38namespace name_tree {
39class Entry;
40} // namespace name_tree
41
42namespace fib {
43
44class Fib;
45
50{
51public:
52 explicit
53 NextHop(Face& face) noexcept
54 : m_face(&face)
55 {
56 }
57
58 Face&
59 getFace() const noexcept
60 {
61 return *m_face;
62 }
63
64 uint64_t
65 getCost() const noexcept
66 {
67 return m_cost;
68 }
69
70 void
71 setCost(uint64_t cost) noexcept
72 {
73 m_cost = cost;
74 }
75
76private:
77 Face* m_face; // pointer instead of reference so that NextHop is movable
78 uint64_t m_cost = 0;
79};
80
84using NextHopList = std::vector<NextHop>;
85
90class Entry : noncopyable
91{
92public:
93 explicit
94 Entry(const Name& prefix);
95
96 const Name&
97 getPrefix() const noexcept
98 {
99 return m_prefix;
100 }
101
102 const NextHopList&
103 getNextHops() const noexcept
104 {
105 return m_nextHops;
106 }
107
111 bool
112 hasNextHops() const noexcept
113 {
114 return !m_nextHops.empty();
115 }
116
120 bool
121 hasNextHop(const Face& face) const noexcept;
122
123private:
131 std::pair<NextHopList::iterator, bool>
132 addOrUpdateNextHop(Face& face, uint64_t cost);
133
138 bool
139 removeNextHop(const Face& face);
140
143 NextHopList::iterator
144 findNextHop(const Face& face) noexcept;
145
148 void
149 sortNextHops();
150
151private:
152 Name m_prefix;
153 NextHopList m_nextHops;
154
155 name_tree::Entry* m_nameTreeEntry = nullptr;
156
157 friend ::nfd::name_tree::Entry;
158 friend Fib;
159};
160
161} // namespace fib
162} // namespace nfd
163
164#endif // NFD_DAEMON_TABLE_FIB_ENTRY_HPP
Generalization of a network interface.
Definition face.hpp:118
Represents an entry in the FIB.
Definition fib-entry.hpp:91
const Name & getPrefix() const noexcept
Definition fib-entry.hpp:97
bool hasNextHop(const Face &face) const noexcept
Returns whether there is a NextHop record for face.
Definition fib-entry.cpp:43
bool hasNextHops() const noexcept
Returns whether this Entry has any NextHop records.
const NextHopList & getNextHops() const noexcept
Represents the Forwarding Information Base (FIB).
Definition fib.hpp:51
Represents a nexthop record in a FIB entry.
Definition fib-entry.hpp:50
NextHop(Face &face) noexcept
Definition fib-entry.hpp:53
void setCost(uint64_t cost) noexcept
Definition fib-entry.hpp:71
Face & getFace() const noexcept
Definition fib-entry.hpp:59
uint64_t getCost() const noexcept
Definition fib-entry.hpp:65
An entry in the name tree.
std::vector< NextHop > NextHopList
A collection of nexthops in a FIB entry.
Definition fib-entry.hpp:84
-status-http-server
Definition common.hpp:71