Loading...
Searching...
No Matches
route.hpp
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2014-2025, 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_RIB_ROUTE_HPP
27#define NFD_DAEMON_RIB_ROUTE_HPP
28
29#include "core/common.hpp"
30
31#include <ndn-cxx/encoding/nfd-constants.hpp>
32#include <ndn-cxx/mgmt/nfd/route-flags-traits.hpp>
33#include <ndn-cxx/prefix-announcement.hpp>
34#include <ndn-cxx/util/scheduler.hpp>
35
36#include <type_traits>
37
38namespace nfd::rib {
39
43class Route : public ndn::nfd::RouteFlagsTraits<Route>, private boost::equality_comparable<Route>
44{
45public:
49
54 Route(const ndn::PrefixAnnouncement& ann, uint64_t faceId);
55
56 const ndn::scheduler::EventId&
58 {
59 return m_expirationEvent;
60 }
61
62 void
63 setExpirationEvent(ndn::scheduler::EventId&& eid)
64 {
65 m_expirationEvent = std::move(eid);
66 }
67
68 void
70 {
71 m_expirationEvent.cancel();
72 }
73
74 std::underlying_type_t<ndn::nfd::RouteFlags>
75 getFlags() const
76 {
77 return flags;
78 }
79
80public: // non-member operators (hidden friends)
81 friend bool
82 operator==(const Route& lhs, const Route& rhs)
83 {
84 return lhs.faceId == rhs.faceId &&
85 lhs.origin == rhs.origin &&
86 lhs.cost == rhs.cost &&
87 lhs.flags == rhs.flags &&
88 lhs.expires == rhs.expires &&
89 lhs.announcement == rhs.announcement;
90 }
91
92public:
94 static constexpr uint64_t PA_ROUTE_COST = 2048;
95
96 uint64_t faceId = 0;
97 ndn::nfd::RouteOrigin origin = ndn::nfd::ROUTE_ORIGIN_APP;
98 uint64_t cost = 0;
99 std::underlying_type_t<ndn::nfd::RouteFlags> flags = ndn::nfd::ROUTE_FLAGS_NONE;
100 std::optional<time::steady_clock::time_point> expires;
101
106 std::optional<ndn::PrefixAnnouncement> announcement;
107
116 time::steady_clock::time_point annExpires;
117
118private:
119 ndn::scheduler::EventId m_expirationEvent;
120};
121
122std::ostream&
123operator<<(std::ostream& os, const Route& route);
124
125} // namespace nfd::rib
126
127#endif // NFD_DAEMON_RIB_ROUTE_HPP
Represents a route for a name prefix.
Definition route.hpp:44
std::underlying_type_t< ndn::nfd::RouteFlags > getFlags() const
Definition route.hpp:75
ndn::nfd::RouteOrigin origin
Definition route.hpp:97
uint64_t cost
Definition route.hpp:98
Route()
Default constructor.
std::underlying_type_t< ndn::nfd::RouteFlags > flags
Definition route.hpp:99
time::steady_clock::time_point annExpires
Expiration time of the prefix announcement.
Definition route.hpp:116
std::optional< time::steady_clock::time_point > expires
Definition route.hpp:100
const ndn::scheduler::EventId & getExpirationEvent() const
Definition route.hpp:57
void setExpirationEvent(ndn::scheduler::EventId &&eid)
Definition route.hpp:63
void cancelExpirationEvent()
Definition route.hpp:69
std::optional< ndn::PrefixAnnouncement > announcement
The prefix announcement that caused the creation of this route.
Definition route.hpp:106
friend bool operator==(const Route &lhs, const Route &rhs)
Definition route.hpp:82
uint64_t faceId
Definition route.hpp:96
static constexpr uint64_t PA_ROUTE_COST
Cost of route created by prefix announcement.
Definition route.hpp:94
std::ostream & operator<<(std::ostream &os, const FibUpdate &update)