Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef _CCNB_PARSER_COMMON_H_ |
| 22 | #define _CCNB_PARSER_COMMON_H_ |
| 23 | |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 24 | #include "ns3/ndn-common.h" |
| 25 | |
| 26 | #ifndef NDN_NAMESPACE_BEGIN |
| 27 | #error "dafaq" |
| 28 | #endif |
| 29 | |
| 30 | NDN_NAMESPACE_BEGIN; |
| 31 | |
| 32 | namespace wire { |
Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 35 | * \ingroup ndn |
| 36 | * \defgroup ndn-ccnb CCNB decoding routines |
Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 37 | */ |
| 38 | /** |
Alexander Afanasyev | 2b4c947 | 2012-08-09 15:00:38 -0700 | [diff] [blame] | 39 | * \ingroup ndn-ccnb |
Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 40 | * \brief Namespace for ccnb parer |
| 41 | */ |
| 42 | namespace CcnbParser { |
| 43 | |
| 44 | // forward declarations |
| 45 | class Block; |
| 46 | class Blob; |
| 47 | class Udata; |
| 48 | class Tag; |
| 49 | class Attr; |
| 50 | class Dtag; |
| 51 | class Dattr; |
| 52 | class Ext; |
| 53 | |
Alexander Afanasyev | e709f3d | 2011-08-21 17:55:45 -0700 | [diff] [blame] | 54 | |
| 55 | /** |
| 56 | * \brief Exception thrown if there is a parsing error |
| 57 | * |
| 58 | * \todo inherit this class from some exception class and provide meaningful error messages |
| 59 | */ |
| 60 | class CcnbDecodingException {}; |
| 61 | |
Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 62 | /** |
| 63 | * \brief Type tag for a ccnb start marker. |
| 64 | * |
| 65 | * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html |
| 66 | */ |
| 67 | enum ccn_tt { |
| 68 | CCN_EXT, /**< starts composite extension - numval is subtype */ |
| 69 | CCN_TAG, /**< starts composite - numval is tagnamelen-1 */ |
| 70 | CCN_DTAG, /**< starts composite - numval is tagdict index (enum ccn_dtag) */ |
| 71 | CCN_ATTR, /**< attribute - numval is attrnamelen-1, value follows */ |
| 72 | CCN_DATTR, /**< attribute numval is attrdict index */ |
| 73 | CCN_BLOB, /**< opaque binary data - numval is byte count */ |
| 74 | CCN_UDATA, /**< UTF-8 encoded character data - numval is byte count */ |
| 75 | CCN_NO_TOKEN /**< should not occur in encoding */ |
| 76 | }; |
| 77 | |
| 78 | /** \brief CCN_CLOSE terminates composites */ |
| 79 | enum {CCN_CLOSE = 0}; |
| 80 | |
| 81 | /** |
| 82 | * \brief DTAG identifies ccnb-encoded elements. |
| 83 | * |
| 84 | * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html |
| 85 | */ |
| 86 | enum ccn_dtag { |
| 87 | CCN_DTAG_Any = 13, |
| 88 | CCN_DTAG_Name = 14, |
| 89 | CCN_DTAG_Component = 15, |
| 90 | CCN_DTAG_Certificate = 16, |
| 91 | CCN_DTAG_Collection = 17, |
| 92 | CCN_DTAG_CompleteName = 18, |
| 93 | CCN_DTAG_Content = 19, |
| 94 | CCN_DTAG_SignedInfo = 20, |
| 95 | CCN_DTAG_ContentDigest = 21, |
| 96 | CCN_DTAG_ContentHash = 22, |
| 97 | CCN_DTAG_Count = 24, |
| 98 | CCN_DTAG_Header = 25, |
| 99 | CCN_DTAG_Interest = 26, /* 20090915 */ |
| 100 | CCN_DTAG_Key = 27, |
| 101 | CCN_DTAG_KeyLocator = 28, |
| 102 | CCN_DTAG_KeyName = 29, |
| 103 | CCN_DTAG_Length = 30, |
| 104 | CCN_DTAG_Link = 31, |
| 105 | CCN_DTAG_LinkAuthenticator = 32, |
| 106 | CCN_DTAG_NameComponentCount = 33, /* DeprecatedInInterest */ |
| 107 | CCN_DTAG_RootDigest = 36, |
| 108 | CCN_DTAG_Signature = 37, |
| 109 | CCN_DTAG_Start = 38, |
| 110 | CCN_DTAG_Timestamp = 39, |
| 111 | CCN_DTAG_Type = 40, |
| 112 | CCN_DTAG_Nonce = 41, |
| 113 | CCN_DTAG_Scope = 42, |
| 114 | CCN_DTAG_Exclude = 43, |
| 115 | CCN_DTAG_Bloom = 44, |
| 116 | CCN_DTAG_BloomSeed = 45, |
| 117 | CCN_DTAG_AnswerOriginKind = 47, |
| 118 | CCN_DTAG_InterestLifetime = 48, |
| 119 | CCN_DTAG_Witness = 53, |
| 120 | CCN_DTAG_SignatureBits = 54, |
| 121 | CCN_DTAG_DigestAlgorithm = 55, |
| 122 | CCN_DTAG_BlockSize = 56, |
| 123 | CCN_DTAG_FreshnessSeconds = 58, |
| 124 | CCN_DTAG_FinalBlockID = 59, |
| 125 | CCN_DTAG_PublisherPublicKeyDigest = 60, |
| 126 | CCN_DTAG_PublisherCertificateDigest = 61, |
| 127 | CCN_DTAG_PublisherIssuerKeyDigest = 62, |
| 128 | CCN_DTAG_PublisherIssuerCertificateDigest = 63, |
| 129 | CCN_DTAG_ContentObject = 64, /* 20090915 */ |
| 130 | CCN_DTAG_WrappedKey = 65, |
| 131 | CCN_DTAG_WrappingKeyIdentifier = 66, |
| 132 | CCN_DTAG_WrapAlgorithm = 67, |
| 133 | CCN_DTAG_KeyAlgorithm = 68, |
| 134 | CCN_DTAG_Label = 69, |
| 135 | CCN_DTAG_EncryptedKey = 70, |
| 136 | CCN_DTAG_EncryptedNonceKey = 71, |
| 137 | CCN_DTAG_WrappingKeyName = 72, |
| 138 | CCN_DTAG_Action = 73, |
| 139 | CCN_DTAG_FaceID = 74, |
| 140 | CCN_DTAG_IPProto = 75, |
| 141 | CCN_DTAG_Host = 76, |
| 142 | CCN_DTAG_Port = 77, |
| 143 | CCN_DTAG_MulticastInterface = 78, |
| 144 | CCN_DTAG_ForwardingFlags = 79, |
| 145 | CCN_DTAG_FaceInstance = 80, |
| 146 | CCN_DTAG_ForwardingEntry = 81, |
| 147 | CCN_DTAG_MulticastTTL = 82, |
| 148 | CCN_DTAG_MinSuffixComponents = 83, |
| 149 | CCN_DTAG_MaxSuffixComponents = 84, |
| 150 | CCN_DTAG_ChildSelector = 85, |
| 151 | CCN_DTAG_RepositoryInfo = 86, |
| 152 | CCN_DTAG_Version = 87, |
| 153 | CCN_DTAG_RepositoryVersion = 88, |
| 154 | CCN_DTAG_GlobalPrefix = 89, |
| 155 | CCN_DTAG_LocalName = 90, |
| 156 | CCN_DTAG_Policy = 91, |
| 157 | CCN_DTAG_Namespace = 92, |
| 158 | CCN_DTAG_GlobalPrefixName = 93, |
| 159 | CCN_DTAG_PolicyVersion = 94, |
| 160 | CCN_DTAG_KeyValueSet = 95, |
| 161 | CCN_DTAG_KeyValuePair = 96, |
| 162 | CCN_DTAG_IntegerValue = 97, |
| 163 | CCN_DTAG_DecimalValue = 98, |
| 164 | CCN_DTAG_StringValue = 99, |
| 165 | CCN_DTAG_BinaryValue = 100, |
| 166 | CCN_DTAG_NameValue = 101, |
| 167 | CCN_DTAG_Entry = 102, |
| 168 | CCN_DTAG_ACL = 103, |
| 169 | CCN_DTAG_ParameterizedName = 104, |
| 170 | CCN_DTAG_Prefix = 105, |
| 171 | CCN_DTAG_Suffix = 106, |
| 172 | CCN_DTAG_Root = 107, |
| 173 | CCN_DTAG_ProfileName = 108, |
| 174 | CCN_DTAG_Parameters = 109, |
| 175 | CCN_DTAG_InfoString = 110, |
| 176 | CCN_DTAG_StatusResponse = 112, |
| 177 | CCN_DTAG_StatusCode = 113, |
| 178 | CCN_DTAG_StatusText = 114, |
Alexander Afanasyev | a46844b | 2011-11-21 19:13:26 -0800 | [diff] [blame] | 179 | CCN_DTAG_Nack = 200, |
Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 180 | CCN_DTAG_SequenceNumber = 256, |
| 181 | CCN_DTAG_CCNProtocolDataUnit = 17702112 |
| 182 | }; |
| 183 | |
Alexander Afanasyev | 1043c70 | 2013-07-15 16:21:09 -0700 | [diff] [blame] | 184 | } // CcnbParser |
| 185 | } // wire |
| 186 | |
| 187 | NDN_NAMESPACE_END |
Alexander Afanasyev | 8b37905 | 2011-08-21 16:58:20 -0700 | [diff] [blame] | 188 | |
| 189 | #endif // _CCNB_PARSER_COMMON_H_ |