00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "ipv4-impl.h"
00021 #include "ipv4-l3-protocol.h"
00022 #include "ipv4-interface.h"
00023 #include "ns3/assert.h"
00024 #include "ns3/net-device.h"
00025
00026 namespace ns3 {
00027
00028 Ipv4Impl::Ipv4Impl ()
00029 : m_ipv4 (0)
00030 {}
00031 Ipv4Impl::~Ipv4Impl ()
00032 {
00033 NS_ASSERT (m_ipv4 == 0);
00034 }
00035 void
00036 Ipv4Impl::SetIpv4 (Ptr<Ipv4L3Protocol> ipv4)
00037 {
00038 m_ipv4 = ipv4;
00039 }
00040 void
00041 Ipv4Impl::DoDispose (void)
00042 {
00043 m_ipv4 = 0;
00044 }
00045
00046 void
00047 Ipv4Impl::AddRoutingProtocol (Ptr<Ipv4RoutingProtocol> routingProtocol,
00048 int16_t priority)
00049 {
00050 m_ipv4->AddRoutingProtocol (routingProtocol, priority);
00051 }
00052
00053 void
00054 Ipv4Impl::AddHostRouteTo (Ipv4Address dest,
00055 Ipv4Address nextHop,
00056 uint32_t interface)
00057 {
00058 m_ipv4->AddHostRouteTo (dest, nextHop, interface);
00059 }
00060 void
00061 Ipv4Impl::AddHostRouteTo (Ipv4Address dest,
00062 uint32_t interface)
00063 {
00064 m_ipv4->AddHostRouteTo (dest, interface);
00065 }
00066 void
00067 Ipv4Impl::AddNetworkRouteTo (Ipv4Address network,
00068 Ipv4Mask networkMask,
00069 Ipv4Address nextHop,
00070 uint32_t interface)
00071 {
00072 m_ipv4->AddNetworkRouteTo (network, networkMask, nextHop, interface);
00073 }
00074 void
00075 Ipv4Impl::AddNetworkRouteTo (Ipv4Address network,
00076 Ipv4Mask networkMask,
00077 uint32_t interface)
00078 {
00079 m_ipv4->AddNetworkRouteTo (network, networkMask, interface);
00080 }
00081 void
00082 Ipv4Impl::SetDefaultRoute (Ipv4Address nextHop,
00083 uint32_t interface)
00084 {
00085 m_ipv4->SetDefaultRoute (nextHop, interface);
00086 }
00087 uint32_t
00088 Ipv4Impl::GetNRoutes (void)
00089 {
00090 return m_ipv4->GetNRoutes ();
00091 }
00092 Ipv4Route
00093 Ipv4Impl::GetRoute (uint32_t i)
00094 {
00095 return *m_ipv4->GetRoute (i);
00096 }
00097 void
00098 Ipv4Impl::RemoveRoute (uint32_t i)
00099 {
00100 return m_ipv4->RemoveRoute (i);
00101 }
00102
00103 void
00104 Ipv4Impl::AddMulticastRoute (Ipv4Address origin,
00105 Ipv4Address group,
00106 uint32_t inputInterface,
00107 std::vector<uint32_t> outputInterfaces)
00108 {
00109 m_ipv4->AddMulticastRoute (origin, group, inputInterface, outputInterfaces);
00110 }
00111
00112 void
00113 Ipv4Impl::SetDefaultMulticastRoute (uint32_t outputInterface)
00114 {
00115 m_ipv4->SetDefaultMulticastRoute (outputInterface);
00116 }
00117
00118 uint32_t
00119 Ipv4Impl::GetNMulticastRoutes (void) const
00120 {
00121 return m_ipv4->GetNMulticastRoutes ();
00122 }
00123
00124 Ipv4MulticastRoute
00125 Ipv4Impl::GetMulticastRoute (uint32_t i) const
00126 {
00127 return *m_ipv4->GetMulticastRoute (i);
00128 }
00129
00130 void
00131 Ipv4Impl::RemoveMulticastRoute (Ipv4Address origin,
00132 Ipv4Address group,
00133 uint32_t inputInterface)
00134 {
00135 m_ipv4->RemoveMulticastRoute (origin, group, inputInterface);
00136 }
00137
00138 void
00139 Ipv4Impl::RemoveMulticastRoute (uint32_t i)
00140 {
00141 return m_ipv4->RemoveMulticastRoute (i);
00142 }
00143
00144 uint32_t
00145 Ipv4Impl::AddInterface (Ptr<NetDevice> device)
00146 {
00147 return m_ipv4->AddInterface (device);
00148 }
00149
00150 uint32_t
00151 Ipv4Impl::GetNInterfaces (void)
00152 {
00153 return m_ipv4->GetNInterfaces ();
00154 }
00155
00156 uint32_t
00157 Ipv4Impl::FindInterfaceForAddr (Ipv4Address addr) const
00158 {
00159 return m_ipv4->FindInterfaceForAddr (addr);
00160 }
00161
00162 uint32_t
00163 Ipv4Impl::FindInterfaceForAddr (Ipv4Address addr, Ipv4Mask mask) const
00164 {
00165 return m_ipv4->FindInterfaceForAddr (addr, mask);
00166 }
00167
00168 int32_t
00169 Ipv4Impl::FindInterfaceForDevice (Ptr<NetDevice> device) const
00170 {
00171 return m_ipv4->FindInterfaceIndexForDevice (device);
00172 }
00173
00174 Ptr<NetDevice>
00175 Ipv4Impl::GetNetDevice (uint32_t i)
00176 {
00177 return m_ipv4->GetInterface (i)-> GetDevice ();
00178 }
00179
00180 void
00181 Ipv4Impl::JoinMulticastGroup (Ipv4Address origin, Ipv4Address group)
00182 {
00183 m_ipv4->JoinMulticastGroup(origin, group);
00184 }
00185
00186 void
00187 Ipv4Impl::LeaveMulticastGroup (Ipv4Address origin, Ipv4Address group)
00188 {
00189 m_ipv4->LeaveMulticastGroup(origin, group);
00190 }
00191
00192 void
00193 Ipv4Impl::SetAddress (uint32_t i, Ipv4Address address)
00194 {
00195 m_ipv4->SetAddress (i, address);
00196 }
00197 void
00198 Ipv4Impl::SetNetworkMask (uint32_t i, Ipv4Mask mask)
00199 {
00200 m_ipv4->SetNetworkMask (i, mask);
00201 }
00202 Ipv4Mask
00203 Ipv4Impl::GetNetworkMask (uint32_t i) const
00204 {
00205 return m_ipv4->GetNetworkMask (i);
00206 }
00207
00208 Ipv4Address
00209 Ipv4Impl::GetAddress (uint32_t i) const
00210 {
00211 return m_ipv4->GetAddress (i);
00212 }
00213
00214 void
00215 Ipv4Impl::SetMetric (uint32_t i, uint16_t metric)
00216 {
00217 m_ipv4->SetMetric (i, metric);
00218 }
00219
00220 uint16_t
00221 Ipv4Impl::GetMetric (uint32_t i) const
00222 {
00223 return m_ipv4->GetMetric (i);
00224 }
00225
00226 bool
00227 Ipv4Impl::GetIfIndexForDestination (Ipv4Address dest, uint32_t &ifIndex) const
00228 {
00229 return m_ipv4->GetIfIndexForDestination (dest, ifIndex);
00230 }
00231
00232 Ipv4Address
00233 Ipv4Impl::GetSourceAddress (Ipv4Address destination) const
00234 {
00235 uint32_t ifIndex = 0xffffffff;
00236
00237 bool result = m_ipv4->GetIfIndexForDestination (destination, ifIndex);
00238
00239 if (result)
00240 {
00241 return m_ipv4->GetAddress (ifIndex);
00242 }
00243 else
00244 {
00245
00246
00247
00248 return Ipv4Address::GetAny ();
00249 }
00250 }
00251
00252 uint16_t
00253 Ipv4Impl::GetMtu (uint32_t i) const
00254 {
00255 return m_ipv4->GetMtu (i);
00256 }
00257 bool
00258 Ipv4Impl::IsUp (uint32_t i) const
00259 {
00260 return m_ipv4->IsUp (i);
00261 }
00262 void
00263 Ipv4Impl::SetUp (uint32_t i)
00264 {
00265 m_ipv4->SetUp (i);
00266 }
00267 void
00268 Ipv4Impl::SetDown (uint32_t i)
00269 {
00270 m_ipv4->SetDown (i);
00271 }
00272
00273 }