View | Details | Raw Unified | Return to bug 1702
Collapse All | Expand All

(-)a/examples/ipv6/icmpv6-redirect.cc (-3 / +5 lines)
 Lines 148-159    Link Here 
148
148
149
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
149
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
150
  Ipv6InterfaceContainer iic1 = ipv6.Assign (ndc1);
150
  Ipv6InterfaceContainer iic1 = ipv6.Assign (ndc1);
151
  iic1.SetRouter (2, true);
151
152
  iic1.SetRouter (1, true);
152
  Ipv6StaticRoutingHelper staticRoutes;
153
  staticRoutes.SetDefaultRoute (iic1, 1);
153
154
154
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
155
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
155
  Ipv6InterfaceContainer iic2 = ipv6.Assign (ndc2);
156
  Ipv6InterfaceContainer iic2 = ipv6.Assign (ndc2);
156
  iic2.SetRouter (0, true);
157
158
  staticRoutes.SetDefaultRoute (iic2, 0);
157
159
158
  stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 0), iic1.GetInterfaceIndex (1));
160
  stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 0), iic1.GetInterfaceIndex (1));
159
161
(-)a/src/internet/helper/ipv6-interface-container.cc (+7 lines)
 Lines 117-121    Link Here 
117
  routing->SetDefaultRoute (routerAddress, m_interfaces[i].second);
117
  routing->SetDefaultRoute (routerAddress, m_interfaces[i].second);
118
}
118
}
119
119
120
Ipv6Address Ipv6InterfaceContainer::GetLinkLocalAddress (uint32_t i)
121
{
122
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
123
  Ipv6Address address = ipv6->GetAddress (m_interfaces[i].second, 0).GetAddress ();
124
  return address;
125
}
126
120
} /* namespace ns3 */
127
} /* namespace ns3 */
121
128
(-)a/src/internet/helper/ipv6-interface-container.h (-2 / +10 lines)
 Lines 27-32    Link Here 
27
27
28
#include "ns3/ipv6.h"
28
#include "ns3/ipv6.h"
29
#include "ns3/ipv6-address.h"
29
#include "ns3/ipv6-address.h"
30
#include "ns3/deprecated.h"
30
31
31
namespace ns3
32
namespace ns3
32
{
33
{
 Lines 149-162    Link Here 
149
   * \param i index
150
   * \param i index
150
   * \param router true : is a router, false : is an host
151
   * \param router true : is a router, false : is an host
151
   */
152
   */
152
  void SetRouter (uint32_t i, bool router);
153
  void SetRouter (uint32_t i, bool router) NS_DEPRECATED;
153
154
154
  /**
155
  /**
155
   * \brief Set the default route for the specified index.
156
   * \brief Set the default route for the specified index.
156
   * \param i index
157
   * \param i index
157
   * \param router the default router
158
   * \param router the default router
158
   */
159
   */
159
  void SetDefaultRoute (uint32_t i, uint32_t router);
160
  void SetDefaultRoute (uint32_t i, uint32_t router) NS_DEPRECATED;
161
162
  /**
163
   * \brief Get the link-local address for the specified index.
164
   * \param i index
165
   * \return the link-local address
166
   */
167
  Ipv6Address GetLinkLocalAddress (uint32_t i);
160
168
161
private:
169
private:
162
  typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > InterfaceVector;
170
  typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > InterfaceVector;
(-)a/src/internet/helper/ipv6-static-routing-helper.cc (+38 lines)
 Lines 28-33    Link Here 
28
#include "ns3/assert.h"
28
#include "ns3/assert.h"
29
#include "ns3/ipv6-address.h"
29
#include "ns3/ipv6-address.h"
30
#include "ns3/ipv6-routing-protocol.h"
30
#include "ns3/ipv6-routing-protocol.h"
31
#include "ns3/ipv6-interface-container.h"
31
32
32
#include "ipv6-static-routing-helper.h"
33
#include "ipv6-static-routing-helper.h"
33
34
 Lines 211-214    Link Here 
211
}
212
}
212
#endif
213
#endif
213
214
215
216
void Ipv6StaticRoutingHelper::SetDefaultRoute (Ptr<Node> n, uint32_t i, Ipv6Address routerAddr)
217
{
218
  Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
219
  Ptr<Ipv6StaticRouting> routing = GetStaticRouting (ipv6);
220
  routing->SetDefaultRoute (routerAddr, i);
221
}
222
223
void Ipv6StaticRoutingHelper::SetDefaultRoute (Ipv6InterfaceContainer ic, Ipv6Address routerAddr)
224
{
225
  Ipv6InterfaceContainer::Iterator iter;
226
  for (iter=ic.Begin(); iter!=ic.End(); iter++)
227
    {
228
      Ptr<Ipv6> ipv6 = iter->first;
229
      Ptr<Ipv6StaticRouting> routing = GetStaticRouting (ipv6);
230
      routing->SetDefaultRoute (routerAddr, iter->second);
231
    }
232
}
233
234
void Ipv6StaticRoutingHelper::SetDefaultRoute (Ipv6InterfaceContainer ic, uint32_t routerIndex)
235
{
236
  NS_ASSERT(ic.GetN () >= routerIndex);
237
238
  Ipv6InterfaceContainer::Iterator iter;
239
  Ipv6Address routerAddr = ic.GetLinkLocalAddress(routerIndex);
240
  uint32_t index;
241
  for (iter=ic.Begin(), index=0; iter!=ic.End(); iter++, index++)
242
    {
243
      if (index != routerIndex)
244
        {
245
          Ptr<Ipv6> ipv6 = iter->first;
246
          Ptr<Ipv6StaticRouting> routing = GetStaticRouting (ipv6);
247
          routing->SetDefaultRoute (routerAddr, iter->second);
248
        }
249
    }
250
}
251
214
} // namespace ns3
252
} // namespace ns3
(-)a/src/internet/helper/ipv6-static-routing-helper.h (+23 lines)
 Lines 116-121    Link Here 
116
  void SetDefaultMulticastRoute (std::string nName, Ptr<NetDevice> nd);
116
  void SetDefaultMulticastRoute (std::string nName, Ptr<NetDevice> nd);
117
  void SetDefaultMulticastRoute (std::string nName, std::string ndName);
117
  void SetDefaultMulticastRoute (std::string nName, std::string ndName);
118
#endif
118
#endif
119
120
  /**
121
   * \brief Set the default route for the specified node.
122
   * \param n Node
123
   * \param i output interface
124
   * \param router the default router address (must be link-local)
125
   */
126
  void SetDefaultRoute (Ptr<Node> n, uint32_t i, Ipv6Address routerAddr);
127
128
  /**
129
   * \brief Set the default route for a group of nodes.
130
   * \param ic the nodes' interfaces
131
   * \param router the default router address (must be link-local)
132
   */
133
  void SetDefaultRoute (Ipv6InterfaceContainer ic, Ipv6Address routerAddr);
134
135
  /**
136
   * \brief Set the default route for a group of nodes.
137
   * \param ic the nodes' interfaces
138
   * \param routerIndex the default router index in the Interface Container ic
139
   */
140
  void SetDefaultRoute (Ipv6InterfaceContainer ic, uint32_t routerIndex);
141
119
private:
142
private:
120
  /**
143
  /**
121
   * \internal
144
   * \internal

Return to bug 1702