src/helper/ipv4-global-routing-helper.cc
changeset 4616 a84f60b6cd12
child 5353 a63513286aa0
equal deleted inserted replaced
4612:0053aa3d8c22 4616:a84f60b6cd12
       
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 /*
       
     3  * Copyright (c) 2008 INRIA
       
     4  *
       
     5  * This program is free software; you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License version 2 as
       
     7  * published by the Free Software Foundation;
       
     8  *
       
     9  * This program is distributed in the hope that it will be useful,
       
    10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12  * GNU General Public License for more details.
       
    13  *
       
    14  * You should have received a copy of the GNU General Public License
       
    15  * along with this program; if not, write to the Free Software
       
    16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    17  *
       
    18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
       
    19  */
       
    20 #include "ipv4-global-routing-helper.h"
       
    21 #include "ns3/global-router-interface.h"
       
    22 #include "ns3/ipv4-global-routing.h"
       
    23 #include "ns3/ipv4-list-routing.h"
       
    24 #include "ns3/log.h"
       
    25 
       
    26 NS_LOG_COMPONENT_DEFINE("GlobalRoutingHelper");
       
    27 
       
    28 namespace ns3 {
       
    29 
       
    30 Ipv4GlobalRoutingHelper::Ipv4GlobalRoutingHelper ()
       
    31 {}
       
    32 Ptr<Ipv4RoutingProtocol> 
       
    33 Ipv4GlobalRoutingHelper::Create (Ptr<Node> node) const
       
    34 {
       
    35   NS_LOG_LOGIC ("Adding GlobalRouter interface to node " << 
       
    36 		node->GetId ());
       
    37 
       
    38   Ptr<GlobalRouter> globalRouter = CreateObject<GlobalRouter> ();
       
    39   node->AggregateObject (globalRouter);
       
    40 
       
    41   NS_LOG_LOGIC ("Adding GlobalRouting Protocol to node " << node->GetId ());
       
    42   Ptr<Ipv4GlobalRouting> globalRouting = CreateObject<Ipv4GlobalRouting> ();
       
    43   globalRouter->SetRoutingProtocol (globalRouting);
       
    44 
       
    45   return globalRouting;
       
    46 }
       
    47 
       
    48 void 
       
    49 Ipv4GlobalRoutingHelper::PopulateRoutingTables (void)
       
    50 {
       
    51   GlobalRouteManager::BuildGlobalRoutingDatabase ();
       
    52   GlobalRouteManager::InitializeRoutes ();
       
    53 }
       
    54 void 
       
    55 Ipv4GlobalRoutingHelper::RecomputeRoutingTables (void)
       
    56 {
       
    57   GlobalRouteManager::DeleteGlobalRoutes ();
       
    58   GlobalRouteManager::BuildGlobalRoutingDatabase ();
       
    59   GlobalRouteManager::InitializeRoutes ();
       
    60 }
       
    61 
       
    62 
       
    63 } // namespace ns3