blob: 7c0e1d071ff77d0ef30525f9ef2e5f5134c4bc8f [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"
Ilya Moiseenko888161d2011-08-29 13:01:17 -070029#include "ccnx-content-store.h"
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070030
31namespace ns3 {
32
33class Node;
34class NetDevice;
35class Packet;
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070036class CcnxForwardingStrategy;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070037
38/**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070039 * \defgroup ccnx NDN abstraction
40 *
41 * This is an abstract implementation of NDN protocol
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070042 */
43/**
44 * \ingroup ccnx
Alexander Afanasyev7112f482011-08-17 14:05:57 -070045 * \brief Interface to manage Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070046 *
47 * This class defines the API to manipulate the following aspects of
Alexander Afanasyev7112f482011-08-17 14:05:57 -070048 * the Ccnx stack implementation:
49 * -# register a face (CcnxFace-derived object) for use by the Ccnx
50 * layer
51 * -# register forwarding strategy (CcnxForwardingStrategy-derived
52 * object) to use by Ccnx stack
53 * -# export Ccnx configuration attributes
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070054 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070055 * Each CcnxFace-derived object has conceptually a single Ccnx
56 * interface associated with it.
57 *
58 * In addition, this class defines CCNx packet coding constants
59 *
60 * \see CcnxFace, CcnxForwardingStrategy
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070061 */
62class Ccnx : public Object
63{
64public:
Alexander Afanasyev7112f482011-08-17 14:05:57 -070065 /**
66 * \brief Interface ID
67 *
68 * \return interface ID
69 */
70 static TypeId GetTypeId ();
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070071
72 /**
Alexander Afanasyev7112f482011-08-17 14:05:57 -070073 * \brief Send a packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070074 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070075 * \param face face where to send this packet
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070076 * \param packet fully prepared CCNx packet to send
Alexander Afanasyev7112f482011-08-17 14:05:57 -070077 *
78 * Higher-level layers (forwarding strategy in particular) call this
79 * method to send a packet down the stack to the MAC and PHY layers.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070080 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070081 virtual void
82 Send (const Ptr<CcnxFace> &face, const Ptr<Packet> &packet) = 0;
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070083
84 /**
85 * \brief Lower layers calls this method after demultiplexing
86 *
87 * Lower-layer-dependent implementation of CcnxFace will do actual work
88 * to set up demultiplexing and call this function as a callback
89 *
90 * \param face face from which packet came from
91 * \param p the packet
92 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070093 virtual void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070094 Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070095
96 /**
97 * \brief Register a new forwarding strategy to be used by this Ccnx
98 * stack
99 *
100 * This call will replace any forwarding strategy that has been
101 * previously registered.
102 *
103 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy
104 * object
105 */
106 virtual void
107 SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
108
109 /**
110 * \brief Get the forwarding strategy being used by this Ccnx stack
111 *
112 * \returns smart pointer to CcnxForwardingStrategy object, or null
113 * pointer if none
114 */
115 virtual Ptr<CcnxForwardingStrategy>
116 GetForwardingStrategy (void) const = 0;
117
118 /**
119 * \brief Add face to CCNx stack
120 *
121 * \param face smart pointer to CcnxFace-derived object
122 * (CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace) \returns the
123 * index of the Ccnx interface added.
124 *
125 * \see CcnxLocalFace, CcnxNetDeviceFace, CcnxUdpFace
126 */
127 virtual uint32_t
128 AddFace (const Ptr<CcnxFace> &face) = 0;
129
130 /**
131 * \brief Get current number of faces added to CCNx stack
132 *
133 * \returns the number of faces
134 */
135 virtual uint32_t
136 GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700137
138 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700139 * \param face The face number of an Ccnx interface.
140 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700141 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700142 virtual Ptr<CcnxFace>
143 GetFace (uint32_t face) const = 0;
Ilya Moiseenko888161d2011-08-29 13:01:17 -0700144
145 Ptr<CcnxContentStore> m_contentStore;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700146};
147
148} // namespace ns3
149
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700150#endif /* _CCNX_H_ */