Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 2 | /* |
| 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 Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 18 | * Author: |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 19 | */ |
| 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 | |
| 30 | namespace ns3 { |
| 31 | |
| 32 | class Node; |
| 33 | class NetDevice; |
| 34 | class Packet; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 35 | class CcnxForwardingStrategy; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 36 | |
| 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 | */ |
| 59 | class Ccnx : public Object |
| 60 | { |
| 61 | public: |
| 62 | static TypeId GetTypeId (void); |
| 63 | Ccnx (); |
| 64 | virtual ~Ccnx (); |
| 65 | |
| 66 | /** |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 67 | * \brief Register a new forwarding protocol to be used by this Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 68 | * |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 69 | * This call will replace any forwarding protocol that has been previously |
| 70 | * registered. If you want to add multiple forwarding protocols, you must |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 71 | * add them to a CcnxListForwardingStrategy directly. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 72 | * |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 73 | * \param forwardingStrategy smart pointer to CcnxForwardingStrategy object |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 74 | */ |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 75 | virtual void SetForwardingStrategy (Ptr<CcnxForwardingStrategy> forwardingStrategy) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 76 | |
| 77 | /** |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 78 | * \brief Get the forwarding protocol to be used by this Ccnx stack |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 79 | * |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 80 | * \returns smart pointer to CcnxForwardingStrategy object, or null pointer if none |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 81 | */ |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 82 | virtual Ptr<CcnxForwardingStrategy> GetForwardingStrategy (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 83 | |
| 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 Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 93 | virtual uint32_t AddFace (Ptr<CcnxFace> face) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * \returns the number of interfaces added by the user. |
| 97 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 98 | virtual uint32_t GetNFaces (void) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 99 | |
| 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 Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 107 | // virtual void Send (Ptr<Packet> packet, Ptr<CcnxRoute> route) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 108 | |
| 109 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 110 | * \param face The face number of an Ccnx interface. |
| 111 | * \returns The CcnxFace associated with the Ccnx face number. |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 112 | */ |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 113 | virtual Ptr<CcnxFace> GetFace (uint32_t face) const = 0; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 114 | |
| 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 Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 120 | |
| 121 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 122 | * \param face The face number of an Ccnx face |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 123 | * \param metric forwarding metric (cost) associated to the underlying |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 124 | * Ccnx interface |
| 125 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 126 | virtual void SetMetric (uint32_t face, uint16_t metric) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 127 | |
| 128 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 129 | * \param face The interface number of an Ccnx interface |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 130 | * \returns forwarding metric (cost) associated to the underlying |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 131 | * Ccnx interface |
| 132 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 133 | virtual uint16_t GetMetric (uint32_t face) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 134 | |
| 135 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 136 | * \param face Interface number of Ccnx interface |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 137 | * \returns the Maximum Transmission Unit (in bytes) associated |
| 138 | * to the underlying Ccnx interface |
| 139 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 140 | virtual uint16_t GetMtu (uint32_t face) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 141 | |
| 142 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 143 | * \param face Interface number of Ccnx interface |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 144 | * \returns true if the underlying interface is in the "up" state, |
| 145 | * false otherwise. |
| 146 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 147 | virtual bool IsUp (uint32_t face) const = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 150 | * \param face Interface number of Ccnx interface |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 151 | * |
| 152 | * Set the interface into the "up" state. In this state, it is |
| 153 | * considered valid during Ccnx forwarding. |
| 154 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 155 | virtual void SetUp (uint32_t face) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 156 | |
| 157 | /** |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 158 | * \param face Interface number of Ccnx interface |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 159 | * |
| 160 | * Set the interface into the "down" state. In this state, it is |
| 161 | * ignored during Ccnx forwarding. |
| 162 | */ |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 163 | virtual void SetDown (uint32_t face) = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | } // namespace ns3 |
| 167 | |
| 168 | #endif /* CCNX_H */ |