Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -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) 2006 Georgia Tech Research Corporation |
| 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 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 21 | #include "ccnx-l3-protocol.h" |
| 22 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 23 | #include "ns3/packet.h" |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 24 | #include "ns3/net-device.h" |
| 25 | #include "ns3/node.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 26 | #include "ns3/log.h" |
| 27 | #include "ns3/callback.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 28 | #include "ns3/uinteger.h" |
| 29 | #include "ns3/trace-source-accessor.h" |
| 30 | #include "ns3/object-vector.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 31 | #include "ns3/boolean.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 32 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 33 | #include "ccnx-face.h" |
| 34 | #include "ccnx-route.h" |
| 35 | #include "ccnx-forwarding-protocol.h" |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 36 | |
| 37 | NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol"); |
| 38 | |
| 39 | namespace ns3 { |
| 40 | |
| 41 | const uint16_t CcnxL3Protocol::PROT_NUMBER = 0x7777; |
| 42 | |
| 43 | NS_OBJECT_ENSURE_REGISTERED (CcnxL3Protocol); |
| 44 | |
| 45 | TypeId |
| 46 | CcnxL3Protocol::GetTypeId (void) |
| 47 | { |
| 48 | static TypeId tid = TypeId ("ns3::CcnxL3Protocol") |
| 49 | .SetParent<Ccnx> () |
| 50 | .AddConstructor<CcnxL3Protocol> () |
| 51 | .AddTraceSource ("Tx", "Send ccnx packet to outgoing interface.", |
| 52 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_txTrace)) |
| 53 | .AddTraceSource ("Rx", "Receive ccnx packet from incoming interface.", |
| 54 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_rxTrace)) |
| 55 | .AddTraceSource ("Drop", "Drop ccnx packet", |
| 56 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_dropTrace)) |
| 57 | .AddAttribute ("InterfaceList", "The set of Ccnx interfaces associated to this Ccnx stack.", |
| 58 | ObjectVectorValue (), |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 59 | MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces), |
| 60 | MakeObjectVectorChecker<CcnxFace> ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 61 | |
| 62 | .AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is about to be queued for transmission", |
| 63 | MakeTraceSourceAccessor (&CcnxL3Protocol::m_sendOutgoingTrace)) |
| 64 | |
| 65 | ; |
| 66 | return tid; |
| 67 | } |
| 68 | |
| 69 | CcnxL3Protocol::CcnxL3Protocol() |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 70 | { |
| 71 | NS_LOG_FUNCTION (this); |
| 72 | } |
| 73 | |
| 74 | CcnxL3Protocol::~CcnxL3Protocol () |
| 75 | { |
| 76 | NS_LOG_FUNCTION (this); |
| 77 | } |
| 78 | |
| 79 | void |
| 80 | CcnxL3Protocol::SetNode (Ptr<Node> node) |
| 81 | { |
| 82 | m_node = node; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* |
| 86 | * This method is called by AddAgregate and completes the aggregation |
| 87 | * by setting the node in the ccnx stack |
| 88 | */ |
| 89 | void |
| 90 | CcnxL3Protocol::NotifyNewAggregate () |
| 91 | { |
| 92 | if (m_node == 0) |
| 93 | { |
| 94 | Ptr<Node>node = this->GetObject<Node>(); |
| 95 | // verify that it's a valid node and that |
| 96 | // the node has not been set before |
| 97 | if (node != 0) |
| 98 | { |
| 99 | this->SetNode (node); |
| 100 | } |
| 101 | } |
| 102 | Object::NotifyNewAggregate (); |
| 103 | } |
| 104 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 105 | void |
| 106 | CcnxL3Protocol::SetForwardingProtocol (Ptr<CcnxForwardingProtocol> forwardingProtocol) |
| 107 | { |
| 108 | NS_LOG_FUNCTION (this); |
| 109 | m_forwardingProtocol = forwardingProtocol; |
| 110 | m_forwardingProtocol->SetCcnx (this); |
| 111 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 112 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 113 | Ptr<CcnxForwardingProtocol> |
| 114 | CcnxL3Protocol::GetForwardingProtocol (void) const |
| 115 | { |
| 116 | return m_forwardingProtocol; |
| 117 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 118 | |
| 119 | void |
| 120 | CcnxL3Protocol::DoDispose (void) |
| 121 | { |
| 122 | NS_LOG_FUNCTION (this); |
| 123 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 124 | for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 125 | { |
| 126 | *i = 0; |
| 127 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 128 | m_faces.clear (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 129 | m_node = 0; |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 130 | // m_forwardingProtocol = 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 131 | Object::DoDispose (); |
| 132 | } |
| 133 | |
| 134 | uint32_t |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 135 | CcnxL3Protocol::AddFace (Ptr<CcnxFace> face) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 136 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 137 | NS_LOG_FUNCTION (this << *face); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 138 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 139 | // Ptr<Node> node = GetObject<Node> (); ///< \todo not sure why this thing should be called... |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 140 | face->SetNode (m_node); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 141 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 142 | if (face->GetDevice() != 0) |
| 143 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 144 | m_node->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::ReceiveFromLower, this), |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 145 | CcnxL3Protocol::PROT_NUMBER, face->GetDevice(), true/*promiscuous mode*/); |
| 146 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 147 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 148 | uint32_t index = m_faces.size (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 149 | m_faces.push_back (face); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 150 | return index; |
| 151 | } |
| 152 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 153 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 154 | Ptr<CcnxFace> |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 155 | CcnxL3Protocol::GetFace (uint32_t index) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 156 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 157 | if (index < m_faces.size ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 158 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 159 | return m_faces[index]; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 160 | } |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | uint32_t |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 165 | CcnxL3Protocol::GetNFaces (void) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 166 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 167 | return m_faces.size (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 168 | } |
| 169 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 170 | Ptr<CcnxFace> |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 171 | CcnxL3Protocol::GetFaceForDevice (Ptr<const NetDevice> device) const |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 172 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 173 | for (CcnxFaceList::const_iterator i = m_faces.begin (); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 174 | i != m_faces.end (); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 175 | i++) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 176 | { |
| 177 | if ((*i)->GetDevice () == device) |
| 178 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 179 | return *i; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 180 | } |
| 181 | } |
| 182 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 183 | NS_ASSERT_MSG (false, "Should never get to this place" ); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 184 | return 0; |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 187 | // Callback from lower layer |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 188 | void |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 189 | CcnxL3Protocol::ReceiveFromLower ( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from, |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 190 | const Address &to, NetDevice::PacketType packetType) |
| 191 | { |
| 192 | NS_LOG_FUNCTION (this << &device << p << protocol << from); |
| 193 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 194 | NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ()); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 195 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 196 | Ptr<CcnxFace> ccnxFace = GetFaceForDevice (device); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 197 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 198 | Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet |
| 199 | ReceiveAndProcess (ccnxFace, packet); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 200 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 201 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 202 | // Callback from higher level |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 203 | void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<Packet> packet) |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 204 | { |
| 205 | if ( incomingFace->IsUp ()) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 206 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 207 | NS_LOG_LOGIC ("Dropping received packet -- interface is down"); |
| 208 | m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 209 | return; |
| 210 | } |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 211 | |
| 212 | m_rxTrace (packet, m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 213 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 214 | NS_ASSERT_MSG (m_forwardingProtocol != 0, "Need a forwarding protocol object to process packets"); |
| 215 | if (!m_forwardingProtocol->RouteInput (packet, incomingFace, |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 216 | MakeCallback (&CcnxL3Protocol::Send, this), |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 217 | MakeCallback (&CcnxL3Protocol::RouteInputError, this) |
| 218 | )) |
| 219 | { |
| 220 | NS_LOG_WARN ("No route found for forwarding packet. Drop."); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 221 | m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), incomingFace); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 222 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | |
| 226 | void |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 227 | CcnxL3Protocol::Send (Ptr<Packet> packet, Ptr<CcnxRoute> route) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 228 | { |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 229 | NS_LOG_FUNCTION (this << "packet: " << packet << ", route: "<< route); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 230 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 231 | if (route == 0) |
| 232 | { |
| 233 | NS_LOG_WARN ("No route to host. Drop."); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 234 | m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), 0); |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 235 | return; |
| 236 | } |
| 237 | Ptr<CcnxFace> outFace = route->GetOutputFace (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 238 | |
Alexander Afanasyev | 9825610 | 2011-08-14 01:00:02 -0700 | [diff] [blame] | 239 | if (outFace->IsUp ()) |
| 240 | { |
| 241 | NS_LOG_LOGIC ("Sending via face " << *outFace); |
| 242 | m_txTrace (packet, m_node->GetObject<Ccnx> (), outFace); |
| 243 | outFace->Send (packet); |
| 244 | } |
| 245 | else |
| 246 | { |
| 247 | NS_LOG_LOGIC ("Dropping -- outgoing interface is down: " << *outFace); |
| 248 | m_dropTrace (packet, DROP_INTERFACE_DOWN, m_node->GetObject<Ccnx> (), outFace); |
| 249 | } |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 253 | void |
| 254 | CcnxL3Protocol::SetMetric (uint32_t i, uint16_t metric) |
| 255 | { |
| 256 | NS_LOG_FUNCTION (this << i << metric); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 257 | Ptr<CcnxFace> face = GetFace (i); |
| 258 | face->SetMetric (metric); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | uint16_t |
| 262 | CcnxL3Protocol::GetMetric (uint32_t i) const |
| 263 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 264 | Ptr<const CcnxFace> face = GetFace (i); |
| 265 | return face->GetMetric (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | uint16_t |
| 269 | CcnxL3Protocol::GetMtu (uint32_t i) const |
| 270 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 271 | Ptr<CcnxFace> face = GetFace (i); |
| 272 | return face->GetDevice ()->GetMtu (); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | bool |
| 276 | CcnxL3Protocol::IsUp (uint32_t i) const |
| 277 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 278 | Ptr<CcnxFace> interface = GetFace (i); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 279 | return interface->IsUp (); |
| 280 | } |
| 281 | |
| 282 | void |
| 283 | CcnxL3Protocol::SetUp (uint32_t i) |
| 284 | { |
| 285 | NS_LOG_FUNCTION (this << i); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 286 | Ptr<CcnxFace> interface = GetFace (i); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 287 | interface->SetUp (); |
| 288 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 289 | if (m_forwardingProtocol != 0) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 290 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 291 | m_forwardingProtocol->NotifyInterfaceUp (i); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | |
| 295 | void |
| 296 | CcnxL3Protocol::SetDown (uint32_t ifaceIndex) |
| 297 | { |
| 298 | NS_LOG_FUNCTION (this << ifaceIndex); |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 299 | Ptr<CcnxFace> interface = GetFace (ifaceIndex); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 300 | interface->SetDown (); |
| 301 | |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 302 | if (m_forwardingProtocol != 0) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 303 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 304 | m_forwardingProtocol->NotifyInterfaceDown (ifaceIndex); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 305 | } |
| 306 | } |
| 307 | |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 308 | void |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 309 | CcnxL3Protocol::RouteInputError (Ptr<Packet> p)//, Socket::SocketErrno sockErrno) |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 310 | { |
Alexander Afanasyev | 45b92d4 | 2011-08-14 23:11:38 -0700 | [diff] [blame] | 311 | // NS_LOG_FUNCTION (this << p << ipHeader << sockErrno); |
| 312 | // NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " with errno " << sockErrno); |
| 313 | m_dropTrace (p, DROP_ROUTE_ERROR, m_node->GetObject<Ccnx> (), 0); |
Alexander Afanasyev | 08d984e | 2011-08-13 19:20:22 -0700 | [diff] [blame] | 314 | } |
| 315 | |
| 316 | } //namespace ns3 |