NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
fib-entry.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
22 #ifndef NDN_MGMT_NFD_FIB_ENTRY_HPP
23 #define NDN_MGMT_NFD_FIB_ENTRY_HPP
24 
25 #include "../../encoding/block.hpp"
26 #include "../../name.hpp"
27 #include <list>
28 
29 namespace ndn {
30 namespace nfd {
31 
35 {
36 public:
37  class Error : public tlv::Error
38  {
39  public:
40  explicit
41  Error(const std::string& what)
42  : tlv::Error(what)
43  {
44  }
45  };
46 
47  NextHopRecord();
48 
49  explicit
50  NextHopRecord(const Block& block);
51 
52  uint64_t
53  getFaceId() const
54  {
55  return m_faceId;
56  }
57 
59  setFaceId(uint64_t faceId);
60 
61  uint64_t
62  getCost() const
63  {
64  return m_cost;
65  }
66 
68  setCost(uint64_t cost);
69 
70  template<encoding::Tag TAG>
71  size_t
72  wireEncode(EncodingImpl<TAG>& block) const;
73 
74  const Block&
75  wireEncode() const;
76 
77  void
78  wireDecode(const Block& wire);
79 
80 private:
81  uint64_t m_faceId;
82  uint64_t m_cost;
83 
84  mutable Block m_wire;
85 };
86 
89 class FibEntry
90 {
91 public:
92  class Error : public tlv::Error
93  {
94  public:
95  explicit
96  Error(const std::string& what)
97  : tlv::Error(what)
98  {
99  }
100  };
101 
102  FibEntry();
103 
104  explicit
105  FibEntry(const Block& block);
106 
107  const Name&
108  getPrefix() const
109  {
110  return m_prefix;
111  }
112 
113  FibEntry&
114  setPrefix(const Name& prefix);
115 
116  const std::list<NextHopRecord>&
118  {
119  return m_nextHopRecords;
120  }
121 
122  FibEntry&
123  addNextHopRecord(const NextHopRecord& nextHopRecord);
124 
125  template<typename T>
126  FibEntry&
127  setNextHopRecords(const T& begin, const T& end)
128  {
129  m_nextHopRecords.clear();
130  m_nextHopRecords.assign(begin, end);
131  m_wire.reset();
132  return *this;
133  }
134 
135  template<encoding::Tag TAG>
136  size_t
137  wireEncode(EncodingImpl<TAG>& block) const;
138 
139  const Block&
140  wireEncode() const;
141 
142  void
143  wireDecode(const Block& wire);
144 
145 private:
146  Name m_prefix;
147  std::list<NextHopRecord> m_nextHopRecords;
148 
149  mutable Block m_wire;
150 };
151 
152 } // namespace nfd
153 } // namespace ndn
154 
155 #endif // NDN_MGMT_NFD_FIB_ENTRY_HPP
Copyright (c) 2011-2015 Regents of the University of California.
const std::list< NextHopRecord > & getNextHopRecords() const
Definition: fib-entry.hpp:117
NextHopRecord & setFaceId(uint64_t faceId)
Definition: fib-entry.cpp:59
Class representing a wire element of NDN-TLV packet format.
Definition: block.hpp:43
uint64_t getCost() const
Definition: fib-entry.hpp:62
void wireDecode(const Block &wire)
Definition: fib-entry.cpp:116
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-common.hpp:40
Error(const std::string &what)
Definition: fib-entry.hpp:41
NextHopRecord & setCost(uint64_t cost)
Definition: fib-entry.cpp:67
Name abstraction to represent an absolute name.
Definition: name.hpp:46
Error(const std::string &what)
Definition: fib-entry.hpp:96
const Name & getPrefix() const
Definition: fib-entry.hpp:108
uint64_t getFaceId() const
Definition: fib-entry.hpp:53
FibEntry & setNextHopRecords(const T &begin, const T &end)
Definition: fib-entry.hpp:127
represents an error in TLV encoding or decoding
Definition: tlv.hpp:50
const Block & wireEncode() const
Definition: fib-entry.cpp:99