blob: 6d8461e46080a6aebb9c8a04dc84afb3032f3643 [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 Afanasyev08d984e2011-08-13 19:20:22 -070028namespace ns3 {
29
30class Node;
31class NetDevice;
32class Packet;
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070033class CcnxForwardingStrategy;
Alexander Afanasyev78cf0c92011-09-01 19:57:14 -070034class CcnxFace;
35
36/**
37 * \internal
38 * \brief Private namespace for CCNx content store implementation
39 */
40namespace __ccnx_private
41{
42class i_face {};
43class i_metric {};
44class i_nth {};
45class i_prefix {};
46class i_ordered {}; ///< tag for Boost.MultiIndex container (ordered by prefix)
47class i_mru {};
48}
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070049
50/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070051 * \defgroup ccnx NDN abstraction
52 *
53 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070054 */
55/**
56 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070057 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070058 *
59 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070060 * the Ccnx stack implementation:
61 * -# register a face (CcnxFace-derived object) for use by the Ccnx
62 * layer
63 * -# register forwarding strategy (CcnxForwardingStrategy-derived
64 * object) to use by Ccnx stack
65 * -# export Ccnx configuration attributes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070066 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070067 * Each CcnxFace-derived object has conceptually a single Ccnx
68 * interface associated with it.
69 *
70 * In addition, this class defines CCNx packet coding constants
71 *
72 * \see CcnxFace, CcnxForwardingStrategy
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070073 */
74class Ccnx : public Object
75{
76public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070077 /**
78 * \brief Interface ID
79 *
80 * \return interface ID
81 */
82 static TypeId GetTypeId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070083
84 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070085 * \brief Send a packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070086 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070087 * \param face face where to send this packet
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070088 * \param packet fully prepared CCNx packet to send
Alexander Afanasyev7112f482011-08-17 14:05:57 -070089 *
90 * Higher-level layers (forwarding strategy in particular) call this
91 * method to send a packet down the stack to the MAC and PHY layers.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070092 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070093 virtual void
94 Send (const Ptr<CcnxFace> &face, const Ptr<Packet> &packet) = 0;
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070095
96 /**
97 * \brief Lower layers calls this method after demultiplexing
98 *
99 * Lower-layer-dependent implementation of CcnxFace will do actual work
100 * to set up demultiplexing and call this function as a callback
101 *
102 * \param face face from which packet came from
103 * \param p the packet
104 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700105 virtual void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -0700106 Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700107
108 /**
109 * \brief Register a new forwarding strategy to be used by this Ccnx
110 * stack
111 *
112 * This call will replace any forwarding strategy that has been
113 * previously registered.
114 *
115 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
116 * object
117 */
118 virtual void
119 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
120
121 /**
122 * \brief Get the forwarding strategy being used by this Ccnx stack
123 *
124 * \returns smart pointer to CcnxForwardingStrategy object, or null
125 * pointer if none
126 */
127 virtual Ptr<CcnxForwardingStrategy>
128 GetForwardingStrategy (void) const = 0;
129
130 /**
131 * \brief Add face to CCNx stack
132 *
133 * \param face smart pointer to CcnxFace-derived object
134 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
135 * index of the Ccnx interface added.
136 *
137 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
138 */
139 virtual uint32_t
140 AddFace (const Ptr<CcnxFace> &face) = 0;
141
142 /**
143 * \brief Get current number of faces added to CCNx stack
144 *
145 * \returns the number of faces
146 */
147 virtual uint32_t
148 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700149
150 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700151 * \param face The face number of an Ccnx interface.
152 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700153 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700154 virtual Ptr<CcnxFace>
155 GetFace (uint32_t face) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700156};
157
158} // namespace ns3
159
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700160#endif /* _CCNX_H_ */