blob: 12c45d28cf53b85f4c3efb7581986850dfb4794e [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/*
3 * Copyright (c) 2007 INRIA
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 Afanasyev98256102011-08-14 01:00:02 -070018 * Author:
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070019 */
20#ifndef CCNX_H
21#define CCNX_H
22
23#include <stdint.h>
24#include "ns3/object.h"
25#include "ns3/socket.h"
26#include "ns3/callback.h"
27
28#include "ccnx-route.h"
29
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/**
38 * \ingroup internet
39 * \defgroup ccnx Ccnx
40 */
41/**
42 * \ingroup ccnx
43 * \brief Access to the Ccnx forwarding table, interfaces, and configuration
44 *
45 * This class defines the API to manipulate the following aspects of
46 * the Ccnx implementation:
47 * -# register a NetDevice for use by the Ccnx layer (basically, to
48 * create Ccnx-related state such as addressing and neighbor cache that
49 * is associated with a NetDevice)
50 * -# manipulate the status of the NetDevice from the Ccnx perspective,
51 * such as marking it as Up or Down,
52 // * -# adding, deleting, and getting addresses associated to the Ccnx
53 // * interfaces.
54 * -# exporting Ccnx configuration attributes
55 *
56 * Each NetDevice has conceptually a single Ccnx interface associated
57 * with it.
58 */
59class Ccnx : public Object
60{
61public:
62 static TypeId GetTypeId (void);
63 Ccnx ();
64 virtual ~Ccnx ();
65
66 /**
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070067 * \brief Register a new forwarding protocol to be used by this Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070068 *
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070069 * This call will replace any forwarding protocol that has been previously
70 * registered. If you want to add multiple forwarding protocols, you must
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070071 * add them to a CcnxListForwardingStrategy directly.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070072 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070073 * \param forwardingStrategy smart pointer to CcnxForwardingStrategy object
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070074 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070075 virtual void SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070076
77 /**
Alexander Afanasyev45b92d42011-08-14 23:11:38 -070078 * \brief Get the forwarding protocol to be used by this Ccnx stack
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070079 *
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070080 * \returns smart pointer to CcnxForwardingStrategy object, or null pointer if none
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070081 */
Alexander Afanasyevc74a6022011-08-15 20:01:35 -070082 virtual Ptr<CcnxForwardingStrategy> GetForwardingStrategy (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070083
84 /**
85 * \param device device to add to the list of Ccnx interfaces
86 * which can be used as output interfaces during packet forwarding.
87 * \returns the index of the Ccnx interface added.
88 *
89 * Once a device has been added, it can never be removed: if you want
90 * to disable it, you can invoke Ccnx::SetDown which will
91 * make sure that it is never used during packet forwarding.
92 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070093 virtual uint32_t AddFace (Ptr<CcnxFace> face) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070094
95 /**
96 * \returns the number of interfaces added by the user.
97 */
Alexander Afanasyev98256102011-08-14 01:00:02 -070098 virtual uint32_t GetNFaces (void) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -070099
100 /**
101 * \param packet packet to send
102 * \param route route entry
103 *
104 * Higher-level layers call this method to send a packet
105 * down the stack to the MAC and PHY layers.
106 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700107 // virtual void Send (Ptr<Packet> packet, Ptr<CcnxRoute> route) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700108
109 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700110 * \param face The face number of an Ccnx interface.
111 * \returns The CcnxFace associated with the Ccnx face number.
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700112 */
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700113 virtual Ptr<CcnxFace> GetFace (uint32_t face) const = 0;
Alexander Afanasyev98256102011-08-14 01:00:02 -0700114
115 // /**
116 // * \param face CcnxFace object pointer
117 // * \returns The interface number of an Ccnx face or -1 if not found.
118 // */
119 // virtual int32_t GetFaceForDevice (Ptr<const CcnxFace> face) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700120
121 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700122 * \param face The face number of an Ccnx face
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700123 * \param metric forwarding metric (cost) associated to the underlying
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700124 * Ccnx interface
125 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700126 virtual void SetMetric (uint32_t face, uint16_t metric) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700127
128 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700129 * \param face The interface number of an Ccnx interface
Alexander Afanasyev45b92d42011-08-14 23:11:38 -0700130 * \returns forwarding metric (cost) associated to the underlying
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700131 * Ccnx interface
132 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700133 virtual uint16_t GetMetric (uint32_t face) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700134
135 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700136 * \param face Interface number of Ccnx interface
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700137 * \returns the Maximum Transmission Unit (in bytes) associated
138 * to the underlying Ccnx interface
139 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700140 virtual uint16_t GetMtu (uint32_t face) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700141
142 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700143 * \param face Interface number of Ccnx interface
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700144 * \returns true if the underlying interface is in the "up" state,
145 * false otherwise.
146 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700147 virtual bool IsUp (uint32_t face) const = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700148
149 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700150 * \param face Interface number of Ccnx interface
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700151 *
152 * Set the interface into the "up" state. In this state, it is
153 * considered valid during Ccnx forwarding.
154 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700155 virtual void SetUp (uint32_t face) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700156
157 /**
Alexander Afanasyev98256102011-08-14 01:00:02 -0700158 * \param face Interface number of Ccnx interface
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700159 *
160 * Set the interface into the "down" state. In this state, it is
161 * ignored during Ccnx forwarding.
162 */
Alexander Afanasyev98256102011-08-14 01:00:02 -0700163 virtual void SetDown (uint32_t face) = 0;
Alexander Afanasyev08d984e2011-08-13 19:20:22 -0700164};
165
166} // namespace ns3
167
168#endif /* CCNX_H */