blob: c7627ab6562ffdb3187dde81b63f15d384e9ff50 [file] [log] [blame]
Alexander Afanasyevc74a6022011-08-15 20:01:35 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07002/*
Alexander Afanasyev7112f482011-08-17 14:05:57 -07003 * Copyright (c) 2011 University of California, Los Angeles
Alexander Afanasyev08d984e2011-08-13 19:20:22 -07004 *
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 Afanasyev7112f482011-08-17 14:05:57 -070018 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070019 */
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070020
Alexander Afanasyev7112f482011-08-17 14:05:57 -070021#ifndef _CCNX_H_
22#define _CCNX_H_
23
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070024#include "ns3/object.h"
25#include "ns3/socket.h"
26#include "ns3/callback.h"
27
Alexander Afanasyev7112f482011-08-17 14:05:57 -070028#include "ccnx-face.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070029
30namespace ns3 {
31
32class Node;
33class NetDevice;
34class Packet;
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070035class CcnxForwardingStrategy;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070036
37/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070038 * \defgroup ccnx NDN abstraction
39 *
40 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070041 */
42/**
43 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070044 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070045 *
46 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070047 * 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 Afanasyev08d984e2011-08-13 19:20:22 -070053 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070054 * 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 Afanasyev08d984e2011-08-13 19:20:22 -070060 */
61class Ccnx : public Object
62{
63public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070064 /**
65 * \brief Interface ID
66 *
67 * \return interface ID
68 */
69 static TypeId GetTypeId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070070
71 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070072 * \brief Register a new forwarding strategy to be used by this Ccnx
73 * stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070074 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070075 * This call will replace any forwarding strategy that has been
76 * previously registered.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070077 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070078 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
79 * object
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070080 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070081 virtual void SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070082
83 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070084 * \brief Get the forwarding strategy being used by this Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070085 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070086 * \returns smart pointer to CcnxForwardingStrategy object, or null
87 * pointer if none
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070088 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070089 virtual Ptr<CcnxForwardingStrategy> GetForwardingStrategy (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070090
91 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070092 * \brief Add face to CCNx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070093 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070094 * \param face smart pointer to CcnxFace-derived object
95 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
96 * index of the Ccnx interface added.
97 *
98 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070099 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700100 virtual uint32_t AddFace (const Ptr<CcnxFace> &face) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700101
102 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700103 * \brief Get current number of faces added to CCNx stack
104 *
105 * \returns the number of faces
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700106 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700107 virtual uint32_t GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700108
109 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700110 * \brief Send a packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700111 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700112 * \param packet fully prepared CCNx packet to send
113 * \param face face where to send this packet
114 *
115 * Higher-level layers (forwarding strategy in particular) call this
116 * method to send a packet down the stack to the MAC and PHY layers.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700117 */
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700118 virtual void Send (Ptr<Packet> packet, const Ptr<CcnxFace> &face) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700119
120 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700121 * \param face The face number of an Ccnx interface.
122 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700123 */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700124 virtual Ptr<CcnxFace> GetFace (uint32_t face) const = 0;
Alexander Afanasyev98256102011-08-14 01:00:02 -0700125
Alexander Afanasyev834f35c2011-08-16 17:13:50 -0700126public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700127 /**
128 * \brief Type tag for a ccnb start marker.
Alexander Afanasyev834f35c2011-08-16 17:13:50 -0700129 *
130 * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html
131 */
132 enum ccn_tt {
133 CCN_EXT, /**< starts composite extension - numval is subtype */
134 CCN_TAG, /**< starts composite - numval is tagnamelen-1 */
135 CCN_DTAG, /**< starts composite - numval is tagdict index (enum ccn_dtag) */
136 CCN_ATTR, /**< attribute - numval is attrnamelen-1, value follows */
137 CCN_DATTR, /**< attribute numval is attrdict index */
138 CCN_BLOB, /**< opaque binary data - numval is byte count */
139 CCN_UDATA, /**< UTF-8 encoded character data - numval is byte count */
140 CCN_NO_TOKEN /**< should not occur in encoding */
141 };
142
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700143 /** \brief CCN_CLOSE terminates composites */
Alexander Afanasyev834f35c2011-08-16 17:13:50 -0700144 enum {CCN_CLOSE = 0};
145
Alexander Afanasyev834f35c2011-08-16 17:13:50 -0700146 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700147 * \brief DTAG identifies ccnb-encoded elements.
Alexander Afanasyev834f35c2011-08-16 17:13:50 -0700148 *
149 * \see http://www.ccnx.org/releases/latest/doc/technical/DTAG.html
150 */
151 enum ccn_dtag {
152 CCN_DTAG_Any = 13,
153 CCN_DTAG_Name = 14,
154 CCN_DTAG_Component = 15,
155 CCN_DTAG_Certificate = 16,
156 CCN_DTAG_Collection = 17,
157 CCN_DTAG_CompleteName = 18,
158 CCN_DTAG_Content = 19,
159 CCN_DTAG_SignedInfo = 20,
160 CCN_DTAG_ContentDigest = 21,
161 CCN_DTAG_ContentHash = 22,
162 CCN_DTAG_Count = 24,
163 CCN_DTAG_Header = 25,
164 CCN_DTAG_Interest = 26, /* 20090915 */
165 CCN_DTAG_Key = 27,
166 CCN_DTAG_KeyLocator = 28,
167 CCN_DTAG_KeyName = 29,
168 CCN_DTAG_Length = 30,
169 CCN_DTAG_Link = 31,
170 CCN_DTAG_LinkAuthenticator = 32,
171 CCN_DTAG_NameComponentCount = 33, /* DeprecatedInInterest */
172 CCN_DTAG_RootDigest = 36,
173 CCN_DTAG_Signature = 37,
174 CCN_DTAG_Start = 38,
175 CCN_DTAG_Timestamp = 39,
176 CCN_DTAG_Type = 40,
177 CCN_DTAG_Nonce = 41,
178 CCN_DTAG_Scope = 42,
179 CCN_DTAG_Exclude = 43,
180 CCN_DTAG_Bloom = 44,
181 CCN_DTAG_BloomSeed = 45,
182 CCN_DTAG_AnswerOriginKind = 47,
183 CCN_DTAG_InterestLifetime = 48,
184 CCN_DTAG_Witness = 53,
185 CCN_DTAG_SignatureBits = 54,
186 CCN_DTAG_DigestAlgorithm = 55,
187 CCN_DTAG_BlockSize = 56,
188 CCN_DTAG_FreshnessSeconds = 58,
189 CCN_DTAG_FinalBlockID = 59,
190 CCN_DTAG_PublisherPublicKeyDigest = 60,
191 CCN_DTAG_PublisherCertificateDigest = 61,
192 CCN_DTAG_PublisherIssuerKeyDigest = 62,
193 CCN_DTAG_PublisherIssuerCertificateDigest = 63,
194 CCN_DTAG_ContentObject = 64, /* 20090915 */
195 CCN_DTAG_WrappedKey = 65,
196 CCN_DTAG_WrappingKeyIdentifier = 66,
197 CCN_DTAG_WrapAlgorithm = 67,
198 CCN_DTAG_KeyAlgorithm = 68,
199 CCN_DTAG_Label = 69,
200 CCN_DTAG_EncryptedKey = 70,
201 CCN_DTAG_EncryptedNonceKey = 71,
202 CCN_DTAG_WrappingKeyName = 72,
203 CCN_DTAG_Action = 73,
204 CCN_DTAG_FaceID = 74,
205 CCN_DTAG_IPProto = 75,
206 CCN_DTAG_Host = 76,
207 CCN_DTAG_Port = 77,
208 CCN_DTAG_MulticastInterface = 78,
209 CCN_DTAG_ForwardingFlags = 79,
210 CCN_DTAG_FaceInstance = 80,
211 CCN_DTAG_ForwardingEntry = 81,
212 CCN_DTAG_MulticastTTL = 82,
213 CCN_DTAG_MinSuffixComponents = 83,
214 CCN_DTAG_MaxSuffixComponents = 84,
215 CCN_DTAG_ChildSelector = 85,
216 CCN_DTAG_RepositoryInfo = 86,
217 CCN_DTAG_Version = 87,
218 CCN_DTAG_RepositoryVersion = 88,
219 CCN_DTAG_GlobalPrefix = 89,
220 CCN_DTAG_LocalName = 90,
221 CCN_DTAG_Policy = 91,
222 CCN_DTAG_Namespace = 92,
223 CCN_DTAG_GlobalPrefixName = 93,
224 CCN_DTAG_PolicyVersion = 94,
225 CCN_DTAG_KeyValueSet = 95,
226 CCN_DTAG_KeyValuePair = 96,
227 CCN_DTAG_IntegerValue = 97,
228 CCN_DTAG_DecimalValue = 98,
229 CCN_DTAG_StringValue = 99,
230 CCN_DTAG_BinaryValue = 100,
231 CCN_DTAG_NameValue = 101,
232 CCN_DTAG_Entry = 102,
233 CCN_DTAG_ACL = 103,
234 CCN_DTAG_ParameterizedName = 104,
235 CCN_DTAG_Prefix = 105,
236 CCN_DTAG_Suffix = 106,
237 CCN_DTAG_Root = 107,
238 CCN_DTAG_ProfileName = 108,
239 CCN_DTAG_Parameters = 109,
240 CCN_DTAG_InfoString = 110,
241 CCN_DTAG_StatusResponse = 112,
242 CCN_DTAG_StatusCode = 113,
243 CCN_DTAG_StatusText = 114,
244 CCN_DTAG_SequenceNumber = 256,
245 CCN_DTAG_CCNProtocolDataUnit = 17702112
246 };
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700247};
248
249} // namespace ns3
250
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700251#endif /* _CCNX_H_ */