Skip to content

Instantly share code, notes, and snippets.

@piotrjurkiewicz
Last active December 20, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piotrjurkiewicz/6067864 to your computer and use it in GitHub Desktop.
Save piotrjurkiewicz/6067864 to your computer and use it in GitHub Desktop.
--- ./src/tap-bridge/model/tap-bridge.cc 2013-07-22 04:03:53.671898613 +0200
+++ ./src/tap-bridge/model/tap-bridge.cc 2013-07-19 08:36:33.963029004 +0200
@@ -674,6 +674,7 @@ TapBridge::CreateTap (void)
NS_LOG_INFO ("Underlying ns-3 device will continue to use default address, what can lead to connectivity errors");
}
}
+ NotifyLinkUp ();
return;
}
}
@@ -1064,18 +1065,25 @@ TapBridge::GetMtu (void) const
return m_mtu;
}
+void
+TapBridge::NotifyLinkUp (void)
+{
+ m_linkUp = true;
+ m_linkChangeCallbacks ();
+}
bool
TapBridge::IsLinkUp (void) const
{
NS_LOG_FUNCTION_NOARGS ();
- return true;
+ return m_linkUp;
}
void
TapBridge::AddLinkChangeCallback (Callback<void> callback)
{
NS_LOG_FUNCTION_NOARGS ();
+ m_linkChangeCallbacks.ConnectWithoutContext (callback);
}
bool
--- ./src/tap-bridge/model/tap-bridge.h 2013-07-22 04:03:53.671898613 +0200
+++ ./src/tap-bridge/model/tap-bridge.h 2013-07-19 08:11:22.510991547 +0200
@@ -291,6 +291,8 @@ private:
*/
Ptr<Packet> Filter (Ptr<Packet> packet, Address *src, Address *dst, uint16_t *type);
+ void NotifyLinkUp (void);
+
/**
* \internal
*
@@ -463,6 +465,22 @@ private:
* multithreaded apps is not a good thing.
*/
uint32_t m_nodeId;
+
+ /**
+ * \internal
+ *
+ * Flag indicating whether or not the link is up. In this case,
+ * whether or not ns-3 is connected to the underlying TAP device
+ * with a file descriptor.
+ */
+ bool m_linkUp;
+
+ /**
+ * \internal
+ *
+ * Callbacks to fire if the link changes state (up or down).
+ */
+ TracedCallback<> m_linkChangeCallbacks;
};
} // namespace ns3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment