|
|
| 94 |
{ |
94 |
{ |
| 95 |
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac64Address::ConvertFrom (addr)), Ipv6Prefix (64)); |
95 |
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac64Address::ConvertFrom (addr)), Ipv6Prefix (64)); |
| 96 |
AddAddress (ifaddr); |
96 |
AddAddress (ifaddr); |
|
|
97 |
m_linkLocalAddress = ifaddr; |
| 97 |
} |
98 |
} |
| 98 |
else if (Mac48Address::IsMatchingType (addr)) |
99 |
else if (Mac48Address::IsMatchingType (addr)) |
| 99 |
{ |
100 |
{ |
| 100 |
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac48Address::ConvertFrom (addr)), Ipv6Prefix (64)); |
101 |
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac48Address::ConvertFrom (addr)), Ipv6Prefix (64)); |
| 101 |
AddAddress (ifaddr); |
102 |
AddAddress (ifaddr); |
|
|
103 |
m_linkLocalAddress = ifaddr; |
| 102 |
} |
104 |
} |
| 103 |
else if (Mac16Address::IsMatchingType (addr)) |
105 |
else if (Mac16Address::IsMatchingType (addr)) |
| 104 |
{ |
106 |
{ |
| 105 |
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac16Address::ConvertFrom (addr)), Ipv6Prefix (64)); |
107 |
Ipv6InterfaceAddress ifaddr = Ipv6InterfaceAddress (Ipv6Address::MakeAutoconfiguredLinkLocalAddress (Mac16Address::ConvertFrom (addr)), Ipv6Prefix (64)); |
| 106 |
AddAddress (ifaddr); |
108 |
AddAddress (ifaddr); |
|
|
109 |
m_linkLocalAddress = ifaddr; |
| 107 |
} |
110 |
} |
| 108 |
else |
111 |
else |
| 109 |
{ |
112 |
{ |
|
|
| 213 |
{ |
216 |
{ |
| 214 |
for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
217 |
for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 215 |
{ |
218 |
{ |
| 216 |
if ((*it).GetAddress () == addr) |
219 |
if (it->first.GetAddress () == addr) |
| 217 |
{ |
220 |
{ |
| 218 |
return false; |
221 |
return false; |
| 219 |
} |
222 |
} |
| 220 |
} |
223 |
} |
| 221 |
|
224 |
|
| 222 |
m_addresses.push_back (iface); |
225 |
Ipv6Address solicited = Ipv6Address::MakeSolicitedAddress (iface.GetAddress ()); |
|
|
226 |
m_addresses.push_back (std::make_pair (iface, solicited)); |
| 223 |
|
227 |
|
| 224 |
if (!addr.IsAny () || !addr.IsLocalhost ()) |
228 |
if (!addr.IsAny () || !addr.IsLocalhost ()) |
| 225 |
{ |
229 |
{ |
|
|
| 249 |
/* IPv6 interface has always at least one IPv6 link-local address */ |
253 |
/* IPv6 interface has always at least one IPv6 link-local address */ |
| 250 |
NS_LOG_FUNCTION_NOARGS (); |
254 |
NS_LOG_FUNCTION_NOARGS (); |
| 251 |
|
255 |
|
|
|
256 |
return m_linkLocalAddress; |
| 257 |
} |
| 258 |
|
| 259 |
bool Ipv6Interface::IsSolicitedMulticastAddress (Ipv6Address address) const |
| 260 |
{ |
| 261 |
/* IPv6 interface has always at least one IPv6 Solicited Multicast address */ |
| 262 |
NS_LOG_FUNCTION_NOARGS (); |
| 263 |
|
| 252 |
for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
264 |
for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 253 |
{ |
265 |
{ |
| 254 |
if ((*it).GetAddress ().IsLinkLocal ()) |
266 |
if (it->second == address) |
| 255 |
{ |
267 |
{ |
| 256 |
return (*it); |
268 |
return true; |
| 257 |
} |
269 |
} |
| 258 |
} |
270 |
} |
| 259 |
NS_ASSERT_MSG (false, "No link-local address on interface " << this); |
271 |
|
| 260 |
Ipv6InterfaceAddress addr; |
272 |
return false; |
| 261 |
return addr; /* quiet compiler */ |
|
|
| 262 |
} |
273 |
} |
| 263 |
|
274 |
|
| 264 |
Ipv6InterfaceAddress Ipv6Interface::GetAddress (uint32_t index) const |
275 |
Ipv6InterfaceAddress Ipv6Interface::GetAddress (uint32_t index) const |
|
|
| 272 |
{ |
283 |
{ |
| 273 |
if (i == index) |
284 |
if (i == index) |
| 274 |
{ |
285 |
{ |
| 275 |
return (*it); |
286 |
return it->first; |
| 276 |
} |
287 |
} |
| 277 |
i++; |
288 |
i++; |
| 278 |
} |
289 |
} |
|
|
| 303 |
{ |
314 |
{ |
| 304 |
if (i == index) |
315 |
if (i == index) |
| 305 |
{ |
316 |
{ |
| 306 |
Ipv6InterfaceAddress iface = (*it); |
317 |
Ipv6InterfaceAddress iface = it->first; |
| 307 |
m_addresses.erase (it); |
318 |
m_addresses.erase (it); |
| 308 |
return iface; |
319 |
return iface; |
| 309 |
} |
320 |
} |
|
|
| 329 |
|
340 |
|
| 330 |
for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
341 |
for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 331 |
{ |
342 |
{ |
| 332 |
if((*it).GetAddress() == address) |
343 |
if(it->first.GetAddress () == address) |
| 333 |
{ |
344 |
{ |
| 334 |
Ipv6InterfaceAddress iface = (*it); |
345 |
Ipv6InterfaceAddress iface = it->first; |
| 335 |
m_addresses.erase(it); |
346 |
m_addresses.erase(it); |
| 336 |
return iface; |
347 |
return iface; |
| 337 |
} |
348 |
} |
|
|
| 345 |
|
356 |
|
| 346 |
for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin (); it != m_addresses.end (); ++it) |
357 |
for (Ipv6InterfaceAddressList::const_iterator it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 347 |
{ |
358 |
{ |
| 348 |
Ipv6InterfaceAddress ifaddr = (*it); |
359 |
Ipv6InterfaceAddress ifaddr = it->first; |
| 349 |
|
360 |
|
| 350 |
if (ifaddr.GetPrefix ().IsMatch (ifaddr.GetAddress (), dst)) |
361 |
if (ifaddr.GetPrefix ().IsMatch (ifaddr.GetAddress (), dst)) |
| 351 |
{ |
362 |
{ |
|
|
| 381 |
/* check if destination is for one of our interface */ |
392 |
/* check if destination is for one of our interface */ |
| 382 |
for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
393 |
for (Ipv6InterfaceAddressListCI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 383 |
{ |
394 |
{ |
| 384 |
if (dest == (*it).GetAddress ()) |
395 |
if (dest == it->first.GetAddress ()) |
| 385 |
{ |
396 |
{ |
| 386 |
ipv6->Receive (m_device, p, Ipv6L3Protocol::PROT_NUMBER, |
397 |
ipv6->Receive (m_device, p, Ipv6L3Protocol::PROT_NUMBER, |
| 387 |
m_device->GetBroadcast (), |
398 |
m_device->GetBroadcast (), |
|
|
| 483 |
|
494 |
|
| 484 |
for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
495 |
for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 485 |
{ |
496 |
{ |
| 486 |
if ((*it).GetAddress () == address) |
497 |
if (it->first.GetAddress () == address) |
| 487 |
{ |
498 |
{ |
| 488 |
(*it).SetState (state); |
499 |
it->first.SetState (state); |
| 489 |
return; |
500 |
return; |
| 490 |
} |
501 |
} |
| 491 |
} |
502 |
} |
|
|
| 498 |
|
509 |
|
| 499 |
for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
510 |
for (Ipv6InterfaceAddressListI it = m_addresses.begin (); it != m_addresses.end (); ++it) |
| 500 |
{ |
511 |
{ |
| 501 |
if ((*it).GetAddress () == address) |
512 |
if (it->first.GetAddress () == address) |
| 502 |
{ |
513 |
{ |
| 503 |
(*it).SetNsDadUid (uid); |
514 |
it->first.SetNsDadUid (uid); |
| 504 |
return; |
515 |
return; |
| 505 |
} |
516 |
} |
| 506 |
} |
517 |
} |