1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2009 University of Washington 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 19 #ifndef IPV4_STATIC_ROUTING_HELPER_H 20 #define IPV4_STATIC_ROUTING_HELPER_H 21 22 #include "ns3/ipv4.h" 23 #include "ns3/ipv4-static-routing.h" 24 #include "ns3/ptr.h" 25 #include "ns3/ipv4-address.h" 26 #include "ns3/node.h" 27 #include "ns3/net-device.h" 28 #include "ns3/ipv4-routing-helper.h" 29 #include "ns3/node-container.h" 30 #include "ns3/net-device-container.h" 31 32 namespace ns3 { 33 34 /** 35 * \ingroup ipv4Helpers 36 * 37 * \brief Helper class that adds ns3::Ipv4StaticRouting objects 38 * 39 * This class is expected to be used in conjunction with 40 * ns3::InternetStackHelper::SetRoutingHelper 41 */ 42 class Ipv4StaticRoutingHelper : public Ipv4RoutingHelper 43 { 44 public: 45 /* 46 * Construct an Ipv4StaticRoutingHelper object, used to make configuration 47 * of static routing easier. 48 */ 49 Ipv4StaticRoutingHelper (); 50 51 /** 52 * \brief Construct an Ipv4StaticRoutingHelper from another previously 53 * initialized instance (Copy Constructor). 54 * \param o object to be copied 55 */ 56 Ipv4StaticRoutingHelper (const Ipv4StaticRoutingHelper &o); 57 58 /** 59 * \returns pointer to clone of this Ipv4StaticRoutingHelper 60 * 61 * This method is mainly for internal use by the other helpers; 62 * clients are expected to free the dynamic memory allocated by this method 63 */ 64 Ipv4StaticRoutingHelper* Copy (void) const; 65 66 /** 67 * \param node the node on which the routing protocol will run 68 * \returns a newly-created routing protocol 69 * 70 * This method will be called by ns3::InternetStackHelper::Install 71 */ 72 virtual Ptr<Ipv4RoutingProtocol> Create (Ptr<Node> node) const; 73 74 /** 75 * Try and find the static routing protocol as either the main routing 76 * protocol or in the list of routing protocols associated with the 77 * Ipv4 provided. 78 * 79 * \param ipv4 the Ptr<Ipv4> to search for the static routing protocol 80 * \returns Ipv4StaticRouting pointer or 0 if not found 81 */ 82 Ptr<Ipv4StaticRouting> GetStaticRouting (Ptr<Ipv4> ipv4) const; 83 84 /** 85 * \brief Add a multicast route to a node and net device using explicit 86 * Ptr<Node> and Ptr<NetDevice> 87 * 88 * \param n The node. 89 * \param source Source address. 90 * \param group Multicast group. 91 * \param input Input NetDevice. 92 * \param output Output NetDevices. 93 */ 94 void AddMulticastRoute (Ptr<Node> n, Ipv4Address source, Ipv4Address group, 95 Ptr<NetDevice> input, NetDeviceContainer output); 96 97 /** 98 * \brief Add a multicast route to a node and device using a name string 99 * previously associated to the node using the Object Name Service and a 100 * Ptr<NetDevice> 101 * 102 * \param n The node. 103 * \param source Source address. 104 * \param group Multicast group. 105 * \param input Input NetDevice. 106 * \param output Output NetDevices. 107 */ 108 void AddMulticastRoute (std::string n, Ipv4Address source, Ipv4Address group, 109 Ptr<NetDevice> input, NetDeviceContainer output); 110 111 /** 112 * \brief Add a multicast route to a node and device using a Ptr<Node> and a 113 * name string previously associated to the device using the Object Name Service. 114 * 115 * \param n The node. 116 * \param source Source address. 117 * \param group Multicast group. 118 * \param inputName Input NetDevice. 119 * \param output Output NetDevices. 120 */ 121 void AddMulticastRoute (Ptr<Node> n, Ipv4Address source, Ipv4Address group, 122 std::string inputName, NetDeviceContainer output); 123 124 /** 125 * \brief Add a multicast route to a node and device using name strings 126 * previously associated to both the node and device using the Object Name 127 * Service. 128 * 129 * \param nName The node. 130 * \param source Source address. 131 * \param group Multicast group. 132 * \param inputName Input NetDevice. 133 * \param output Output NetDevices. 134 */ 135 void AddMulticastRoute (std::string nName, Ipv4Address source, Ipv4Address group, 136 std::string inputName, NetDeviceContainer output); 137 138 /** 139 * \brief Add a default route to the static routing protocol to forward 140 * packets out a particular interface 141 * 142 * Functionally equivalent to: 143 * route add 224.0.0.0 netmask 240.0.0.0 dev nd 144 * \param n node 145 * \param nd device of the node to add default route 146 */ 147 void SetDefaultMulticastRoute (Ptr<Node> n, Ptr<NetDevice> nd); 148 149 /** 150 * \brief Add a default route to the static routing protocol to forward 151 * packets out a particular interface 152 * 153 * Functionally equivalent to: 154 * route add 224.0.0.0 netmask 240.0.0.0 dev nd 155 * \param n node 156 * \param ndName string with name previously associated to device using the 157 * Object Name Service 158 */ 159 void SetDefaultMulticastRoute (Ptr<Node> n, std::string ndName); 160 161 /** 162 * \brief Add a default route to the static routing protocol to forward 163 * packets out a particular interface 164 * 165 * Functionally equivalent to: 166 * route add 224.0.0.0 netmask 240.0.0.0 dev nd 167 * \param nName string with name previously associated to node using the 168 * Object Name Service 169 * \param nd device of the node to add default route 170 */ 171 void SetDefaultMulticastRoute (std::string nName, Ptr<NetDevice> nd); 172 173 /** 174 * \brief Add a default route to the static routing protocol to forward 175 * packets out a particular interface 176 * 177 * Functionally equivalent to: 178 * route add 224.0.0.0 netmask 240.0.0.0 dev nd 179 * \param nName string with name previously associated to node using the 180 * Object Name Service 181 * \param ndName string with name previously associated to device using the 182 * Object Name Service 183 */ 184 void SetDefaultMulticastRoute (std::string nName, std::string ndName); 185 private: 186 /** 187 * \brief Assignment operator declared private and not implemented to disallow 188 * assignment and prevent the compiler from happily inserting its own. 189 * \returns 190 */ 191 Ipv4StaticRoutingHelper &operator = (const Ipv4StaticRoutingHelper &); 192 }; 193 194 } // namespace ns3 195 196 #endif /* IPV4_STATIC_ROUTING_HELPER_H */ 197