add NetDevice::SetReceiveCallback and use it

This commit is contained in:
Mathieu Lacage committed 2007-04-30 10:37:22 +02:00
1 parent 5717501324
commit 9230407c7e
4 files changed
+30 -9

No files matched your search

+15 -1
View File
@@ -30,6 +30,7 @@
#include "udp.h"
#include "ipv4.h"
#include "arp.h"
#include "net-device.h"
namespace ns3 {
@@ -144,7 +145,20 @@ InternetNode::GetArp (void) const
void
InternetNode::DoAddDevice (NetDevice *device) const
{
//XXX
device->SetReceiveCallback (MakeCallback (&InternetNode::ReceiveFromDevice, this));
}
bool
InternetNode::ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const
{
L3Protocol *target = GetL3Demux()->Lookup(protocolNumber);
if (target != 0)
{
Packet packet = p;
target->Receive(packet, *device);
return true;
}
return false;
}