|
Lines 523-540
Ipv4NixVectorRouting::RouteOutput (Ptr<P
|
Link Here
|
|---|
|
| 523 |
uint32_t numberOfBits = nixVectorForPacket->BitCount (m_totalNeighbors); |
523 |
uint32_t numberOfBits = nixVectorForPacket->BitCount (m_totalNeighbors); |
| 524 |
uint32_t nodeIndex = nixVectorForPacket->ExtractNeighborIndex (numberOfBits); |
524 |
uint32_t nodeIndex = nixVectorForPacket->ExtractNeighborIndex (numberOfBits); |
| 525 |
|
525 |
|
| 526 |
// Possibly search here in a cache for this node index |
526 |
// Search here in a cache for this node index |
| 527 |
// and look for a Ipv4Route. If we have it, don't |
527 |
// and look for a Ipv4Route, if output device, |
| 528 |
// need to do the next 3 lines. |
528 |
// oif, is not specified |
| 529 |
rtentry = GetIpv4RouteInCache (header.GetDestination ()); |
529 |
if (!oif) |
| 530 |
// not in cache |
530 |
{ |
|
|
531 |
rtentry = GetIpv4RouteInCache (header.GetDestination ()); |
| 532 |
} |
| 533 |
// not in cache or a specified output |
| 534 |
// device is to be used |
| 531 |
if (!rtentry) |
535 |
if (!rtentry) |
| 532 |
{ |
536 |
{ |
| 533 |
NS_LOG_LOGIC ("Ipv4Route not in cache, build: "); |
537 |
NS_LOG_LOGIC ("Ipv4Route not in cache, build: "); |
| 534 |
Ipv4Address gatewayIp; |
538 |
Ipv4Address gatewayIp; |
| 535 |
uint32_t index = FindNetDeviceForNixIndex (nodeIndex, gatewayIp); |
539 |
uint32_t index = FindNetDeviceForNixIndex (nodeIndex, gatewayIp); |
|
|
540 |
int32_t interfaceIndex = 0; |
| 536 |
|
541 |
|
| 537 |
uint32_t interfaceIndex = (m_ipv4)->GetInterfaceForDevice(m_node->GetDevice(index)); |
542 |
if (!oif) |
|
|
543 |
{ |
| 544 |
interfaceIndex = (m_ipv4)->GetInterfaceForDevice(m_node->GetDevice(index)); |
| 545 |
} |
| 546 |
else |
| 547 |
{ |
| 548 |
interfaceIndex = (m_ipv4)->GetInterfaceForDevice(oif); |
| 549 |
} |
| 550 |
|
| 551 |
NS_ASSERT_MSG (interfaceIndex != -1, "Interface index not found for device"); |
| 552 |
|
| 538 |
Ipv4InterfaceAddress ifAddr = m_ipv4->GetAddress (interfaceIndex, 0); |
553 |
Ipv4InterfaceAddress ifAddr = m_ipv4->GetAddress (interfaceIndex, 0); |
| 539 |
|
554 |
|
| 540 |
// start filling in the Ipv4Route info |
555 |
// start filling in the Ipv4Route info |
|
Lines 543-549
Ipv4NixVectorRouting::RouteOutput (Ptr<P
|
Link Here
|
|---|
|
| 543 |
|
558 |
|
| 544 |
rtentry->SetGateway (gatewayIp); |
559 |
rtentry->SetGateway (gatewayIp); |
| 545 |
rtentry->SetDestination (header.GetDestination ()); |
560 |
rtentry->SetDestination (header.GetDestination ()); |
| 546 |
rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIndex)); |
561 |
|
|
|
562 |
if (!oif) |
| 563 |
{ |
| 564 |
rtentry->SetOutputDevice (m_ipv4->GetNetDevice (interfaceIndex)); |
| 565 |
} |
| 566 |
else |
| 567 |
{ |
| 568 |
rtentry->SetOutputDevice (oif); |
| 569 |
} |
| 547 |
|
570 |
|
| 548 |
sockerr = Socket::ERROR_NOTERROR; |
571 |
sockerr = Socket::ERROR_NOTERROR; |
| 549 |
|
572 |
|