Small extension of InterestHeader API (cheat for python bindings)
diff --git a/bindings/modulegen__gcc_ILP32.py b/bindings/modulegen__gcc_ILP32.py
index 8a75ad4..f6a2843 100644
--- a/bindings/modulegen__gcc_ILP32.py
+++ b/bindings/modulegen__gcc_ILP32.py
@@ -5727,6 +5727,11 @@
'ns3::TypeId',
[],
is_const=True, is_virtual=True)
+ ## ndn-interest-header.h (module 'ndnSIM'): static ns3::Ptr<ns3::ndn::InterestHeader> ns3::ndn::InterestHeader::GetInterest(ns3::Ptr<ns3::Packet> packet) [member function]
+ cls.add_method('GetInterest',
+ 'ns3::Ptr< ns3::ndn::InterestHeader >',
+ [param('ns3::Ptr< ns3::Packet >', 'packet')],
+ is_static=True)
## ndn-interest-header.h (module 'ndnSIM'): ns3::Time ns3::ndn::InterestHeader::GetInterestLifetime() const [member function]
cls.add_method('GetInterestLifetime',
'ns3::Time',
diff --git a/bindings/modulegen__gcc_LP64.py b/bindings/modulegen__gcc_LP64.py
index 8a75ad4..f6a2843 100644
--- a/bindings/modulegen__gcc_LP64.py
+++ b/bindings/modulegen__gcc_LP64.py
@@ -5727,6 +5727,11 @@
'ns3::TypeId',
[],
is_const=True, is_virtual=True)
+ ## ndn-interest-header.h (module 'ndnSIM'): static ns3::Ptr<ns3::ndn::InterestHeader> ns3::ndn::InterestHeader::GetInterest(ns3::Ptr<ns3::Packet> packet) [member function]
+ cls.add_method('GetInterest',
+ 'ns3::Ptr< ns3::ndn::InterestHeader >',
+ [param('ns3::Ptr< ns3::Packet >', 'packet')],
+ is_static=True)
## ndn-interest-header.h (module 'ndnSIM'): ns3::Time ns3::ndn::InterestHeader::GetInterestLifetime() const [member function]
cls.add_method('GetInterestLifetime',
'ns3::Time',
diff --git a/model/ndn-interest-header.cc b/model/ndn-interest-header.cc
index 39c87e9..d0ebaab 100644
--- a/model/ndn-interest-header.cc
+++ b/model/ndn-interest-header.cc
@@ -27,6 +27,7 @@
#include "ns3/log.h"
#include "ns3/unused.h"
+#include "ns3/packet.h"
#include "../helper/ndn-encoding-helper.h"
#include "../helper/ndn-decoding-helper.h"
@@ -77,6 +78,15 @@
{
}
+Ptr<InterestHeader>
+InterestHeader::GetInterest (Ptr<Packet> packet)
+{
+ Ptr<InterestHeader> interest = Create<InterestHeader> ();
+ packet->RemoveHeader (*interest);
+
+ return interest;
+}
+
void
InterestHeader::SetName (Ptr<NameComponents> name)
{
diff --git a/model/ndn-interest-header.h b/model/ndn-interest-header.h
index df48fb0..f645255 100644
--- a/model/ndn-interest-header.h
+++ b/model/ndn-interest-header.h
@@ -34,6 +34,9 @@
#include "ndn-name-components.h"
namespace ns3 {
+
+class Packet;
+
namespace ndn {
/**
@@ -385,6 +388,12 @@
*/
virtual uint32_t Deserialize (Buffer::Iterator start);
+ /**
+ * @brief Cheat for python bindings
+ */
+ static Ptr<InterestHeader>
+ GetInterest (Ptr<Packet> packet);
+
private:
Ptr<NameComponents> m_name; ///< Interest name
int32_t m_minSuffixComponents; ///< Minimum suffix components. not used if negative