Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 2 | /* |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 3 | * Copyright (c) 2011 University of California, Los Angeles |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 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 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 18 | * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 19 | */ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 20 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 21 | #ifndef _CCNX_H_ |
| 22 | #define _CCNX_H_ |
| 23 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 24 | #include "ns3/object.h" |
| 25 | #include "ns3/socket.h" |
| 26 | #include "ns3/callback.h" |
| 27 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 28 | #include "ccnx-face.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 29 | |
| 30 | namespace ns3 { |
| 31 | |
| 32 | class Node; |
| 33 | class NetDevice; |
| 34 | class Packet; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 35 | class CcnxForwardingStrategy; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 38 | * \defgroup ccnx NDN abstraction |
| 39 | * |
| 40 | * This is an abstract implementation of NDN protocol |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 41 | */ |
| 42 | /** |
| 43 | * \ingroup ccnx |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 44 | * \brief Interface to manage Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 45 | * |
| 46 | * This class defines the API to manipulate the following aspects of |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 47 | * the Ccnx stack implementation: |
| 48 | * -# register a face (CcnxFace-derived object) for use by the Ccnx |
| 49 | * layer |
| 50 | * -# register forwarding strategy (CcnxForwardingStrategy-derived |
| 51 | * object) to use by Ccnx stack |
| 52 | * -# export Ccnx configuration attributes |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 53 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 54 | * Each CcnxFace-derived object has conceptually a single Ccnx |
| 55 | * interface associated with it. |
| 56 | * |
| 57 | * In addition, this class defines CCNx packet coding constants |
| 58 | * |
| 59 | * \see CcnxFace, CcnxForwardingStrategy |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 60 | */ |
| 61 | class Ccnx : public Object |
| 62 | { |
| 63 | public: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 64 | /** |
| 65 | * \brief Interface ID |
| 66 | * |
| 67 | * \return interface ID |
| 68 | */ |
| 69 | static TypeId GetTypeId (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 70 | |
| 71 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 72 | * \brief Send a packet to a specified face |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 73 | * |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 74 | * \param face face where to send this packet |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 75 | * \param packet fully prepared CCNx packet to send |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 76 | * |
| 77 | * Higher-level layers (forwarding strategy in particular) call this |
| 78 | * method to send a packet down the stack to the MAC and PHY layers. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 79 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 80 | virtual void |
| 81 | Send (const Ptr<CcnxFace> &face, const Ptr<Packet> &packet) = 0; |
Alexander Afanasyev | ab1d560 | 2011-08-17 19:17:18 -0700 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * \brief Lower layers calls this method after demultiplexing |
| 85 | * |
| 86 | * Lower-layer-dependent implementation of CcnxFace will do actual work |
| 87 | * to set up demultiplexing and call this function as a callback |
| 88 | * |
| 89 | * \param face face from which packet came from |
| 90 | * \param p the packet |
| 91 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 92 | virtual void |
Alexander Afanasyev | 0ab833e | 2011-08-18 15:49:13 -0700 | [diff] [blame] | 93 | Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0; |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * \brief Register a new forwarding strategy to be used by this Ccnx |
| 97 | * stack |
| 98 | * |
| 99 | * This call will replace any forwarding strategy that has been |
| 100 | * previously registered. |
| 101 | * |
| 102 | * \param forwardingStrategy smart pointer to CcnxForwardingStrategy |
| 103 | * object |
| 104 | */ |
| 105 | virtual void |
| 106 | SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0; |
| 107 | |
| 108 | /** |
| 109 | * \brief Get the forwarding strategy being used by this Ccnx stack |
| 110 | * |
| 111 | * \returns smart pointer to CcnxForwardingStrategy object, or null |
| 112 | * pointer if none |
| 113 | */ |
| 114 | virtual Ptr<CcnxForwardingStrategy> |
| 115 | GetForwardingStrategy (void) const = 0; |
| 116 | |
| 117 | /** |
| 118 | * \brief Add face to CCNx stack |
| 119 | * |
| 120 | * \param face smart pointer to CcnxFace-derived object |
| 121 | * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the |
| 122 | * index of the Ccnx interface added. |
| 123 | * |
| 124 | * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace |
| 125 | */ |
| 126 | virtual uint32_t |
| 127 | AddFace (const Ptr<CcnxFace> &face) = 0; |
| 128 | |
| 129 | /** |
| 130 | * \brief Get current number of faces added to CCNx stack |
| 131 | * |
| 132 | * \returns the number of faces |
| 133 | */ |
| 134 | virtual uint32_t |
| 135 | GetNFaces (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 138 | * \param face The face number of an Ccnx interface. |
| 139 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 140 | */ |
Alexander Afanasyev | 56f79ea | 2011-08-17 23:54:27 -0700 | [diff] [blame] | 141 | virtual Ptr<CcnxFace> |
| 142 | GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 143 | |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 144 | public: |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 145 | /** |
| 146 | * \brief Type tag for a ccnb start marker. |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 147 | * |
| 148 | * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html |
| 149 | */ |
| 150 | enum ccn_tt { |
| 151 | CCN_EXT, /**< starts composite extension - numval is subtype */ |
| 152 | CCN_TAG, /**< starts composite - numval is tagnamelen-1 */ |
| 153 | CCN_DTAG, /**< starts composite - numval is tagdict index (enum ccn_dtag) */ |
| 154 | CCN_ATTR, /**< attribute - numval is attrnamelen-1, value follows */ |
| 155 | CCN_DATTR, /**< attribute numval is attrdict index */ |
| 156 | CCN_BLOB, /**< opaque binary data - numval is byte count */ |
| 157 | CCN_UDATA, /**< UTF-8 encoded character data - numval is byte count */ |
| 158 | CCN_NO_TOKEN /**< should not occur in encoding */ |
| 159 | }; |
| 160 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 161 | /** \brief CCN_CLOSE terminates composites */ |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 162 | enum {CCN_CLOSE = 0}; |
| 163 | |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 164 | /** |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 165 | * \brief DTAG identifies ccnb-encoded elements. |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 166 | * |
| 167 | * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html |
| 168 | */ |
| 169 | enum ccn_dtag { |
| 170 | CCN_DTAG_Any = 13, |
| 171 | CCN_DTAG_Name = 14, |
| 172 | CCN_DTAG_Component = 15, |
| 173 | CCN_DTAG_Certificate = 16, |
| 174 | CCN_DTAG_Collection = 17, |
| 175 | CCN_DTAG_CompleteName = 18, |
| 176 | CCN_DTAG_Content = 19, |
| 177 | CCN_DTAG_SignedInfo = 20, |
| 178 | CCN_DTAG_ContentDigest = 21, |
| 179 | CCN_DTAG_ContentHash = 22, |
| 180 | CCN_DTAG_Count = 24, |
| 181 | CCN_DTAG_Header = 25, |
| 182 | CCN_DTAG_Interest = 26, /* 20090915 */ |
| 183 | CCN_DTAG_Key = 27, |
| 184 | CCN_DTAG_KeyLocator = 28, |
| 185 | CCN_DTAG_KeyName = 29, |
| 186 | CCN_DTAG_Length = 30, |
| 187 | CCN_DTAG_Link = 31, |
| 188 | CCN_DTAG_LinkAuthenticator = 32, |
| 189 | CCN_DTAG_NameComponentCount = 33, /* DeprecatedInInterest */ |
| 190 | CCN_DTAG_RootDigest = 36, |
| 191 | CCN_DTAG_Signature = 37, |
| 192 | CCN_DTAG_Start = 38, |
| 193 | CCN_DTAG_Timestamp = 39, |
| 194 | CCN_DTAG_Type = 40, |
| 195 | CCN_DTAG_Nonce = 41, |
| 196 | CCN_DTAG_Scope = 42, |
| 197 | CCN_DTAG_Exclude = 43, |
| 198 | CCN_DTAG_Bloom = 44, |
| 199 | CCN_DTAG_BloomSeed = 45, |
| 200 | CCN_DTAG_AnswerOriginKind = 47, |
| 201 | CCN_DTAG_InterestLifetime = 48, |
| 202 | CCN_DTAG_Witness = 53, |
| 203 | CCN_DTAG_SignatureBits = 54, |
| 204 | CCN_DTAG_DigestAlgorithm = 55, |
| 205 | CCN_DTAG_BlockSize = 56, |
| 206 | CCN_DTAG_FreshnessSeconds = 58, |
| 207 | CCN_DTAG_FinalBlockID = 59, |
| 208 | CCN_DTAG_PublisherPublicKeyDigest = 60, |
| 209 | CCN_DTAG_PublisherCertificateDigest = 61, |
| 210 | CCN_DTAG_PublisherIssuerKeyDigest = 62, |
| 211 | CCN_DTAG_PublisherIssuerCertificateDigest = 63, |
| 212 | CCN_DTAG_ContentObject = 64, /* 20090915 */ |
| 213 | CCN_DTAG_WrappedKey = 65, |
| 214 | CCN_DTAG_WrappingKeyIdentifier = 66, |
| 215 | CCN_DTAG_WrapAlgorithm = 67, |
| 216 | CCN_DTAG_KeyAlgorithm = 68, |
| 217 | CCN_DTAG_Label = 69, |
| 218 | CCN_DTAG_EncryptedKey = 70, |
| 219 | CCN_DTAG_EncryptedNonceKey = 71, |
| 220 | CCN_DTAG_WrappingKeyName = 72, |
| 221 | CCN_DTAG_Action = 73, |
| 222 | CCN_DTAG_FaceID = 74, |
| 223 | CCN_DTAG_IPProto = 75, |
| 224 | CCN_DTAG_Host = 76, |
| 225 | CCN_DTAG_Port = 77, |
| 226 | CCN_DTAG_MulticastInterface = 78, |
| 227 | CCN_DTAG_ForwardingFlags = 79, |
| 228 | CCN_DTAG_FaceInstance = 80, |
| 229 | CCN_DTAG_ForwardingEntry = 81, |
| 230 | CCN_DTAG_MulticastTTL = 82, |
| 231 | CCN_DTAG_MinSuffixComponents = 83, |
| 232 | CCN_DTAG_MaxSuffixComponents = 84, |
| 233 | CCN_DTAG_ChildSelector = 85, |
| 234 | CCN_DTAG_RepositoryInfo = 86, |
| 235 | CCN_DTAG_Version = 87, |
| 236 | CCN_DTAG_RepositoryVersion = 88, |
| 237 | CCN_DTAG_GlobalPrefix = 89, |
| 238 | CCN_DTAG_LocalName = 90, |
| 239 | CCN_DTAG_Policy = 91, |
| 240 | CCN_DTAG_Namespace = 92, |
| 241 | CCN_DTAG_GlobalPrefixName = 93, |
| 242 | CCN_DTAG_PolicyVersion = 94, |
| 243 | CCN_DTAG_KeyValueSet = 95, |
| 244 | CCN_DTAG_KeyValuePair = 96, |
| 245 | CCN_DTAG_IntegerValue = 97, |
| 246 | CCN_DTAG_DecimalValue = 98, |
| 247 | CCN_DTAG_StringValue = 99, |
| 248 | CCN_DTAG_BinaryValue = 100, |
| 249 | CCN_DTAG_NameValue = 101, |
| 250 | CCN_DTAG_Entry = 102, |
| 251 | CCN_DTAG_ACL = 103, |
| 252 | CCN_DTAG_ParameterizedName = 104, |
| 253 | CCN_DTAG_Prefix = 105, |
| 254 | CCN_DTAG_Suffix = 106, |
| 255 | CCN_DTAG_Root = 107, |
| 256 | CCN_DTAG_ProfileName = 108, |
| 257 | CCN_DTAG_Parameters = 109, |
| 258 | CCN_DTAG_InfoString = 110, |
| 259 | CCN_DTAG_StatusResponse = 112, |
| 260 | CCN_DTAG_StatusCode = 113, |
| 261 | CCN_DTAG_StatusText = 114, |
| 262 | CCN_DTAG_SequenceNumber = 256, |
| 263 | CCN_DTAG_CCNProtocolDataUnit = 17702112 |
| 264 | }; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 265 | }; |
| 266 | |
| 267 | } // namespace ns3 |
| 268 | |
Alexander Afanasyev | 7112f48 | 2011-08-17 14:05:57 -0700 | [diff] [blame] | 269 | #endif /* _CCNX_H_ */ |