View | Details | Raw Unified | Return to bug 407
Collapse All | Expand All

(-)olsr/olsr-repositories.h (+56 lines)
 Lines 231-236   operator << (std::ostream &os, const Top Link Here 
231
  return os;
231
  return os;
232
}
232
}
233
233
234
/// Association
235
struct Association
236
{
237
  Ipv4Address networkAddr;
238
  Ipv4Mask netmask;
239
};
240
241
static inline bool
242
operator == (const Association &a, const Association &b)
243
{
244
  return (a.networkAddr == b.networkAddr
245
          && a.netmask == b.netmask);
246
}
247
248
static inline std::ostream&
249
operator << (std::ostream &os, const Association &tuple)
250
{
251
  os << "Association(networkAddr=" << tuple.networkAddr
252
     << ", netmask=" << tuple.netmask
253
     << ")";
254
  return os;
255
}
256
257
/// An Association Tuple
258
struct AssociationTuple
259
{
260
  /// Main address of the gateway.
261
  Ipv4Address gatewayAddr;
262
  /// Network Address of network reachable through gatewayAddr
263
  Ipv4Address networkAddr;
264
  /// Netmask of network reachable through gatewayAddr
265
  Ipv4Mask netmask;
266
  /// Time at which this tuple expires and must be removed
267
  Time expirationTime;
268
};
269
270
static inline bool
271
operator == (const AssociationTuple &a, const AssociationTuple &b)
272
{
273
  return (a.gatewayAddr == b.gatewayAddr
274
          && a.networkAddr == b.networkAddr
275
          && a.netmask == b.netmask);
276
}
277
278
static inline std::ostream&
279
operator << (std::ostream &os, const AssociationTuple &tuple)
280
{
281
  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
282
     << ", networkAddr=" << tuple.networkAddr
283
     << ", netmask=" << tuple.netmask
284
     << ", expirationTime=" << tuple.expirationTime
285
     << ")";
286
  return os;
287
}
234
288
235
typedef std::set<Ipv4Address> 			MprSet;	///< MPR Set type.
289
typedef std::set<Ipv4Address> 			MprSet;	///< MPR Set type.
236
typedef std::vector<MprSelectorTuple>		MprSelectorSet;	///< MPR Selector Set type.
290
typedef std::vector<MprSelectorTuple>		MprSelectorSet;	///< MPR Selector Set type.
 Lines 240-245   typedef std::vector<TwoHopNeighborTuple> Link Here 
240
typedef std::vector<TopologyTuple>		TopologySet;	///< Topology Set type.
294
typedef std::vector<TopologyTuple>		TopologySet;	///< Topology Set type.
241
typedef std::vector<DuplicateTuple>		DuplicateSet;	///< Duplicate Set type.
295
typedef std::vector<DuplicateTuple>		DuplicateSet;	///< Duplicate Set type.
242
typedef std::vector<IfaceAssocTuple>		IfaceAssocSet; ///< Interface Association Set type.
296
typedef std::vector<IfaceAssocTuple>		IfaceAssocSet; ///< Interface Association Set type.
297
typedef std::vector<AssociationTuple>		AssociationSet; ///< Association Set type.
298
typedef std::vector<Association>		Associations; ///< Association Set type.
243
299
244
300
245
}}; // namespace ns3, olsr
301
}}; // namespace ns3, olsr
(-)olsr/olsr-routing-protocol.cc (-1 / +211 lines)
 Lines 79-84    Link Here 
79
#define OLSR_DUP_HOLD_TIME	Seconds (30)
79
#define OLSR_DUP_HOLD_TIME	Seconds (30)
80
/// MID holding time.
80
/// MID holding time.
81
#define OLSR_MID_HOLD_TIME	(Scalar (3) * m_midInterval)
81
#define OLSR_MID_HOLD_TIME	(Scalar (3) * m_midInterval)
82
/// HNA holding time.
83
#define OLSR_HNA_HOLD_TIME  (Scalar (3) * m_hnaInterval)
82
84
83
85
84
/********** Link types **********/
86
/********** Link types **********/
 Lines 165-170   RoutingProtocol::GetTypeId (void) Link Here 
165
                   TimeValue (Seconds (5)),
167
                   TimeValue (Seconds (5)),
166
                   MakeTimeAccessor (&RoutingProtocol::m_midInterval),
168
                   MakeTimeAccessor (&RoutingProtocol::m_midInterval),
167
                   MakeTimeChecker ())
169
                   MakeTimeChecker ())
170
    .AddAttribute ("HnaInterval", "HNA messages emission interval.  Normally it is equal to TcInterval.",
171
                   TimeValue (Seconds (5)),
172
                   MakeTimeAccessor (&RoutingProtocol::m_hnaInterval),
173
                   MakeTimeChecker ())
168
    .AddAttribute ("Willingness", "Willingness of a node to carry and forward traffic for other nodes.",
174
    .AddAttribute ("Willingness", "Willingness of a node to carry and forward traffic for other nodes.",
169
                   EnumValue (OLSR_WILL_DEFAULT),
175
                   EnumValue (OLSR_WILL_DEFAULT),
170
                   MakeEnumAccessor (&RoutingProtocol::m_willingness),
176
                   MakeEnumAccessor (&RoutingProtocol::m_willingness),
 Lines 189-194   RoutingProtocol::RoutingProtocol () Link Here 
189
    m_helloTimer (Timer::CANCEL_ON_DESTROY),
195
    m_helloTimer (Timer::CANCEL_ON_DESTROY),
190
    m_tcTimer (Timer::CANCEL_ON_DESTROY),
196
    m_tcTimer (Timer::CANCEL_ON_DESTROY),
191
    m_midTimer (Timer::CANCEL_ON_DESTROY),
197
    m_midTimer (Timer::CANCEL_ON_DESTROY),
198
    m_hnaTimer (Timer::CANCEL_ON_DESTROY),
192
    m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
199
    m_queuedMessagesTimer (Timer::CANCEL_ON_DESTROY)
193
{}
200
{}
194
201
 Lines 204-209   RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4 Link Here 
204
  m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
211
  m_helloTimer.SetFunction (&RoutingProtocol::HelloTimerExpire, this);
205
  m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this);
212
  m_tcTimer.SetFunction (&RoutingProtocol::TcTimerExpire, this);
206
  m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this);
213
  m_midTimer.SetFunction (&RoutingProtocol::MidTimerExpire, this);
214
  m_hnaTimer.SetFunction (&RoutingProtocol::HnaTimerExpire, this);
207
  m_queuedMessagesTimer.SetFunction (&RoutingProtocol::SendQueuedMessages, this);
215
  m_queuedMessagesTimer.SetFunction (&RoutingProtocol::SendQueuedMessages, this);
208
216
209
  m_packetSequenceNumber = OLSR_MAX_SEQ_NUM;
217
  m_packetSequenceNumber = OLSR_MAX_SEQ_NUM;
 Lines 284-289   void RoutingProtocol::DoStart () Link Here 
284
  HelloTimerExpire ();
292
  HelloTimerExpire ();
285
  TcTimerExpire ();
293
  TcTimerExpire ();
286
  MidTimerExpire ();
294
  MidTimerExpire ();
295
  HnaTimerExpire ();
287
296
288
  NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
297
  NS_LOG_DEBUG ("OLSR on node " << m_mainAddress << " started");
289
}
298
}
 Lines 398-403   RoutingProtocol::RecvOlsr (Ptr<Socket> s Link Here 
398
              ProcessMid (messageHeader, senderIfaceAddr);
407
              ProcessMid (messageHeader, senderIfaceAddr);
399
              break;
408
              break;
400
409
410
            case olsr::MessageHeader::HNA_MESSAGE:
411
              NS_LOG_DEBUG (Simulator::Now ().GetSeconds ()
412
                            << "s OLSR node " << m_mainAddress
413
                            <<  " received HNA message of size " << messageHeader.GetSerializedSize ());
414
              ProcessHna (messageHeader, senderIfaceAddr);
415
              break;        
401
            default:
416
            default:
402
              NS_LOG_DEBUG ("OLSR message type " <<
417
              NS_LOG_DEBUG ("OLSR message type " <<
403
                        int (messageHeader.GetMessageType ()) <<
418
                        int (messageHeader.GetMessageType ()) <<
 Lines 1038-1043   RoutingProtocol::RoutingTableComputation Link Here 
1038
                    entry1.distance);
1053
                    entry1.distance);
1039
        }
1054
        }
1040
    }
1055
    }
1056
    
1057
  // 5. For each tuple in the association set,
1058
  //    If there is no entry in the routing table with:
1059
  //        R_dest_addr     == A_network_addr/A_netmask
1060
  //   then a new routing entry is created.
1061
  const AssociationSet &associationSet = m_state.GetAssociationSet ();
1062
  for (AssociationSet::const_iterator it = associationSet.begin ();
1063
       it != associationSet.end (); it++)
1064
    {
1065
      AssociationTuple const &tuple = *it;
1066
      RoutingTableEntry entry1, entry2;
1067
      
1068
      bool have_entry1 = Lookup (tuple.networkAddr.CombineMask (tuple.netmask), entry1);
1069
      bool have_entry2 = Lookup (tuple.gatewayAddr, entry2);
1070
      bool to_add = false;
1071
      
1072
      if (!have_entry1)
1073
        {
1074
          to_add = true;
1075
        }
1076
      else if(have_entry2 && entry1.distance > entry2.distance)
1077
        {
1078
           RemoveEntry(tuple.networkAddr.CombineMask (tuple.netmask));
1079
           to_add = true;           
1080
        }
1081
        
1082
      if(to_add == true)
1083
        {
1084
          AddEntry (tuple.networkAddr.CombineMask (tuple.netmask),
1085
                    entry2.nextAddr,
1086
                    entry2.interface,
1087
                    entry2.distance);
1088
        }
1089
    }
1041
1090
1042
  NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end.");
1091
  NS_LOG_DEBUG ("Node " << m_mainAddress << ": RoutingTableComputation end.");
1043
  m_routingTableChanged (GetSize ());
1092
  m_routingTableChanged (GetSize ());
 Lines 1280-1285   RoutingProtocol::ProcessMid (const olsr: Link Here 
1280
  NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END.");
1329
  NS_LOG_DEBUG ("Node " << m_mainAddress << " ProcessMid from " << senderIface << " -> END.");
1281
}
1330
}
1282
1331
1332
///
1333
/// \brief Processes a HNA message following RFC 3626 specification.
1334
///
1335
/// The Host Network Association Set is updated (if needed) with the information
1336
/// of the received HNA message.
1337
///
1338
/// \param msg the %OLSR message which contains the HNA message.
1339
/// \param sender_iface the address of the interface where the message was sent from.
1340
///
1341
void
1342
RoutingProtocol::ProcessHna (const olsr::MessageHeader &msg,
1343
                       const Ipv4Address &senderIface)
1344
{
1345
  const olsr::MessageHeader::Hna &hna = msg.GetHna ();
1346
  Time now = Simulator::Now ();
1347
  
1348
  // 1. If the sender interface of this message is not in the symmetric
1349
  // 1-hop neighborhood of this node, the message MUST be discarded.
1350
  const LinkTuple *link_tuple = m_state.FindSymLinkTuple (senderIface, now);
1351
  if (link_tuple == NULL)
1352
    return;
1353
  
1354
  // 2. Otherwise, for each (network address, netmask) pair in the
1355
  // message:
1356
  
1357
  for (std::vector<olsr::MessageHeader::Hna::Association>::const_iterator it = hna.associations.begin();
1358
       it != hna.associations.end() ; it++)
1359
    {
1360
      AssociationTuple *tuple = m_state.FindAssociationTuple(msg.GetOriginatorAddress(),it->address,it->mask);
1361
  
1362
      // 2.1  if an entry in the association set already exists, where:
1363
      //          A_gateway_addr == originator address
1364
      //          A_network_addr == network address
1365
      //          A_netmask      == netmask
1366
      //      then the holding time for that tuple MUST be set to:
1367
      //          A_time         =  current time + validity time
1368
      
1369
      if(tuple != NULL)
1370
        {
1371
          tuple->expirationTime = now + msg.GetVTime ();
1372
        }
1373
        
1374
      // 2.2 otherwise, a new tuple MUST be recorded with:
1375
      //          A_gateway_addr =  originator address
1376
      //          A_network_addr =  network address
1377
      //          A_netmask      =  netmask
1378
      //          A_time         =  current time + validity time
1379
      
1380
      else
1381
        {
1382
          const AssociationTuple &assocTuple = (AssociationTuple){msg.GetOriginatorAddress(),it->address,it->mask,now + msg.GetVTime ()};
1383
          
1384
          AddAssociationTuple (assocTuple);
1385
          
1386
          //Schedule Association Tuple deletion
1387
          Simulator::Schedule (DELAY (assocTuple.expirationTime),
1388
                               &RoutingProtocol::AssociationTupleTimerExpire, this,
1389
                               assocTuple.gatewayAddr,assocTuple.networkAddr,assocTuple.netmask);
1390
        }
1391
        
1392
    }
1393
}
1283
1394
1284
///
1395
///
1285
/// \brief OLSR's default forwarding algorithm.
1396
/// \brief OLSR's default forwarding algorithm.
 Lines 1622-1627   RoutingProtocol::SendMid () Link Here 
1622
}
1733
}
1623
1734
1624
///
1735
///
1736
/// \brief Creates a new %OLSR HNA message which is buffered for being sent later on.
1737
///
1738
void
1739
RoutingProtocol::SendHna ()
1740
{
1741
  olsr::MessageHeader msg;
1742
1743
  msg.SetVTime (OLSR_HNA_HOLD_TIME);
1744
  msg.SetOriginatorAddress (m_mainAddress);
1745
  msg.SetTimeToLive (255);
1746
  msg.SetHopCount (0);
1747
  msg.SetMessageSequenceNumber (GetMessageSequenceNumber ());
1748
  olsr::MessageHeader::Hna &hna = msg.GetHna ();
1749
  
1750
  std::vector<olsr::MessageHeader::Hna::Association>
1751
    &associations = hna.associations;
1752
  
1753
  // Pack all host-network associations into the packet's associations vector
1754
  for (Associations::const_iterator it = m_state.GetHostNetAssocSet ().begin ();
1755
        it != m_state.GetHostNetAssocSet ().end (); it++)
1756
    {
1757
      associations.push_back((olsr::MessageHeader::Hna::Association){it->networkAddr,it->netmask});
1758
    }
1759
    
1760
  if(associations.size () == 0)
1761
    return;
1762
  
1763
  QueueMessage (msg, JITTER);
1764
}
1765
1766
///
1767
/// \brief Injects a (networkAddr, netmask) tuple for which the node
1768
///        can generate an HNA message for
1769
///
1770
void
1771
RoutingProtocol::InjectRoute (Ipv4Address networkAddr, Ipv4Mask netmask)
1772
{
1773
  m_state.InsertHostNetAssociation ((Association) {networkAddr, netmask});
1774
}
1775
1776
///
1625
/// \brief	Updates Link Set according to a new received HELLO message (following RFC 3626
1777
/// \brief	Updates Link Set according to a new received HELLO message (following RFC 3626
1626
///		specification). Neighbor Set is also updated if needed.
1778
///		specification). Neighbor Set is also updated if needed.
1627
void
1779
void
 Lines 2301-2306   RoutingProtocol::RemoveIfaceAssocTuple ( Link Here 
2301
  m_state.EraseIfaceAssocTuple (tuple);
2453
  m_state.EraseIfaceAssocTuple (tuple);
2302
}
2454
}
2303
2455
2456
///
2457
/// \brief Adds a host network association tuple to the Association Set.
2458
///
2459
/// \param tuple the host network association tuple to be added.
2460
///
2461
void
2462
RoutingProtocol::AddAssociationTuple (const AssociationTuple &tuple)
2463
{
2464
  m_state.InsertAssociationTuple (tuple);
2465
}
2466
2467
///
2468
/// \brief Removes a host network association tuple from the Association Set.
2469
///
2470
/// \param tuple the host network association tuple to be removed.
2471
///
2472
void
2473
RoutingProtocol::RemoveAssociationTuple (const AssociationTuple &tuple)
2474
{
2475
  m_state.EraseAssociationTuple (tuple);
2476
}
2477
2304
2478
2305
uint16_t RoutingProtocol::GetPacketSequenceNumber ()
2479
uint16_t RoutingProtocol::GetPacketSequenceNumber ()
2306
{
2480
{
 Lines 2347-2353   RoutingProtocol::TcTimerExpire () Link Here 
2347
2521
2348
///
2522
///
2349
/// \brief Sends a MID message (if the node has more than one interface) and resets the MID timer.
2523
/// \brief Sends a MID message (if the node has more than one interface) and resets the MID timer.
2350
/// \warning Currently it does nothing because there is no support for multiple interfaces.
2351
/// \param e The event which has expired.
2524
/// \param e The event which has expired.
2352
///
2525
///
2353
void
2526
void
 Lines 2358-2363   RoutingProtocol::MidTimerExpire () Link Here 
2358
}
2531
}
2359
2532
2360
///
2533
///
2534
/// \brief Sends an HNA message (if the node implements support for non-OLSR interfaces).
2535
/// \warning Currently it does nothing because there is no support for mixed interfaces.
2536
/// \param e The event which has expired.
2537
///
2538
void
2539
RoutingProtocol::HnaTimerExpire ()
2540
{
2541
  SendHna ();
2542
  m_hnaTimer.Schedule (m_hnaInterval);
2543
}
2544
2545
///
2361
/// \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime.
2546
/// \brief Removes tuple if expired. Else timer is rescheduled to expire at tuple.expirationTime.
2362
///
2547
///
2363
/// The task of actually removing the tuple is left to the OLSR agent.
2548
/// The task of actually removing the tuple is left to the OLSR agent.
 Lines 2538-2543   RoutingProtocol::IfaceAssocTupleTimerExp Link Here 
2538
}
2723
}
2539
2724
2540
///
2725
///
2726
/// \brief Removes tuple_ if expired. Else timer is rescheduled to expire at tuple_->time().
2727
/// \warning Actually this is never invoked because there is no support for mixed interfaces.
2728
/// \param e The event which has expired.
2729
///
2730
void
2731
RoutingProtocol::AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask)
2732
{
2733
  AssociationTuple *tuple = m_state.FindAssociationTuple (gatewayAddr, networkAddr, netmask);
2734
  if (tuple == NULL)
2735
    {
2736
      return;
2737
    }
2738
  if (tuple->expirationTime < Simulator::Now ())
2739
    {
2740
      RemoveAssociationTuple (*tuple);
2741
    }
2742
  else
2743
    {
2744
      m_events.Track (Simulator::Schedule (DELAY (tuple->expirationTime),
2745
                                           &RoutingProtocol::AssociationTupleTimerExpire,
2746
                                           this, gatewayAddr, networkAddr, netmask));
2747
    }
2748
}
2749
2750
///
2541
/// \brief Clears the routing table and frees the memory assigned to each one of its entries.
2751
/// \brief Clears the routing table and frees the memory assigned to each one of its entries.
2542
///
2752
///
2543
void
2753
void
(-)olsr/olsr-routing-protocol.h (+16 lines)
 Lines 123-128   private: Link Here 
123
  Time m_tcInterval;
123
  Time m_tcInterval;
124
  /// MID messages' emission interval.
124
  /// MID messages' emission interval.
125
  Time m_midInterval;
125
  Time m_midInterval;
126
  /// HNA messages' emission interval.
127
  Time m_hnaInterval;
126
  /// Willingness for forwarding packets on behalf of other nodes.
128
  /// Willingness for forwarding packets on behalf of other nodes.
127
  uint8_t m_willingness;
129
  uint8_t m_willingness;
128
	
130
	
 Lines 185-190   private: Link Here 
185
  Timer m_midTimer;
187
  Timer m_midTimer;
186
  void MidTimerExpire ();
188
  void MidTimerExpire ();
187
189
190
  Timer m_hnaTimer;
191
  void HnaTimerExpire ();
192
188
  void DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber);
193
  void DupTupleTimerExpire (Ipv4Address address, uint16_t sequenceNumber);
189
  bool m_linkTupleTimerFirstTime;
194
  bool m_linkTupleTimerFirstTime;
190
  void LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr);
195
  void LinkTupleTimerExpire (Ipv4Address neighborIfaceAddr);
 Lines 192-197   private: Link Here 
192
  void MprSelTupleTimerExpire (Ipv4Address mainAddr);
197
  void MprSelTupleTimerExpire (Ipv4Address mainAddr);
193
  void TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr);
198
  void TopologyTupleTimerExpire (Ipv4Address destAddr, Ipv4Address lastAddr);
194
  void IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr);
199
  void IfaceAssocTupleTimerExpire (Ipv4Address ifaceAddr);
200
  void AssociationTupleTimerExpire (Ipv4Address gatewayAddr, Ipv4Address networkAddr, Ipv4Mask netmask);
195
201
196
  void IncrementAnsn ();
202
  void IncrementAnsn ();
197
203
 Lines 208-213   private: Link Here 
208
  void SendHello ();
214
  void SendHello ();
209
  void SendTc ();
215
  void SendTc ();
210
  void SendMid ();
216
  void SendMid ();
217
  void SendHna ();
211
218
212
  void NeighborLoss (const LinkTuple &tuple);
219
  void NeighborLoss (const LinkTuple &tuple);
213
  void AddDuplicateTuple (const DuplicateTuple &tuple);
220
  void AddDuplicateTuple (const DuplicateTuple &tuple);
 Lines 225-230   private: Link Here 
225
  void RemoveTopologyTuple (const TopologyTuple &tuple);
232
  void RemoveTopologyTuple (const TopologyTuple &tuple);
226
  void AddIfaceAssocTuple (const IfaceAssocTuple &tuple);
233
  void AddIfaceAssocTuple (const IfaceAssocTuple &tuple);
227
  void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple);
234
  void RemoveIfaceAssocTuple (const IfaceAssocTuple &tuple);
235
  void AddAssociationTuple (const AssociationTuple &tuple);
236
  void RemoveAssociationTuple (const AssociationTuple &tuple);
228
237
229
  void ProcessHello (const olsr::MessageHeader &msg,
238
  void ProcessHello (const olsr::MessageHeader &msg,
230
                     const Ipv4Address &receiverIface,
239
                     const Ipv4Address &receiverIface,
 Lines 233-238   private: Link Here 
233
                  const Ipv4Address &senderIface);
242
                  const Ipv4Address &senderIface);
234
  void ProcessMid (const olsr::MessageHeader &msg,
243
  void ProcessMid (const olsr::MessageHeader &msg,
235
                   const Ipv4Address &senderIface);
244
                   const Ipv4Address &senderIface);
245
  void ProcessHna (const olsr::MessageHeader &msg,
246
		   const Ipv4Address &senderIface);
236
247
237
  void LinkSensing (const olsr::MessageHeader &msg,
248
  void LinkSensing (const olsr::MessageHeader &msg,
238
                    const olsr::MessageHeader::Hello &hello,
249
                    const olsr::MessageHeader::Hello &hello,
 Lines 246-251   private: Link Here 
246
                               const olsr::MessageHeader::Hello &hello);
257
                               const olsr::MessageHeader::Hello &hello);
247
258
248
  int Degree (NeighborTuple const &tuple);
259
  int Degree (NeighborTuple const &tuple);
260
261
  /// Inject Route to be sent in HNA message
262
263
  void InjectRoute (Ipv4Address networkAddr, Ipv4Mask netmask);
264
249
  /// Check that address is one of my interfaces
265
  /// Check that address is one of my interfaces
250
  bool IsMyOwnAddress (const Ipv4Address & a) const;
266
  bool IsMyOwnAddress (const Ipv4Address & a) const;
251
267
(-)olsr/olsr-state.cc (+57 lines)
 Lines 487-490   OlsrState::FindNeighborInterfaces (const Link Here 
487
  return retval;
487
  return retval;
488
}
488
}
489
489
490
/********** Host-Network Association Set Manipulation **********/
491
492
AssociationTuple*
493
OlsrState::FindAssociationTuple (const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
494
{
495
  for (AssociationSet::iterator it = m_associationSet.begin ();
496
	it != m_associationSet.end (); it++)
497
    {
498
      if (it->gatewayAddr == gatewayAddr and it->networkAddr == networkAddr and it->netmask == netmask)
499
        {
500
          return &(*it);
501
        }
502
    }
503
   return NULL;
504
}
505
506
void
507
OlsrState::EraseAssociationTuple (const AssociationTuple &tuple)
508
{
509
  for (AssociationSet::iterator it = m_associationSet.begin ();
510
       it != m_associationSet.end (); it++)
511
    {
512
      if (*it == tuple)
513
        {
514
          m_associationSet.erase (it);
515
          break;
516
        }
517
    }
518
}
519
520
void
521
OlsrState::InsertAssociationTuple (const AssociationTuple &tuple)
522
{
523
  m_associationSet.push_back (tuple);
524
}
525
526
527
void
528
OlsrState::EraseHostNetAssociation (const Association &tuple)
529
{
530
  for (Associations::iterator it = m_hostNetAssocSet.begin ();
531
       it != m_hostNetAssocSet.end (); it++)
532
    {
533
      if (*it == tuple)
534
        {
535
          m_hostNetAssocSet.erase (it);
536
          break;
537
        }
538
    }
539
}
540
541
void
542
OlsrState::InsertHostNetAssociation (const Association &tuple)
543
{
544
  m_hostNetAssocSet.push_back(tuple);
545
}
546
490
} // namespace ns3
547
} // namespace ns3
(-)olsr/olsr-state.h (+21 lines)
 Lines 45-50   protected: Link Here 
45
  MprSelectorSet m_mprSelectorSet;	///< MPR Selector Set (RFC 3626, section 4.3.4).
45
  MprSelectorSet m_mprSelectorSet;	///< MPR Selector Set (RFC 3626, section 4.3.4).
46
  DuplicateSet m_duplicateSet;	///< Duplicate Set (RFC 3626, section 3.4).
46
  DuplicateSet m_duplicateSet;	///< Duplicate Set (RFC 3626, section 3.4).
47
  IfaceAssocSet m_ifaceAssocSet;	///< Interface Association Set (RFC 3626, section 4.1).
47
  IfaceAssocSet m_ifaceAssocSet;	///< Interface Association Set (RFC 3626, section 4.1).
48
  AssociationSet m_associationSet;	///< Association Set (RFC 3626, section 12.2)
49
  Associations m_hostNetAssocSet;	///< The set of associations a node has
48
50
49
public:
51
public:
50
52
 Lines 147-152   public: Link Here 
147
  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
149
  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
148
  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
150
  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
149
151
152
  // Host-Network Association
153
  const AssociationSet & GetAssociationSet () const  // Associations known to the node
154
  {
155
    return m_associationSet;
156
  }
157
158
  const Associations & GetHostNetAssocSet () const  // Set of associations that the node has
159
  {
160
    return m_hostNetAssocSet;
161
  }
162
163
  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr,\
164
					  const Ipv4Address &networkAddr,\
165
					  const Ipv4Mask &netmask);
166
  void EraseAssociationTuple (const AssociationTuple &tuple);
167
  void InsertAssociationTuple (const AssociationTuple &tuple);
168
  void EraseHostNetAssociation (const Association &tuple);
169
  void InsertHostNetAssociation (const Association &tuple);
170
150
  // Returns a vector of all interfaces of a given neighbor, with the
171
  // Returns a vector of all interfaces of a given neighbor, with the
151
  // exception of the "main" one.
172
  // exception of the "main" one.
152
  std::vector<Ipv4Address>
173
  std::vector<Ipv4Address>

Return to bug 407