OLSR: get main address of the peer from the UDP source address and the 'interface association' table; this way the UDP source address need not be the same as the main address.
1.1 --- a/src/routing/olsr/olsr-agent-impl.cc Sun Feb 03 18:29:25 2008 +0000
1.2 +++ b/src/routing/olsr/olsr-agent-impl.cc Sun Feb 03 18:50:55 2008 +0000
1.3 @@ -346,32 +346,36 @@
1.4 DuplicateTuple *duplicated = m_state.FindDuplicateTuple
1.5 (messageHeader.GetOriginatorAddress (),
1.6 messageHeader.GetMessageSequenceNumber ());
1.7 +
1.8 + // Get main address of the peer, which may be different from the packet source address
1.9 + const IfaceAssocTuple *ifaceAssoc = m_state.FindIfaceAssocTuple (inetSourceAddr.GetIpv4 ());
1.10 + Ipv4Address peerMainAddress;
1.11 + if (ifaceAssoc != NULL)
1.12 + {
1.13 + peerMainAddress = ifaceAssoc->mainAddr;
1.14 + }
1.15 + else
1.16 + {
1.17 + peerMainAddress = inetSourceAddr.GetIpv4 () ;
1.18 + }
1.19
1.20 if (duplicated == NULL)
1.21 {
1.22 - // Note: normally inetSourceAddr.GetIpv4 () should be equal
1.23 - // to messageHeader.GetOriginatorAddress (), but something
1.24 - // was broken inside NS-3 UDP sockets and the ability to
1.25 - // override source address (via Bind()) is no longer
1.26 - // available. Bottom line is, OLSR packets are no longer
1.27 - // being sent with the main address, and to work around this
1.28 - // issue we look at the Originator Address field of OLSR
1.29 - // messages contained in the packet.
1.30 switch (messageHeader.GetMessageType ())
1.31 {
1.32 case olsr::MessageHeader::HELLO_MESSAGE:
1.33 NS_LOG_DEBUG ("OLSR node received HELLO message of size " << messageHeader.GetSerializedSize ());
1.34 - ProcessHello (messageHeader, m_mainAddress, messageHeader.GetOriginatorAddress ());
1.35 + ProcessHello (messageHeader, m_mainAddress, peerMainAddress);
1.36 break;
1.37
1.38 case olsr::MessageHeader::TC_MESSAGE:
1.39 NS_LOG_DEBUG ("OLSR node received TC message of size " << messageHeader.GetSerializedSize ());
1.40 - ProcessTc (messageHeader, messageHeader.GetOriginatorAddress ());
1.41 + ProcessTc (messageHeader, peerMainAddress);
1.42 break;
1.43
1.44 case olsr::MessageHeader::MID_MESSAGE:
1.45 NS_LOG_DEBUG ("OLSR node received MID message of size " << messageHeader.GetSerializedSize ());
1.46 - ProcessMid (messageHeader, messageHeader.GetOriginatorAddress ());
1.47 + ProcessMid (messageHeader, peerMainAddress);
1.48 break;
1.49
1.50 default:
1.51 @@ -404,7 +408,7 @@
1.52 // Remaining messages are also forwarded using the default algorithm.
1.53 if (messageHeader.GetMessageType () != olsr::MessageHeader::HELLO_MESSAGE)
1.54 ForwardDefault (messageHeader, duplicated,
1.55 - m_mainAddress, messageHeader.GetOriginatorAddress ());
1.56 + m_mainAddress, peerMainAddress);
1.57 }
1.58
1.59 }