Last active
December 20, 2015 03:59
-
-
Save piotrjurkiewicz/6067864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- ./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