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

(-)a/RELEASE_NOTES (+1 lines)
 Lines 37-42    Link Here 
37
- Bug 1697 - ICMPv6 Redirect trigger contains multiple bugs
37
- Bug 1697 - ICMPv6 Redirect trigger contains multiple bugs
38
- Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
38
- Bug 1700 - Ipv6RawSocket does not honor the bound address when sending packets
39
- Bug 1701 - Ipv6StaticRouting: the source address should match the destination scope
39
- Bug 1701 - Ipv6StaticRouting: the source address should match the destination scope
40
- Bug 1702 - Ipv6InterfaceContainer::SetRouter should not always add the router as the default router.
40
- Bug 1703 - Nodes don't react to a DAD
41
- Bug 1703 - Nodes don't react to a DAD
41
- Bug 1712 - The IP (v4 and v6) forwarding needs a test
42
- Bug 1712 - The IP (v4 and v6) forwarding needs a test
42
- Bug 1718 - Ipv4StaticRouting log component is misspelled
43
- Bug 1718 - Ipv4StaticRouting log component is misspelled
(-)a/examples/ipv6/fragmentation-ipv6.cc (-2 / +4 lines)
 Lines 129-138    Link Here 
129
  Ipv6AddressHelper ipv6;
129
  Ipv6AddressHelper ipv6;
130
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
130
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
131
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
131
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
132
  i1.SetRouter (1, true);
132
  i1.SetForwarding (1, true);
133
  i1.SetDefaultRouteInAllNodes (1);
133
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
134
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
134
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
135
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
135
  i2.SetRouter (0, true);
136
  i2.SetForwarding (0, true);
137
  i2.SetDefaultRouteInAllNodes (0);
136
138
137
  stackHelper.PrintRoutingTable (n0);
139
  stackHelper.PrintRoutingTable (n0);
138
140
(-)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
  iic1.SetForwarding (2, true);
152
  iic1.SetRouter (1, true);
152
  iic1.SetForwarding (1, true);
153
  iic1.SetDefaultRouteInAllNodes (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
  iic2.SetForwarding (0, true);
158
  iic2.SetDefaultRouteInAllNodes (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/examples/ipv6/loose-routing-ipv6.cc (-10 / +20 lines)
 Lines 106-136    Link Here 
106
106
107
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
107
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
108
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
108
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
109
  i1.SetRouter (1, true);
109
  i1.SetForwarding (1, true);
110
  i1.SetDefaultRouteInAllNodes (1);
110
111
111
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
112
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
112
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
113
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
113
  i2.SetRouter (1, true);
114
  i2.SetForwarding (1, true);
115
  i2.SetDefaultRouteInAllNodes (1);
114
116
115
  ipv6.SetBase (Ipv6Address ("2001:3::"), Ipv6Prefix (64));
117
  ipv6.SetBase (Ipv6Address ("2001:3::"), Ipv6Prefix (64));
116
  Ipv6InterfaceContainer i3 = ipv6.Assign (d3);
118
  Ipv6InterfaceContainer i3 = ipv6.Assign (d3);
117
  i3.SetRouter (0, true);
119
  i3.SetForwarding (0, true);
118
  i3.SetRouter (1, true);
120
  i3.SetDefaultRouteInAllNodes (0);
121
  i3.SetForwarding (1, true);
122
  i3.SetDefaultRouteInAllNodes (1);
119
123
120
  ipv6.SetBase (Ipv6Address ("2001:4::"), Ipv6Prefix (64));
124
  ipv6.SetBase (Ipv6Address ("2001:4::"), Ipv6Prefix (64));
121
  Ipv6InterfaceContainer i4 = ipv6.Assign (d4);
125
  Ipv6InterfaceContainer i4 = ipv6.Assign (d4);
122
  i4.SetRouter (0, true);
126
  i4.SetForwarding (0, true);
123
  i4.SetRouter (1, true);
127
  i4.SetDefaultRouteInAllNodes (0);
128
  i4.SetForwarding (1, true);
129
  i4.SetDefaultRouteInAllNodes (1);
124
130
125
  ipv6.SetBase (Ipv6Address ("2001:5::"), Ipv6Prefix (64));
131
  ipv6.SetBase (Ipv6Address ("2001:5::"), Ipv6Prefix (64));
126
  Ipv6InterfaceContainer i5 = ipv6.Assign (d5);
132
  Ipv6InterfaceContainer i5 = ipv6.Assign (d5);
127
  i5.SetRouter (0, true);
133
  i5.SetForwarding (0, true);
128
  i5.SetRouter (1, true);
134
  i5.SetDefaultRouteInAllNodes (0);
135
  i5.SetForwarding (1, true);
136
  i5.SetDefaultRouteInAllNodes (1);
129
137
130
  ipv6.SetBase (Ipv6Address ("2001:6::"), Ipv6Prefix (64));
138
  ipv6.SetBase (Ipv6Address ("2001:6::"), Ipv6Prefix (64));
131
  Ipv6InterfaceContainer i6 = ipv6.Assign (d6);
139
  Ipv6InterfaceContainer i6 = ipv6.Assign (d6);
132
  i6.SetRouter (0, true);
140
  i6.SetForwarding (0, true);
133
  i6.SetRouter (1, true);
141
  i6.SetDefaultRouteInAllNodes (0);
142
  i6.SetForwarding (1, true);
143
  i6.SetDefaultRouteInAllNodes (1);
134
144
135
  NS_LOG_INFO ("Create Applications.");
145
  NS_LOG_INFO ("Create Applications.");
136
146
(-)a/examples/ipv6/radvd-two-prefix.cc (-2 / +4 lines)
 Lines 145-151    Link Here 
145
  NetDeviceContainer tmp2;
145
  NetDeviceContainer tmp2;
146
  tmp2.Add (d1.Get (1)); /* R */
146
  tmp2.Add (d1.Get (1)); /* R */
147
  Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
147
  Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
148
  iicr1.SetRouter (0, true);
148
  iicr1.SetForwarding (0, true);
149
  iicr1.SetDefaultRouteInAllNodes (0);
149
  iic1.Add (iicr1);
150
  iic1.Add (iicr1);
150
151
151
  /* add another IPv6 address for second prefix advertised on first subnet */
152
  /* add another IPv6 address for second prefix advertised on first subnet */
 Lines 156-162    Link Here 
156
  NetDeviceContainer tmp3;
157
  NetDeviceContainer tmp3;
157
  tmp3.Add (d2.Get (0)); /* R */
158
  tmp3.Add (d2.Get (0)); /* R */
158
  Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
159
  Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
159
  iicr2.SetRouter (0, true);
160
  iicr2.SetForwarding (0, true);
161
  iicr2.SetDefaultRouteInAllNodes (0);
160
162
161
  NetDeviceContainer tmp4;
163
  NetDeviceContainer tmp4;
162
  tmp4.Add (d2.Get (1)); /* n1 */
164
  tmp4.Add (d2.Get (1)); /* n1 */
(-)a/examples/ipv6/radvd.cc (-2 / +4 lines)
 Lines 92-98    Link Here 
92
  NetDeviceContainer tmp2;
92
  NetDeviceContainer tmp2;
93
  tmp2.Add (d1.Get (1)); /* R */
93
  tmp2.Add (d1.Get (1)); /* R */
94
  Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
94
  Ipv6InterfaceContainer iicr1 = ipv6.Assign (tmp2); /* R interface to the first subnet is just statically assigned */
95
  iicr1.SetRouter (0, true);
95
  iicr1.SetForwarding (0, true);
96
  iicr1.SetDefaultRouteInAllNodes (0);
96
  iic1.Add (iicr1);
97
  iic1.Add (iicr1);
97
98
98
  /* second subnet R - n1 */
99
  /* second subnet R - n1 */
 Lines 100-106    Link Here 
100
  NetDeviceContainer tmp3;
101
  NetDeviceContainer tmp3;
101
  tmp3.Add (d2.Get (0)); /* R */
102
  tmp3.Add (d2.Get (0)); /* R */
102
  Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
103
  Ipv6InterfaceContainer iicr2 = ipv6.Assign (tmp3); /* R interface */
103
  iicr2.SetRouter (0, true);
104
  iicr2.SetForwarding (0, true);
105
  iicr2.SetDefaultRouteInAllNodes (0);
104
106
105
  NetDeviceContainer tmp4;
107
  NetDeviceContainer tmp4;
106
  tmp4.Add (d2.Get (1)); /* n1 */
108
  tmp4.Add (d2.Get (1)); /* n1 */
(-)a/examples/routing/simple-routing-ping6.cc (-2 / +4 lines)
 Lines 130-139    Link Here 
130
  Ipv6AddressHelper ipv6;
130
  Ipv6AddressHelper ipv6;
131
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
131
  ipv6.SetBase (Ipv6Address ("2001:1::"), Ipv6Prefix (64));
132
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
132
  Ipv6InterfaceContainer i1 = ipv6.Assign (d1);
133
  i1.SetRouter (1, true);
133
  i1.SetForwarding (1, true);
134
  i1.SetDefaultRouteInAllNodes (1);
134
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
135
  ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
135
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
136
  Ipv6InterfaceContainer i2 = ipv6.Assign (d2);
136
  i2.SetRouter (0, true);
137
  i2.SetForwarding (0, true);
138
  i2.SetDefaultRouteInAllNodes (0);
137
139
138
  stackHelper.PrintRoutingTable (n0);
140
  stackHelper.PrintRoutingTable (n0);
139
141
(-)a/src/fd-net-device/examples/fd-tap-ping6.cc (-2 / +4 lines)
 Lines 102-108    Link Here 
102
 
102
 
103
  ipv6.SetBase (Ipv6Address ("2001:0DB8:1::"), Ipv6Prefix (64));
103
  ipv6.SetBase (Ipv6Address ("2001:0DB8:1::"), Ipv6Prefix (64));
104
  Ipv6InterfaceContainer i1 = ipv6.Assign (devs);
104
  Ipv6InterfaceContainer i1 = ipv6.Assign (devs);
105
  i1.SetRouter (1, true);
105
  i1.SetForwarding (1, true);
106
  i1.SetDefaultRouteInAllNodes (1);
106
  
107
  
107
  ipv6.SetBase (Ipv6Address ("2001:0DB8:2::"), Ipv6Prefix (64));
108
  ipv6.SetBase (Ipv6Address ("2001:0DB8:2::"), Ipv6Prefix (64));
108
  Ipv6Address tapAddr = ipv6.NewAddress ();
109
  Ipv6Address tapAddr = ipv6.NewAddress ();
 Lines 124-130    Link Here 
124
  Ptr<FdNetDevice> fdevice = device->GetObject<FdNetDevice> ();
125
  Ptr<FdNetDevice> fdevice = device->GetObject<FdNetDevice> ();
125
  fdevice-> SetIsMulticast (true);
126
  fdevice-> SetIsMulticast (true);
126
  Ipv6InterfaceContainer i2 = ipv6.Assign (fdevs);
127
  Ipv6InterfaceContainer i2 = ipv6.Assign (fdevs);
127
  i2.SetRouter (0, true);
128
  i2.SetForwarding (0, true);
129
  i2.SetDefaultRouteInAllNodes (0);
128
130
129
  //
131
  //
130
  // Create the Ping6 application.
132
  // Create the Ping6 application.
(-)a/src/internet/helper/ipv6-interface-container.cc (-6 / +190 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2008-2009 Strasbourg University
3
 * Copyright (c) 2008-2009 Strasbourg University
4
 *               2013 Universita' di Firenze
4
 *
5
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * 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
 * it under the terms of the GNU General Public License version 2 as
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 *
18
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
20
 *         Tommaso Pecorella <tommaso.pecorella@unifi.it>
19
 */
21
 */
20
22
21
#include "ns3/node-list.h"
23
#include "ns3/node-list.h"
 Lines 24-43    Link Here 
24
#include "ipv6-interface-container.h"
26
#include "ipv6-interface-container.h"
25
#include "ns3/ipv6-static-routing-helper.h"
27
#include "ns3/ipv6-static-routing-helper.h"
26
28
27
namespace ns3 
29
namespace ns3 {
28
{
29
30
30
Ipv6InterfaceContainer::Ipv6InterfaceContainer ()
31
Ipv6InterfaceContainer::Ipv6InterfaceContainer ()
31
{
32
{
32
}
33
}
33
34
34
Ipv6InterfaceContainer::Iterator 
35
Ipv6InterfaceContainer::Iterator
35
Ipv6InterfaceContainer::Begin (void) const
36
Ipv6InterfaceContainer::Begin (void) const
36
{
37
{
37
  return m_interfaces.begin ();
38
  return m_interfaces.begin ();
38
}
39
}
39
40
40
Ipv6InterfaceContainer::Iterator 
41
Ipv6InterfaceContainer::Iterator
41
Ipv6InterfaceContainer::End (void) const
42
Ipv6InterfaceContainer::End (void) const
42
{
43
{
43
  return m_interfaces.end ();
44
  return m_interfaces.end ();
 Lines 81-86    Link Here 
81
82
82
void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router)
83
void Ipv6InterfaceContainer::SetRouter (uint32_t i, bool router)
83
{
84
{
85
  // This function is deprecated and should be substituted by:
86
  // SetForwarding (RouterInterfaceIndex, true);
87
  // SetDefaultRouteInAllNodes (RouterInterfaceIndex);
88
84
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
89
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
85
  ipv6->SetForwarding (m_interfaces[i].second, router);
90
  ipv6->SetForwarding (m_interfaces[i].second, router);
86
91
 Lines 105-115    Link Here 
105
    }
110
    }
106
}
111
}
107
112
113
void Ipv6InterfaceContainer::SetForwarding (uint32_t i, bool router)
114
{
115
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
116
  ipv6->SetForwarding (m_interfaces[i].second, router);
117
}
118
119
void Ipv6InterfaceContainer::SetDefaultRouteInAllNodes (uint32_t router)
120
{
121
  Ptr<Ipv6> ipv6 = m_interfaces[router].first;
122
  uint32_t other;
123
124
  Ipv6Address routerAddress;
125
  for (uint32_t i = 0; i < ipv6->GetNAddresses (m_interfaces[router].second); i++)
126
    {
127
      Ipv6InterfaceAddress routerIaddress;
128
      routerIaddress = ipv6->GetAddress (m_interfaces[router].second, i);
129
      if (routerIaddress.GetScope () == Ipv6InterfaceAddress::LINKLOCAL)
130
        {
131
          routerAddress = routerIaddress.GetAddress ();
132
          break;
133
        }
134
    }
135
  NS_ASSERT_MSG (routerAddress != Ipv6Address::GetAny (), "No link-local address found on router, aborting");
136
137
  for (other = 0; other < m_interfaces.size (); other++)
138
    {
139
      if (other != router)
140
        {
141
          Ptr<Ipv6StaticRouting> routing = 0;
142
          Ipv6StaticRoutingHelper routingHelper;
143
144
          ipv6 = m_interfaces[other].first;
145
          routing = routingHelper.GetStaticRouting (ipv6);
146
          routing->SetDefaultRoute (routerAddress, m_interfaces[other].second);
147
        }
148
    }
149
}
150
151
void Ipv6InterfaceContainer::SetDefaultRouteInAllNodes (Ipv6Address routerAddress)
152
{
153
  uint32_t routerIndex;
154
  bool found = false;
155
  for (uint32_t index = 0; index < m_interfaces.size (); index++)
156
    {
157
      Ptr<Ipv6> ipv6 = m_interfaces[index].first;
158
      for (uint32_t i = 0; i < ipv6->GetNAddresses (m_interfaces[index].second); i++)
159
        {
160
          Ipv6Address addr = ipv6->GetAddress (m_interfaces[index].second, i).GetAddress ();
161
          if (addr == routerAddress)
162
            {
163
              routerIndex = index;
164
              found = true;
165
              break;
166
            }
167
        }
168
      if (found)
169
        {
170
          break;
171
        }
172
    }
173
  NS_ASSERT_MSG (found != true, "No such address in the interfaces. Aborting.");
174
175
  Ipv6Address routerLinkLocalAddress = GetLinkLocalAddress (routerIndex);
176
  uint32_t other;
177
178
  for (other = 0; other < m_interfaces.size (); other++)
179
    {
180
      if (other != routerIndex)
181
        {
182
          Ptr<Ipv6StaticRouting> routing = 0;
183
          Ipv6StaticRoutingHelper routingHelper;
184
185
          Ptr<Ipv6> ipv6 = m_interfaces[other].first;
186
          routing = routingHelper.GetStaticRouting (ipv6);
187
          routing->SetDefaultRoute (routerLinkLocalAddress, m_interfaces[other].second);
188
        }
189
    }
190
}
191
192
108
void Ipv6InterfaceContainer::SetDefaultRoute (uint32_t i, uint32_t router)
193
void Ipv6InterfaceContainer::SetDefaultRoute (uint32_t i, uint32_t router)
109
{
194
{
195
  NS_ASSERT_MSG (i != router, "A node shouldn't set itself as the default router, isn't it? Aborting.");
196
110
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
197
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
111
  Ptr<Ipv6> ipv6Router = m_interfaces[router].first;
198
112
  Ipv6Address routerAddress = ipv6Router->GetAddress (m_interfaces[router].second, 0).GetAddress ();
199
  Ipv6Address routerAddress = GetLinkLocalAddress (router);
200
  NS_ASSERT_MSG (routerAddress != Ipv6Address::GetAny (), "No link-local address found on router, aborting");
201
113
  Ptr<Ipv6StaticRouting> routing = 0;
202
  Ptr<Ipv6StaticRouting> routing = 0;
114
  Ipv6StaticRoutingHelper routingHelper;
203
  Ipv6StaticRoutingHelper routingHelper;
115
204
 Lines 117-121    Link Here 
117
  routing->SetDefaultRoute (routerAddress, m_interfaces[i].second);
206
  routing->SetDefaultRoute (routerAddress, m_interfaces[i].second);
118
}
207
}
119
208
209
210
void Ipv6InterfaceContainer::SetDefaultRoute (uint32_t i, Ipv6Address routerAddr)
211
{
212
  uint32_t routerIndex;
213
  bool found = false;
214
  for (uint32_t index = 0; index < m_interfaces.size (); index++)
215
    {
216
      Ptr<Ipv6> ipv6 = m_interfaces[index].first;
217
      for (uint32_t i = 0; i < ipv6->GetNAddresses (m_interfaces[index].second); i++)
218
        {
219
          Ipv6Address addr = ipv6->GetAddress (m_interfaces[index].second, i).GetAddress ();
220
          if (addr == routerAddr)
221
            {
222
              routerIndex = index;
223
              found = true;
224
              break;
225
            }
226
        }
227
      if (found)
228
        {
229
          break;
230
        }
231
    }
232
  NS_ASSERT_MSG (found != true, "No such address in the interfaces. Aborting.");
233
234
  NS_ASSERT_MSG (i != routerIndex, "A node shouldn't set itself as the default router, isn't it? Aborting.");
235
236
  Ptr<Ipv6> ipv6 = m_interfaces[i].first;
237
  Ipv6Address routerLinkLocalAddress = GetLinkLocalAddress (routerIndex);
238
  Ptr<Ipv6StaticRouting> routing = 0;
239
  Ipv6StaticRoutingHelper routingHelper;
240
241
  routing = routingHelper.GetStaticRouting (ipv6);
242
  routing->SetDefaultRoute (routerLinkLocalAddress, m_interfaces[i].second);
243
}
244
245
246
Ipv6Address Ipv6InterfaceContainer::GetLinkLocalAddress (uint32_t index)
247
{
248
  Ptr<Ipv6> ipv6 = m_interfaces[index].first;
249
  for (uint32_t i = 0; i < ipv6->GetNAddresses (m_interfaces[index].second); i++)
250
    {
251
      Ipv6InterfaceAddress iAddress;
252
      iAddress = ipv6->GetAddress (m_interfaces[index].second, i);
253
      if (iAddress.GetScope () == Ipv6InterfaceAddress::LINKLOCAL)
254
        {
255
          return iAddress.GetAddress ();
256
        }
257
    }
258
  return Ipv6Address::GetAny ();
259
}
260
261
Ipv6Address Ipv6InterfaceContainer::GetLinkLocalAddress (Ipv6Address address)
262
{
263
  if (address.IsLinkLocal ())
264
    {
265
      return address;
266
    }
267
268
  uint32_t nodeIndex;
269
  bool found = false;
270
  for (uint32_t index = 0; index < m_interfaces.size (); index++)
271
    {
272
      Ptr<Ipv6> ipv6 = m_interfaces[index].first;
273
      for (uint32_t i = 0; i < ipv6->GetNAddresses (m_interfaces[index].second); i++)
274
        {
275
          Ipv6Address addr = ipv6->GetAddress (m_interfaces[index].second, i).GetAddress ();
276
          if (addr == address)
277
            {
278
              nodeIndex = index;
279
              found = true;
280
              break;
281
            }
282
        }
283
      if (found)
284
        {
285
          break;
286
        }
287
    }
288
  NS_ASSERT_MSG (found != true, "No such address in the interfaces. Aborting.");
289
290
  Ptr<Ipv6> ipv6 = m_interfaces[nodeIndex].first;
291
  for (uint32_t i = 0; i < ipv6->GetNAddresses (m_interfaces[nodeIndex].second); i++)
292
    {
293
      Ipv6InterfaceAddress iAddress;
294
      iAddress = ipv6->GetAddress (m_interfaces[nodeIndex].second, i);
295
      if (iAddress.GetScope () == Ipv6InterfaceAddress::LINKLOCAL)
296
        {
297
          return iAddress.GetAddress ();
298
        }
299
    }
300
  return Ipv6Address::GetAny ();
301
}
302
303
120
} /* namespace ns3 */
304
} /* namespace ns3 */
121
305
(-)a/src/internet/helper/ipv6-interface-container.h (-1 / +47 lines)
 Lines 1-6    Link Here 
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
2
/*
3
 * Copyright (c) 2008-2009 Strasbourg University
3
 * Copyright (c) 2008-2009 Strasbourg University
4
 *               2013 Universita' di Firenze
4
 *
5
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * 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
 * it under the terms of the GNU General Public License version 2 as
 Lines 16-21    Link Here 
16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
 *
18
 *
18
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
20
 *         Tommaso Pecorella <tommaso.pecorella@unifi.it>
19
 */
21
 */
20
22
21
#ifndef IPV6_INTERFACE_CONTAINER_H
23
#ifndef IPV6_INTERFACE_CONTAINER_H
 Lines 27-32    Link Here 
27
29
28
#include "ns3/ipv6.h"
30
#include "ns3/ipv6.h"
29
#include "ns3/ipv6-address.h"
31
#include "ns3/ipv6-address.h"
32
#include "ns3/deprecated.h"
30
33
31
namespace ns3
34
namespace ns3
32
{
35
{
 Lines 81-86    Link Here 
81
  Ipv6Address GetAddress (uint32_t i, uint32_t j) const;
84
  Ipv6Address GetAddress (uint32_t i, uint32_t j) const;
82
85
83
  /**
86
  /**
87
   * \brief Get the link-local address for the specified index.
88
   * \param i index
89
   * \return the link-local address, or "::" if the interface has no link local address.
90
   */
91
  Ipv6Address GetLinkLocalAddress (uint32_t i);
92
93
  /**
94
   * \brief Get the link-local address for the node with the specified global address.
95
   * \param address the address to find.
96
   * \return the link-local address, or "::" if the interface has no link local address.
97
   */
98
  Ipv6Address GetLinkLocalAddress (Ipv6Address address);
99
100
  /**
84
   * \brief Add a couple IPv6/interface.
101
   * \brief Add a couple IPv6/interface.
85
   * \param ipv6 IPv6 address
102
   * \param ipv6 IPv6 address
86
   * \param interface interface index
103
   * \param interface interface index
 Lines 149-155    Link Here 
149
   * \param i index
166
   * \param i index
150
   * \param router true : is a router, false : is an host
167
   * \param router true : is a router, false : is an host
151
   */
168
   */
152
  void SetRouter (uint32_t i, bool router);
169
  void SetRouter (uint32_t i, bool router) NS_DEPRECATED;
170
171
  /**
172
   * \brief Set the state of the stack (act as a router or as an host) for the specified index.
173
   * This automatically sets all the node's interfaces to the same forwarding state.
174
   * \param i index
175
   * \param state true : is a router, false : is an host
176
   */
177
  void SetForwarding (uint32_t i, bool state);
178
179
  /**
180
   * \brief Set the default route for all the devices (except the router itself).
181
   * \param router the default router index
182
   */
183
  void SetDefaultRouteInAllNodes (uint32_t router);
184
185
  /**
186
   * \brief Set the default route for all the devices (except the router itself).
187
   * Note that the route will be set to the link-local address of the node with the specified address.
188
   * \param routerAddr the default router address
189
   */
190
  void SetDefaultRouteInAllNodes (Ipv6Address routerAddr);
153
191
154
  /**
192
  /**
155
   * \brief Set the default route for the specified index.
193
   * \brief Set the default route for the specified index.
 Lines 158-163    Link Here 
158
   */
196
   */
159
  void SetDefaultRoute (uint32_t i, uint32_t router);
197
  void SetDefaultRoute (uint32_t i, uint32_t router);
160
198
199
  /**
200
   * \brief Set the default route for the specified index.
201
   * Note that the route will be set to the link-local address of the node with the specified address.
202
   * \param i index
203
   * \param routerAddr the default router address
204
   */
205
  void SetDefaultRoute (uint32_t i, Ipv6Address routerAddr);
206
161
private:
207
private:
162
  typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > InterfaceVector;
208
  typedef std::vector<std::pair<Ptr<Ipv6>, uint32_t> > InterfaceVector;
163
209

Return to bug 1702