model: Another set of refactoring/renaming to make code compile (not tested yet)
Refs #1005 (http://redmine.named-data.net/)
diff --git a/examples/custom-apps/custom-app.cc b/examples/custom-apps/custom-app.cc
index 7ab508c..80652ba 100644
--- a/examples/custom-apps/custom-app.cc
+++ b/examples/custom-apps/custom-app.cc
@@ -94,26 +94,26 @@
Ptr<ndn::Name> prefix = Create<ndn::Name> ("/prefix/sub"); // another way to create name
// Create and configure ndn::Interest
- Ptr<ndn::Interest> interestHeader = Create<ndn::Interest> ();
+ Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
UniformVariable rand (0,std::numeric_limits<uint32_t>::max ());
- interestHeader->SetNonce (rand.GetValue ());
- interestHeader->SetName (prefix);
- interestHeader->SetInterestLifetime (Seconds (1.0));
+ interest->SetNonce (rand.GetValue ());
+ interest->SetName (prefix);
+ interest->SetInterestLifetime (Seconds (1.0));
NS_LOG_DEBUG ("Sending Interest packet for " << *prefix);
- // Forward packet to lower (network) layer
- Ptr<Packet> payload = Create<Packet> ();
- m_face->ReceiveInterest (interestHeader, payload);
-
// Call trace (for logging purposes)
- m_transmittedInterests (interestHeader, this, m_face);
+ m_transmittedInterests (interest, this, m_face);
+
+ m_face->ReceiveInterest (interest);
}
// Callback that will be called when Interest arrives
void
-CustomApp::OnInterest (const Ptr<const ndn::Interest> &interest, Ptr<Packet> origPacket)
+CustomApp::OnInterest (Ptr<const ndn::Interest> interest)
{
+ ndn::App::OnInterest (interest);
+
NS_LOG_DEBUG ("Received Interest packet for " << interest->GetName ());
// Create and configure ndn::ContentObject and ndn::ContentObjectTail
@@ -121,29 +121,24 @@
// Note that Interests send out by the app will not be sent back to the app !
- Ptr<ndn::ContentObject> data = Create<ndn::ContentObject> ();
+ Ptr<ndn::ContentObject> data = Create<ndn::ContentObject> (Create<Packet> (1024));
data->SetName (Create<ndn::Name> (interest->GetName ())); // data will have the same name as Interests
- // Create packet and add header and trailer
- NS_LOG_DEBUG ("Sending ContentObject packet for " << data->GetName ());
-
- // Forward packet to lower (network) layer
- Ptr<Packet> payload = Create<Packet> (1024);
- m_face->ReceiveData (data, payload);
+ NS_LOG_DEBUG ("Sending ContentObject packet for " << data->GetName ());
// Call trace (for logging purposes)
- m_transmittedContentObjects (data, payload, this, m_face);
+ m_transmittedContentObjects (data, this, m_face);
+
+ m_face->ReceiveData (data);
}
// Callback that will be called when Data arrives
void
-CustomApp::OnContentObject (const Ptr<const ndn::ContentObject> &contentObject,
- Ptr<Packet> payload)
+CustomApp::OnContentObject (Ptr<const ndn::ContentObject> contentObject)
{
NS_LOG_DEBUG ("Receiving ContentObject packet for " << contentObject->GetName ());
std::cout << "DATA received for name " << contentObject->GetName () << std::endl;
}
-
} // namespace ns3
diff --git a/examples/custom-apps/custom-app.h b/examples/custom-apps/custom-app.h
index 0d33bd8..ed21a2c 100644
--- a/examples/custom-apps/custom-app.h
+++ b/examples/custom-apps/custom-app.h
@@ -54,12 +54,11 @@
// (overridden from ndn::App) Callback that will be called when Interest arrives
virtual void
- OnInterest (const Ptr<const ndn::Interest> &interest, Ptr<Packet> origPacket);
+ OnInterest (Ptr<const ndn::Interest> interest);
// (overridden from ndn::App) Callback that will be called when Data arrives
virtual void
- OnContentObject (const Ptr<const ndn::ContentObject> &contentObject,
- Ptr<Packet> payload);
+ OnContentObject (Ptr<const ndn::ContentObject> contentObject);
private:
void
diff --git a/examples/custom-apps/dumb-requester.cc b/examples/custom-apps/dumb-requester.cc
index 643e24c..b1a0592 100644
--- a/examples/custom-apps/dumb-requester.cc
+++ b/examples/custom-apps/dumb-requester.cc
@@ -91,29 +91,26 @@
Ptr<ndn::Name> prefix = Create<ndn::Name> (m_name); // another way to create name
// Create and configure ndn::Interest
- ndn::Interest interestHeader;
+ Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
UniformVariable rand (0,std::numeric_limits<uint32_t>::max ());
- interestHeader.SetNonce (rand.GetValue ());
- interestHeader.SetName (prefix);
- interestHeader.SetInterestLifetime (Seconds (1.0));
-
- // Create packet and add ndn::Interest
- Ptr<Packet> packet = Create<Packet> ();
- packet->AddHeader (interestHeader);
+ interest->SetNonce (rand.GetValue ());
+ interest->SetName (prefix);
+ interest->SetInterestLifetime (Seconds (1.0));
NS_LOG_DEBUG ("Sending Interest packet for " << *prefix);
- // Forward packet to lower (network) layer
- m_protocolHandler (packet);
// Call trace (for logging purposes)
- m_transmittedInterests (&interestHeader, this, m_face);
+ m_transmittedInterests (interest, this, m_face);
+
+ // Forward packet to lower (network) layer
+ m_face->ReceiveInterest (interest);
+
Simulator::Schedule (Seconds (1.0), &DumbRequester::SendInterest, this);
}
void
-DumbRequester::OnContentObject (const Ptr<const ndn::ContentObject> &contentObject,
- Ptr<Packet> payload)
+DumbRequester::OnContentObject (Ptr<const ndn::ContentObject> contentObject)
{
NS_LOG_DEBUG ("Receiving ContentObject packet for " << contentObject->GetName ());
}
diff --git a/examples/custom-apps/dumb-requester.h b/examples/custom-apps/dumb-requester.h
index 06ed812..c2340e0 100644
--- a/examples/custom-apps/dumb-requester.h
+++ b/examples/custom-apps/dumb-requester.h
@@ -52,8 +52,7 @@
// (overridden from ndn::App) Callback that will be called when Data arrives
virtual void
- OnContentObject (const Ptr<const ndn::ContentObject> &contentObject,
- Ptr<Packet> payload);
+ OnContentObject (Ptr<const ndn::ContentObject> contentObject);
private:
void
diff --git a/examples/custom-apps/hijacker.cc b/examples/custom-apps/hijacker.cc
index 4213f97..a4d7601 100644
--- a/examples/custom-apps/hijacker.cc
+++ b/examples/custom-apps/hijacker.cc
@@ -45,9 +45,9 @@
}
void
-Hijacker::OnInterest (const Ptr<const ndn::Interest> &interest, Ptr<Packet> packet)
+Hijacker::OnInterest (Ptr<const ndn::Interest> interest)
{
- ndn::App::OnInterest (interest, packet); // forward call to perform app-level tracing
+ ndn::App::OnInterest (interest); // forward call to perform app-level tracing
// do nothing else (hijack interest)
NS_LOG_DEBUG ("Do nothing for incoming interest for" << interest->GetName ());
diff --git a/examples/custom-apps/hijacker.h b/examples/custom-apps/hijacker.h
index 07185de..a90166d 100644
--- a/examples/custom-apps/hijacker.h
+++ b/examples/custom-apps/hijacker.h
@@ -39,7 +39,7 @@
// Receive all Interests but do nothing in response
void
- OnInterest (const Ptr<const ndn::Interest> &interest, Ptr<Packet> packet);
+ OnInterest (Ptr<const ndn::Interest> interest);
protected:
// inherited from Application base class.
diff --git a/examples/custom-apps/ndn-api-app.h b/examples/custom-apps/ndn-api-app.h
index 26df590..4e9e487 100644
--- a/examples/custom-apps/ndn-api-app.h
+++ b/examples/custom-apps/ndn-api-app.h
@@ -25,7 +25,7 @@
#include "ns3/network-module.h"
#include "ns3/ndnSIM-module.h"
-#include "ns3/ndnSIM/ndn.cxx/ndn-handler.h"
+// #include "ns3/ndnSIM/ndn.cxx/ndn-handler.h"
namespace ns3 {
namespace ndn {
@@ -51,7 +51,7 @@
StopApplication ();
private:
- Ptr<Handler> m_handler;
+ // Ptr<Handler> m_handler;
};
} // namespace ndn
diff --git a/examples/custom-strategies/custom-strategy.cc b/examples/custom-strategies/custom-strategy.cc
index 05e7e83..b1bb6c2 100644
--- a/examples/custom-strategies/custom-strategy.cc
+++ b/examples/custom-strategies/custom-strategy.cc
@@ -44,8 +44,7 @@
bool
CustomStrategy::DoPropagateInterest (Ptr<Face> inFace,
- Ptr<const Interest> header,
- Ptr<const Packet> origPacket,
+ Ptr<const Interest> interest,
Ptr<pit::Entry> pitEntry)
{
typedef fib::FaceMetricContainer::type::index<fib::i_metric>::type FacesByMetric;
@@ -57,7 +56,7 @@
// forward to best-metric face
if (faceIterator != faces.end ())
{
- if (TrySendOutInterest (inFace, faceIterator->GetFace (), header, origPacket, pitEntry))
+ if (TrySendOutInterest (inFace, faceIterator->GetFace (), interest, pitEntry))
propagatedCount ++;
faceIterator ++;
@@ -66,7 +65,7 @@
// forward to second-best-metric face
if (faceIterator != faces.end ())
{
- if (TrySendOutInterest (inFace, faceIterator->GetFace (), header, origPacket, pitEntry))
+ if (TrySendOutInterest (inFace, faceIterator->GetFace (), interest, pitEntry))
propagatedCount ++;
faceIterator ++;
@@ -76,8 +75,7 @@
void
CustomStrategy::DidSendOutInterest (Ptr<Face> inFace, Ptr<Face> outFace,
- Ptr<const Interest> header,
- Ptr<const Packet> origPacket,
+ Ptr<const Interest> interest,
Ptr<pit::Entry> pitEntry)
{
m_counter ++;
diff --git a/examples/custom-strategies/custom-strategy.h b/examples/custom-strategies/custom-strategy.h
index 057669a..051901c 100644
--- a/examples/custom-strategies/custom-strategy.h
+++ b/examples/custom-strategies/custom-strategy.h
@@ -30,15 +30,13 @@
protected:
virtual bool
DoPropagateInterest (Ptr<Face> incomingFace,
- Ptr<const Interest> header,
- Ptr<const Packet> origPacket,
+ Ptr<const Interest> interest,
Ptr<pit::Entry> pitEntry);
public:
virtual void
DidSendOutInterest (Ptr<Face> inFace, Ptr<Face> outFace,
- Ptr<const Interest> header,
- Ptr<const Packet> origPacket,
+ Ptr<const Interest> interest,
Ptr<pit::Entry> pitEntry);
virtual void