Simplify promiscuous mode API: NetDevices always operate in promiscuous mode, normal receive callbacks receive extra destination address and packet type.

This commit is contained in:
Gustavo J. A. M. Carneiro committed 2008-07-07 12:18:05 +01:00
1 parent 8f38c8907b
commit e525ff58ab
20 files changed
+115 -222

No files matched your search

+8 -1
View File
@@ -114,9 +114,16 @@ ArpL3Protocol::FindCache (Ptr<NetDevice> device)
}
void
ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from)
ArpL3Protocol::Receive(Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION_NOARGS ();
if (packetType == NetDevice::PACKET_OTHERHOST)
{
return;
}
Ptr<ArpCache> cache = FindCache (device);
ArpHeader arp;
packet->RemoveHeader (arp);
+2 -1
View File
@@ -54,7 +54,8 @@ public:
/**
* \brief Recieve a packet
*/
void Receive(Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from);
void Receive(Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from, const Address &to,
NetDevice::PacketType packetType);
/**
* \brief Perform an ARP lookup
* \param p
+7 -1
View File
@@ -449,10 +449,16 @@ Ipv4L3Protocol::FindInterfaceForDevice (Ptr<const NetDevice> device)
}
void
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from)
Ipv4L3Protocol::Receive( Ptr<NetDevice> device, Ptr<Packet> packet, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType)
{
NS_LOG_FUNCTION (this << &device << packet << protocol << from);
if (packetType == NetDevice::PACKET_OTHERHOST)
{
return;
}
NS_LOG_LOGIC ("Packet from " << from << " received on node " << m_node->GetId ());
uint32_t index = 0;
+3 -1
View File
@@ -25,6 +25,7 @@
#include <stdint.h>
#include "ns3/ipv4-address.h"
#include "ns3/ptr.h"
#include "ns3/net-device.h"
#include "ns3/ipv4.h"
#include "ns3/traced-callback.h"
#include "ns3/ipv4-header.h"
@@ -82,7 +83,8 @@ public:
* - implement a per-NetDevice ARP cache
* - send back arp replies on the right device
*/
void Receive( Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from);
void Receive( Ptr<NetDevice> device, Ptr<Packet> p, uint16_t protocol, const Address &from,
const Address &to, NetDevice::PacketType packetType);
/**
* \param packet packet to send
@@ -73,7 +73,10 @@ Ipv4LoopbackInterface::SendTo (Ptr<Packet> packet, Ipv4Address dest)
m_node->GetObject<Ipv4L3Protocol> ();
ipv4->Receive (0, packet, Ipv4L3Protocol::PROT_NUMBER,
Mac48Address ("ff:ff:ff:ff:ff:ff"));
Mac48Address ("ff:ff:ff:ff:ff:ff"),
Mac48Address ("ff:ff:ff:ff:ff:ff"),
NetDevice::PACKET_HOST // note: linux uses PACKET_LOOPBACK here
);
}
}//namespace ns3