Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.

This commit is contained in:
Gustavo J. A. M. Carneiro
2008-05-29 09:34:31 +01:00
parent b135ced7aa
commit 39c1412e3e
3 changed files with 10 additions and 6 deletions

View File

@@ -26,6 +26,8 @@
#include "ns3/ptr.h"
#include "ns3/traced-callback.h"
#include "ipv4-interface.h"
namespace ns3 {
class ArpCache;

View File

@@ -40,12 +40,6 @@ AddInternetStack (Ptr<Node> node)
Ptr<ArpL3Protocol> arp = CreateObject<ArpL3Protocol> ();
ipv4->SetNode (node);
arp->SetNode (node);
// XXX remove the PeekPointer below.
node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, PeekPointer (ipv4)),
Ipv4L3Protocol::PROT_NUMBER, 0);
node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (arp)),
ArpL3Protocol::PROT_NUMBER, 0);
Ptr<Ipv4L4Demux> ipv4L4Demux = CreateObject<Ipv4L4Demux> ();
Ptr<UdpL4Protocol> udp = CreateObject<UdpL4Protocol> ();

View File

@@ -29,6 +29,7 @@
#include "ns3/uinteger.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/object-vector.h"
#include "arp-l3-protocol.h"
#include "ipv4-l3-protocol.h"
#include "ipv4-l4-protocol.h"
@@ -320,6 +321,13 @@ uint32_t
Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
{
NS_LOG_FUNCTION (this << &device);
Ptr<Node> node = GetObject<Node> ();
node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this),
Ipv4L3Protocol::PROT_NUMBER, device);
node->RegisterProtocolHandler (MakeCallback (&ArpL3Protocol::Receive, PeekPointer (GetObject<ArpL3Protocol> ())),
ArpL3Protocol::PROT_NUMBER, device);
Ptr<ArpIpv4Interface> interface = CreateObject<ArpIpv4Interface> ();
interface->SetNode (m_node);
interface->SetDevice (device);