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-2019 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  }
45  return os << "Unknown(" << static_cast<uint32_t>(st) << ')';
46 }
47 
48 std::ostream&
49 operator<<(std::ostream& os, ContentTypeValue ct)
50 {
51  switch (ct) {
52  case ContentType_Blob:
53  return os << "Blob";
54  case ContentType_Link:
55  return os << "Link";
56  case ContentType_Key:
57  return os << "Key";
58  case ContentType_Nack:
59  return os << "Nack";
61  return os << "Manifest";
63  return os << "PrefixAnn";
64  case ContentType_Flic:
65  return os << "FLIC";
66  }
67 
68  if (ct >= 6 && ct <= 1023) {
69  os << "Reserved(";
70  }
71  else if (ct >= 9000 && ct <= 9999) {
72  os << "Experimental(";
73  }
74  else {
75  os << "Unknown(";
76  }
77  return os << static_cast<uint32_t>(ct) << ')';
78 }
79 
80 } // namespace tlv
81 } // namespace ndn
ndn::tlv::ContentType_Key
@ ContentType_Key
public key, certificate
Definition: tlv.hpp:159
tlv.hpp
ndn::tlv::ContentTypeValue
ContentTypeValue
ContentType values.
Definition: tlv.hpp:156
ndn::tlv::ContentType_Manifest
@ ContentType_Manifest
Definition: tlv.hpp:161
ndn::tlv::SignatureSha256WithEcdsa
@ SignatureSha256WithEcdsa
Definition: tlv.hpp:132
ndn::tlv::ContentType_Link
@ ContentType_Link
another name that identifies the actual data content
Definition: tlv.hpp:158
ndn::tlv::DigestSha256
@ DigestSha256
Definition: tlv.hpp:130
ndn::tlv::ContentType_Nack
@ ContentType_Nack
application-level nack
Definition: tlv.hpp:160
ndn::tlv::ContentType_Flic
@ ContentType_Flic
File-Like ICN Collection.
Definition: tlv.hpp:163
ndn::tlv::SignatureSha256WithRsa
@ SignatureSha256WithRsa
Definition: tlv.hpp:131
ndn::tlv::SignatureTypeValue
SignatureTypeValue
SignatureType values.
Definition: tlv.hpp:129
ndn::tlv::operator<<
std::ostream & operator<<(std::ostream &os, SignatureTypeValue st)
Definition: tlv.cpp:33
ndn::tlv::ContentType_Blob
@ ContentType_Blob
payload
Definition: tlv.hpp:157
ndn::tlv::SignatureHmacWithSha256
@ SignatureHmacWithSha256
Definition: tlv.hpp:133
ndn::to_string
std::string to_string(const T &val)
Definition: backports.hpp:102
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition: tlv.hpp:53
ndn::tlv::Error::Error
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:27
ndn::tlv::ContentType_PrefixAnn
@ ContentType_PrefixAnn
prefix announcement
Definition: tlv.hpp:162
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34