NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
tlv.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2020 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 
22 #include "ndn-cxx/encoding/tlv.hpp"
23 
24 namespace ndn {
25 namespace tlv {
26 
27 Error::Error(const char* expectedType, uint32_t actualType)
28  : Error("Expecting "s + expectedType + " element, but TLV has type " + to_string(actualType))
29 {
30 }
31 
32 std::ostream&
33 operator<<(std::ostream& os, SignatureTypeValue st)
34 {
35  switch (st) {
36  case DigestSha256:
37  return os << "DigestSha256";
39  return os << "SignatureSha256WithRsa";
41  return os << "SignatureSha256WithEcdsa";
43  return os << "SignatureHmacWithSha256";
44  case NullSignature:
45  return os << "NullSignature";
46  }
47  return os << "Unknown(" << static_cast<uint32_t>(st) << ')';
48 }
49 
50 std::ostream&
51 operator<<(std::ostream& os, ContentTypeValue ct)
52 {
53  switch (ct) {
54  case ContentType_Blob:
55  return os << "Blob";
56  case ContentType_Link:
57  return os << "Link";
58  case ContentType_Key:
59  return os << "Key";
60  case ContentType_Nack:
61  return os << "Nack";
63  return os << "Manifest";
65  return os << "PrefixAnn";
66  case ContentType_Flic:
67  return os << "FLIC";
68  }
69 
70  if (ct <= 1023) {
71  os << "Reserved(";
72  }
73  else if (ct >= 9000 && ct <= 9999) {
74  os << "Experimental(";
75  }
76  else {
77  os << "Unknown(";
78  }
79  return os << static_cast<uint32_t>(ct) << ')';
80 }
81 
82 } // namespace tlv
83 } // namespace ndn
Copyright (c) 2011-2015 Regents of the University of California.
std::ostream & operator<<(std::ostream &os, SignatureTypeValue st)
Definition: tlv.cpp:33
std::string to_string(const T &val)
Definition: backports.hpp:86
public key, certificate
Definition: tlv.hpp:163
prefix announcement
Definition: tlv.hpp:166
File-Like ICN Collection.
Definition: tlv.hpp:167
another name that identifies the actual data content
Definition: tlv.hpp:162
ContentTypeValue
ContentType values.
Definition: tlv.hpp:160
SignatureTypeValue
SignatureType values.
Definition: tlv.hpp:132
application-level nack
Definition: tlv.hpp:164
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:27
represents an error in TLV encoding or decoding
Definition: tlv.hpp:52