NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
nack-header.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2017 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  *
21  * @author Eric Newberry <enewberry@email.arizona.edu>
22  */
23 
24 #ifndef NDN_CXX_LP_NACK_HEADER_HPP
25 #define NDN_CXX_LP_NACK_HEADER_HPP
26 
27 #include "../common.hpp"
28 #include "../encoding/encoding-buffer.hpp"
29 #include "../encoding/block-helpers.hpp"
30 
31 #include "tlv.hpp"
32 
33 namespace ndn {
34 namespace lp {
35 
39 enum class NackReason {
40  NONE = 0,
41  CONGESTION = 50,
42  DUPLICATE = 100,
43  NO_ROUTE = 150
44 };
45 
46 std::ostream&
47 operator<<(std::ostream& os, NackReason reason);
48 
53 bool
55 
60 {
61 public:
62  NackHeader();
63 
64  explicit
65  NackHeader(const Block& block);
66 
67  template<encoding::Tag TAG>
68  size_t
69  wireEncode(EncodingImpl<TAG>& encoder) const;
70 
71  const Block&
72  wireEncode() const;
73 
74  void
75  wireDecode(const Block& wire);
76 
77 public: // reason
83  getReason() const;
84 
89  NackHeader&
90  setReason(NackReason reason);
91 
92 private:
93  NackReason m_reason;
94  mutable Block m_wire;
95 };
96 
98 
99 } // namespace lp
100 } // namespace ndn
101 
102 #endif // NDN_CXX_LP_NACK_HEADER_HPP
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(CachePolicy)
Copyright (c) 2011-2015 Regents of the University of California.
Represents a TLV element of NDN packet format.
Definition: block.hpp:42
NackReason
indicates the reason type of a network NACK
Definition: nack-header.hpp:39
std::ostream & operator<<(std::ostream &os, CachePolicyType policy)
bool isLessSevere(lp::NackReason x, lp::NackReason y)
compare NackReason for severity
Definition: nack-header.cpp:50
represents a Network NACK header
Definition: nack-header.hpp:59