[Bug 653] NetDevice link change callback (SetLinkChangeCallback -> AddLinkChangeCallback).

This commit is contained in:
Sebastien Vincent
2009-09-08 06:29:26 +02:00
parent 345a0d99e2
commit 8cbdcd69c1
22 changed files with 47 additions and 59 deletions

View File

@@ -109,6 +109,13 @@ router solicitation, DAD
<li><b>WifiMode</b>
<p>WifiMode now has a WifiPhyStandard attribute which identifies the standard the WifiMode belongs to. To properly set this attribute when creating a new WifiMode, it is now required to explicitly pass a WifiPhyStandard parameter to all WifiModeFactory::CreateXXXX() methods. The WifiPhyStandard value of an existing WifiMode can be retrieved using the new method WifiMode::GetStandard().</p>
</li>
<li><b>NetDevice</b>
<p>In order to have multiple link change callback in NetDevice (i.e. to flush ARP and IPv6 neighbor discovery caches), the following member method has been renamed:</p>
<pre>
- virtual void SetLinkChangeCallback (Callback&lt;void&gt; callback);
+ virtual void AddLinkChangeCallback (Callback&lt;void&gt; callback);</pre>
Now each NetDevice subclasses have a TracedCallback&lt;&gt; object (list of callbacks) instead of Callback&lt;void&gt; ones.
</li>
</ul>
<hr>

View File

@@ -317,7 +317,7 @@ BridgeNetDevice::IsLinkUp (void) const
void
BridgeNetDevice::SetLinkChangeCallback (Callback<void> callback)
BridgeNetDevice::AddLinkChangeCallback (Callback<void> callback)
{}

View File

@@ -96,7 +96,7 @@ public:
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;

View File

@@ -839,12 +839,8 @@ CsmaNetDevice::GetQueue (void) const
CsmaNetDevice::NotifyLinkUp (void)
{
NS_LOG_FUNCTION_NOARGS ();
m_linkUp = true;
if (m_linkChangeCallback.IsNull () == false)
{
m_linkChangeCallback ();
}
m_linkChangeCallbacks ();
}
void
@@ -890,10 +886,10 @@ CsmaNetDevice::IsLinkUp (void) const
}
void
CsmaNetDevice::SetLinkChangeCallback (Callback<void> callback)
CsmaNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
NS_LOG_FUNCTION (&callback);
m_linkChangeCallback = callback;
m_linkChangeCallbacks.ConnectWithoutContext (callback);
}
bool

View File

@@ -306,7 +306,7 @@ public:
virtual void SetAddress (Address address);
virtual Address GetAddress (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;
@@ -806,9 +806,9 @@ private:
bool m_linkUp;
/**
* Callback to fire if the link changes state (up or down).
* List of callbacks to fire if the link changes state (up or down).
*/
Callback<void> m_linkChangeCallback;
TracedCallback<> m_linkChangeCallbacks;
static const uint16_t DEFAULT_FRAME_SIZE = 1518;
static const uint16_t ETHERNET_OVERHEAD = 18;

View File

@@ -869,10 +869,7 @@ void
EmuNetDevice::NotifyLinkUp (void)
{
m_linkUp = true;
if (!m_linkChangeCallback.IsNull ())
{
m_linkChangeCallback ();
}
m_linkChangeCallbacks ();
}
void
@@ -943,9 +940,9 @@ EmuNetDevice::IsLinkUp (void) const
}
void
EmuNetDevice::SetLinkChangeCallback (Callback<void> callback)
EmuNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
m_linkChangeCallback = callback;
m_linkChangeCallbacks.ConnectWithoutContext (callback);
}
bool

View File

@@ -110,7 +110,7 @@ public:
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
@@ -459,9 +459,9 @@ private:
bool m_isMulticast;
/**
* Callback to fire if the link changes state (up or down).
* Callbacks to fire if the link changes state (up or down).
*/
Callback<void> m_linkChangeCallback;
TracedCallback<> m_linkChangeCallbacks;
/**
* The unix/linux name of the underlying device (e.g., eth0)

View File

@@ -366,10 +366,7 @@ PointToPointNetDevice::GetQueue(void) const
PointToPointNetDevice::NotifyLinkUp (void)
{
m_linkUp = true;
if (!m_linkChangeCallback.IsNull ())
{
m_linkChangeCallback ();
}
m_linkChangeCallbacks ();
}
void
@@ -415,9 +412,9 @@ PointToPointNetDevice::IsLinkUp (void) const
}
void
PointToPointNetDevice::SetLinkChangeCallback (Callback<void> callback)
PointToPointNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
m_linkChangeCallback = callback;
m_linkChangeCallbacks.ConnectWithoutContext (callback);
}
//

View File

@@ -231,7 +231,7 @@ public:
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
@@ -520,7 +520,7 @@ private:
NetDevice::PromiscReceiveCallback m_promiscCallback;
uint32_t m_ifIndex;
bool m_linkUp;
Callback<void> m_linkChangeCallback;
TracedCallback<> m_linkChangeCallbacks;
static const uint16_t DEFAULT_MTU = 1500;
static const uint16_t PPP_OVERHEAD = 2;

View File

@@ -1026,7 +1026,7 @@ TapBridge::IsLinkUp (void) const
}
void
TapBridge::SetLinkChangeCallback (Callback<void> callback)
TapBridge::AddLinkChangeCallback (Callback<void> callback)
{
NS_LOG_FUNCTION_NOARGS ();
}

View File

@@ -181,7 +181,7 @@ public:
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;

View File

@@ -194,7 +194,7 @@ VirtualNetDevice::IsLinkUp (void) const
}
void
VirtualNetDevice::SetLinkChangeCallback (Callback<void> callback)
VirtualNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
}

View File

@@ -122,7 +122,7 @@ public:
virtual Address GetAddress (void) const;
virtual uint16_t GetMtu (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;

View File

@@ -196,9 +196,9 @@ WifiNetDevice::IsLinkUp (void) const
return m_phy != 0 && m_linkUp;
}
void
WifiNetDevice::SetLinkChangeCallback (Callback<void> callback)
WifiNetDevice::AddLinkChangeCallback (Callback<void> callback)
{
m_linkChange = callback;
m_linkChanges.ConnectWithoutContext (callback);
}
bool
WifiNetDevice::IsBroadcast (void) const
@@ -312,19 +312,13 @@ void
WifiNetDevice::LinkUp (void)
{
m_linkUp = true;
if (!m_linkChange.IsNull ())
{
m_linkChange ();
}
m_linkChanges ();
}
void
WifiNetDevice::LinkDown (void)
{
m_linkUp = false;
if (!m_linkChange.IsNull ())
{
m_linkChange ();
}
m_linkChanges ();
}
bool

View File

@@ -83,7 +83,7 @@ public:
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;
@@ -123,7 +123,7 @@ private:
uint32_t m_ifIndex;
bool m_linkUp;
Callback<void> m_linkChange;
TracedCallback<> m_linkChanges;
mutable uint16_t m_mtu;
bool m_configComplete;
};

View File

@@ -116,7 +116,7 @@ ArpL3Protocol::CreateCache (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface)
Ptr<ArpCache> cache = CreateObject<ArpCache> ();
cache->SetDevice (device, interface);
NS_ASSERT (device->IsBroadcast ());
device->SetLinkChangeCallback (MakeCallback (&ArpCache::Flush, cache));
device->AddLinkChangeCallback (MakeCallback (&ArpCache::Flush, cache));
cache->SetArpRequestCallback (MakeCallback (&ArpL3Protocol::SendArpRequest, this));
m_cacheList.push_back (cache);
return cache;

View File

@@ -1076,12 +1076,9 @@ Ptr<NdiscCache> Icmpv6L4Protocol::CreateCache (Ptr<NetDevice> device, Ptr<Ipv6In
{
Ptr<Ipv6L3Protocol> ipv6 = m_node->GetObject<Ipv6L3Protocol> ();
Ptr<NdiscCache> cache = CreateObject<NdiscCache> ();
cache->SetDevice (device, interface);
/* XXX : make a list of callback in net-device.cc
* else we override IPv4 flushing ARP table...
*/
/* device->SetLinkChangeCallback (MakeCallback (&NdiscCache::Flush, cache)); */
device->AddLinkChangeCallback (MakeCallback (&NdiscCache::Flush, cache));
m_cacheList.push_back (cache);
return cache;
}

View File

@@ -125,7 +125,7 @@ LoopbackNetDevice::IsLinkUp (void) const
}
void
LoopbackNetDevice::SetLinkChangeCallback (Callback<void> callback)
LoopbackNetDevice::AddLinkChangeCallback (Callback<void> callback)
{}
bool

View File

@@ -50,7 +50,7 @@ public:
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;

View File

@@ -128,12 +128,12 @@ public:
/**
* \param callback the callback to invoke
*
* Register a callback invoked whenever the link
* Add a callback invoked whenever the link
* status changes to UP. This callback is typically used
* by the IP/ARP layer to flush the ARP cache
* whenever the link goes up.
* by the IP/ARP layer to flush the ARP cache and by IPv6 stack
* to flush NDISC cache whenever the link goes up.
*/
virtual void SetLinkChangeCallback (Callback<void> callback) = 0;
virtual void AddLinkChangeCallback (Callback<void> callback) = 0;
/**
* \return true if this interface supports a broadcast address,
* false otherwise.

View File

@@ -121,7 +121,7 @@ SimpleNetDevice::IsLinkUp (void) const
return true;
}
void
SimpleNetDevice::SetLinkChangeCallback (Callback<void> callback)
SimpleNetDevice::AddLinkChangeCallback (Callback<void> callback)
{}
bool
SimpleNetDevice::IsBroadcast (void) const

View File

@@ -53,7 +53,7 @@ public:
virtual bool SetMtu (const uint16_t mtu);
virtual uint16_t GetMtu (void) const;
virtual bool IsLinkUp (void) const;
virtual void SetLinkChangeCallback (Callback<void> callback);
virtual void AddLinkChangeCallback (Callback<void> callback);
virtual bool IsBroadcast (void) const;
virtual Address GetBroadcast (void) const;
virtual bool IsMulticast (void) const;