model: Another set of refactoring/renaming to make code compile (not tested yet)

Refs #1005 (http://redmine.named-data.net/)
diff --git a/apps/ndn-app.cc b/apps/ndn-app.cc
index 7880849..35db66e 100644
--- a/apps/ndn-app.cc
+++ b/apps/ndn-app.cc
@@ -94,25 +94,24 @@
 }
 
 void
-App::OnInterest (const Ptr<const Interest> &interest, Ptr<Packet> packet)
+App::OnInterest (Ptr<const Interest> interest)
 {
   NS_LOG_FUNCTION (this << interest);
   m_receivedInterests (interest, this, m_face);
 }
 
 void
-App::OnNack (const Ptr<const Interest> &interest, Ptr<Packet> packet)
+App::OnNack (Ptr<const Interest> interest)
 {
   NS_LOG_FUNCTION (this << interest);
   m_receivedNacks (interest, this, m_face);
 }
 
 void
-App::OnContentObject (const Ptr<const ContentObject> &contentObject,
-                          Ptr<Packet> payload)
+App::OnContentObject (Ptr<const ContentObject> contentObject)
 {
-  NS_LOG_FUNCTION (this << contentObject << payload);
-  m_receivedContentObjects (contentObject, payload, this, m_face);
+  NS_LOG_FUNCTION (this << contentObject);
+  m_receivedContentObjects (contentObject, this, m_face);
 }
 
 // Application Methods
diff --git a/apps/ndn-app.h b/apps/ndn-app.h
index 491cae4..fd29ab0 100644
--- a/apps/ndn-app.h
+++ b/apps/ndn-app.h
@@ -46,12 +46,6 @@
 class App: public Application
 {
 public:
-  /**
-   * @brief A callback to pass packets to underlying NDN protocol
-   */
-  typedef Callback<bool, Ptr<const Interest>, Ptr<const Packet> > InterestHandler;
-  typedef Callback<bool, Ptr<const ContentObject>, Ptr<const Packet> > DataHandler;
-  
   static TypeId GetTypeId ();
 
   /**
@@ -73,14 +67,14 @@
    *                 may be useful to get packet tags
    */
   virtual void
-  OnInterest (const Ptr<const Interest> &interest, Ptr<Packet> packet);
+  OnInterest (Ptr<const Interest> interest);
 
   /**
    * @brief Method that will be called every time new NACK arrives
    * @param interest Interest header
    */
   virtual void
-  OnNack (const Ptr<const Interest> &interest, Ptr<Packet> packet);
+  OnNack (Ptr<const Interest> interest);
   
   /**
    * @brief Method that will be called every time new ContentObject arrives
@@ -88,8 +82,7 @@
    * @param payload payload (potentially virtual) of the ContentObject packet (may include packet tags of original packet)
    */
   virtual void
-  OnContentObject (const Ptr<const ContentObject> &contentObject,
-                   Ptr<Packet> payload);
+  OnContentObject (Ptr<const ContentObject> contentObject);
   
 protected:
   /**
@@ -115,14 +108,14 @@
   TracedCallback<Ptr<const Interest>,
                  Ptr<App>, Ptr<Face> > m_receivedNacks; ///< @brief App-level trace of received NACKs
 
-  TracedCallback<Ptr<const ContentObject>, Ptr<const Packet>,
+  TracedCallback<Ptr<const ContentObject>,
                  Ptr<App>, Ptr<Face> > m_receivedContentObjects; ///< @brief App-level trace of received Data
 
 
   TracedCallback<Ptr<const Interest>,
                  Ptr<App>, Ptr<Face> > m_transmittedInterests; ///< @brief App-level trace of transmitted Interests
 
-  TracedCallback<Ptr<const ContentObject>, Ptr<const Packet>,
+  TracedCallback<Ptr<const ContentObject>,
                  Ptr<App>, Ptr<Face> > m_transmittedContentObjects; ///< @brief App-level trace of transmitted Data
 };
 
diff --git a/apps/ndn-consumer-window.cc b/apps/ndn-consumer-window.cc
index 474c4fc..ae4a0c9 100644
--- a/apps/ndn-consumer-window.cc
+++ b/apps/ndn-consumer-window.cc
@@ -27,6 +27,8 @@
 #include "ns3/string.h"
 #include "ns3/uinteger.h"
 #include "ns3/double.h"
+#include "ns3/ndn-content-object.h"
+#include "ns3/ndn-interest.h"
 
 NS_LOG_COMPONENT_DEFINE ("ndn.ConsumerWindow");
 
@@ -184,10 +186,9 @@
 ///////////////////////////////////////////////////
 
 void
-ConsumerWindow::OnContentObject (const Ptr<const ContentObject> &contentObject,
-                                     Ptr<Packet> payload)
+ConsumerWindow::OnContentObject (Ptr<const ContentObject> contentObject)
 {
-  Consumer::OnContentObject (contentObject, payload);
+  Consumer::OnContentObject (contentObject);
 
   m_window = m_window + 1;
 
@@ -198,9 +199,9 @@
 }
 
 void
-ConsumerWindow::OnNack (const Ptr<const Interest> &interest, Ptr<Packet> payload)
+ConsumerWindow::OnNack (Ptr<const Interest> interest)
 {
-  Consumer::OnNack (interest, payload);
+  Consumer::OnNack (interest);
 
   if (m_inFlight > static_cast<uint32_t> (0)) m_inFlight--;
 
diff --git a/apps/ndn-consumer-window.h b/apps/ndn-consumer-window.h
index e89d0a7..42ee006 100644
--- a/apps/ndn-consumer-window.h
+++ b/apps/ndn-consumer-window.h
@@ -50,11 +50,10 @@
   // OnInterest (const Ptr<const Interest> &interest);
 
   virtual void
-  OnNack (const Ptr<const Interest> &interest, Ptr<Packet> payload);
+  OnNack (Ptr<const Interest> interest);
 
   virtual void
-  OnContentObject (const Ptr<const ContentObject> &contentObject,
-                   Ptr<Packet> payload);
+  OnContentObject (Ptr<const ContentObject> contentObject);
 
   virtual void
   OnTimeout (uint32_t sequenceNumber);
diff --git a/apps/ndn-consumer-zipf-mandelbrot.cc b/apps/ndn-consumer-zipf-mandelbrot.cc
index e15cf3a..866eb48 100644
--- a/apps/ndn-consumer-zipf-mandelbrot.cc
+++ b/apps/ndn-consumer-zipf-mandelbrot.cc
@@ -179,19 +179,12 @@
   (*nameWithSequence) (seq);
   //
 
-  Interest interestHeader;
-  interestHeader.SetNonce (m_rand.GetValue ());
-  interestHeader.SetName  (nameWithSequence);
+  Ptr<Interest> interest = Create<Interest> ();
+  interest->SetNonce (m_rand.GetValue ());
+  interest->SetName  (nameWithSequence);
 
-  // NS_LOG_INFO ("Requesting Interest: \n" << interestHeader);
+  // NS_LOG_INFO ("Requesting Interest: \n" << *interest);
   NS_LOG_INFO ("> Interest for " << seq<<", Total: "<<m_seq<<", face: "<<m_face->GetId());
-
-  Ptr<Packet> packet = Create<Packet> ();
-
-  //NS_LOG_DEBUG ("= Interest for " << seq<<", Total: "<<m_seq<<", face: "<<m_face->GetId());
-  packet->AddHeader (interestHeader);
-  //NS_LOG_DEBUG ("Interest packet size: " << packet->GetSize ());
-
   NS_LOG_DEBUG ("Trying to add " << seq << " with " << Simulator::Now () << ". already " << m_seqTimeouts.size () << " items");
 
   m_seqTimeouts.insert (SeqTimeout (seq, Simulator::Now ()));
@@ -202,14 +195,13 @@
 
   m_seqRetxCounts[seq] ++;
 
-  m_transmittedInterests (&interestHeader, this, m_face);
-
   m_rtt->SentSeq (SequenceNumber32 (seq), 1);
 
   FwHopCountTag hopCountTag;
-  packet->AddPacketTag (hopCountTag);
+  interest->GetPayload ()->AddPacketTag (hopCountTag);
 
-  m_protocolHandler (packet);
+  m_transmittedInterests (interest, this, m_face);
+  m_face->ReceiveInterest (interest);
 
   ConsumerZipfMandelbrot::ScheduleNextPacket ();
 }
diff --git a/apps/ndn-consumer.cc b/apps/ndn-consumer.cc
index e5c2a44..b6dba28 100644
--- a/apps/ndn-consumer.cc
+++ b/apps/ndn-consumer.cc
@@ -202,25 +202,21 @@
   (*nameWithSequence) (seq);
   //
 
-  Interest interestHeader;
-  interestHeader.SetNonce               (m_rand.GetValue ());
-  interestHeader.SetName                (nameWithSequence);
-  interestHeader.SetInterestLifetime    (m_interestLifeTime);
+  Ptr<Interest> interest = Create<Interest> ();
+  interest->SetNonce               (m_rand.GetValue ());
+  interest->SetName                (nameWithSequence);
+  interest->SetInterestLifetime    (m_interestLifeTime);
 
-  // NS_LOG_INFO ("Requesting Interest: \n" << interestHeader);
+  // NS_LOG_INFO ("Requesting Interest: \n" << *interest);
   NS_LOG_INFO ("> Interest for " << seq);
 
-  Ptr<Packet> packet = Create<Packet> ();
-  packet->AddHeader (interestHeader);
-  NS_LOG_DEBUG ("Interest packet size: " << packet->GetSize ());
-
   WillSendOutInterest (seq);  
 
   FwHopCountTag hopCountTag;
-  packet->AddPacketTag (hopCountTag);
+  interest->GetPayload ()->AddPacketTag (hopCountTag);
 
-  m_transmittedInterests (&interestHeader, this, m_face);
-  m_protocolHandler (packet);
+  m_transmittedInterests (interest, this, m_face);
+  m_face->ReceiveInterest (interest);
 
   ScheduleNextPacket ();
 }
@@ -231,23 +227,22 @@
 
 
 void
-Consumer::OnContentObject (const Ptr<const ContentObject> &contentObject,
-                               Ptr<Packet> payload)
+Consumer::OnContentObject (Ptr<const ContentObject> data)
 {
   if (!m_active) return;
 
-  App::OnContentObject (contentObject, payload); // tracing inside
+  App::OnContentObject (data); // tracing inside
 
-  NS_LOG_FUNCTION (this << contentObject << payload);
+  NS_LOG_FUNCTION (this << data);
 
-  // NS_LOG_INFO ("Received content object: " << boost::cref(*contentObject));
+  // NS_LOG_INFO ("Received content object: " << boost::cref(*data));
 
-  uint32_t seq = boost::lexical_cast<uint32_t> (contentObject->GetName ().GetComponents ().back ());
+  uint32_t seq = boost::lexical_cast<uint32_t> (data->GetName ().GetComponents ().back ());
   NS_LOG_INFO ("< DATA for " << seq);
 
   int hopCount = -1;
   FwHopCountTag hopCountTag;
-  if (payload->RemovePacketTag (hopCountTag))
+  if (data->GetPayload ()->PeekPacketTag (hopCountTag))
     {
       hopCount = hopCountTag.Get ();
     }
@@ -275,11 +270,11 @@
 }
 
 void
-Consumer::OnNack (const Ptr<const Interest> &interest, Ptr<Packet> origPacket)
+Consumer::OnNack (Ptr<const Interest> interest)
 {
   if (!m_active) return;
 
-  App::OnNack (interest, origPacket); // tracing inside
+  App::OnNack (interest); // tracing inside
 
   // NS_LOG_DEBUG ("Nack type: " << interest->GetNack ());
 
diff --git a/apps/ndn-consumer.h b/apps/ndn-consumer.h
index 7dd4cdc..bb9e30a 100644
--- a/apps/ndn-consumer.h
+++ b/apps/ndn-consumer.h
@@ -61,11 +61,10 @@
   // OnInterest (const Ptr<const Interest> &interest);
 
   virtual void
-  OnNack (const Ptr<const Interest> &interest, Ptr<Packet> packet);
+  OnNack (Ptr<const Interest> interest);
 
   virtual void
-  OnContentObject (const Ptr<const ContentObject> &contentObject,
-                   Ptr<Packet> payload);
+  OnContentObject (Ptr<const ContentObject> contentObject);
 
   /**
    * @brief Timeout event
diff --git a/apps/ndn-producer.cc b/apps/ndn-producer.cc
index 90ccce0..526e522 100644
--- a/apps/ndn-producer.cc
+++ b/apps/ndn-producer.cc
@@ -108,36 +108,29 @@
 
 
 void
-Producer::OnInterest (const Ptr<const Interest> &interest, Ptr<Packet> origPacket)
+Producer::OnInterest (Ptr<const Interest> interest)
 {
-  App::OnInterest (interest, origPacket); // tracing inside
+  App::OnInterest (interest); // tracing inside
 
   NS_LOG_FUNCTION (this << interest);
 
   if (!m_active) return;
     
-  static ContentObjectTail tail;
-  Ptr<ContentObject> header = Create<ContentObject> ();
-  header->SetName (Create<Name> (interest->GetName ()));
-  header->SetFreshness (m_freshness);
+  Ptr<ContentObject> data = Create<ContentObject> (Create<Packet> (m_virtualPayloadSize));
+  data->SetName (Create<Name> (interest->GetName ()));
+  data->SetFreshness (m_freshness);
 
-  NS_LOG_INFO ("node("<< GetNode()->GetId() <<") respodning with ContentObject:\n" << boost::cref(*header));
-  
-  Ptr<Packet> packet = Create<Packet> (m_virtualPayloadSize);
-  
-  packet->AddHeader (*header);
-  packet->AddTrailer (tail);
+  NS_LOG_INFO ("node("<< GetNode()->GetId() <<") respodning with ContentObject:\n" << data->GetName ());
 
   // Echo back FwHopCountTag if exists
   FwHopCountTag hopCountTag;
-  if (origPacket->RemovePacketTag (hopCountTag))
+  if (interest->GetPayload ()->PeekPacketTag (hopCountTag))
     {
-      packet->AddPacketTag (hopCountTag);
+      data->GetPayload ()->AddPacketTag (hopCountTag);
     }
 
-  m_protocolHandler (packet);
-  
-  m_transmittedContentObjects (header, packet, this, m_face);
+  m_face->ReceiveData (data);
+  m_transmittedContentObjects (data, this, m_face);
 }
 
 } // namespace ndn
diff --git a/apps/ndn-producer.h b/apps/ndn-producer.h
index bce01d3..1563d12 100644
--- a/apps/ndn-producer.h
+++ b/apps/ndn-producer.h
@@ -48,7 +48,7 @@
   Producer ();
 
   // inherited from NdnApp
-  void OnInterest (const Ptr<const Interest> &interest, Ptr<Packet> packet);
+  void OnInterest (Ptr<const Interest> interest);
 
 protected:
   // inherited from Application base class.