In OLSR agent, work around newly introduced bug in UDP sockets prenting Bind from working as e.g. Linux. Add note explaining what's wrong.
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Fri Feb 01 18:07:45 2008 +0000 (2008-02-01)
changeset 229615c4fbd9c7c6
parent 2295 39452dbe604b
child 2297 127c9adfd39f
In OLSR agent, work around newly introduced bug in UDP sockets prenting Bind from working as e.g. Linux. Add note explaining what's wrong.
src/routing/olsr/olsr-agent-impl.cc
     1.1 --- a/src/routing/olsr/olsr-agent-impl.cc	Fri Feb 01 17:17:24 2008 +0000
     1.2 +++ b/src/routing/olsr/olsr-agent-impl.cc	Fri Feb 01 18:07:45 2008 +0000
     1.3 @@ -167,6 +167,7 @@
     1.4    m_tcTimer (Timer::CANCEL_ON_DESTROY),
     1.5    m_midTimer (Timer::CANCEL_ON_DESTROY)
     1.6  {
     1.7 +  NS_LOG_DEBUG ("Created olsr::AgentImpl");
     1.8    m_helloTimer.SetFunction (&AgentImpl::HelloTimerExpire, this);
     1.9    m_tcTimer.SetFunction (&AgentImpl::TcTimerExpire, this);
    1.10    m_midTimer.SetFunction (&AgentImpl::MidTimerExpire, this);
    1.11 @@ -348,21 +349,29 @@
    1.12        
    1.13        if (duplicated == NULL)
    1.14          {
    1.15 +          // Note: normally inetSourceAddr.GetIpv4 () should be equal
    1.16 +          // to messageHeader.GetOriginatorAddress (), but something
    1.17 +          // was broken inside NS-3 UDP sockets and the ability to
    1.18 +          // override source address (via Bind()) is no longer
    1.19 +          // available.  Bottom line is, OLSR packets are no longer
    1.20 +          // being sent with the main address, and to work around this
    1.21 +          // issue we look at the Originator Address field of OLSR
    1.22 +          // messages contained in the packet.
    1.23            switch (messageHeader.GetMessageType ())
    1.24              {
    1.25              case olsr::MessageHeader::HELLO_MESSAGE:
    1.26                NS_LOG_DEBUG ("OLSR node received HELLO message of size " << messageHeader.GetSerializedSize ());
    1.27 -              ProcessHello (messageHeader, m_mainAddress, inetSourceAddr.GetIpv4 ());
    1.28 +              ProcessHello (messageHeader, m_mainAddress, messageHeader.GetOriginatorAddress ());
    1.29                break;
    1.30  
    1.31              case olsr::MessageHeader::TC_MESSAGE:
    1.32                NS_LOG_DEBUG ("OLSR node received TC message of size " << messageHeader.GetSerializedSize ());
    1.33 -              ProcessTc (messageHeader, inetSourceAddr.GetIpv4 ());
    1.34 +              ProcessTc (messageHeader, messageHeader.GetOriginatorAddress ());
    1.35                break;
    1.36  
    1.37              case olsr::MessageHeader::MID_MESSAGE:
    1.38                NS_LOG_DEBUG ("OLSR node received MID message of size " << messageHeader.GetSerializedSize ());
    1.39 -              ProcessMid (messageHeader, inetSourceAddr.GetIpv4 ());
    1.40 +              ProcessMid (messageHeader, messageHeader.GetOriginatorAddress ());
    1.41                break;
    1.42  
    1.43              default:
    1.44 @@ -395,7 +404,7 @@
    1.45            // Remaining messages are also forwarded using the default algorithm.
    1.46            if (messageHeader.GetMessageType ()  != olsr::MessageHeader::HELLO_MESSAGE)
    1.47              ForwardDefault (messageHeader, duplicated,
    1.48 -                            m_mainAddress, inetSourceAddr.GetIpv4 ());
    1.49 +                            m_mainAddress, messageHeader.GetOriginatorAddress ());
    1.50          }
    1.51  	
    1.52      }
    1.53 @@ -775,13 +784,13 @@
    1.54          {
    1.55            RoutingTableEntry entry;
    1.56            bool foundEntry = m_routingTable->Lookup (nb2hop_tuple.neighborMainAddr, entry);
    1.57 -          if (!foundEntry)
    1.58 -            NS_FATAL_ERROR ("m_routingTable->Lookup failure");
    1.59 -
    1.60 -          m_routingTable->AddEntry (nb2hop_tuple.twoHopNeighborAddr,
    1.61 -                                    entry.nextAddr,
    1.62 -                                    entry.interface,
    1.63 -                                    2);
    1.64 +          if (foundEntry)
    1.65 +            {
    1.66 +              m_routingTable->AddEntry (nb2hop_tuple.twoHopNeighborAddr,
    1.67 +                                        entry.nextAddr,
    1.68 +                                        entry.interface,
    1.69 +                                        2);
    1.70 +            }
    1.71          }
    1.72      }
    1.73