Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 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 | * |
| 18 | * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
| 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; |
| 35 | // class CcnxRoutingProtocol; |
| 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 | /** |
| 67 | * \brief Register a new routing protocol to be used by this Ccnx stack |
| 68 | * |
| 69 | * This call will replace any routing protocol that has been previously |
| 70 | * registered. If you want to add multiple routing protocols, you must |
| 71 | * add them to a CcnxListRoutingProtocol directly. |
| 72 | * |
| 73 | * \param routingProtocol smart pointer to CcnxRoutingProtocol object |
| 74 | */ |
| 75 | // virtual void SetRoutingProtocol (Ptr<CcnxRoutingProtocol> routingProtocol) = 0; |
| 76 | |
| 77 | /** |
| 78 | * \brief Get the routing protocol to be used by this Ccnx stack |
| 79 | * |
| 80 | * \returns smart pointer to CcnxRoutingProtocol object, or null pointer if none |
| 81 | */ |
| 82 | // virtual Ptr<CcnxRoutingProtocol> GetRoutingProtocol (void) const = 0; |
| 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 | */ |
| 93 | virtual uint32_t AddInterface (Ptr<NetDevice> device) = 0; |
| 94 | |
| 95 | /** |
| 96 | * \returns the number of interfaces added by the user. |
| 97 | */ |
| 98 | virtual uint32_t GetNInterfaces (void) const = 0; |
| 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 | */ |
| 107 | virtual void Send (Ptr<Packet> packet, Ptr<CcnxRoute> route) = 0; |
| 108 | |
| 109 | /** |
| 110 | * \param interface The interface number of an Ccnx interface. |
| 111 | * \returns The NetDevice associated with the Ccnx interface number. |
| 112 | */ |
| 113 | virtual Ptr<NetDevice> GetNetDevice (uint32_t interface) = 0; |
| 114 | |
| 115 | /** |
| 116 | * \param device The NetDevice for an CcnxInterface |
| 117 | * \returns The interface number of an Ccnx interface or -1 if not found. |
| 118 | */ |
| 119 | virtual int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const = 0; |
| 120 | |
| 121 | /** |
| 122 | * \param interface The interface number of an Ccnx interface |
| 123 | * \param metric routing metric (cost) associated to the underlying |
| 124 | * Ccnx interface |
| 125 | */ |
| 126 | virtual void SetMetric (uint32_t interface, uint16_t metric) = 0; |
| 127 | |
| 128 | /** |
| 129 | * \param interface The interface number of an Ccnx interface |
| 130 | * \returns routing metric (cost) associated to the underlying |
| 131 | * Ccnx interface |
| 132 | */ |
| 133 | virtual uint16_t GetMetric (uint32_t interface) const = 0; |
| 134 | |
| 135 | /** |
| 136 | * \param interface Interface number of Ccnx interface |
| 137 | * \returns the Maximum Transmission Unit (in bytes) associated |
| 138 | * to the underlying Ccnx interface |
| 139 | */ |
| 140 | virtual uint16_t GetMtu (uint32_t interface) const = 0; |
| 141 | |
| 142 | /** |
| 143 | * \param interface Interface number of Ccnx interface |
| 144 | * \returns true if the underlying interface is in the "up" state, |
| 145 | * false otherwise. |
| 146 | */ |
| 147 | virtual bool IsUp (uint32_t interface) const = 0; |
| 148 | |
| 149 | /** |
| 150 | * \param interface Interface number of Ccnx interface |
| 151 | * |
| 152 | * Set the interface into the "up" state. In this state, it is |
| 153 | * considered valid during Ccnx forwarding. |
| 154 | */ |
| 155 | virtual void SetUp (uint32_t interface) = 0; |
| 156 | |
| 157 | /** |
| 158 | * \param interface Interface number of Ccnx interface |
| 159 | * |
| 160 | * Set the interface into the "down" state. In this state, it is |
| 161 | * ignored during Ccnx forwarding. |
| 162 | */ |
| 163 | virtual void SetDown (uint32_t interface) = 0; |
| 164 | }; |
| 165 | |
| 166 | } // namespace ns3 |
| 167 | |
| 168 | #endif /* CCNX_H */ |