Remove static routing dependencies in code
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 12 Jun 2009 13:44:19 -0700
changeset 4560 2f106fd728ab
parent 4559 51fb48b38c2f
child 4561 cf6e27dd3a08
Remove static routing dependencies in code
bindings/python/ns3_module_internet_stack.py
bindings/python/ns3_module_node.py
bindings/python/ns3_module_olsr.py
src/helper/internet-stack-helper.cc
src/helper/olsr-helper.cc
src/internet-stack/ipv4-l3-protocol.cc
src/internet-stack/ipv4-l3-protocol.h
src/internet-stack/ipv4-list-routing-impl.cc
src/internet-stack/ipv4-list-routing-impl.h
src/internet-stack/ipv4-static-routing-impl.cc
src/internet-stack/ipv4-static-routing-impl.h
src/internet-stack/tcp-socket-impl.cc
src/internet-stack/tcp-test.cc
src/internet-stack/udp-test.cc
src/node/ipv4-routing-protocol.h
src/node/ipv4-static-routing.h
src/node/ipv4.h
src/routing/global-routing/global-route-manager-impl.cc
src/routing/global-routing/ipv4-global-routing.cc
src/routing/global-routing/ipv4-global-routing.h
src/routing/olsr/olsr-routing-protocol.cc
src/routing/olsr/olsr-routing-protocol.h
--- a/bindings/python/ns3_module_internet_stack.py	Fri Jun 19 09:17:08 2009 +0200
+++ b/bindings/python/ns3_module_internet_stack.py	Fri Jun 12 13:44:19 2009 -0700
@@ -541,6 +541,31 @@
                    'bool', 
                    [param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')], 
                    is_virtual=True)
+    ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::NotifyInterfaceUp(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceUp', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   is_virtual=True)
+    ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::NotifyInterfaceDown(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceDown', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   is_virtual=True)
+    ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::NotifyAddAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyAddAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   is_virtual=True)
+    ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::NotifyRemoveAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyRemoveAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   is_virtual=True)
+    ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::SetIpv4(ns3::Ptr<ns3::Ipv4> ipv4) [member function]
+    cls.add_method('SetIpv4', 
+                   'void', 
+                   [param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')], 
+                   is_virtual=True)
     ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::AddHostRouteTo(ns3::Ipv4Address dest, ns3::Ipv4Address nextHop, uint32_t interface) [member function]
     cls.add_method('AddHostRouteTo', 
                    'void', 
@@ -616,16 +641,6 @@
                    'void', 
                    [param('uint32_t', 'index')], 
                    is_virtual=True)
-    ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::SetNode(ns3::Ptr<ns3::Node> node) [member function]
-    cls.add_method('SetNode', 
-                   'void', 
-                   [param('ns3::Ptr< ns3::Node >', 'node')], 
-                   is_virtual=True)
-    ## ipv4-static-routing-impl.h: ns3::Ptr<ns3::Node> ns3::Ipv4StaticRoutingImpl::GetNode() const [member function]
-    cls.add_method('GetNode', 
-                   'ns3::Ptr< ns3::Node >', 
-                   [], 
-                   is_const=True, is_virtual=True)
     ## ipv4-static-routing-impl.h: void ns3::Ipv4StaticRoutingImpl::DoDispose() [member function]
     cls.add_method('DoDispose', 
                    'void', 
@@ -653,6 +668,31 @@
                    'bool', 
                    [param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')], 
                    is_virtual=True)
+    ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::NotifyInterfaceUp(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceUp', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   is_virtual=True)
+    ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::NotifyInterfaceDown(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceDown', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   is_virtual=True)
+    ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::NotifyAddAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyAddAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   is_virtual=True)
+    ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::NotifyRemoveAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyRemoveAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   is_virtual=True)
+    ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::SetIpv4(ns3::Ptr<ns3::Ipv4> ipv4) [member function]
+    cls.add_method('SetIpv4', 
+                   'void', 
+                   [param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')], 
+                   is_virtual=True)
     ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::AddRoutingProtocol(ns3::Ptr<ns3::Ipv4RoutingProtocol> routingProtocol, int16_t priority) [member function]
     cls.add_method('AddRoutingProtocol', 
                    'void', 
@@ -673,15 +713,6 @@
                    'ns3::Ptr< ns3::Ipv4StaticRouting >', 
                    [], 
                    is_const=True, is_virtual=True)
-    ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::SetNode(ns3::Ptr<ns3::Node> node) [member function]
-    cls.add_method('SetNode', 
-                   'void', 
-                   [param('ns3::Ptr< ns3::Node >', 'node')])
-    ## ipv4-list-routing-impl.h: ns3::Ptr<ns3::Node> ns3::Ipv4ListRoutingImpl::GetNode() const [member function]
-    cls.add_method('GetNode', 
-                   'ns3::Ptr< ns3::Node >', 
-                   [], 
-                   is_const=True)
     ## ipv4-list-routing-impl.h: void ns3::Ipv4ListRoutingImpl::DoDispose() [member function]
     cls.add_method('DoDispose', 
                    'void', 
--- a/bindings/python/ns3_module_node.py	Fri Jun 19 09:17:08 2009 +0200
+++ b/bindings/python/ns3_module_node.py	Fri Jun 12 13:44:19 2009 -0700
@@ -2855,6 +2855,31 @@
                    'bool', 
                    [param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')], 
                    is_pure_virtual=True, is_virtual=True)
+    ## ipv4-routing-protocol.h: void ns3::Ipv4RoutingProtocol::NotifyInterfaceUp(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceUp', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   is_pure_virtual=True, is_virtual=True)
+    ## ipv4-routing-protocol.h: void ns3::Ipv4RoutingProtocol::NotifyInterfaceDown(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceDown', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   is_pure_virtual=True, is_virtual=True)
+    ## ipv4-routing-protocol.h: void ns3::Ipv4RoutingProtocol::NotifyAddAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyAddAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   is_pure_virtual=True, is_virtual=True)
+    ## ipv4-routing-protocol.h: void ns3::Ipv4RoutingProtocol::NotifyRemoveAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyRemoveAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   is_pure_virtual=True, is_virtual=True)
+    ## ipv4-routing-protocol.h: void ns3::Ipv4RoutingProtocol::SetIpv4(ns3::Ptr<ns3::Ipv4> ipv4) [member function]
+    cls.add_method('SetIpv4', 
+                   'void', 
+                   [param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')], 
+                   is_pure_virtual=True, is_virtual=True)
     return
 
 def register_Ns3Ipv4StaticRouting_methods(root_module, cls):
@@ -2942,16 +2967,6 @@
                    'void', 
                    [param('uint32_t', 'index')], 
                    is_pure_virtual=True, is_virtual=True)
-    ## ipv4-static-routing.h: void ns3::Ipv4StaticRouting::SetNode(ns3::Ptr<ns3::Node> node) [member function]
-    cls.add_method('SetNode', 
-                   'void', 
-                   [param('ns3::Ptr< ns3::Node >', 'node')], 
-                   is_pure_virtual=True, is_virtual=True)
-    ## ipv4-static-routing.h: ns3::Ptr<ns3::Node> ns3::Ipv4StaticRouting::GetNode() const [member function]
-    cls.add_method('GetNode', 
-                   'ns3::Ptr< ns3::Node >', 
-                   [], 
-                   is_pure_virtual=True, is_const=True, is_virtual=True)
     return
 
 def register_Ns3NetDevice_methods(root_module, cls):
--- a/bindings/python/ns3_module_olsr.py	Fri Jun 19 09:17:08 2009 +0200
+++ b/bindings/python/ns3_module_olsr.py	Fri Jun 12 13:44:19 2009 -0700
@@ -747,10 +747,6 @@
                    is_static=True)
     ## olsr-routing-protocol.h: ns3::olsr::RoutingProtocol::RoutingProtocol() [constructor]
     cls.add_constructor([])
-    ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::SetNode(ns3::Ptr<ns3::Node> node) [member function]
-    cls.add_method('SetNode', 
-                   'void', 
-                   [param('ns3::Ptr< ns3::Node >', 'node')])
     ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::Start() [member function]
     cls.add_method('Start', 
                    'void', 
@@ -769,6 +765,31 @@
                    'bool', 
                    [param('ns3::Ptr< ns3::Packet const >', 'p'), param('ns3::Ipv4Header const &', 'header'), param('ns3::Ptr< ns3::NetDevice const >', 'idev'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4Route >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ucb'), param('ns3::Callback< void, ns3::Ptr< ns3::Ipv4MulticastRoute >, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'mcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, unsigned int, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'lcb'), param('ns3::Callback< void, ns3::Ptr< ns3::Packet const >, ns3::Ipv4Header const &, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty, ns3::empty >', 'ecb')], 
                    visibility='private', is_virtual=True)
+    ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::NotifyInterfaceUp(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceUp', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   visibility='private', is_virtual=True)
+    ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::NotifyInterfaceDown(uint32_t interface) [member function]
+    cls.add_method('NotifyInterfaceDown', 
+                   'void', 
+                   [param('uint32_t', 'interface')], 
+                   visibility='private', is_virtual=True)
+    ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::NotifyAddAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyAddAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   visibility='private', is_virtual=True)
+    ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::NotifyRemoveAddress(uint32_t interface, ns3::Ipv4InterfaceAddress address) [member function]
+    cls.add_method('NotifyRemoveAddress', 
+                   'void', 
+                   [param('uint32_t', 'interface'), param('ns3::Ipv4InterfaceAddress', 'address')], 
+                   visibility='private', is_virtual=True)
+    ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::SetIpv4(ns3::Ptr<ns3::Ipv4> ipv4) [member function]
+    cls.add_method('SetIpv4', 
+                   'void', 
+                   [param('ns3::Ptr< ns3::Ipv4 >', 'ipv4')], 
+                   visibility='private', is_virtual=True)
     ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::DoDispose() [member function]
     cls.add_method('DoDispose', 
                    'void', 
--- a/src/helper/internet-stack-helper.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/helper/internet-stack-helper.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -244,10 +244,8 @@
   // XXX cut this over to use of TypeIds and factories
   Ptr<Ipv4ListRoutingImpl> ipv4RoutingImpl = CreateObject<Ipv4ListRoutingImpl> ();
   Ptr<Ipv4StaticRoutingImpl> ipv4staticRoutingImpl = CreateObject<Ipv4StaticRoutingImpl> ();
-  ipv4staticRoutingImpl->SetNode (node);
   ipv4RoutingImpl->AddRoutingProtocol (ipv4staticRoutingImpl, 0);
   ipv4->SetRoutingProtocol (ipv4RoutingImpl);
-  ipv4RoutingImpl->SetNode (node);
 }
 
 void
--- a/src/helper/olsr-helper.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/helper/olsr-helper.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -76,7 +76,6 @@
   Ptr<Ipv4ListRouting> ipv4Routing = DynamicCast<Ipv4ListRouting> (ipv4->GetRoutingProtocol ());
   NS_ASSERT (ipv4Routing);
   ipv4Routing->AddRoutingProtocol (agent, 10);
-  agent->SetNode (node);
   agent->Start ();
 }
 void 
--- a/src/internet-stack/ipv4-l3-protocol.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/ipv4-l3-protocol.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -163,12 +163,7 @@
 {
   NS_LOG_FUNCTION (this);
   m_routingProtocol = routingProtocol;
-  // XXX should check all interfaces to see if any were set to Up state
-  // prior to a routing protocol being added
-  if (GetStaticRouting () != 0)
-    {
-      GetStaticRouting ()->AddHostRouteTo (Ipv4Address::GetLoopback (), 0);
-    }
+  m_routingProtocol->SetIpv4 (this);
 }
 
 
@@ -230,11 +225,11 @@
   Ptr<Node> node = GetObject<Node> ();
   node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this), 
                                  Ipv4L3Protocol::PROT_NUMBER, device);
-  if (GetStaticRouting () != 0)
+  interface->SetUp ();
+  if (m_routingProtocol != 0)
     {
-      GetStaticRouting ()->AddHostRouteTo (Ipv4Address::GetLoopback (), index);
+      m_routingProtocol->NotifyInterfaceUp (index);
     }
-  interface->SetUp ();
 }
 
 void 
@@ -244,26 +239,6 @@
   m_defaultTtl = ttl;
 }
     
-// XXX need to remove dependencies on Ipv4StaticRouting from this class
-Ptr<Ipv4StaticRouting>
-Ipv4L3Protocol::GetStaticRouting (void) const
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  Ptr<Ipv4StaticRouting> staticRouting;
-  if (m_routingProtocol != 0)
-    {
-      Ptr<Ipv4StaticRoutingImpl> sr = DynamicCast<Ipv4StaticRoutingImpl> (m_routingProtocol);
-      if (sr != 0)
-        {
-          return sr;
-        }
-      Ptr<Ipv4ListRoutingImpl> lr = DynamicCast<Ipv4ListRoutingImpl> (m_routingProtocol);
-      NS_ASSERT (lr);
-      staticRouting = lr->GetStaticRouting ();
-    }
-  return staticRouting;
-}
-
 uint32_t 
 Ipv4L3Protocol::AddInterface (Ptr<NetDevice> device)
 {
@@ -761,7 +736,12 @@
 {
   NS_LOG_FUNCTION (this << i << address);
   Ptr<Ipv4Interface> interface = GetInterface (i);
-  return interface->AddAddress (address);
+  uint32_t index = interface->AddAddress (address);
+  if (m_routingProtocol != 0)
+    {
+      m_routingProtocol->NotifyAddAddress (i, address);
+    }
+  return index;
 }
 
 Ipv4InterfaceAddress 
@@ -819,18 +799,9 @@
   Ptr<Ipv4Interface> interface = GetInterface (i);
   interface->SetUp ();
 
-  // If interface address and network mask have been set, add a route
-  // to the network of the interface (like e.g. ifconfig does on a
-  // Linux box)
-  for (uint32_t j = 0; j < interface->GetNAddresses (); j++)
+  if (m_routingProtocol != 0)
     {
-      if (((interface->GetAddress (j).GetLocal ()) != (Ipv4Address ()))
-          && (interface->GetAddress (j).GetMask ()) != (Ipv4Mask ()))
-        {
-          NS_ASSERT_MSG (GetStaticRouting(), "SetUp:: No static routing");
-          GetStaticRouting ()->AddNetworkRouteTo (interface->GetAddress (j).GetLocal ().CombineMask (interface->GetAddress (j).GetMask ()),
-            interface->GetAddress (j).GetMask (), i);
-        }
+      m_routingProtocol->NotifyInterfaceUp (i);
     }
 }
 
@@ -841,21 +812,9 @@
   Ptr<Ipv4Interface> interface = GetInterface (ifaceIndex);
   interface->SetDown ();
 
-  // Remove all static routes that are going through this interface
-  bool modified = true;
-  while (modified)
+  if (m_routingProtocol != 0)
     {
-      modified = false;
-      for (uint32_t i = 0; i < GetStaticRouting ()->GetNRoutes (); i++)
-        {
-          Ipv4RoutingTableEntry route = GetStaticRouting ()->GetRoute (i);
-          if (route.GetInterface () == ifaceIndex)
-            {
-              GetStaticRouting ()->RemoveRoute (i);
-              modified = true;
-              break;
-            }
-        }
+      m_routingProtocol->NotifyInterfaceDown (ifaceIndex);
     }
 }
 
--- a/src/internet-stack/ipv4-l3-protocol.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/ipv4-l3-protocol.h	Fri Jun 12 13:44:19 2009 -0700
@@ -218,7 +218,6 @@
   TracedCallback<Ptr<const Packet> > m_dropTrace;
 
   Ptr<Ipv4RoutingProtocol> m_routingProtocol;
-  Ptr<Ipv4StaticRouting> GetStaticRouting (void) const;
 
   SocketList m_sockets;
 };
--- a/src/internet-stack/ipv4-list-routing-impl.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/ipv4-list-routing-impl.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -42,7 +42,7 @@
 
 
 Ipv4ListRoutingImpl::Ipv4ListRoutingImpl () 
- : m_node (0)
+ : m_ipv4 (0)
 {
   NS_LOG_FUNCTION_NOARGS ();
 }
@@ -65,7 +65,7 @@
       (*rprotoIter).second = 0;
     }
   m_routingProtocols.clear ();
-  m_node = 0;
+  m_ipv4 = 0;
 }
 
 Ptr<Ipv4Route>
@@ -102,18 +102,17 @@
 {
   bool retVal = false;
   NS_LOG_FUNCTION (p << header << idev);
-  NS_LOG_LOGIC ("RouteInput logic for node: " << m_node->GetId ());
+  NS_LOG_LOGIC ("RouteInput logic for node: " << m_ipv4->GetObject<Node> ()->GetId ());
 
-  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
-  NS_ASSERT (ipv4);
-  uint32_t iif = ipv4->GetInterfaceForDevice (idev); 
+  NS_ASSERT (m_ipv4 != 0);
+  uint32_t iif = m_ipv4->GetInterfaceForDevice (idev); 
 
   // Multicast recognition; handle local delivery here
   //
   if (header.GetDestination().IsMulticast ())
     {
 #ifdef NOTYET
-      if (ipv4->MulticastCheckGroup (iif, header.GetDestination ()))
+      if (m_ipv4->MulticastCheckGroup (iif, header.GetDestination ()))
 #endif
       if (true)
         {
@@ -152,11 +151,11 @@
  // destination unicast address does not match one of the iif addresses,
  // but we check our other interfaces.  This could be an option
  // (to remove the outer loop immediately below and just check iif).
-  for (uint32_t j = 0; j < ipv4->GetNInterfaces (); j++)
+  for (uint32_t j = 0; j < m_ipv4->GetNInterfaces (); j++)
     {
-      for (uint32_t i = 0; i < ipv4->GetNAddresses (j); i++)
+      for (uint32_t i = 0; i < m_ipv4->GetNAddresses (j); i++)
         {
-          Ipv4InterfaceAddress iaddr = ipv4->GetAddress (j, i);
+          Ipv4InterfaceAddress iaddr = m_ipv4->GetAddress (j, i);
           Ipv4Address addr = iaddr.GetLocal ();
           if (addr.IsEqual (header.GetDestination ()))
             {
@@ -195,13 +194,79 @@
   return retVal;
 }
 
+void 
+Ipv4ListRoutingImpl::NotifyInterfaceUp (uint32_t interface)
+{
+  NS_LOG_FUNCTION (this << interface);
+  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
+         m_routingProtocols.begin ();
+       rprotoIter != m_routingProtocols.end ();
+       rprotoIter++)
+    {
+      (*rprotoIter).second->NotifyInterfaceUp (interface);
+    }  
+}
+void 
+Ipv4ListRoutingImpl::NotifyInterfaceDown (uint32_t interface)
+{
+  NS_LOG_FUNCTION (this << interface);
+  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
+         m_routingProtocols.begin ();
+       rprotoIter != m_routingProtocols.end ();
+       rprotoIter++)
+    {
+      (*rprotoIter).second->NotifyInterfaceDown (interface);
+    }  
+}
+void 
+Ipv4ListRoutingImpl::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{
+  NS_LOG_FUNCTION(this << interface << address);
+  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
+         m_routingProtocols.begin ();
+       rprotoIter != m_routingProtocols.end ();
+       rprotoIter++)
+    {
+      (*rprotoIter).second->NotifyAddAddress (interface, address);
+    }  
+}
+void 
+Ipv4ListRoutingImpl::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{
+  NS_LOG_FUNCTION(this << interface << address);
+  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
+         m_routingProtocols.begin ();
+       rprotoIter != m_routingProtocols.end ();
+       rprotoIter++)
+    {
+      (*rprotoIter).second->NotifyRemoveAddress (interface, address);
+    }  
+}
+void 
+Ipv4ListRoutingImpl::SetIpv4 (Ptr<Ipv4> ipv4)
+{
+  NS_LOG_FUNCTION(this << ipv4);
+  NS_ASSERT (m_ipv4 == 0);
+  for (Ipv4RoutingProtocolList::const_iterator rprotoIter =
+         m_routingProtocols.begin ();
+       rprotoIter != m_routingProtocols.end ();
+       rprotoIter++)
+    {
+      (*rprotoIter).second->SetIpv4 (ipv4);
+    }  
+  m_ipv4 = ipv4;
+}
+
 void
 Ipv4ListRoutingImpl::AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol, int16_t priority)
 {
   NS_LOG_FUNCTION (this << routingProtocol->GetInstanceTypeId () << priority);
-  m_routingProtocols.push_back
-    (std::pair<int, Ptr<Ipv4RoutingProtocol> > (-priority, routingProtocol));
+  m_routingProtocols.push_back (std::make_pair (-priority, routingProtocol));
   m_routingProtocols.sort ();
+  if (m_ipv4 != 0)
+    {
+      routingProtocol->SetIpv4 (m_ipv4);
+    }
 }
 
 uint32_t 
@@ -253,19 +318,4 @@
 
 }
 
-void
-Ipv4ListRoutingImpl::SetNode (Ptr<Node> node)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  m_node = node;
-}
-
-Ptr<Node> 
-Ipv4ListRoutingImpl::GetNode (void) const
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_node;
-}
-
-
 }//namespace ns3
--- a/src/internet-stack/ipv4-list-routing-impl.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/ipv4-list-routing-impl.h	Fri Jun 12 13:44:19 2009 -0700
@@ -39,6 +39,11 @@
   virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, 
                            UnicastForwardCallback ucb, MulticastForwardCallback mcb, 
                            LocalDeliverCallback lcb, ErrorCallback ecb);
+  virtual void NotifyInterfaceUp (uint32_t interface);
+  virtual void NotifyInterfaceDown (uint32_t interface);
+  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
 
   virtual void AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol, int16_t priority);
 
@@ -47,16 +52,12 @@
   virtual Ptr<Ipv4RoutingProtocol> GetRoutingProtocol (uint32_t index, int16_t& priority) const;
   virtual Ptr<Ipv4StaticRouting> GetStaticRouting (void) const;
 
-
-  void SetNode (Ptr<Node> node);
-  Ptr<Node> GetNode (void) const;
-
 protected:
   void DoDispose (void);
 private:
-  typedef std::list< std::pair< int, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList;
+  typedef std::list< std::pair< int16_t, Ptr<Ipv4RoutingProtocol> > > Ipv4RoutingProtocolList;
   Ipv4RoutingProtocolList m_routingProtocols;
-  Ptr<Node> m_node;
+  Ptr<Ipv4> m_ipv4;
 
 };
 
--- a/src/internet-stack/ipv4-static-routing-impl.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/ipv4-static-routing-impl.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -42,7 +42,7 @@
 }
 
 Ipv4StaticRoutingImpl::Ipv4StaticRoutingImpl () 
-: m_defaultRoute (0), m_node (0)
+: m_defaultRoute (0), m_ipv4 (0)
 {
   NS_LOG_FUNCTION_NOARGS ();
 }
@@ -222,15 +222,14 @@
       if ((*i)->GetDest ().IsEqual (dest)) 
         {
           NS_LOG_LOGIC ("Found global host route" << *i);
-          Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
           Ipv4RoutingTableEntry* route = (*i);
           rtentry = Create<Ipv4Route> ();
           rtentry->SetDestination (route->GetDest ());
           // XXX handle multi-address case
-          rtentry->SetSource (ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
+          rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
           rtentry->SetGateway (route->GetGateway ());
           uint32_t interfaceIdx = route->GetInterface ();
-          rtentry->SetOutputDevice (ipv4->GetNetDevice (interfaceIdx));
+          rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
           return rtentry;
         }
     }
@@ -244,15 +243,14 @@
       if (mask.IsMatch (dest, entry)) 
         {
           NS_LOG_LOGIC ("Found global network route" << *j);
-          Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
           Ipv4RoutingTableEntry* route = (*j);
           rtentry = Create<Ipv4Route> ();
           rtentry->SetDestination (route->GetDest ());
           // XXX handle multi-address case
-          rtentry->SetSource (ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
+          rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
           rtentry->SetGateway (route->GetGateway ());
           uint32_t interfaceIdx = route->GetInterface ();
-          rtentry->SetOutputDevice (ipv4->GetNetDevice (interfaceIdx));
+          rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
           return rtentry;
         }
     }
@@ -260,15 +258,14 @@
     {
       NS_ASSERT (m_defaultRoute->IsDefault ());
       NS_LOG_LOGIC ("Found global network route" << m_defaultRoute);
-      Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
       Ipv4RoutingTableEntry* route = m_defaultRoute;
       rtentry = Create<Ipv4Route> ();
       rtentry->SetDestination (route->GetDest ());
       // XXX handle multi-address case
-      rtentry->SetSource (ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
+      rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
       rtentry->SetGateway (route->GetGateway ());
       uint32_t interfaceIdx = route->GetInterface ();
-      rtentry->SetOutputDevice (ipv4->GetNetDevice (interfaceIdx));
+      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
       return rtentry;
     }
   return 0;
@@ -307,7 +304,6 @@
               interface == route->GetInputInterface ())
             {
               NS_LOG_LOGIC ("Found multicast route" << *i);
-              Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
               mrtentry = Create<Ipv4MulticastRoute> ();
               mrtentry->SetGroup (route->GetGroup ());
               mrtentry->SetOrigin (route->GetOrigin ());
@@ -480,13 +476,12 @@
                              LocalDeliverCallback lcb, ErrorCallback ecb)
 {
   NS_LOG_FUNCTION (this << p << ipHeader << ipHeader.GetSource () << ipHeader.GetDestination () << idev);
-  Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
 
   if (ipHeader.GetDestination ().IsMulticast ())
     {
       NS_LOG_LOGIC ("Multicast destination");
       Ptr<Ipv4MulticastRoute> mrtentry =  LookupStatic(ipHeader.GetSource (),
-        ipHeader.GetDestination (), ipv4->GetInterfaceForDevice (idev));
+        ipHeader.GetDestination (), m_ipv4->GetInterfaceForDevice (idev));
 
       if (mrtentry)
         {
@@ -550,22 +545,100 @@
     {
       delete (*i);
     }
+  m_ipv4 = 0;
   Ipv4RoutingProtocol::DoDispose ();
 }
 
-void
-Ipv4StaticRoutingImpl::SetNode (Ptr<Node> node)
+void 
+Ipv4StaticRoutingImpl::NotifyInterfaceUp (uint32_t i)
 {
-  NS_LOG_FUNCTION_NOARGS ();
-  m_node = node;
+  // If interface address and network mask have been set, add a route
+  // to the network of the interface (like e.g. ifconfig does on a
+  // Linux box)
+  for (uint32_t j = 0; j < m_ipv4->GetNAddresses (i); j++)
+    {
+      if (m_ipv4->GetAddress (i,j).GetLocal () != Ipv4Address () &&
+          m_ipv4->GetAddress (i,j).GetMask () != Ipv4Mask ())
+        {
+          AddNetworkRouteTo (m_ipv4->GetAddress (i,j).GetLocal ().CombineMask (m_ipv4->GetAddress (i,j).GetMask ()),
+                             m_ipv4->GetAddress (i,j).GetMask (), i);
+        }
+    }
+}
+
+void 
+Ipv4StaticRoutingImpl::NotifyInterfaceDown (uint32_t i)
+{
+  // Remove all static routes that are going through this interface
+  for (uint32_t j = 0; j < GetNRoutes (); j++)
+    {
+      Ipv4RoutingTableEntry route = GetRoute (j);
+      if (route.GetInterface () == i)
+        {
+          RemoveRoute (j);
+        }
+    }
 }
 
-Ptr<Node>
-Ipv4StaticRoutingImpl::GetNode (void) const
+void 
+Ipv4StaticRoutingImpl::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{
+  NS_LOG_FUNCTION (this << interface);
+  if (!m_ipv4->IsUp (interface))
+    {
+      return;
+    }
+
+  Ipv4Address networkAddress = address.GetLocal ().CombineMask (address.GetMask ());
+  Ipv4Mask networkMask = address.GetMask ();
+  if (address.GetLocal () != Ipv4Address () &&
+      address.GetMask () != Ipv4Mask ())
+    {
+      AddNetworkRouteTo (networkAddress,
+                         networkMask, interface);
+    }
+}
+void 
+Ipv4StaticRoutingImpl::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
 {
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_node; 
-} 
+  if (!m_ipv4->IsUp (interface))
+    {
+      return;
+    }
+  Ipv4Address networkAddress = address.GetLocal ().CombineMask (address.GetMask ());
+  Ipv4Mask networkMask = address.GetMask ();
+  // Remove all static routes that are going through this interface
+  // which reference this network
+  for (uint32_t j = 0; j < GetNRoutes (); j++)
+    {
+      Ipv4RoutingTableEntry route = GetRoute (j);
+      if (route.GetInterface () == interface &&
+          route.IsNetwork () && 
+          route.GetDestNetwork () == networkAddress &&
+          route.GetDestNetworkMask () == networkMask)
+        {
+          RemoveRoute (j);
+        }
+    }
+}
 
+void 
+Ipv4StaticRoutingImpl::SetIpv4 (Ptr<Ipv4> ipv4)
+{
+  NS_LOG_FUNCTION (this << ipv4);
+  NS_ASSERT (m_ipv4 == 0 && ipv4 != 0);
+  m_ipv4 = ipv4;
+  for (uint32_t i = 0; i < m_ipv4->GetNInterfaces (); i++)
+    {
+      if (m_ipv4->IsUp (i))
+        {
+          NotifyInterfaceUp (i);
+        }
+      else
+        {
+          NotifyInterfaceDown (i);
+        }
+    }
+}
 
 }//namespace ns3
--- a/src/internet-stack/ipv4-static-routing-impl.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/ipv4-static-routing-impl.h	Fri Jun 12 13:44:19 2009 -0700
@@ -56,6 +56,13 @@
                              UnicastForwardCallback ucb, MulticastForwardCallback mcb,
                              LocalDeliverCallback lcb, ErrorCallback ecb);
 
+  virtual void NotifyInterfaceUp (uint32_t interface);
+  virtual void NotifyInterfaceDown (uint32_t interface);
+  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
+
+
 /**
  * \brief Add a host route to the static routing table.
  *
@@ -332,11 +339,8 @@
  */
   void RemoveMulticastRoute (uint32_t index);
 
-  void SetNode (Ptr<Node> node);
-  Ptr<Node> GetNode (void) const;
-
 protected:
-  void DoDispose (void);
+  virtual void DoDispose (void);
 
 private:
   typedef std::list<Ipv4RoutingTableEntry *> HostRoutes;
@@ -359,7 +363,7 @@
   Ipv4RoutingTableEntry *m_defaultRoute;
   MulticastRoutes m_multicastRoutes;
 
-  Ptr<Node> m_node;
+  Ptr<Ipv4> m_ipv4;
 };
 
 } // Namespace ns3
--- a/src/internet-stack/tcp-socket-impl.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/tcp-socket-impl.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -25,15 +25,16 @@
 #include "ns3/ipv4.h"
 #include "ns3/ipv4-interface-address.h"
 #include "ns3/ipv4-route.h"
-#include "tcp-socket-impl.h"
-#include "tcp-l4-protocol.h"
-#include "ipv4-end-point.h"
+#include "ns3/ipv4-routing-protocol.h"
 #include "ns3/simulation-singleton.h"
-#include "tcp-typedefs.h"
 #include "ns3/simulator.h"
 #include "ns3/packet.h"
 #include "ns3/uinteger.h"
 #include "ns3/trace-source-accessor.h"
+#include "tcp-typedefs.h"
+#include "tcp-socket-impl.h"
+#include "tcp-l4-protocol.h"
+#include "ipv4-end-point.h"
 
 #include <algorithm>
 
--- a/src/internet-stack/tcp-test.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/tcp-test.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -59,9 +59,7 @@
   //Routing for Ipv4
   Ptr<Ipv4ListRoutingImpl> ipv4RoutingImpl = CreateObject<Ipv4ListRoutingImpl> ();
   ipv4->SetRoutingProtocol (ipv4RoutingImpl);
-  ipv4RoutingImpl->SetNode (node);
   Ptr<Ipv4StaticRoutingImpl> ipv4staticRoutingImpl = CreateObject<Ipv4StaticRoutingImpl> ();
-  ipv4staticRoutingImpl->SetNode (node);
   ipv4RoutingImpl->AddRoutingProtocol (ipv4staticRoutingImpl, 0);
   node->AggregateObject(ipv4);
   //ICMP
--- a/src/internet-stack/udp-test.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/internet-stack/udp-test.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -59,9 +59,7 @@
   //Routing for Ipv4
   Ptr<Ipv4ListRoutingImpl> ipv4RoutingImpl = CreateObject<Ipv4ListRoutingImpl> ();
   ipv4->SetRoutingProtocol (ipv4RoutingImpl);
-  ipv4RoutingImpl->SetNode (node);
   Ptr<Ipv4StaticRoutingImpl> ipv4staticRoutingImpl = CreateObject<Ipv4StaticRoutingImpl> ();
-  ipv4staticRoutingImpl->SetNode (node);
   ipv4RoutingImpl->AddRoutingProtocol (ipv4staticRoutingImpl, 0);
   node->AggregateObject(ipv4);
   //ICMP
--- a/src/node/ipv4-routing-protocol.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/node/ipv4-routing-protocol.h	Fri Jun 12 13:44:19 2009 -0700
@@ -23,6 +23,8 @@
 #include "ns3/object.h"
 #include "ns3/socket.h"
 #include "ipv4-header.h"
+#include "ipv4-interface-address.h"
+#include "ipv4.h"
 
 namespace ns3 {
 
@@ -91,6 +93,48 @@
   virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, 
                              UnicastForwardCallback ucb, MulticastForwardCallback mcb, 
                              LocalDeliverCallback lcb, ErrorCallback ecb) = 0;
+
+  /**
+   * \param interface the index of the interface we are being notified about
+   *
+   * Protocols are expected to implement this method to be notified of the state change of
+   * an interface in a node.
+   */
+  virtual void NotifyInterfaceUp (uint32_t interface) = 0;
+  /**
+   * \param interface the index of the interface we are being notified about
+   *
+   * Protocols are expected to implement this method to be notified of the state change of
+   * an interface in a node.
+   */
+  virtual void NotifyInterfaceDown (uint32_t interface) = 0;
+
+  /**
+   * \param interface the index of the interface we are being notified about
+   * \param address a new address being added to an interface
+   *
+   * Protocols are expected to implement this method to be notified whenever
+   * a new address is added to an interface. Typically used to add a 'network route' on an
+   * interface. Can be invoked on an up or down interface.
+   */
+  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
+
+  /**
+   * \param interface the index of the interface we are being notified about
+   * \param address a new address being added to an interface
+   *
+   * Protocols are expected to implement this method to be notified whenever
+   * a new address is removed from an interface. Typically used to remove the 'network route' of an
+   * interface. Can be invoked on an up or down interface.
+   */
+  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
+
+  /**
+   * \param ipv4 the ipv4 object this routing protocol is being associated with
+   * 
+   * Typically, invoked directly or indirectly from ns3::Ipv4::SetRoutingProtocol
+   */
+  virtual void SetIpv4 (Ptr<Ipv4> ipv4) = 0;
 };
 
 } //namespace ns3
--- a/src/node/ipv4-static-routing.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/node/ipv4-static-routing.h	Fri Jun 12 13:44:19 2009 -0700
@@ -357,10 +357,6 @@
  * \see Ipv4StaticRouting::AddRoute
  */
   virtual void RemoveMulticastRoute (uint32_t index) = 0;
-
-  virtual void SetNode (Ptr<Node> node) = 0;
-  virtual Ptr<Node> GetNode (void) const = 0;
-
 };
 
 } // Namespace ns3
--- a/src/node/ipv4.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/node/ipv4.h	Fri Jun 12 13:44:19 2009 -0700
@@ -24,7 +24,6 @@
 #include "ns3/object.h"
 #include "ns3/socket.h"
 #include "ns3/callback.h"
-#include "ipv4-routing-protocol.h"
 #include "ipv4-address.h"
 #include "ipv4-interface-address.h"
 
@@ -33,6 +32,7 @@
 class Node;
 class NetDevice;
 class Packet;
+class Ipv4RoutingProtocol;
 
 /**
  * \ingroup node
--- a/src/routing/global-routing/global-route-manager-impl.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/routing/global-routing/global-route-manager-impl.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -416,7 +416,6 @@
 
       NS_LOG_LOGIC ("Adding GlobalRouting Protocol to node " << node->GetId ());
       Ptr<Ipv4GlobalRouting> globalRouting = CreateObject<Ipv4GlobalRouting> ();
-      globalRouting->SetNode (node);
       // Here, we check whether there is an existing Ipv4RoutingProtocol object
       // to add this protocol to.
       Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
--- a/src/routing/global-routing/ipv4-global-routing.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/routing/global-routing/ipv4-global-routing.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -139,14 +139,13 @@
     }
   if (found == true)
     {
-      Ptr<Ipv4> ipv4 = m_node->GetObject<Ipv4> ();
       rtentry = Create<Ipv4Route> ();
       rtentry->SetDestination (route->GetDest ());
       // XXX handle multi-address case
-      rtentry->SetSource (ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
+      rtentry->SetSource (m_ipv4->GetAddress (route->GetInterface(), 0).GetLocal ());
       rtentry->SetGateway (route->GetGateway ());
       uint32_t interfaceIdx = route->GetInterface ();
-      rtentry->SetOutputDevice (ipv4->GetNetDevice (interfaceIdx));
+      rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIdx));
       return rtentry;
     }
   else 
@@ -318,21 +317,25 @@
                     // route request.
     }
 }
-
-void
-Ipv4GlobalRouting::SetNode (Ptr<Node> node)
+void 
+Ipv4GlobalRouting::NotifyInterfaceUp (uint32_t i)
+{}
+void 
+Ipv4GlobalRouting::NotifyInterfaceDown (uint32_t i)
+{}
+void 
+Ipv4GlobalRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{}
+void 
+Ipv4GlobalRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{}
+void 
+Ipv4GlobalRouting::SetIpv4 (Ptr<Ipv4> ipv4)
 {
-  NS_LOG_FUNCTION_NOARGS ();
-  m_node = node;
-}
-
-Ptr<Node>
-Ipv4GlobalRouting::GetNode (void) const
-{
-  NS_LOG_FUNCTION_NOARGS ();
-  return m_node;
+  NS_LOG_FUNCTION(this << ipv4);
+  NS_ASSERT (m_ipv4 == 0 && ipv4 != 0);
+  m_ipv4 = ipv4;
 }
 
 
-
 }//namespace ns3
--- a/src/routing/global-routing/ipv4-global-routing.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/routing/global-routing/ipv4-global-routing.h	Fri Jun 12 13:44:19 2009 -0700
@@ -85,6 +85,11 @@
   virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
                              UnicastForwardCallback ucb, MulticastForwardCallback mcb,
                              LocalDeliverCallback lcb, ErrorCallback ecb);
+  virtual void NotifyInterfaceUp (uint32_t interface);
+  virtual void NotifyInterfaceDown (uint32_t interface);
+  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
 
 /**
  * \brief Add a host route to the global routing table.
@@ -189,9 +194,6 @@
  */
   void RemoveRoute (uint32_t i);
 
-  void SetNode (Ptr<Node> node);
-  Ptr<Node> GetNode (void) const;
-
 protected:
   void DoDispose (void);
 
@@ -208,7 +210,7 @@
   HostRoutes m_hostRoutes;
   NetworkRoutes m_networkRoutes;
 
-  Ptr<Node> m_node;
+  Ptr<Ipv4> m_ipv4;
 };
 
 } // Namespace ns3
--- a/src/routing/olsr/olsr-routing-protocol.cc	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/routing/olsr/olsr-routing-protocol.cc	Fri Jun 12 13:44:19 2009 -0700
@@ -185,19 +185,21 @@
 
 
 RoutingProtocol::RoutingProtocol ()
-  :
-  m_helloTimer (Timer::CANCEL_ON_DESTROY),
-  m_tcTimer (Timer::CANCEL_ON_DESTROY),
-  m_midTimer (Timer::CANCEL_ON_DESTROY),
-  m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
+  : m_ipv4 (0),
+    m_helloTimer (Timer::CANCEL_ON_DESTROY),
+    m_tcTimer (Timer::CANCEL_ON_DESTROY),
+    m_midTimer (Timer::CANCEL_ON_DESTROY),
+    m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
 {}
 
 RoutingProtocol::~RoutingProtocol ()
 {}
 
 void
-RoutingProtocol::SetNode (Ptr<Node> node)
+RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
 {
+  NS_ASSERT (ipv4 != 0);
+  NS_ASSERT (m_ipv4 == 0);
   NS_LOG_DEBUG ("Created olsr::RoutingProtocol");
   m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
   m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this);
@@ -210,8 +212,7 @@
 
   m_linkTupleTimerFirstTime = true;
 
-  m_ipv4 = node->GetObject<Ipv4> ();
-  NS_ASSERT (m_ipv4);
+  m_ipv4 = ipv4;
 }
 
 void RoutingProtocol::DoDispose ()
@@ -2651,6 +2652,18 @@
       return false;
     }
 }
+void 
+RoutingProtocol::NotifyInterfaceUp (uint32_t i)
+{}
+void 
+RoutingProtocol::NotifyInterfaceDown (uint32_t i)
+{}
+void 
+RoutingProtocol::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{}
+void 
+RoutingProtocol::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address)
+{}
 
 
 ///
--- a/src/routing/olsr/olsr-routing-protocol.h	Fri Jun 19 09:17:08 2009 +0200
+++ b/src/routing/olsr/olsr-routing-protocol.h	Fri Jun 12 13:44:19 2009 -0700
@@ -36,6 +36,7 @@
 #include "ns3/timer.h"
 #include "ns3/traced-callback.h"
 #include "ns3/ipv4.h"
+#include "ns3/ipv4-routing-protocol.h"
 
 #include <vector>
 #include <map>
@@ -67,8 +68,6 @@
   RoutingProtocol ();
   virtual ~RoutingProtocol ();
 
-  void SetNode (Ptr<Node> node);
-
   void Start ();
   void SetMainInterface (uint32_t interface);
 
@@ -125,6 +124,12 @@
    virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
                              UnicastForwardCallback ucb, MulticastForwardCallback mcb,
                              LocalDeliverCallback lcb, ErrorCallback ecb);  
+  virtual void NotifyInterfaceUp (uint32_t interface);
+  virtual void NotifyInterfaceDown (uint32_t interface);
+  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
+
 
   void DoDispose ();