diff --git a/src/helper/internet-stack-helper.cc b/src/helper/internet-stack-helper.cc index ba598267c..999f66747 100644 --- a/src/helper/internet-stack-helper.cc +++ b/src/helper/internet-stack-helper.cc @@ -163,7 +163,7 @@ #include "ns3/node.h" #include "ns3/core-config.h" #include "ns3/ipv4-list-routing.h" -#include "ns3/ipv4-static-routing-impl.h" +#include "ns3/ipv4-static-routing.h" #include namespace ns3 { @@ -243,8 +243,8 @@ InternetStackHelper::Install (Ptr node) const Ptr ipv4 = node->GetObject (); // XXX cut this over to use of TypeIds and factories Ptr ipv4Routing = CreateObject (); - Ptr ipv4staticRoutingImpl = CreateObject (); - ipv4Routing->AddRoutingProtocol (ipv4staticRoutingImpl, 0); + Ptr ipv4staticRouting = CreateObject (); + ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); ipv4->SetRoutingProtocol (ipv4Routing); } diff --git a/src/internet-stack/ipv4-l3-protocol.cc b/src/internet-stack/ipv4-l3-protocol.cc index d5e6981ea..21982a81e 100644 --- a/src/internet-stack/ipv4-l3-protocol.cc +++ b/src/internet-stack/ipv4-l3-protocol.cc @@ -32,13 +32,11 @@ #include "ns3/ipv4-header.h" #include "ns3/boolean.h" #include "ns3/ipv4-routing-table-entry.h" -#include "ns3/ipv4-static-routing.h" #include "loopback-net-device.h" #include "arp-l3-protocol.h" #include "ipv4-l3-protocol.h" #include "ipv4-l4-protocol.h" -#include "ipv4-list-routing.h" #include "icmpv4-l4-protocol.h" #include "ipv4-interface.h" #include "ipv4-raw-socket-impl.h" diff --git a/src/internet-stack/ipv4-l3-protocol.h b/src/internet-stack/ipv4-l3-protocol.h index 57e0dbf69..f39bc6cef 100644 --- a/src/internet-stack/ipv4-l3-protocol.h +++ b/src/internet-stack/ipv4-l3-protocol.h @@ -30,7 +30,6 @@ #include "ns3/traced-callback.h" #include "ns3/ipv4-header.h" #include "ns3/ipv4-routing-protocol.h" -#include "ipv4-static-routing-impl.h" namespace ns3 { diff --git a/src/internet-stack/tcp-test.cc b/src/internet-stack/tcp-test.cc index 7b6820911..12f2af89d 100644 --- a/src/internet-stack/tcp-test.cc +++ b/src/internet-stack/tcp-test.cc @@ -37,8 +37,8 @@ #include "icmpv4-l4-protocol.h" #include "udp-l4-protocol.h" #include "tcp-l4-protocol.h" -#include "ipv4-static-routing-impl.h" -#include "ipv4-list-routing.h" +#include "ns3/ipv4-static-routing.h" +#include "ns3/ipv4-list-routing.h" #include "ns3/node.h" #include "ns3/inet-socket-address.h" @@ -58,8 +58,8 @@ AddInternetStack (Ptr node) //Routing for Ipv4 Ptr ipv4Routing = CreateObject (); ipv4->SetRoutingProtocol (ipv4Routing); - Ptr ipv4staticRoutingImpl = CreateObject (); - ipv4Routing->AddRoutingProtocol (ipv4staticRoutingImpl, 0); + Ptr ipv4staticRouting = CreateObject (); + ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); node->AggregateObject(ipv4); //ICMP Ptr icmp = CreateObject (); diff --git a/src/internet-stack/udp-test.cc b/src/internet-stack/udp-test.cc index 8e670d87e..36d514706 100644 --- a/src/internet-stack/udp-test.cc +++ b/src/internet-stack/udp-test.cc @@ -41,8 +41,8 @@ #include "icmpv4-l4-protocol.h" #include "udp-l4-protocol.h" #include "tcp-l4-protocol.h" -#include "ipv4-list-routing.h" -#include "ipv4-static-routing-impl.h" +#include "ns3/ipv4-list-routing.h" +#include "ns3/ipv4-static-routing.h" #include #include @@ -59,8 +59,8 @@ AddInternetStack (Ptr node) //Routing for Ipv4 Ptr ipv4Routing = CreateObject (); ipv4->SetRoutingProtocol (ipv4Routing); - Ptr ipv4staticRoutingImpl = CreateObject (); - ipv4Routing->AddRoutingProtocol (ipv4staticRoutingImpl, 0); + Ptr ipv4staticRouting = CreateObject (); + ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); node->AggregateObject(ipv4); //ICMP Ptr icmp = CreateObject (); diff --git a/src/internet-stack/wscript b/src/internet-stack/wscript index 467929dfa..6e97c09d4 100644 --- a/src/internet-stack/wscript +++ b/src/internet-stack/wscript @@ -81,8 +81,6 @@ def build(bld): 'ipv4-checksum.cc', 'ipv4-interface.cc', 'ipv4-l3-protocol.cc', - 'ipv4-static-routing-impl.cc', - 'ipv4-list-routing.cc', 'ipv4-end-point.cc', 'udp-l4-protocol.cc', 'tcp-l4-protocol.cc', @@ -110,8 +108,6 @@ def build(bld): 'udp-header.h', 'tcp-header.h', 'sequence-number.h', - 'ipv4-list-routing.h', - 'ipv4-static-routing-impl.h', 'icmpv4.h', ] diff --git a/src/node/ipv4-list-routing.cc b/src/node/ipv4-list-routing.cc deleted file mode 100644 index beedb12dd..000000000 --- a/src/node/ipv4-list-routing.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2009 University of Washington - * - * 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 - */ - -#include "ipv4-list-routing.h" - -namespace ns3 { - -NS_OBJECT_ENSURE_REGISTERED (Ipv4ListRouting); - -TypeId -Ipv4ListRouting::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::Ipv4ListRouting") - .SetParent () - ; - return tid; -} - -} // namespace ns3 diff --git a/src/node/ipv4-list-routing.h b/src/node/ipv4-list-routing.h deleted file mode 100644 index 79f49edcf..000000000 --- a/src/node/ipv4-list-routing.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2009 University of Washington - * - * 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 - */ - -#ifndef IPV4_LIST_ROUTING_H -#define IPV4_LIST_ROUTING_H - -#include "ipv4-routing-protocol.h" - -namespace ns3 { - -/** - * \ingroup ipv4Routing - * - * This class is a specialization of Ipv4RoutingProtocol that allows - * other instances of Ipv4RoutingProtocol to be inserted in a - * prioritized list. Routing protocols in the list are consulted one - * by one, from highest to lowest proirity, until a routing protocol - * is found that will take the packet (this corresponds to a non-zero - * return value to RouteOutput, or a return value of true to RouteInput). - * The order by which routing protocols with the same priority value - * are consulted is undefined. - * - */ -class Ipv4ListRouting : public Ipv4RoutingProtocol -{ -public: - static TypeId GetTypeId (void); - /** - * \brief Register a new routing protocol to be used in this IPv4 stack - * - * \param routingProtocol new routing protocol implementation object - * \param priority priority to give to this routing protocol. - * Values may range between -32768 and +32767. - */ - virtual void AddRoutingProtocol (Ptr routingProtocol, int16_t priority) = 0; - /** - * \return number of routing protocols in the list - */ - virtual uint32_t GetNRoutingProtocols (void) const = 0; - /** - * \return pointer to routing protocol indexed by - * \param index index of protocol to return - * \param priority output parameter, set to the priority of the protocol - being returned - */ - virtual Ptr GetRoutingProtocol (uint32_t index, int16_t& priority) const = 0; -}; - -} //namespace ns3 - -#endif /* IPV4_LIST_ROUTING_H */ diff --git a/src/node/ipv4-static-routing.cc b/src/node/ipv4-static-routing.cc deleted file mode 100644 index 512d1e04f..000000000 --- a/src/node/ipv4-static-routing.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2009 University of Washington - * - * 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 - */ - -#include "ipv4-static-routing.h" - -namespace ns3 { - -NS_OBJECT_ENSURE_REGISTERED (Ipv4StaticRouting); - -TypeId -Ipv4StaticRouting::GetTypeId (void) -{ - static TypeId tid = TypeId ("ns3::Ipv4StaticRouting") - .SetParent () - ; - return tid; -} - -} // namespace ns3 diff --git a/src/node/wscript b/src/node/wscript index ac7c37472..4c1dc1e1e 100644 --- a/src/node/wscript +++ b/src/node/wscript @@ -20,8 +20,6 @@ def build(bld): 'ethernet-trailer.cc', 'ipv4-route.cc', 'ipv4-routing-protocol.cc', - 'ipv4-static-routing.cc', - 'ipv4-routing-table-entry.cc', 'queue.cc', 'drop-tail-queue.cc', 'channel.cc', @@ -61,8 +59,6 @@ def build(bld): 'address-utils.h', 'ipv4-route.h', 'ipv4-routing-protocol.h', - 'ipv4-static-routing.h', - 'ipv4-routing-table-entry.h', 'queue.h', 'drop-tail-queue.h', 'llc-snap-header.h', diff --git a/src/internet-stack/ipv4-list-routing.cc b/src/routing/list-routing/ipv4-list-routing.cc similarity index 100% rename from src/internet-stack/ipv4-list-routing.cc rename to src/routing/list-routing/ipv4-list-routing.cc diff --git a/src/internet-stack/ipv4-list-routing.h b/src/routing/list-routing/ipv4-list-routing.h similarity index 100% rename from src/internet-stack/ipv4-list-routing.h rename to src/routing/list-routing/ipv4-list-routing.h diff --git a/src/routing/list-routing/wscript b/src/routing/list-routing/wscript new file mode 100644 index 000000000..870c94a07 --- /dev/null +++ b/src/routing/list-routing/wscript @@ -0,0 +1,13 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + module = bld.create_ns3_module('list-routing', ['node']) + module.source = [ + 'ipv4-list-routing.cc', + ] + headers = bld.new_task_gen('ns3header') + headers.module = 'list-routing' + headers.source = [ + 'ipv4-list-routing.h', + ] + diff --git a/src/node/ipv4-routing-table-entry.cc b/src/routing/static-routing/ipv4-routing-table-entry.cc similarity index 100% rename from src/node/ipv4-routing-table-entry.cc rename to src/routing/static-routing/ipv4-routing-table-entry.cc diff --git a/src/node/ipv4-routing-table-entry.h b/src/routing/static-routing/ipv4-routing-table-entry.h similarity index 100% rename from src/node/ipv4-routing-table-entry.h rename to src/routing/static-routing/ipv4-routing-table-entry.h diff --git a/src/internet-stack/ipv4-static-routing-impl.cc b/src/routing/static-routing/ipv4-static-routing.cc similarity index 88% rename from src/internet-stack/ipv4-static-routing-impl.cc rename to src/routing/static-routing/ipv4-static-routing.cc index 75f284d8c..92b959814 100644 --- a/src/internet-stack/ipv4-static-routing-impl.cc +++ b/src/routing/static-routing/ipv4-static-routing.cc @@ -22,33 +22,33 @@ #include "ns3/packet.h" #include "ns3/node.h" #include "ns3/ipv4-route.h" -#include "ipv4-static-routing-impl.h" -#include "ns3/ipv4-routing-table-entry.h" +#include "ipv4-static-routing.h" +#include "ipv4-routing-table-entry.h" -NS_LOG_COMPONENT_DEFINE ("Ipv4StaticRoutingImpl"); +NS_LOG_COMPONENT_DEFINE ("Ipv4StaticRouting"); namespace ns3 { -NS_OBJECT_ENSURE_REGISTERED (Ipv4StaticRoutingImpl); +NS_OBJECT_ENSURE_REGISTERED (Ipv4StaticRouting); TypeId -Ipv4StaticRoutingImpl::GetTypeId (void) +Ipv4StaticRouting::GetTypeId (void) { - static TypeId tid = TypeId ("ns3::Ipv4StaticRoutingImpl") - .SetParent () - .AddConstructor () + static TypeId tid = TypeId ("ns3::Ipv4StaticRouting") + .SetParent () + .AddConstructor () ; return tid; } -Ipv4StaticRoutingImpl::Ipv4StaticRoutingImpl () +Ipv4StaticRouting::Ipv4StaticRouting () : m_defaultRoute (0), m_ipv4 (0) { NS_LOG_FUNCTION_NOARGS (); } void -Ipv4StaticRoutingImpl::AddHostRouteTo (Ipv4Address dest, +Ipv4StaticRouting::AddHostRouteTo (Ipv4Address dest, Ipv4Address nextHop, uint32_t interface) { @@ -59,7 +59,7 @@ Ipv4StaticRoutingImpl::AddHostRouteTo (Ipv4Address dest, } void -Ipv4StaticRoutingImpl::AddHostRouteTo (Ipv4Address dest, +Ipv4StaticRouting::AddHostRouteTo (Ipv4Address dest, uint32_t interface) { NS_LOG_FUNCTION_NOARGS (); @@ -69,7 +69,7 @@ Ipv4StaticRoutingImpl::AddHostRouteTo (Ipv4Address dest, } void -Ipv4StaticRoutingImpl::AddNetworkRouteTo (Ipv4Address network, +Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, uint32_t interface) @@ -84,7 +84,7 @@ Ipv4StaticRoutingImpl::AddNetworkRouteTo (Ipv4Address network, } void -Ipv4StaticRoutingImpl::AddNetworkRouteTo (Ipv4Address network, +Ipv4StaticRouting::AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, uint32_t interface) { @@ -97,7 +97,7 @@ Ipv4StaticRoutingImpl::AddNetworkRouteTo (Ipv4Address network, } void -Ipv4StaticRoutingImpl::SetDefaultRoute (Ipv4Address nextHop, +Ipv4StaticRouting::SetDefaultRoute (Ipv4Address nextHop, uint32_t interface) { NS_LOG_FUNCTION_NOARGS (); @@ -108,7 +108,7 @@ Ipv4StaticRoutingImpl::SetDefaultRoute (Ipv4Address nextHop, } void -Ipv4StaticRoutingImpl::AddMulticastRoute(Ipv4Address origin, +Ipv4StaticRouting::AddMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, std::vector outputInterfaces) @@ -124,7 +124,7 @@ Ipv4StaticRoutingImpl::AddMulticastRoute(Ipv4Address origin, // these routes are _not_ consulted in the forwarding process-- only // for originating packets void -Ipv4StaticRoutingImpl::SetDefaultMulticastRoute(uint32_t outputInterface) +Ipv4StaticRouting::SetDefaultMulticastRoute(uint32_t outputInterface) { NS_LOG_FUNCTION_NOARGS (); Ipv4RoutingTableEntry *route = new Ipv4RoutingTableEntry (); @@ -137,18 +137,18 @@ Ipv4StaticRoutingImpl::SetDefaultMulticastRoute(uint32_t outputInterface) } uint32_t -Ipv4StaticRoutingImpl::GetNMulticastRoutes (void) const +Ipv4StaticRouting::GetNMulticastRoutes (void) const { NS_LOG_FUNCTION_NOARGS (); return m_multicastRoutes.size (); } Ipv4MulticastRoutingTableEntry -Ipv4StaticRoutingImpl::GetMulticastRoute (uint32_t index) const +Ipv4StaticRouting::GetMulticastRoute (uint32_t index) const { NS_LOG_FUNCTION_NOARGS (); NS_ASSERT_MSG(index < m_multicastRoutes.size (), - "Ipv4StaticRoutingImpl::GetMulticastRoute (): Index out of range"); + "Ipv4StaticRouting::GetMulticastRoute (): Index out of range"); if (index < m_multicastRoutes.size ()) { @@ -168,7 +168,7 @@ Ipv4StaticRoutingImpl::GetMulticastRoute (uint32_t index) const } bool -Ipv4StaticRoutingImpl::RemoveMulticastRoute(Ipv4Address origin, +Ipv4StaticRouting::RemoveMulticastRoute(Ipv4Address origin, Ipv4Address group, uint32_t inputInterface) { @@ -191,7 +191,7 @@ Ipv4StaticRoutingImpl::RemoveMulticastRoute(Ipv4Address origin, } void -Ipv4StaticRoutingImpl::RemoveMulticastRoute(uint32_t index) +Ipv4StaticRouting::RemoveMulticastRoute(uint32_t index) { NS_LOG_FUNCTION_NOARGS (); uint32_t tmp = 0; @@ -210,7 +210,7 @@ Ipv4StaticRoutingImpl::RemoveMulticastRoute(uint32_t index) } Ptr -Ipv4StaticRoutingImpl::LookupStatic (Ipv4Address dest) +Ipv4StaticRouting::LookupStatic (Ipv4Address dest) { NS_LOG_FUNCTION_NOARGS (); Ptr rtentry = 0; @@ -269,7 +269,7 @@ Ipv4StaticRoutingImpl::LookupStatic (Ipv4Address dest) } Ptr -Ipv4StaticRoutingImpl::LookupStatic ( +Ipv4StaticRouting::LookupStatic ( Ipv4Address origin, Ipv4Address group, uint32_t interface) @@ -321,7 +321,7 @@ Ipv4StaticRoutingImpl::LookupStatic ( } uint32_t -Ipv4StaticRoutingImpl::GetNRoutes (void) +Ipv4StaticRouting::GetNRoutes (void) { NS_LOG_FUNCTION_NOARGS (); uint32_t n = 0; @@ -335,7 +335,7 @@ Ipv4StaticRoutingImpl::GetNRoutes (void) } Ipv4RoutingTableEntry -Ipv4StaticRoutingImpl::GetDefaultRoute () +Ipv4StaticRouting::GetDefaultRoute () { NS_LOG_FUNCTION_NOARGS (); if (m_defaultRoute != 0) @@ -349,7 +349,7 @@ Ipv4StaticRoutingImpl::GetDefaultRoute () } Ipv4RoutingTableEntry -Ipv4StaticRoutingImpl::GetRoute (uint32_t index) +Ipv4StaticRouting::GetRoute (uint32_t index) { NS_LOG_FUNCTION_NOARGS (); if (index == 0 && m_defaultRoute != 0) @@ -391,7 +391,7 @@ Ipv4StaticRoutingImpl::GetRoute (uint32_t index) return 0; } void -Ipv4StaticRoutingImpl::RemoveRoute (uint32_t index) +Ipv4StaticRouting::RemoveRoute (uint32_t index) { NS_LOG_FUNCTION_NOARGS (); if (index == 0 && m_defaultRoute != 0) @@ -437,7 +437,7 @@ Ipv4StaticRoutingImpl::RemoveRoute (uint32_t index) } Ptr -Ipv4StaticRoutingImpl::RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) +Ipv4StaticRouting::RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr) { NS_LOG_FUNCTION (this << header << oif); Ipv4Address destination = header.GetDestination (); @@ -469,7 +469,7 @@ Ipv4StaticRoutingImpl::RouteOutput (const Ipv4Header &header, uint32_t oif, Sock // XXX this method not robust enough to work outside of ListRouting context // because it will not perform local delivery bool -Ipv4StaticRoutingImpl::RouteInput (Ptr p, const Ipv4Header &ipHeader, Ptr idev, +Ipv4StaticRouting::RouteInput (Ptr p, const Ipv4Header &ipHeader, Ptr idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb) { @@ -511,13 +511,13 @@ Ipv4StaticRoutingImpl::RouteInput (Ptr p, const Ipv4Header &ipHea } } -Ipv4StaticRoutingImpl::~Ipv4StaticRoutingImpl () +Ipv4StaticRouting::~Ipv4StaticRouting () { NS_LOG_FUNCTION_NOARGS (); } void -Ipv4StaticRoutingImpl::DoDispose (void) +Ipv4StaticRouting::DoDispose (void) { NS_LOG_FUNCTION_NOARGS (); for (HostRoutesI i = m_hostRoutes.begin (); @@ -548,7 +548,7 @@ Ipv4StaticRoutingImpl::DoDispose (void) } void -Ipv4StaticRoutingImpl::NotifyInterfaceUp (uint32_t i) +Ipv4StaticRouting::NotifyInterfaceUp (uint32_t i) { // 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 @@ -565,7 +565,7 @@ Ipv4StaticRoutingImpl::NotifyInterfaceUp (uint32_t i) } void -Ipv4StaticRoutingImpl::NotifyInterfaceDown (uint32_t i) +Ipv4StaticRouting::NotifyInterfaceDown (uint32_t i) { // Remove all static routes that are going through this interface for (uint32_t j = 0; j < GetNRoutes (); j++) @@ -579,7 +579,7 @@ Ipv4StaticRoutingImpl::NotifyInterfaceDown (uint32_t i) } void -Ipv4StaticRoutingImpl::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) +Ipv4StaticRouting::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) { NS_LOG_FUNCTION (this << interface); if (!m_ipv4->IsUp (interface)) @@ -597,7 +597,7 @@ Ipv4StaticRoutingImpl::NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddres } } void -Ipv4StaticRoutingImpl::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) +Ipv4StaticRouting::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) { if (!m_ipv4->IsUp (interface)) { @@ -621,7 +621,7 @@ Ipv4StaticRoutingImpl::NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAdd } void -Ipv4StaticRoutingImpl::SetIpv4 (Ptr ipv4) +Ipv4StaticRouting::SetIpv4 (Ptr ipv4) { NS_LOG_FUNCTION (this << ipv4); NS_ASSERT (m_ipv4 == 0 && ipv4 != 0); @@ -640,7 +640,7 @@ Ipv4StaticRoutingImpl::SetIpv4 (Ptr ipv4) } Ipv4Address -Ipv4StaticRoutingImpl::SourceAddressSelection (uint32_t interfaceIdx, Ipv4Address dest) +Ipv4StaticRouting::SourceAddressSelection (uint32_t interfaceIdx, Ipv4Address dest) { if (m_ipv4->GetNAddresses (interfaceIdx) == 1) // common case { diff --git a/src/node/ipv4-static-routing.h b/src/routing/static-routing/ipv4-static-routing.h similarity index 77% rename from src/node/ipv4-static-routing.h rename to src/routing/static-routing/ipv4-static-routing.h index 5acfe4cc1..bf2260270 100644 --- a/src/node/ipv4-static-routing.h +++ b/src/routing/static-routing/ipv4-static-routing.h @@ -38,52 +38,50 @@ class NetDevice; class Ipv4Interface; class Ipv4Address; class Ipv4Header; -class Node; - class Ipv4RoutingTableEntry; class Ipv4MulticastRoutingTableEntry; +class Node; /** * \ingroup ipv4Routing * * \brief Static routing protocol for IP version 4 stacks. * - * In ns-3 we have the concept of a pluggable routing protocol. Routing - * protocols are added to a list maintained by the Ipv4L3Protocol. Every - * stack gets one routing protocol for free -- the Ipv4StaticRouting routing - * protocol is added in the constructor of the Ipv4L3Protocol (this is the - * piece of code that implements the functionality of the IP layer). - * + * This class provides a basic set of methods for inserting static + * unicast and multicast routes into the Ipv4 routing system. + * This particular protocol is designed to be inserted into an + * Ipv4ListRouting protocol and at present cannot be inserted as the + * only routing protocol into Ipv4 (i.e. it must be added to an + * Ipv4ListRouting). + * * The Ipv4StaticRouting class inherits from the abstract base class * Ipv4RoutingProtocol that defines the interface methods that a routing * protocol must support. * - * When a packet arrives in the Ipv4L3Protocol for transmission, it comes - * either from a local source via Ipv4L3Protocol::Send or from a remote - * source via Ipv4L3Protocol::Forwarding. In both cases, a function is called - * (Ipv4L3Protocol::Lookup) to look up the routing information for the packet. - * - * The lookup function iterates through the list of routing protocols asking - * each to see if it can find a route and send the packet. A callback is - * provided during each of these calls that should be considered a pre- - * packaged send call. This is done to allow asynchronous calls into - * routing subsystems in order to support on-demand routing, for example. The - * method for requesting this operation is Ipv4StaticRouting::RequestRoute for - * the static routing protocol. - * - * Each routing protocol is also free to implement its own methods for managing - * routes which you will find below. This class manages a set of "static" or - * manually configured routes for host, network and multicast routes. - * * \see Ipv4RoutingProtocol - * \see Ipv4L3Protocol::AddRoutingProtocol - * \see Ipv4L3Protocol::Ipv4L3Protocol + * \see Ipv4ListRouting + * \see Ipv4ListRouting::AddRoutingProtocol */ class Ipv4StaticRouting : public Ipv4RoutingProtocol { public: static TypeId GetTypeId (void); + Ipv4StaticRouting (); + virtual ~Ipv4StaticRouting (); + + virtual Ptr RouteOutput (const Ipv4Header &header, uint32_t oif, Socket::SocketErrno &sockerr); + + virtual bool RouteInput (Ptr p, const Ipv4Header &header, Ptr 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); + /** * \brief Add a host route to the static routing table. * @@ -94,9 +92,9 @@ public: * * \see Ipv4Address */ - virtual void AddHostRouteTo (Ipv4Address dest, + void AddHostRouteTo (Ipv4Address dest, Ipv4Address nextHop, - uint32_t interface) = 0; + uint32_t interface); /** * \brief Add a host route to the static routing table. * @@ -106,7 +104,8 @@ public: * * \see Ipv4Address */ - virtual void AddHostRouteTo (Ipv4Address dest, uint32_t interface) = 0; + void AddHostRouteTo (Ipv4Address dest, + uint32_t interface); /** * \brief Add a network route to the static routing table. @@ -119,10 +118,10 @@ public: * * \see Ipv4Address */ - virtual void AddNetworkRouteTo (Ipv4Address network, + void AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, Ipv4Address nextHop, - uint32_t interface) = 0; + uint32_t interface); /** * \brief Add a network route to the static routing table. @@ -134,9 +133,9 @@ public: * * \see Ipv4Address */ - virtual void AddNetworkRouteTo (Ipv4Address network, + void AddNetworkRouteTo (Ipv4Address network, Ipv4Mask networkMask, - uint32_t interface) = 0; + uint32_t interface); /** * \brief Add a default route to the static routing table. @@ -156,7 +155,8 @@ public: * \see Ipv4Address * \see Ipv4StaticRouting::Lookup */ - virtual void SetDefaultRoute (Ipv4Address nextHop, uint32_t interface) = 0; + void SetDefaultRoute (Ipv4Address nextHop, + uint32_t interface); /** * \brief Get the number of individual unicast routes that have been added @@ -164,7 +164,7 @@ public: * * \warning The default route counts as one of the routes. */ - virtual uint32_t GetNRoutes (void) = 0; + uint32_t GetNRoutes (void); /** * \brief Get the default route from the static routing table. @@ -174,7 +174,7 @@ public: * * \see Ipv4RoutingTableEntry */ - virtual Ipv4RoutingTableEntry GetDefaultRoute (void) = 0; + Ipv4RoutingTableEntry GetDefaultRoute (void); /** * \brief Get a route from the static unicast routing table. @@ -184,7 +184,7 @@ public: * it will appear as the zeroth entry in the table. This means that if you * add only a default route, the table will have one entry that can be accessed * either by explicity calling GetDefaultRoute () or by calling GetRoute (0). - * + * * Similarly, if the default route has been set, calling RemoveRoute (0) will * remove the default route. * @@ -196,7 +196,7 @@ public: * \see Ipv4RoutingTableEntry * \see Ipv4StaticRouting::RemoveRoute */ - virtual Ipv4RoutingTableEntry GetRoute (uint32_t i) = 0; + Ipv4RoutingTableEntry GetRoute (uint32_t i); /** * \brief Remove a route from the static unicast routing table. @@ -214,7 +214,7 @@ public: * \see Ipv4StaticRouting::GetRoute * \see Ipv4StaticRouting::AddRoute */ - virtual void RemoveRoute (uint32_t i) = 0; + void RemoveRoute (uint32_t i); /** * \brief Add a multicast route to the static routing table. @@ -259,10 +259,10 @@ public: * * \see Ipv4Address */ - virtual void AddMulticastRoute (Ipv4Address origin, + void AddMulticastRoute (Ipv4Address origin, Ipv4Address group, uint32_t inputInterface, - std::vector outputInterfaces) = 0; + std::vector outputInterfaces); /** * \brief Add a default multicast route to the static routing table. @@ -288,7 +288,7 @@ public: * * \see Ipv4Address */ - virtual void SetDefaultMulticastRoute (uint32_t outputInterface) = 0; + void SetDefaultMulticastRoute (uint32_t outputInterface); /** * \brief Get the number of individual multicast routes that have been added @@ -296,7 +296,7 @@ public: * * \warning The default multicast route counts as one of the routes. */ - virtual uint32_t GetNMulticastRoutes (void) const = 0; + uint32_t GetNMulticastRoutes (void) const; /** * \brief Get a route from the static multicast routing table. @@ -312,7 +312,7 @@ public: * \see Ipv4MulticastRoutingTableEntry * \see Ipv4StaticRouting::RemoveRoute */ - virtual Ipv4MulticastRoutingTableEntry GetMulticastRoute (uint32_t i) const = 0; + Ipv4MulticastRoutingTableEntry GetMulticastRoute (uint32_t i) const; /** * \brief Remove a route from the static multicast routing table. @@ -339,9 +339,9 @@ public: * \see Ipv4MulticastRoutingTableEntry * \see Ipv4StaticRouting::AddMulticastRoute */ - virtual bool RemoveMulticastRoute (Ipv4Address origin, + bool RemoveMulticastRoute (Ipv4Address origin, Ipv4Address group, - uint32_t inputInterface) = 0; + uint32_t inputInterface); /** * \brief Remove a route from the static multicast routing table. @@ -356,7 +356,35 @@ public: * \see Ipv4StaticRouting::GetRoute * \see Ipv4StaticRouting::AddRoute */ - virtual void RemoveMulticastRoute (uint32_t index) = 0; + void RemoveMulticastRoute (uint32_t index); + +protected: + virtual void DoDispose (void); + +private: + typedef std::list HostRoutes; + typedef std::list::const_iterator HostRoutesCI; + typedef std::list::iterator HostRoutesI; + typedef std::list NetworkRoutes; + typedef std::list::const_iterator NetworkRoutesCI; + typedef std::list::iterator NetworkRoutesI; + + typedef std::list MulticastRoutes; + typedef std::list::const_iterator MulticastRoutesCI; + typedef std::list::iterator MulticastRoutesI; + + Ptr LookupStatic (Ipv4Address dest); + Ptr LookupStatic (Ipv4Address origin, Ipv4Address group, + uint32_t interface); + + Ipv4Address SourceAddressSelection (uint32_t interface, Ipv4Address dest); + + HostRoutes m_hostRoutes; + NetworkRoutes m_networkRoutes; + Ipv4RoutingTableEntry *m_defaultRoute; + MulticastRoutes m_multicastRoutes; + + Ptr m_ipv4; }; } // Namespace ns3 diff --git a/src/routing/static-routing/wscript b/src/routing/static-routing/wscript new file mode 100644 index 000000000..306eae889 --- /dev/null +++ b/src/routing/static-routing/wscript @@ -0,0 +1,15 @@ +## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- + +def build(bld): + module = bld.create_ns3_module('static-routing', ['node']) + module.source = [ + 'ipv4-static-routing.cc', + 'ipv4-routing-table-entry.cc', + ] + headers = bld.new_task_gen('ns3header') + headers.module = 'static-routing' + headers.source = [ + 'ipv4-static-routing.h', + 'ipv4-routing-table-entry.h', + ] + diff --git a/src/wscript b/src/wscript index 3d57ed021..3042c2356 100644 --- a/src/wscript +++ b/src/wscript @@ -29,6 +29,8 @@ all_modules = ( 'applications/udp-echo', 'routing/olsr', 'routing/global-routing', + 'routing/static-routing', + 'routing/list-routing', 'mobility', 'devices/wifi', 'helper',