blob: 666158f76d68265151042749d4334ce3758c583c [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 Send a packet to a specified face
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070073 *
Alexander Afanasyev7112f482011-08-17 14:05:57 -070074 * \param face face where to send this packet
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070075 * \param packet fully prepared CCNx packet to send
Alexander Afanasyev7112f482011-08-17 14:05:57 -070076 *
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 Afanasyev08d984e2011-08-13 19:20:22 -070079 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070080 virtual void
81 Send (const Ptr<CcnxFace> &face, const Ptr<Packet> &packet) = 0;
Alexander Afanasyevab1d5602011-08-17 19:17:18 -070082
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 Afanasyev56f79ea2011-08-17 23:54:27 -070092 virtual void
Alexander Afanasyev0ab833e2011-08-18 15:49:13 -070093 Receive (const Ptr<CcnxFace> &face, const Ptr<const Packet> &p) = 0;
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -070094
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 Afanasyev08d984e2011-08-13 19:20:22 -0700136
137 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700138 * \param face The face number of an Ccnx interface.
139 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700140 */
Alexander Afanasyev56f79ea2011-08-17 23:54:27 -0700141 virtual Ptr<CcnxFace>
142 GetFace (uint32_t face) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700143};
144
145} // namespace ns3
146
Alexander Afanasyev7112f482011-08-17 14:05:57 -0700147#endif /* _CCNX_H_ */