blob: 97d083fe30d1a18da0a7f7e80a1bd74e23038c1f [file] [log] [blame]
laqinfan35731852017-08-08 06:17:39 -05001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2014-2018, The University of Memphis,
4 * Regents of the University of California,
5 * Arizona Board of Regents.
6 *
7 * This file is part of NLSR (Named-data Link State Routing).
8 * See AUTHORS.md for complete list of NLSR authors and contributors.
9 *
10 * NLSR is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 **/
21
22#ifndef NLSR_TLV_ROUTING_TABLE_STATUS_HPP
23#define NLSR_TLV_ROUTING_TABLE_STATUS_HPP
24
25#include "routing-table-entry.hpp"
26#include "destination.hpp"
27
28#include <ndn-cxx/util/time.hpp>
29#include <ndn-cxx/encoding/block.hpp>
30#include <ndn-cxx/encoding/encoding-buffer.hpp>
31#include <ndn-cxx/encoding/tlv.hpp>
32#include <ndn-cxx/name.hpp>
33
34#include <list>
35
36namespace nlsr {
37namespace tlv {
38
39/*! \brief Data abstraction for routing table status
40 *
41 * RtStatus := RT-STATUS-TYPE TLV-LENGTH
42 * RouteTableInfo*
43 *
44 * \sa https://redmine.named-data.net/projects/nlsr/wiki/Routing_Table_Dataset
45 */
46class RoutingTableStatus
47{
48public:
49 class Error : public ndn::tlv::Error
50 {
51 public:
52 explicit
53 Error(const std::string& what)
54 : ndn::tlv::Error(what)
55 {
56 }
57 };
58
59 typedef std::list<RoutingTable> RTList;
60
61 RoutingTableStatus();
62
63 explicit
64 RoutingTableStatus(const ndn::Block& block);
65
66 const std::list<RoutingTable>&
67 getRoutingtable() const
68 {
69 return m_routingtables;
70 }
71
72 RoutingTableStatus&
73 addRoutingTable(const RoutingTable& routeTable);
74
75 RoutingTableStatus&
76 clearRoutingTable();
77
78 bool
79 hasRoutingTable();
80
81 template<ndn::encoding::Tag TAG>
82 size_t
83 wireEncode(ndn::EncodingImpl<TAG>& block) const;
84
85 const ndn::Block&
86 wireEncode() const;
87
88 void
89 wireDecode(const ndn::Block& wire);
90
91private:
92 RTList m_routingtables;
93 bool m_hasRoutingtable;
94
95 mutable ndn::Block m_wire;
96};
97
laqinfana073e2e2018-01-15 21:17:24 +000098NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(RoutingTableStatus);
99
laqinfan35731852017-08-08 06:17:39 -0500100std::ostream&
101operator<<(std::ostream& os, const RoutingTableStatus& rtStatus);
102
103} // namespace tlv
104} // namespace nlsr
105
106#endif // NLSR_TLV_ROUTING_TABLE_STATUS_HPP