add NetDevice::SetReceiveCallback and use it

This commit is contained in:
Mathieu Lacage committed 2007-04-30 10:37:22 +02:00
1 parent 52646de997
commit 4873ff5f39
4 files changed
+30 -9

No files matched your search

+10 -8
View File
@@ -179,19 +179,15 @@ NetDevice::GetChannel (void) const
bool
NetDevice::ForwardUp (Packet& packet)
{
bool retval = false;
LlcSnapHeader llc;
packet.Peek (llc);
packet.Remove (llc);
if (GetNode()->GetL3Demux() != 0)
if (!m_receiveCallback.IsNull ())
{
L3Protocol *target = GetNode()->GetL3Demux()->Lookup(llc.GetType ());
if (target != 0)
{
target->Receive(packet, *this);
return true;
}
retval = m_receiveCallback (this, packet, llc.GetType ());
}
return false;
return retval;
}
void
@@ -226,4 +222,10 @@ NetDevice::NeedsArp (void) const
return DoNeedsArp ();
}
void
NetDevice::SetReceiveCallback (Callback<bool,NetDevice *,const Packet &,uint16_t> cb)
{
m_receiveCallback = cb;
}
}; // namespace ns3