Don't register IPv4 protocol handler for all interfaces, only for IPv4-enabled interfaces.
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
#include "ns3/ptr.h"
|
||||
#include "ns3/traced-callback.h"
|
||||
|
||||
#include "ipv4-interface.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class ArpCache;
|
||||
|
||||
@@ -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> ();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user