diff --git a/src/routing/olsr/olsr-agent-impl.cc b/src/routing/olsr/olsr-agent-impl.cc index 72c99546c..4bf74910f 100644 --- a/src/routing/olsr/olsr-agent-impl.cc +++ b/src/routing/olsr/olsr-agent-impl.cc @@ -350,6 +350,8 @@ AgentImpl::RecvOlsr (Ptr socket, m_rxPacketTrace (olsrPacketHeader, messages); + m_state.SetModified (false); + for (MessageList::const_iterator messageIter = messages.begin (); messageIter != messages.end (); messageIter++) { @@ -446,7 +448,11 @@ AgentImpl::RecvOlsr (Ptr socket, } // After processing all OLSR messages, we must recompute the routing table - RoutingTableComputation (); + if (m_state.GetModified ()) + { + RoutingTableComputation (); + m_state.SetModified (false); + } } /// diff --git a/src/routing/olsr/olsr-state.cc b/src/routing/olsr/olsr-state.cc index a4ee3d892..b44dd8a82 100644 --- a/src/routing/olsr/olsr-state.cc +++ b/src/routing/olsr/olsr-state.cc @@ -127,6 +127,7 @@ OlsrState::EraseNeighborTuple (const NeighborTuple &tuple) if (*it == tuple) { m_neighborSet.erase (it); + m_modified = true; break; } } @@ -141,6 +142,7 @@ OlsrState::EraseNeighborTuple (const Ipv4Address &mainAddr) if (it->neighborMainAddr == mainAddr) { it = m_neighborSet.erase (it); + m_modified = true; break; } } @@ -156,6 +158,7 @@ OlsrState::InsertNeighborTuple (NeighborTuple const &tuple) { // Update it *it = tuple; + m_modified = true; return; } } @@ -189,6 +192,7 @@ OlsrState::EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple) if (*it == tuple) { m_twoHopNeighborSet.erase(it); + m_modified = true; break; } } @@ -206,6 +210,7 @@ OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr, { it = m_twoHopNeighborSet.erase (it); it--; // FIXME: is this correct in the case 'it' pointed to the first element? + m_modified = true; } } } @@ -219,13 +224,16 @@ OlsrState::EraseTwoHopNeighborTuples (const Ipv4Address &neighborMainAddr) if (it->neighborMainAddr == neighborMainAddr) { it = m_twoHopNeighborSet.erase (it); it--; + m_modified = true; } } } void -OlsrState::InsertTwoHopNeighborTuple (TwoHopNeighborTuple const &tuple){ +OlsrState::InsertTwoHopNeighborTuple (TwoHopNeighborTuple const &tuple) +{ m_twoHopNeighborSet.push_back (tuple); + m_modified = true; } /********** MPR Set Manipulation **********/ @@ -323,6 +331,7 @@ OlsrState::EraseLinkTuple (const LinkTuple &tuple) if (*it == tuple) { m_linkSet.erase (it); + m_modified = true; break; } } @@ -332,6 +341,7 @@ LinkTuple& OlsrState::InsertLinkTuple (LinkTuple const &tuple) { m_linkSet.push_back (tuple); + m_modified = true; return m_linkSet.back (); } @@ -371,6 +381,7 @@ OlsrState::EraseTopologyTuple(const TopologyTuple &tuple) if (*it == tuple) { m_topologySet.erase (it); + m_modified = true; break; } } @@ -386,6 +397,7 @@ OlsrState::EraseOlderTopologyTuples (const Ipv4Address &lastAddr, uint16_t ansn) { it = m_topologySet.erase (it); it--; + m_modified = true; } } } @@ -394,6 +406,7 @@ void OlsrState::InsertTopologyTuple (TopologyTuple const &tuple) { m_topologySet.push_back (tuple); + m_modified = true; } /********** Interface Association Set Manipulation **********/ @@ -431,6 +444,7 @@ OlsrState::EraseIfaceAssocTuple (const IfaceAssocTuple &tuple) if (*it == tuple) { m_ifaceAssocSet.erase (it); + m_modified = true; break; } } @@ -440,6 +454,7 @@ void OlsrState::InsertIfaceAssocTuple (const IfaceAssocTuple &tuple) { m_ifaceAssocSet.push_back (tuple); + m_modified = true; } std::vector diff --git a/src/routing/olsr/olsr-state.h b/src/routing/olsr/olsr-state.h index efebc810b..45ec80770 100644 --- a/src/routing/olsr/olsr-state.h +++ b/src/routing/olsr/olsr-state.h @@ -46,8 +46,29 @@ protected: DuplicateSet m_duplicateSet; ///< Duplicate Set (RFC 3626, section 3.4). IfaceAssocSet m_ifaceAssocSet; ///< Interface Association Set (RFC 3626, section 4.1). +// m_modified is set to true when any of the following databases is modified: +// - the link set, +// - the neighbor set, +// - the 2-hop neighbor set, +// - the topology set, +// - the Multiple Interface Association Information Base, + bool m_modified; + public: + OlsrState () + : m_modified (false) + {} + + bool GetModified () const + { + return m_modified; + } + void SetModified (bool modified) + { + m_modified = modified; + } + // MPR selector const MprSelectorSet & GetMprSelectors () const {