Skip to content

Instantly share code, notes, and snippets.

@thehajime
Created November 4, 2014 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thehajime/f1878cdfc0d19bfa1c5d to your computer and use it in GitHub Desktop.
Save thehajime/f1878cdfc0d19bfa1c5d to your computer and use it in GitHub Desktop.
diff --git a/src/network/utils/pcap-file-wrapper.cc b/src/network/utils/pcap-file-wrapper.cc
--- a/src/network/utils/pcap-file-wrapper.cc
+++ b/src/network/utils/pcap-file-wrapper.cc
@@ -55,6 +55,18 @@
Close ();
}
+void
+PcapFileWrapper::DoDispose (void)
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ Close ();
+}
+void
+PcapFileWrapper::NotifyNewAggregate ()
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ Object::NotifyNewAggregate ();
+}
bool
PcapFileWrapper::Fail (void) const
diff --git a/src/network/utils/pcap-file-wrapper.h b/src/network/utils/pcap-file-wrapper.h
--- a/src/network/utils/pcap-file-wrapper.h
+++ b/src/network/utils/pcap-file-wrapper.h
@@ -44,6 +44,8 @@
PcapFileWrapper ();
~PcapFileWrapper ();
+ void DoDispose (void);
+ void NotifyNewAggregate ();
/**
* \return true if the 'fail' bit is set in the underlying iostream, false otherwise.
diff --git a/src/point-to-point/helper/point-to-point-helper.cc b/src/point-to-point/helper/point-to-point-helper.cc
--- a/src/point-to-point/helper/point-to-point-helper.cc
+++ b/src/point-to-point/helper/point-to-point-helper.cc
@@ -103,6 +103,13 @@
Ptr<PcapFileWrapper> file = pcapHelper.CreateFile (filename, std::ios::out,
PcapHelper::DLT_PPP);
pcapHelper.HookDefaultSink<PointToPointNetDevice> (device, "PromiscSniffer", file);
+
+ Ptr<Node> node = device->GetNode ();
+ if (!node->GetObject <PcapFileWrapper>())
+ {
+ node->AggregateObject (file);
+ }
+
}
void
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment