More progress on CCNx stack. Now we have helpers. Everything compiles, but not yet working
diff --git a/model/ccnx-l3-protocol.cc b/model/ccnx-l3-protocol.cc
index bbb5853..b906a4c 100644
--- a/model/ccnx-l3-protocol.cc
+++ b/model/ccnx-l3-protocol.cc
@@ -1,4 +1,4 @@
-// -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*-
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
//
// Copyright (c) 2006 Georgia Tech Research Corporation
//
@@ -18,21 +18,21 @@
// Author:
//
+#include "ccnx-l3-protocol.h"
+
#include "ns3/packet.h"
+#include "ns3/net-device.h"
+#include "ns3/node.h"
#include "ns3/log.h"
#include "ns3/callback.h"
-#include "ns3/ccnx-address.h"
-#include "ns3/ccnx-route.h"
-#include "ns3/node.h"
-#include "ns3/net-device.h"
#include "ns3/uinteger.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/object-vector.h"
#include "ns3/boolean.h"
-//#include "ns3/ccnx-routing-table-entry.h"
-#include "ccnx-l3-protocol.h"
-#include "ccnx-interface.h"
+#include "ccnx-face.h"
+#include "ccnx-route.h"
+#include "ccnx-forwarding-protocol.h"
NS_LOG_COMPONENT_DEFINE ("CcnxL3Protocol");
@@ -56,8 +56,8 @@
MakeTraceSourceAccessor (&CcnxL3Protocol::m_dropTrace))
.AddAttribute ("InterfaceList", "The set of Ccnx interfaces associated to this Ccnx stack.",
ObjectVectorValue (),
- MakeObjectVectorAccessor (&CcnxL3Protocol::m_interfaces),
- MakeObjectVectorChecker<CcnxInterface> ())
+ MakeObjectVectorAccessor (&CcnxL3Protocol::m_faces),
+ MakeObjectVectorChecker<CcnxFace> ())
.AddTraceSource ("SendOutgoing", "A newly-generated packet by this node is about to be queued for transmission",
MakeTraceSourceAccessor (&CcnxL3Protocol::m_sendOutgoingTrace))
@@ -121,7 +121,7 @@
{
NS_LOG_FUNCTION (this);
- for (CcnxInterfaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
+ for (CcnxFaceList::iterator i = m_faces.begin (); i != m_faces.end (); ++i)
{
*i = 0;
}
@@ -137,21 +137,21 @@
NS_LOG_FUNCTION (this << *face);
// Ptr<Node> node = GetObject<Node> (); ///< \todo not sure why this thing should be called...
- face->setNode (m_node);
+ face->SetNode (m_node);
if (face->GetDevice() != 0)
{
- m_node->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::Receive, this),
+ m_node->RegisterProtocolHandler (MakeCallback (&CcnxL3Protocol::ReceiveFromLower, this),
CcnxL3Protocol::PROT_NUMBER, face->GetDevice(), true/*promiscuous mode*/);
}
uint32_t index = m_faces.size ();
- m_faces.push_back (interface);
+ m_faces.push_back (face);
return index;
}
-Ptr<CcnxInterface>
+Ptr<CcnxFace>
CcnxL3Protocol::GetFace (uint32_t index) const
{
if (index < m_faces.size ())
@@ -168,11 +168,11 @@
}
Ptr<CcnxFace>
-GetFaceForDevice (Ptr<const NetDevice> device) const
+CcnxL3Protocol::GetFaceForDevice (Ptr<const NetDevice> device) const
{
- for (CcnxInterfaceList::const_iterator i = m_faces.begin ();
+ for (CcnxFaceList::const_iterator i = m_faces.begin ();
i != m_faces.end ();
- i++, face++)
+ i++)
{
if ((*i)->GetDevice () == device)
{
@@ -180,29 +180,27 @@
}
}
- NS_ASSERT_MSG (false "Should never get to this place" );
+ NS_ASSERT_MSG (false, "Should never get to this place" );
return 0;
}
// Callback from lower layer
void
-CcnxL3Protocol::Receive ( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
+CcnxL3Protocol::ReceiveFromLower ( Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION (this << &device << p << protocol << from);
NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ());
- uint32_t interface = 0;
- Ptr<Packet> packet = p->Copy ();
+ Ptr<CcnxFace> ccnxFace = GetFaceForDevice (device);
- Ptr<CcnxFace> ccnxFace = GetFaceFromDevice (device);
-
- Receive (ccnxFace, p);
+ Ptr<Packet> packet = p->Copy (); // give upper layers a rw copy of the packet
+ ReceiveAndProcess (ccnxFace, packet);
}
// Callback from higher level
-void Receive (Ptr<CcnxFace> incomingFace, Ptr<const Packet> p)
+void CcnxL3Protocol::ReceiveAndProcess (Ptr<CcnxFace> incomingFace, Ptr<Packet> packet)
{
if ( incomingFace->IsUp ())
{
@@ -213,8 +211,8 @@
m_rxTrace (packet, m_node->GetObject<Ccnx> (), incomingFace);
- NS_ASSERT_MSG (m_routingProtocol != 0, "Need a routing protocol object to process packets");
- if (!m_routingProtocol->RouteInput (packet, incomingFace,
+ NS_ASSERT_MSG (m_forwardingProtocol != 0, "Need a forwarding protocol object to process packets");
+ if (!m_forwardingProtocol->RouteInput (packet, incomingFace,
MakeCallback (&CcnxL3Protocol::Send, this),
MakeCallback (&CcnxL3Protocol::RouteInputError, this)
))
@@ -229,11 +227,11 @@
CcnxL3Protocol::Send (Ptr<Packet> packet, Ptr<CcnxRoute> route)
{
NS_LOG_FUNCTION (this << "packet: " << packet << ", route: "<< route);
-
+
if (route == 0)
{
NS_LOG_WARN ("No route to host. Drop.");
- m_dropTrace (ipHeader, packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), 0);
+ m_dropTrace (packet, DROP_NO_ROUTE, m_node->GetObject<Ccnx> (), 0);
return;
}
Ptr<CcnxFace> outFace = route->GetOutputFace ();
@@ -256,28 +254,28 @@
CcnxL3Protocol::SetMetric (uint32_t i, uint16_t metric)
{
NS_LOG_FUNCTION (this << i << metric);
- Ptr<CcnxInterface> interface = GetInterface (i);
- interface->SetMetric (metric);
+ Ptr<CcnxFace> face = GetFace (i);
+ face->SetMetric (metric);
}
uint16_t
CcnxL3Protocol::GetMetric (uint32_t i) const
{
- Ptr<CcnxInterface> interface = GetInterface (i);
- return interface->GetMetric ();
+ Ptr<const CcnxFace> face = GetFace (i);
+ return face->GetMetric ();
}
uint16_t
CcnxL3Protocol::GetMtu (uint32_t i) const
{
- Ptr<CcnxInterface> interface = GetInterface (i);
- return interface->GetDevice ()->GetMtu ();
+ Ptr<CcnxFace> face = GetFace (i);
+ return face->GetDevice ()->GetMtu ();
}
bool
CcnxL3Protocol::IsUp (uint32_t i) const
{
- Ptr<CcnxInterface> interface = GetInterface (i);
+ Ptr<CcnxFace> interface = GetFace (i);
return interface->IsUp ();
}
@@ -285,12 +283,12 @@
CcnxL3Protocol::SetUp (uint32_t i)
{
NS_LOG_FUNCTION (this << i);
- Ptr<CcnxInterface> interface = GetInterface (i);
+ Ptr<CcnxFace> interface = GetFace (i);
interface->SetUp ();
- if (m_routingProtocol != 0)
+ if (m_forwardingProtocol != 0)
{
- m_routingProtocol->NotifyInterfaceUp (i);
+ m_forwardingProtocol->NotifyInterfaceUp (i);
}
}
@@ -298,21 +296,21 @@
CcnxL3Protocol::SetDown (uint32_t ifaceIndex)
{
NS_LOG_FUNCTION (this << ifaceIndex);
- Ptr<CcnxInterface> interface = GetInterface (ifaceIndex);
+ Ptr<CcnxFace> interface = GetFace (ifaceIndex);
interface->SetDown ();
- if (m_routingProtocol != 0)
+ if (m_forwardingProtocol != 0)
{
- m_routingProtocol->NotifyInterfaceDown (ifaceIndex);
+ m_forwardingProtocol->NotifyInterfaceDown (ifaceIndex);
}
}
void
-CcnxL3Protocol::RouteInputError (Ptr<const Packet> p, const CcnxHeader & ipHeader, Socket::SocketErrno sockErrno)
+CcnxL3Protocol::RouteInputError (Ptr<Packet> p)//, Socket::SocketErrno sockErrno)
{
- NS_LOG_FUNCTION (this << p << ipHeader << sockErrno);
- NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " with errno " << sockErrno);
- m_dropTrace (ipHeader, p, DROP_ROUTE_ERROR, m_node->GetObject<Ccnx> (), 0);
+ // NS_LOG_FUNCTION (this << p << ipHeader << sockErrno);
+ // NS_LOG_LOGIC ("Route input failure-- dropping packet to " << ipHeader << " with errno " << sockErrno);
+ m_dropTrace (p, DROP_ROUTE_ERROR, m_node->GetObject<Ccnx> (), 0);
}
} //namespace ns3