remove Node::GetIpv4
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
#include "net-device.h"
|
||||
#include "ipv4-interface.h"
|
||||
#include "node.h"
|
||||
#include "ipv4.h"
|
||||
#include "i-ipv4-private.h"
|
||||
|
||||
NS_DEBUG_COMPONENT_DEFINE ("Arp");
|
||||
|
||||
@@ -79,7 +79,7 @@ Arp::FindCache (NetDevice *device)
|
||||
return *i;
|
||||
}
|
||||
}
|
||||
Ipv4 *ipv4 = m_node->GetIpv4 ();
|
||||
IIpv4Private *ipv4 = m_node->QueryInterface<IIpv4Private> (IIpv4Private::iid);
|
||||
Ipv4Interface *interface = ipv4->FindInterfaceForDevice (device);
|
||||
ipv4->Unref ();
|
||||
ArpCache * cache = new ArpCache (device, interface);
|
||||
|
||||
144
src/node/i-ipv4-impl.cc
Normal file
144
src/node/i-ipv4-impl.cc
Normal file
@@ -0,0 +1,144 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "i-ipv4-impl.h"
|
||||
#include "ipv4.h"
|
||||
#include "ns3/assert.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
IIpv4Impl::IIpv4Impl (Ipv4 *ipv4)
|
||||
: m_ipv4 (ipv4)
|
||||
{
|
||||
m_ipv4->Ref ();
|
||||
}
|
||||
IIpv4Impl::~IIpv4Impl ()
|
||||
{
|
||||
NS_ASSERT (m_ipv4 == 0);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::DoDispose (void)
|
||||
{
|
||||
m_ipv4->Unref ();
|
||||
m_ipv4 = 0;
|
||||
}
|
||||
|
||||
void
|
||||
IIpv4Impl::AddHostRouteTo (Ipv4Address dest,
|
||||
Ipv4Address nextHop,
|
||||
uint32_t interface)
|
||||
{
|
||||
m_ipv4->AddHostRouteTo (dest, nextHop, interface);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::AddHostRouteTo (Ipv4Address dest,
|
||||
uint32_t interface)
|
||||
{
|
||||
m_ipv4->AddHostRouteTo (dest, interface);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::AddNetworkRouteTo (Ipv4Address network,
|
||||
Ipv4Mask networkMask,
|
||||
Ipv4Address nextHop,
|
||||
uint32_t interface)
|
||||
{
|
||||
m_ipv4->AddNetworkRouteTo (network, networkMask, nextHop, interface);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::AddNetworkRouteTo (Ipv4Address network,
|
||||
Ipv4Mask networkMask,
|
||||
uint32_t interface)
|
||||
{
|
||||
m_ipv4->AddNetworkRouteTo (network, networkMask, interface);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::SetDefaultRoute (Ipv4Address nextHop,
|
||||
uint32_t interface)
|
||||
{
|
||||
m_ipv4->SetDefaultRoute (nextHop, interface);
|
||||
}
|
||||
uint32_t
|
||||
IIpv4Impl::GetNRoutes (void)
|
||||
{
|
||||
return m_ipv4->GetNRoutes ();
|
||||
}
|
||||
Ipv4Route *
|
||||
IIpv4Impl::GetRoute (uint32_t i)
|
||||
{
|
||||
return m_ipv4->GetRoute (i);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::RemoveRoute (uint32_t i)
|
||||
{
|
||||
return m_ipv4->RemoveRoute (i);
|
||||
}
|
||||
uint32_t
|
||||
IIpv4Impl::AddInterface (NetDevice *device)
|
||||
{
|
||||
return m_ipv4->AddInterface (device);
|
||||
}
|
||||
uint32_t
|
||||
IIpv4Impl::GetNInterfaces (void)
|
||||
{
|
||||
return m_ipv4->GetNInterfaces ();
|
||||
}
|
||||
|
||||
void
|
||||
IIpv4Impl::SetAddress (uint32_t i, Ipv4Address address)
|
||||
{
|
||||
m_ipv4->SetAddress (i, address);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::SetNetworkMask (uint32_t i, Ipv4Mask mask)
|
||||
{
|
||||
m_ipv4->SetNetworkMask (i, mask);
|
||||
}
|
||||
Ipv4Mask
|
||||
IIpv4Impl::GetNetworkMask (uint32_t i) const
|
||||
{
|
||||
return m_ipv4->GetNetworkMask (i);
|
||||
}
|
||||
Ipv4Address
|
||||
IIpv4Impl::GetAddress (uint32_t i) const
|
||||
{
|
||||
return m_ipv4->GetAddress (i);
|
||||
}
|
||||
uint16_t
|
||||
IIpv4Impl::GetMtu (uint32_t i) const
|
||||
{
|
||||
return m_ipv4->GetMtu (i);
|
||||
}
|
||||
bool
|
||||
IIpv4Impl::IsUp (uint32_t i) const
|
||||
{
|
||||
return m_ipv4->IsUp (i);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::SetUp (uint32_t i)
|
||||
{
|
||||
m_ipv4->SetUp (i);
|
||||
}
|
||||
void
|
||||
IIpv4Impl::SetDown (uint32_t i)
|
||||
{
|
||||
m_ipv4->SetDown (i);
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
73
src/node/i-ipv4-impl.h
Normal file
73
src/node/i-ipv4-impl.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef I_IPV4_IMPL_H
|
||||
#define I_IPV4_IMPL_H
|
||||
|
||||
#include "i-ipv4.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv4;
|
||||
|
||||
class IIpv4Impl : public IIpv4
|
||||
{
|
||||
public:
|
||||
IIpv4Impl (Ipv4 *ipv4);
|
||||
|
||||
virtual ~IIpv4Impl ();
|
||||
|
||||
virtual void AddHostRouteTo (Ipv4Address dest,
|
||||
Ipv4Address nextHop,
|
||||
uint32_t interface);
|
||||
virtual void AddHostRouteTo (Ipv4Address dest,
|
||||
uint32_t interface);
|
||||
virtual void AddNetworkRouteTo (Ipv4Address network,
|
||||
Ipv4Mask networkMask,
|
||||
Ipv4Address nextHop,
|
||||
uint32_t interface);
|
||||
virtual void AddNetworkRouteTo (Ipv4Address network,
|
||||
Ipv4Mask networkMask,
|
||||
uint32_t interface);
|
||||
virtual void SetDefaultRoute (Ipv4Address nextHop,
|
||||
uint32_t interface);
|
||||
virtual uint32_t GetNRoutes (void);
|
||||
virtual Ipv4Route *GetRoute (uint32_t i);
|
||||
virtual void RemoveRoute (uint32_t i);
|
||||
virtual uint32_t AddInterface (NetDevice *device);
|
||||
virtual uint32_t GetNInterfaces (void);
|
||||
|
||||
virtual void SetAddress (uint32_t i, Ipv4Address address);
|
||||
virtual void SetNetworkMask (uint32_t i, Ipv4Mask mask);
|
||||
virtual Ipv4Mask GetNetworkMask (uint32_t t) const;
|
||||
virtual Ipv4Address GetAddress (uint32_t i) const;
|
||||
virtual uint16_t GetMtu (uint32_t i) const;
|
||||
virtual bool IsUp (uint32_t i) const;
|
||||
virtual void SetUp (uint32_t i);
|
||||
virtual void SetDown (uint32_t i);
|
||||
protected:
|
||||
virtual void DoDispose (void);
|
||||
private:
|
||||
Ipv4 *m_ipv4;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* I_IPV4_IMPL_H */
|
||||
69
src/node/i-ipv4-private.cc
Normal file
69
src/node/i-ipv4-private.cc
Normal file
@@ -0,0 +1,69 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "i-ipv4-private.h"
|
||||
#include "ipv4.h"
|
||||
#include "ns3/assert.h"
|
||||
#include "ns3/iid-manager.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
const uint32_t IIpv4Private::iid = IidManager::Allocate ("IIpv4Private");
|
||||
|
||||
IIpv4Private::IIpv4Private (Ipv4 *ipv4)
|
||||
: NsUnknown (IIpv4Private::iid),
|
||||
m_ipv4 (ipv4)
|
||||
{
|
||||
m_ipv4->Ref ();
|
||||
}
|
||||
IIpv4Private::~IIpv4Private ()
|
||||
{
|
||||
NS_ASSERT (m_ipv4 == 0);
|
||||
}
|
||||
TraceResolver *
|
||||
IIpv4Private::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
return m_ipv4->CreateTraceResolver (context);
|
||||
}
|
||||
void
|
||||
IIpv4Private::Send (Packet const &packet, Ipv4Address source,
|
||||
Ipv4Address destination, uint8_t protocol)
|
||||
{
|
||||
m_ipv4->Send (packet, source, destination, protocol);
|
||||
}
|
||||
Ipv4Interface *
|
||||
IIpv4Private::FindInterfaceForDevice (NetDevice const*device)
|
||||
{
|
||||
return m_ipv4->FindInterfaceForDevice (device);
|
||||
}
|
||||
void
|
||||
IIpv4Private::Receive(Packet& p, NetDevice *device)
|
||||
{
|
||||
m_ipv4->Receive (p, device);
|
||||
}
|
||||
void
|
||||
IIpv4Private::DoDispose (void)
|
||||
{
|
||||
m_ipv4->Unref ();
|
||||
m_ipv4 = 0;
|
||||
NsUnknown::DoDispose ();
|
||||
}
|
||||
|
||||
} // namespace ns3
|
||||
57
src/node/i-ipv4-private.h
Normal file
57
src/node/i-ipv4-private.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef I_IPV4_PRIVATE_H
|
||||
#define I_IPV4_PRIVATE_H
|
||||
|
||||
#include "ns3/ns-unknown.h"
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Packet;
|
||||
class Ipv4;
|
||||
class TraceContext;
|
||||
class TraceResolver;
|
||||
class Ipv4Interface;
|
||||
class NetDevice;
|
||||
|
||||
class IIpv4Private : public NsUnknown
|
||||
{
|
||||
public:
|
||||
static const uint32_t iid;
|
||||
IIpv4Private (Ipv4 *ipv4);
|
||||
virtual ~IIpv4Private ();
|
||||
|
||||
TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
void Send (Packet const &packet, Ipv4Address source,
|
||||
Ipv4Address destination, uint8_t protocol);
|
||||
Ipv4Interface *FindInterfaceForDevice (NetDevice const*device);
|
||||
void Receive(Packet& p, NetDevice *device);
|
||||
protected:
|
||||
virtual void DoDispose (void);
|
||||
private:
|
||||
Ipv4 *m_ipv4;
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* I_IPV4_PRIVATE_H */
|
||||
35
src/node/i-ipv4.cc
Normal file
35
src/node/i-ipv4.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#include "i-ipv4.h"
|
||||
#include "ns3/iid-manager.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
const uint32_t IIpv4::iid = IidManager::Allocate ("IIpv4");
|
||||
|
||||
IIpv4::IIpv4 ()
|
||||
: NsUnknown (IIpv4::iid)
|
||||
{}
|
||||
|
||||
IIpv4::~IIpv4 ()
|
||||
{}
|
||||
|
||||
} // namespace ns3
|
||||
138
src/node/i-ipv4.h
Normal file
138
src/node/i-ipv4.h
Normal file
@@ -0,0 +1,138 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2007 INRIA
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
*/
|
||||
#ifndef I_IPV4_H
|
||||
#define I_IPV4_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ns3/ipv4-address.h"
|
||||
#include "ns3/ns-unknown.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class NetDevice;
|
||||
class Packet;
|
||||
class Ipv4Route;
|
||||
|
||||
class IIpv4 : public NsUnknown
|
||||
{
|
||||
public:
|
||||
static const uint32_t iid;
|
||||
IIpv4 ();
|
||||
virtual ~IIpv4 ();
|
||||
|
||||
/**
|
||||
* \param dest destination address
|
||||
* \param nextHop address of next hop.
|
||||
* \param interface interface of next hop.
|
||||
*
|
||||
* add route to host dest through host nextHop
|
||||
* on interface.
|
||||
*/
|
||||
virtual void AddHostRouteTo (Ipv4Address dest,
|
||||
Ipv4Address nextHop,
|
||||
uint32_t interface) = 0;
|
||||
/**
|
||||
* \param dest destination address
|
||||
* \param interface of next hop
|
||||
*
|
||||
* add route to host dest on interface.
|
||||
*/
|
||||
virtual void AddHostRouteTo (Ipv4Address dest,
|
||||
uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param network destination network
|
||||
* \param networkMask netmask of destination network
|
||||
* \param nextHop address of next hop
|
||||
* \param interface interface of next hop
|
||||
*
|
||||
* add route to network dest with netmask
|
||||
* through host nextHop on interface
|
||||
*/
|
||||
virtual void AddNetworkRouteTo (Ipv4Address network,
|
||||
Ipv4Mask networkMask,
|
||||
Ipv4Address nextHop,
|
||||
uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \param network destination network
|
||||
* \param networkMask netmask of destination network
|
||||
* \param interface interface of next hop
|
||||
*
|
||||
* add route to network dest with netmask
|
||||
* on interface
|
||||
*/
|
||||
virtual void AddNetworkRouteTo (Ipv4Address network,
|
||||
Ipv4Mask networkMask,
|
||||
uint32_t interface) = 0;
|
||||
/**
|
||||
* \param nextHop address of default next hop
|
||||
* \param interface interface of default next hop.
|
||||
*
|
||||
* set the default route to host nextHop on
|
||||
* interface.
|
||||
*/
|
||||
virtual void SetDefaultRoute (Ipv4Address nextHop,
|
||||
uint32_t interface) = 0;
|
||||
|
||||
/**
|
||||
* \returns the number of entries in the routing table.
|
||||
*/
|
||||
virtual uint32_t GetNRoutes (void) = 0;
|
||||
/**
|
||||
* \param i index of route to return
|
||||
* \returns the route whose index is i
|
||||
*/
|
||||
virtual Ipv4Route *GetRoute (uint32_t i) = 0;
|
||||
/**
|
||||
* \param i index of route to remove from routing table.
|
||||
*/
|
||||
virtual void RemoveRoute (uint32_t i) = 0;
|
||||
|
||||
/**
|
||||
* \param interface interface to add to the list of ipv4 interfaces
|
||||
* which can be used as output interfaces during packet forwarding.
|
||||
* \returns the index of the interface added.
|
||||
*
|
||||
* Once an interface has been added, it can never be removed: if you want
|
||||
* to disable it, you can invoke Ipv4Interface::SetDown which will
|
||||
* make sure that it is never used during packet forwarding.
|
||||
*/
|
||||
virtual uint32_t AddInterface (NetDevice *device) = 0;
|
||||
/**
|
||||
* \returns the number of interfaces added by the user.
|
||||
*/
|
||||
virtual uint32_t GetNInterfaces (void) = 0;
|
||||
|
||||
virtual void SetAddress (uint32_t i, Ipv4Address address) = 0;
|
||||
virtual void SetNetworkMask (uint32_t i, Ipv4Mask mask) = 0;
|
||||
virtual Ipv4Mask GetNetworkMask (uint32_t t) const = 0;
|
||||
virtual Ipv4Address GetAddress (uint32_t i) const = 0;
|
||||
virtual uint16_t GetMtu (uint32_t i) const = 0;
|
||||
virtual bool IsUp (uint32_t i) const = 0;
|
||||
virtual void SetUp (uint32_t i) = 0;
|
||||
virtual void SetDown (uint32_t i) = 0;
|
||||
|
||||
};
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
#endif /* I_IPV4_H */
|
||||
@@ -33,6 +33,8 @@
|
||||
#include "net-device.h"
|
||||
#include "i-udp-impl.h"
|
||||
#include "i-arp-private.h"
|
||||
#include "i-ipv4-impl.h"
|
||||
#include "i-ipv4-private.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -53,7 +55,11 @@ InternetNode::InternetNode()
|
||||
|
||||
IUdpImpl *udpImpl = new IUdpImpl (udp);
|
||||
IArpPrivate *arpPrivate = new IArpPrivate (arp);
|
||||
IIpv4Impl *ipv4Impl = new IIpv4Impl (ipv4);
|
||||
IIpv4Private *ipv4Private = new IIpv4Private (ipv4);
|
||||
|
||||
NsUnknown::AddInterface (ipv4Private);
|
||||
NsUnknown::AddInterface (ipv4Impl);
|
||||
NsUnknown::AddInterface (arpPrivate);
|
||||
NsUnknown::AddInterface (udpImpl);
|
||||
NsUnknown::AddInterface (applicationList);
|
||||
@@ -64,11 +70,13 @@ InternetNode::InternetNode()
|
||||
applicationList->Unref ();
|
||||
l3Demux->Unref ();
|
||||
ipv4L4Demux->Unref ();
|
||||
ipv4->Unref ();
|
||||
arp->Unref ();
|
||||
ipv4->Unref ();
|
||||
udp->Unref ();
|
||||
udpImpl->Unref ();
|
||||
arpPrivate->Unref ();
|
||||
ipv4Impl->Unref ();
|
||||
ipv4Private->Unref ();
|
||||
}
|
||||
|
||||
InternetNode::~InternetNode ()
|
||||
@@ -84,13 +92,12 @@ TraceResolver *
|
||||
InternetNode::CreateTraceResolver (TraceContext const &context)
|
||||
{
|
||||
CompositeTraceResolver *resolver = new CompositeTraceResolver (context);
|
||||
Ipv4 *ipv4 = GetIpv4 ();
|
||||
IIpv4Private *ipv4 = QueryInterface<IIpv4Private> (IIpv4Private::iid);
|
||||
resolver->Add ("ipv4",
|
||||
MakeCallback (&Ipv4::CreateTraceResolver, ipv4),
|
||||
MakeCallback (&IIpv4Private::CreateTraceResolver, ipv4),
|
||||
InternetNode::IPV4);
|
||||
ipv4->Unref ();
|
||||
|
||||
|
||||
return resolver;
|
||||
}
|
||||
|
||||
@@ -100,16 +107,6 @@ InternetNode::DoDispose()
|
||||
Node::DoDispose ();
|
||||
}
|
||||
|
||||
Ipv4 *
|
||||
InternetNode::GetIpv4 (void) const
|
||||
{
|
||||
L3Demux *l3Demux = QueryInterface<L3Demux> (L3Demux::iid);
|
||||
Ipv4 *ipv4 = static_cast<Ipv4*> (l3Demux->PeekProtocol (Ipv4::PROT_NUMBER));
|
||||
l3Demux->Unref ();
|
||||
ipv4->Ref ();
|
||||
return ipv4;
|
||||
}
|
||||
|
||||
void
|
||||
InternetNode::DoAddDevice (NetDevice *device) const
|
||||
{
|
||||
|
||||
@@ -42,8 +42,6 @@ public:
|
||||
InternetNode();
|
||||
virtual ~InternetNode ();
|
||||
virtual TraceResolver *CreateTraceResolver (TraceContext const &context);
|
||||
// Capability access
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
|
||||
void SetName(std::string name);
|
||||
protected:
|
||||
@@ -51,7 +49,6 @@ protected:
|
||||
private:
|
||||
virtual void DoAddDevice (NetDevice *device) const;
|
||||
bool ReceiveFromDevice (NetDevice *device, const Packet &p, uint16_t protocolNumber) const;
|
||||
// Capabilities
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "ipv4-loopback-interface.h"
|
||||
#include "net-device.h"
|
||||
#include "node.h"
|
||||
#include "ipv4.h"
|
||||
#include "i-ipv4-private.h"
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
@@ -47,7 +47,7 @@ Ipv4LoopbackInterface::DoCreateTraceResolver (TraceContext const &context)
|
||||
void
|
||||
Ipv4LoopbackInterface::SendTo (Packet packet, Ipv4Address dest)
|
||||
{
|
||||
Ipv4 *ipv4 = m_node->GetIpv4 ();
|
||||
IIpv4Private *ipv4 = m_node->QueryInterface<IIpv4Private> (IIpv4Private::iid);
|
||||
ipv4->Receive (packet, PeekDevice ());
|
||||
ipv4->Unref ();
|
||||
}
|
||||
|
||||
@@ -102,10 +102,4 @@ void Node::DoDispose()
|
||||
NsUnknown::DoDispose ();
|
||||
}
|
||||
|
||||
Ipv4 *
|
||||
Node::GetIpv4 (void) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
}//namespace ns3
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class Ipv4;
|
||||
|
||||
class TraceContext;
|
||||
class TraceResolver;
|
||||
class NetDevice;
|
||||
@@ -61,17 +59,6 @@ protected:
|
||||
private:
|
||||
virtual void DoAddDevice (NetDevice *device) const = 0;
|
||||
|
||||
public:
|
||||
// Virtual "Getters" for each capability.
|
||||
// These exist to allow owners of a generic Node pointer to get
|
||||
// a pointer to the underlying capability, a pointer to a "NULL"
|
||||
// capability if one exists, or the nil pointer if not.
|
||||
// Each of these has a default behavior of returning a null capability
|
||||
// of the correct type if one exists, or the nil pointer if no
|
||||
// null capability exists.
|
||||
virtual Ipv4 * GetIpv4 (void) const;
|
||||
|
||||
private:
|
||||
uint32_t m_id; // Node id for this node
|
||||
uint32_t m_sid; // System id for this node
|
||||
std::vector<NetDevice *> m_devices;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "ipv4-end-point.h"
|
||||
#include "node.h"
|
||||
#include "ipv4.h"
|
||||
#include "i-ipv4-private.h"
|
||||
#include "l3-demux.h"
|
||||
#include "udp-socket.h"
|
||||
|
||||
@@ -141,7 +142,7 @@ Udp::Send (Packet packet,
|
||||
|
||||
packet.AddHeader (udpHeader);
|
||||
|
||||
Ipv4 *ipv4 = m_node->GetIpv4 ();
|
||||
IIpv4Private *ipv4 = m_node->QueryInterface<IIpv4Private> (IIpv4Private::iid);
|
||||
if (ipv4 != 0)
|
||||
{
|
||||
ipv4->Send (packet, saddr, daddr, PROT_NUMBER);
|
||||
|
||||
Reference in New Issue
Block a user