routing-table-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-2020, The University of Memphis,
4  * Regents of the University of California
5  *
6  * This file is part of NLSR (Named-data Link State Routing).
7  * See AUTHORS.md for complete list of NLSR authors and contributors.
8  *
9  * NLSR is free software: you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License as published by the Free Software Foundation,
11  * either version 3 of the License, or (at your option) any later version.
12  *
13  * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef NLSR_ROUTING_TABLE_ENTRY_HPP
22 #define NLSR_ROUTING_TABLE_ENTRY_HPP
23 
24 #include "nexthop-list.hpp"
25 
26 #include <ndn-cxx/encoding/block.hpp>
27 #include <ndn-cxx/encoding/encoding-buffer.hpp>
28 #include <ndn-cxx/encoding/tlv.hpp>
29 #include <ndn-cxx/name.hpp>
30 
31 namespace nlsr {
32 
42 {
43 public:
44  using Error = ndn::tlv::Error;
45 
46  RoutingTableEntry() = default;
47 
48  RoutingTableEntry(const ndn::Block& block)
49  {
50  wireDecode(block);
51  }
52 
53  RoutingTableEntry(const ndn::Name& dest)
54  {
55  m_destination = dest;
56  }
57 
58  const ndn::Name&
60  {
61  return m_destination;
62  }
63 
66  {
67  return m_nexthopList;
68  }
69 
70  const NexthopList&
72  {
73  return m_nexthopList;
74  }
75 
76  inline bool
78  {
79  return m_destination == rhs.getDestination() &&
81  }
82 
83  template<ndn::encoding::Tag TAG>
84  size_t
85  wireEncode(ndn::EncodingImpl<TAG>& block) const;
86 
87  const ndn::Block&
88  wireEncode() const;
89 
90  void
91  wireDecode(const ndn::Block& wire);
92 
93 protected:
94  ndn::Name m_destination;
96 
97  mutable ndn::Block m_wire;
98 };
99 
101 
102 std::ostream&
103 operator<<(std::ostream& os, const RoutingTableEntry& rte);
104 
105 } // namespace nlsr
106 
107 #endif // NLSR_ROUTING_TABLE_ENTRY_HPP
Data abstraction for RouteTableInfo.
void wireDecode(const ndn::Block &wire)
ndn::tlv::Error Error
const ndn::Name & getDestination() const
const NexthopList & getNexthopList() const
RoutingTableEntry()=default
NexthopList & getNexthopList()
bool operator==(RoutingTableEntry &rhs)
RoutingTableEntry(const ndn::Block &block)
ndn::Name m_destination
ndn::Block m_wire
const ndn::Block & wireEncode() const
RoutingTableEntry(const ndn::Name &dest)
NexthopList m_nexthopList
Copyright (c) 2014-2020, The University of Memphis, Regents of the University of California.
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(Adjacent)
std::ostream & operator<<(std::ostream &os, const Adjacent &adjacent)
Definition: adjacent.cpp:176