--- a/src/tap-bridge/model/tap-bridge.cc Tue Nov 19 06:50:18 2013 -0800
+++ b/src/tap-bridge/model/tap-bridge.cc Tue Nov 19 06:52:02 2013 -0800
@@ -221,6 +221,9 @@
//
CreateTap ();
+ // Declare the link up
+ NotifyLinkUp ();
+
//
// Now spin up a read thread to read packets from the tap device.
//
@@ -1056,18 +1059,29 @@
return m_mtu;
}
+void
+TapBridge::NotifyLinkUp (void)
+{
+ NS_LOG_FUNCTION_NOARGS ();
+ if (!m_linkUp)
+ {
+ 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
--- a/src/tap-bridge/model/tap-bridge.h Tue Nov 19 06:50:18 2013 -0800
+++ b/src/tap-bridge/model/tap-bridge.h Tue Nov 19 06:52:02 2013 -0800
@@ -291,6 +291,8 @@
*/
Ptr<Packet> Filter (Ptr<Packet> packet, Address *src, Address *dst, uint16_t *type);
+ void NotifyLinkUp (void);
+
/**
* \internal
*
@@ -463,6 +465,22 @@
* 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