From ddefeb0a16b09e5cffa172e13a9e0db2b38a0ae1 Mon Sep 17 00:00:00 2001 From: Borovkova Elena Date: Fri, 21 Aug 2009 18:14:36 +0400 Subject: [PATCH] use Ipv4L3Protocol instead of Ptr --- .../tests/{test-aodv.py => test-aodv2.py} | 0 src/routing/aodv/aodv-routing-protocol.cc | 30 +++++++------------ src/routing/aodv/aodv-routing-protocol.h | 3 -- src/routing/aodv/aodv-rtable.h | 2 -- src/routing/aodv/id-cache.h | 1 - 5 files changed, 10 insertions(+), 26 deletions(-) rename regression/tests/{test-aodv.py => test-aodv2.py} (100%) diff --git a/regression/tests/test-aodv.py b/regression/tests/test-aodv2.py similarity index 100% rename from regression/tests/test-aodv.py rename to regression/tests/test-aodv2.py diff --git a/src/routing/aodv/aodv-routing-protocol.cc b/src/routing/aodv/aodv-routing-protocol.cc index 994d5422a..d0a2c0234 100644 --- a/src/routing/aodv/aodv-routing-protocol.cc +++ b/src/routing/aodv/aodv-routing-protocol.cc @@ -26,20 +26,15 @@ * Pavel Boyko */ #include "aodv-routing-protocol.h" -#include "ns3/socket.h" #include "ns3/log.h" #include "ns3/random-variable.h" #include "ns3/inet-socket-address.h" -#include "ns3/uinteger.h" #include "ns3/trace-source-accessor.h" -#include "ns3/udp-header.h" #include "ns3/udp-socket-factory.h" #include "ns3/wifi-net-device.h" #include "ns3/adhoc-wifi-mac.h" #include -#include "ns3/udp-socket.h" - NS_LOG_COMPONENT_DEFINE ("AodvRoutingProtocol"); namespace ns3 @@ -402,12 +397,11 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i) { NS_LOG_FUNCTION (this << m_ipv4->GetAddress (i, 0).GetLocal ()); Ptr l3 = m_ipv4->GetObject (); - Ptr interface = l3->GetInterface (i); - if (interface->GetNAddresses () > 1) + if (l3->GetNAddresses (i) > 1) { NS_LOG_LOGIC ("AODV does not work with more then one address per each interface."); } - Ipv4InterfaceAddress iface = interface->GetAddress (0); + Ipv4InterfaceAddress iface = l3->GetAddress (i, 0); if (iface.GetLocal () == Ipv4Address ("127.0.0.1")) return; @@ -436,7 +430,7 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i) return; mac->TraceConnectWithoutContext ("TxErrHeader", m_nb.GetTxErrorCallback ()); - m_nb.AddArpCache (interface->GetArpCache ()); + m_nb.AddArpCache (l3->GetInterface (i)->GetArpCache ()); } void @@ -446,8 +440,7 @@ RoutingProtocol::NotifyInterfaceDown (uint32_t i) // Disable layer 2 link state monitoring (if possible) Ptr l3 = m_ipv4->GetObject (); - Ptr interface = l3->GetInterface (i); - Ptr dev = interface->GetDevice (); + Ptr dev = l3->GetNetDevice (i); Ptr wifi = dev->GetObject (); if (wifi != 0) { @@ -456,7 +449,7 @@ RoutingProtocol::NotifyInterfaceDown (uint32_t i) { mac->TraceDisconnectWithoutContext ("TxErrHeader", m_nb.GetTxErrorCallback ()); - m_nb.DelArpCache (interface->GetArpCache ()); + m_nb.DelArpCache (l3->GetInterface (i)->GetArpCache ()); } } @@ -481,12 +474,11 @@ RoutingProtocol::NotifyAddAddress (uint32_t i, Ipv4InterfaceAddress address) { NS_LOG_FUNCTION (this << " interface " << i << " address " << address); Ptr l3 = m_ipv4->GetObject (); - Ptr interface = l3->GetInterface (i); - if (interface->IsDown ()) + if (!l3->IsUp (i)) return; - if (interface->GetNAddresses () == 1) + if (l3->GetNAddresses (i) == 1) { - Ipv4InterfaceAddress iface = interface->GetAddress (0); + Ipv4InterfaceAddress iface = l3->GetAddress (i, 0); Ptr socket = FindSocketWithInterfaceAddress (iface); if (!socket) { @@ -526,10 +518,9 @@ RoutingProtocol::NotifyRemoveAddress (uint32_t i, Ipv4InterfaceAddress address) m_routingTable.DeleteAllRoutesFromInterface (address); m_socketAddresses.erase (socket); Ptr l3 = m_ipv4->GetObject (); - Ptr interface = l3->GetInterface (i); - if (interface->GetNAddresses ()) + if (l3->GetNAddresses (i)) { - Ipv4InterfaceAddress iface = interface->GetAddress (0); + Ipv4InterfaceAddress iface = l3->GetAddress (i, 0); // Create a socket to listen only on this interface Ptr socket = Socket::CreateSocket (GetObject (), UdpSocketFactory::GetTypeId ()); @@ -1182,7 +1173,6 @@ RoutingProtocol::RecvError (Ptr p, Ipv4Address src ) SendRerrMessage (packet, precursors); } m_routingTable.InvalidateRoutesWithDst (unreachable); - m_routingTable.Print(std::cout); } void diff --git a/src/routing/aodv/aodv-routing-protocol.h b/src/routing/aodv/aodv-routing-protocol.h index 199ac8bc6..2c83cd01e 100644 --- a/src/routing/aodv/aodv-routing-protocol.h +++ b/src/routing/aodv/aodv-routing-protocol.h @@ -34,10 +34,7 @@ #include "id-cache.h" #include "aodv-neighbor.h" -#include "ns3/object.h" #include "ns3/node.h" -#include "ns3/socket.h" -#include "ns3/ipv4.h" #include "ns3/ipv4-routing-protocol.h" #include "ns3/ipv4-interface.h" #include "ns3/ipv4-l3-protocol.h" diff --git a/src/routing/aodv/aodv-rtable.h b/src/routing/aodv/aodv-rtable.h index a794bd6df..f6ecd6652 100644 --- a/src/routing/aodv/aodv-rtable.h +++ b/src/routing/aodv/aodv-rtable.h @@ -33,8 +33,6 @@ #include #include "ns3/ipv4.h" #include "ns3/ipv4-route.h" -#include "ns3/ipv4-address.h" -#include "ns3/nstime.h" #include "ns3/timer.h" #include "ns3/net-device.h" diff --git a/src/routing/aodv/id-cache.h b/src/routing/aodv/id-cache.h index 9fd9957a6..caa0663e9 100644 --- a/src/routing/aodv/id-cache.h +++ b/src/routing/aodv/id-cache.h @@ -30,7 +30,6 @@ #define IDCACHE_H_ #include "ns3/ipv4-address.h" -#include "ns3/nstime.h" #include "ns3/simulator.h" #include