Remove class Ipv4Impl
authorTom Henderson <tomh@tomh.org>
Sun, 12 Apr 2009 22:40:31 -0700
changeset 4377 2a05a47dba22
parent 4376 ac217f25fe70
child 4378 3ad10f8db106
Remove class Ipv4Impl
src/internet-stack/internet-stack.cc
src/internet-stack/ipv4-impl.cc
src/internet-stack/ipv4-impl.h
src/internet-stack/ipv4-l3-protocol.cc
src/internet-stack/ipv4-l3-protocol.h
src/internet-stack/wscript
src/node/ipv4.h
--- a/src/internet-stack/internet-stack.cc	Sun Apr 12 22:14:34 2009 -0700
+++ b/src/internet-stack/internet-stack.cc	Sun Apr 12 22:40:31 2009 -0700
@@ -29,7 +29,6 @@
 #include "arp-l3-protocol.h"
 #include "udp-socket-factory-impl.h"
 #include "tcp-socket-factory-impl.h"
-#include "ipv4-impl.h"
 #include "ipv4-raw-socket-factory-impl.h"
 #include "icmpv4-l4-protocol.h"
 #ifdef NETWORK_SIMULATION_CRADLE
@@ -94,9 +93,6 @@
   Ptr<Ipv4L3Protocol> ipv4 = CreateObject<Ipv4L3Protocol> ();
   ipv4->SetNode (node);
   node->AggregateObject (ipv4);
-  Ptr<Ipv4Impl> ipv4Impl = CreateObject<Ipv4Impl> ();
-  ipv4Impl->SetIpv4 (ipv4);
-  node->AggregateObject (ipv4Impl);
 }
 
 void
--- a/src/internet-stack/ipv4-impl.cc	Sun Apr 12 22:14:34 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,255 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * 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 "ipv4-impl.h"
-#include "ipv4-l3-protocol.h"
-#include "ipv4-interface.h"
-#include "ns3/assert.h"
-#include "ns3/net-device.h"
-
-namespace ns3 {
-
-Ipv4Impl::Ipv4Impl ()
-  : m_ipv4 (0)
-{}
-Ipv4Impl::~Ipv4Impl ()
-{
-  NS_ASSERT (m_ipv4 == 0);
-}
-void 
-Ipv4Impl::SetIpv4 (Ptr<Ipv4L3Protocol> ipv4)
-{
-  m_ipv4 = ipv4;
-}
-void 
-Ipv4Impl::DoDispose (void)
-{
-  m_ipv4 = 0;
-}
-
-void
-Ipv4Impl::AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
-                              int16_t priority)
-{
-  m_ipv4->AddRoutingProtocol (routingProtocol, priority);
-}
-
-void 
-Ipv4Impl::AddHostRouteTo (Ipv4Address dest, 
-			   Ipv4Address nextHop, 
-			   uint32_t interface)
-{
-  m_ipv4->AddHostRouteTo (dest, nextHop, interface);
-}
-void 
-Ipv4Impl::AddHostRouteTo (Ipv4Address dest, 
-			   uint32_t interface)
-{
-  m_ipv4->AddHostRouteTo (dest, interface);
-}
-void 
-Ipv4Impl::AddNetworkRouteTo (Ipv4Address network, 
-			      Ipv4Mask networkMask, 
-			      Ipv4Address nextHop, 
-			      uint32_t interface)
-{
-  m_ipv4->AddNetworkRouteTo (network, networkMask, nextHop, interface);
-}
-void 
-Ipv4Impl::AddNetworkRouteTo (Ipv4Address network, 
-			      Ipv4Mask networkMask, 
-			      uint32_t interface)
-{
-  m_ipv4->AddNetworkRouteTo (network, networkMask, interface);
-}
-void 
-Ipv4Impl::SetDefaultRoute (Ipv4Address nextHop, 
-			    uint32_t interface)
-{
-  m_ipv4->SetDefaultRoute (nextHop, interface);
-}
-uint32_t 
-Ipv4Impl::GetNRoutes (void)
-{
-  return m_ipv4->GetNRoutes ();
-}
-Ipv4Route 
-Ipv4Impl::GetRoute (uint32_t i)
-{
-  return *m_ipv4->GetRoute (i);
-}
-void 
-Ipv4Impl::RemoveRoute (uint32_t i)
-{
-  return m_ipv4->RemoveRoute (i);
-}
-
-void
-Ipv4Impl::AddMulticastRoute (Ipv4Address origin,
-                             Ipv4Address group,
-                             uint32_t inputInterface,
-                             std::vector<uint32_t> outputInterfaces)
-{
-  m_ipv4->AddMulticastRoute (origin, group, inputInterface, outputInterfaces);
-}
-
-void
-Ipv4Impl::SetDefaultMulticastRoute (uint32_t outputInterface)
-{
-  m_ipv4->SetDefaultMulticastRoute (outputInterface);
-}
-
-uint32_t 
-Ipv4Impl::GetNMulticastRoutes (void) const
-{
-  return m_ipv4->GetNMulticastRoutes ();
-}
-
-Ipv4MulticastRoute 
-Ipv4Impl::GetMulticastRoute (uint32_t i) const
-{
-  return *m_ipv4->GetMulticastRoute (i);
-}
-
-void
-Ipv4Impl::RemoveMulticastRoute (Ipv4Address origin,
-                                Ipv4Address group,
-                                uint32_t inputInterface)
-{
-  m_ipv4->RemoveMulticastRoute (origin, group, inputInterface);
-}
-
-void 
-Ipv4Impl::RemoveMulticastRoute (uint32_t i)
-{
-  return m_ipv4->RemoveMulticastRoute (i);
-}
-
-uint32_t 
-Ipv4Impl::AddInterface (Ptr<NetDevice> device)
-{
-  return m_ipv4->AddInterface (device);
-}
-
-uint32_t 
-Ipv4Impl::GetNInterfaces (void)
-{
-  return m_ipv4->GetNInterfaces ();
-}
-
-uint32_t 
-Ipv4Impl::FindInterfaceForAddr (Ipv4Address addr) const
-{
-  return m_ipv4->FindInterfaceForAddr (addr);
-}
-
-uint32_t 
-Ipv4Impl::FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const
-{
-  return m_ipv4->FindInterfaceForAddr (addr, mask);
-}
-
-int32_t 
-Ipv4Impl::FindInterfaceForDevice (Ptr<NetDevice> device) const
-{
-  return m_ipv4->FindInterfaceIndexForDevice (device);
-}
-
-Ptr<NetDevice>
-Ipv4Impl::GetNetDevice (uint32_t i)
-{
-  return m_ipv4->GetInterface (i)-> GetDevice ();
-}
-
-void 
-Ipv4Impl::JoinMulticastGroup (Ipv4Address origin, Ipv4Address group)
-{
-  m_ipv4->JoinMulticastGroup(origin, group);
-}
-
-void
-Ipv4Impl::LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group)
-{
-  m_ipv4->LeaveMulticastGroup(origin, group);
-}
-
-uint32_t 
-Ipv4Impl::AddAddress (uint32_t i, Ipv4InterfaceAddress address)
-{
-  return m_ipv4->AddAddress (i, address);
-}
-
-Ipv4InterfaceAddress 
-Ipv4Impl::GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const
-{
-  return m_ipv4->GetAddress (interfaceIndex, addressIndex);
-}
-
-uint32_t 
-Ipv4Impl::GetNAddresses (uint32_t interface) const
-{
-  return m_ipv4->GetNAddresses (interface);
-}
-
-void
-Ipv4Impl::SetMetric (uint32_t i, uint16_t metric) 
-{
-  m_ipv4->SetMetric (i, metric);
-}
-
-uint16_t
-Ipv4Impl::GetMetric (uint32_t i) const
-{
-  return m_ipv4->GetMetric (i);
-}
-
-bool
-Ipv4Impl::GetInterfaceForDestination (Ipv4Address dest, uint32_t &interface) const
-{
-  return m_ipv4->GetInterfaceForDestination (dest, interface);
-}
-
-Ipv4Address 
-Ipv4Impl::GetSourceAddress (Ipv4Address destination) const
-{
-  return m_ipv4->GetSourceAddress (destination);
-}
-
-uint16_t 
-Ipv4Impl::GetMtu (uint32_t i) const
-{
-  return m_ipv4->GetMtu (i);
-}
-bool 
-Ipv4Impl::IsUp (uint32_t i) const
-{
-  return m_ipv4->IsUp (i);
-}
-void 
-Ipv4Impl::SetUp (uint32_t i)
-{
-  m_ipv4->SetUp (i);
-}
-void 
-Ipv4Impl::SetDown (uint32_t i)
-{
-  m_ipv4->SetDown (i);
-}
-
-}//namespace ns3
--- a/src/internet-stack/ipv4-impl.h	Sun Apr 12 22:14:34 2009 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/*
- * Copyright (c) 2007 INRIA
- *
- * 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 IPV4_IMPL_H
-#define IPV4_IMPL_H
-
-#include "ns3/ipv4.h"
-#include "ns3/ptr.h"
-
-namespace ns3 {
-
-class Ipv4L3Protocol;
-
-class Ipv4Impl : public Ipv4
-{
-public:
-  Ipv4Impl ();
-
-  virtual ~Ipv4Impl ();
-
-  void SetIpv4 (Ptr<Ipv4L3Protocol> ipv4);
-
-  virtual void AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
-                                   int16_t priority);
-
-  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 void AddMulticastRoute (Ipv4Address origin,
-                                  Ipv4Address group,
-                                  uint32_t inputInterface,
-                                  std::vector<uint32_t> outputInterfaces);
-
-  virtual void SetDefaultMulticastRoute (uint32_t outputInterface);
-
-  virtual uint32_t GetNMulticastRoutes (void) const;
-  virtual Ipv4MulticastRoute GetMulticastRoute (uint32_t i) const;
-
-  virtual void RemoveMulticastRoute (Ipv4Address origin,
-                                     Ipv4Address group,
-                                     uint32_t inputInterface);
-  virtual void RemoveMulticastRoute (uint32_t i);
-
-  virtual uint32_t AddInterface (Ptr<NetDevice> device);
-  virtual uint32_t GetNInterfaces (void);  
-
-  virtual uint32_t FindInterfaceForAddr (Ipv4Address addr) const;
-  virtual uint32_t FindInterfaceForAddr (Ipv4Address addr, 
-    Ipv4Mask mask) const;
-
-  virtual int32_t FindInterfaceForDevice (Ptr<NetDevice> device) const;
-
-  virtual Ptr<NetDevice> GetNetDevice(uint32_t i);
-
-  virtual void JoinMulticastGroup (Ipv4Address origin, Ipv4Address group);
-  virtual void LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group);
-
-  uint32_t AddAddress (uint32_t i, Ipv4InterfaceAddress address);
-  Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
-  uint32_t GetNAddresses (uint32_t interface) const;
-
-  virtual void SetMetric (uint32_t i, uint16_t metric);
-  virtual uint16_t GetMetric (uint32_t i) const;
-  virtual Ipv4Address GetSourceAddress (Ipv4Address destination) const;
-  virtual bool GetInterfaceForDestination (Ipv4Address dest, 
-    uint32_t &interface) 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:
-  Ptr<Ipv4L3Protocol> m_ipv4;
-};
-
-} // namespace ns3
-
-#endif /* IPV4_IMPL_H */
--- a/src/internet-stack/ipv4-l3-protocol.cc	Sun Apr 12 22:14:34 2009 -0700
+++ b/src/internet-stack/ipv4-l3-protocol.cc	Sun Apr 12 22:40:31 2009 -0700
@@ -53,7 +53,7 @@
 Ipv4L3Protocol::GetTypeId (void)
 {
   static TypeId tid = TypeId ("ns3::Ipv4L3Protocol")
-    .SetParent<Object> ()
+    .SetParent<Ipv4> ()
     .AddConstructor<Ipv4L3Protocol> ()
     .AddAttribute ("DefaultTtl", "The TTL value set by default on all outgoing packets generated on this node.",
                    UintegerValue (64),
@@ -298,7 +298,7 @@
 
 void
 Ipv4L3Protocol::AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
-                                    int priority)
+                                    int16_t priority)
 {
   NS_LOG_FUNCTION (this << &routingProtocol << priority);
   m_routingProtocols.push_back
@@ -313,11 +313,11 @@
   return m_staticRouting->GetNRoutes ();
 }
 
-Ipv4Route *
+Ipv4Route 
 Ipv4L3Protocol::GetRoute (uint32_t index)
 {
   NS_LOG_FUNCTION_NOARGS ();
-  return m_staticRouting->GetRoute (index);
+  return *m_staticRouting->GetRoute (index);
 }
 
 void 
@@ -354,11 +354,11 @@
   return m_staticRouting->GetNMulticastRoutes ();
 }
 
-Ipv4MulticastRoute *
+Ipv4MulticastRoute 
 Ipv4L3Protocol::GetMulticastRoute (uint32_t index) const
 {
   NS_LOG_FUNCTION (this << index);
-  return m_staticRouting->GetMulticastRoute (index);
+  return *m_staticRouting->GetMulticastRoute (index);
 }
 
 void 
@@ -476,7 +476,7 @@
 }
 
 int32_t 
-Ipv4L3Protocol::FindInterfaceIndexForDevice (Ptr<NetDevice> device) const
+Ipv4L3Protocol::FindInterfaceForDevice (Ptr<NetDevice> device) const
 {
   NS_LOG_FUNCTION (this << device);
 
@@ -1101,8 +1101,8 @@
       modified = false;
       for (uint32_t i = 0; i < GetNRoutes (); i++)
         {
-          Ipv4Route *route = GetRoute (i);
-          if (route->GetInterface () == ifaceIndex)
+          Ipv4Route route = GetRoute (i);
+          if (route.GetInterface () == ifaceIndex)
             {
               RemoveRoute (i);
               modified = true;
@@ -1143,5 +1143,12 @@
     }
 }
 
+Ptr<NetDevice>
+Ipv4L3Protocol::GetNetDevice (uint32_t i)
+{
+  return GetInterface (i)-> GetDevice ();
+}
+
+
 
 }//namespace ns3
--- a/src/internet-stack/ipv4-l3-protocol.h	Sun Apr 12 22:14:34 2009 -0700
+++ b/src/internet-stack/ipv4-l3-protocol.h	Sun Apr 12 22:40:31 2009 -0700
@@ -53,7 +53,7 @@
  * This is the actual implementation of IP.  It contains APIs to send and
  * receive packets at the IP layer, as well as APIs for IP routing.
  */
-class Ipv4L3Protocol : public Object
+class Ipv4L3Protocol : public Ipv4
 {
 public:
   static TypeId GetTypeId (void);
@@ -158,7 +158,7 @@
                Ipv4RoutingProtocol::RouteReplyCallback routeReply);
 
   uint32_t GetNRoutes (void);
-  Ipv4Route *GetRoute (uint32_t i);
+  Ipv4Route GetRoute (uint32_t i);
   void RemoveRoute (uint32_t i);
 
   void AddMulticastRoute (Ipv4Address origin,
@@ -169,7 +169,7 @@
   void SetDefaultMulticastRoute (uint32_t onputInterface);
 
   uint32_t GetNMulticastRoutes (void) const;
-  Ipv4MulticastRoute *GetMulticastRoute (uint32_t i) const;
+  Ipv4MulticastRoute GetMulticastRoute (uint32_t i) const;
 
   void RemoveMulticastRoute (Ipv4Address origin,
                              Ipv4Address group,
@@ -182,7 +182,7 @@
 
   uint32_t FindInterfaceForAddr (Ipv4Address addr) const;
   uint32_t FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const;
-  int32_t FindInterfaceIndexForDevice (Ptr<NetDevice> device) const;
+  int32_t FindInterfaceForDevice (Ptr<NetDevice> device) const;
   
   void JoinMulticastGroup (Ipv4Address origin, Ipv4Address group);
   void LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group);
@@ -201,8 +201,10 @@
   void SetUp (uint32_t i);
   void SetDown (uint32_t i);
 
+  Ptr<NetDevice> GetNetDevice (uint32_t i);
+
   void AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
-                           int priority);
+                           int16_t priority);
 
 protected:
 
--- a/src/internet-stack/wscript	Sun Apr 12 22:14:34 2009 -0700
+++ b/src/internet-stack/wscript	Sun Apr 12 22:40:31 2009 -0700
@@ -92,7 +92,6 @@
         'udp-socket-impl.cc',
         'tcp-socket-impl.cc',
         'ipv4-end-point-demux.cc',
-        'ipv4-impl.cc',
         'udp-socket-factory-impl.cc',
         'tcp-socket-factory-impl.cc',
         'pending-data.cc',
--- a/src/node/ipv4.h	Sun Apr 12 22:14:34 2009 -0700
+++ b/src/node/ipv4.h	Sun Apr 12 22:40:31 2009 -0700
@@ -320,7 +320,7 @@
   /**
    * \returns the number of interfaces added by the user.
    */
-  virtual uint32_t GetNInterfaces (void) = 0;  
+  virtual uint32_t GetNInterfaces (void) const = 0;  
 
   /**
    * \brief Find and return the interface ID of the interface that has been