bug 1778: TapBridge linkUp notification patch (modified by Tom Goff)
This commit is contained in:
@@ -221,6 +221,9 @@ TapBridge::StartTapDevice (void)
|
||||
//
|
||||
CreateTap ();
|
||||
|
||||
// Declare the link up
|
||||
NotifyLinkUp ();
|
||||
|
||||
//
|
||||
// Now spin up a read thread to read packets from the tap device.
|
||||
//
|
||||
@@ -1056,18 +1059,29 @@ TapBridge::GetMtu (void) const
|
||||
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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user