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

(-)a/src/internet/model/arp-cache.cc (-12 / +54 lines)
 Lines 313-318   ArpCache::Add (Ipv4Address to) Link Here 
313
  return entry;
313
  return entry;
314
}
314
}
315
315
316
void
317
ArpCache::Remove (ArpCache::Entry *entry)
318
{
319
  NS_LOG_FUNCTION (this << entry);
320
  
321
  for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++)
322
    {
323
      if ((*i).second == entry)
324
        {
325
          m_arpCache.erase (i);
326
          entry->ClearPendingPacket (); //clear the pending packets for entry's ipaddress
327
          delete entry;
328
          return;
329
        }
330
    }
331
  NS_LOG_WARN ("Entry not found in this ARP Cache");
332
}
333
316
ArpCache::Entry::Entry (ArpCache *arp)
334
ArpCache::Entry::Entry (ArpCache *arp)
317
  : m_arp (arp),
335
  : m_arp (arp),
318
    m_state (ALIVE),
336
    m_state (ALIVE),
 Lines 340-351   ArpCache::Entry::IsWaitReply (void) Link Here 
340
  NS_LOG_FUNCTION (this);
358
  NS_LOG_FUNCTION (this);
341
  return (m_state == WAIT_REPLY) ? true : false;
359
  return (m_state == WAIT_REPLY) ? true : false;
342
}
360
}
361
bool
362
ArpCache::Entry::IsPermanent (void)
363
{
364
  NS_LOG_FUNCTION (this);
365
  return (m_state == PERMANENT) ? true : false;
366
}
343
367
344
368
345
void 
369
void 
346
ArpCache::Entry::MarkDead (void) 
370
ArpCache::Entry::MarkDead (void) 
347
{
371
{
348
  NS_LOG_FUNCTION (this);
372
  NS_LOG_FUNCTION (this);
373
  NS_ASSERT (m_state == ALIVE || m_state == WAIT_REPLY || m_state == DEAD);
349
  m_state = DEAD;
374
  m_state = DEAD;
350
  ClearRetries ();
375
  ClearRetries ();
351
  UpdateSeen ();
376
  UpdateSeen ();
 Lines 360-366   ArpCache::Entry::MarkAlive (Address macAddress) Link Here 
360
  ClearRetries ();
385
  ClearRetries ();
361
  UpdateSeen ();
386
  UpdateSeen ();
362
}
387
}
363
388
void
389
ArpCache::Entry::MarkPermanent (void)
390
{
391
  NS_LOG_FUNCTION (this);
392
  NS_ASSERT (m_state == ALIVE);
393
  m_state = PERMANENT;
394
  ClearRetries ();
395
  UpdateSeen ();
396
}
397
void 
398
ArpCache::Entry::MarkWaitReply (Ptr<Packet> waiting)
399
{
400
  NS_LOG_FUNCTION (this << waiting);
401
  NS_ASSERT (m_state == ALIVE || m_state == DEAD);
402
  NS_ASSERT (m_pending.empty ());
403
  m_state = WAIT_REPLY;
404
  m_pending.push_back (waiting);
405
  UpdateSeen ();
406
  m_arp->StartWaitReplyTimer ();
407
}
364
bool
408
bool
365
ArpCache::Entry::UpdateWaitReply (Ptr<Packet> waiting)
409
ArpCache::Entry::UpdateWaitReply (Ptr<Packet> waiting)
366
{
410
{
 Lines 377-393   ArpCache::Entry::UpdateWaitReply (Ptr<Packet> waiting) Link Here 
377
  m_pending.push_back (waiting);
421
  m_pending.push_back (waiting);
378
  return true;
422
  return true;
379
}
423
}
380
void 
424
381
ArpCache::Entry::MarkWaitReply (Ptr<Packet> waiting)
382
{
383
  NS_LOG_FUNCTION (this << waiting);
384
  NS_ASSERT (m_state == ALIVE || m_state == DEAD);
385
  NS_ASSERT (m_pending.empty ());
386
  m_state = WAIT_REPLY;
387
  m_pending.push_back (waiting);
388
  UpdateSeen ();
389
  m_arp->StartWaitReplyTimer ();
390
}
391
425
392
Address
426
Address
393
ArpCache::Entry::GetMacAddress (void) const
427
ArpCache::Entry::GetMacAddress (void) const
 Lines 418-423   ArpCache::Entry::GetTimeout (void) const Link Here 
418
      return m_arp->GetDeadTimeout ();
452
      return m_arp->GetDeadTimeout ();
419
    case ArpCache::Entry::ALIVE:
453
    case ArpCache::Entry::ALIVE:
420
      return m_arp->GetAliveTimeout ();
454
      return m_arp->GetAliveTimeout ();
455
    case ArpCache::Entry::PERMANENT:
456
      return Time::Max ();
421
    default:
457
    default:
422
      NS_ASSERT (false);
458
      NS_ASSERT (false);
423
      return Seconds (0);
459
      return Seconds (0);
 Lines 453-458   ArpCache::Entry::DequeuePending (void) Link Here 
453
    }
489
    }
454
}
490
}
455
void 
491
void 
492
ArpCache::Entry::ClearPendingPacket (void)
493
{
494
  NS_LOG_FUNCTION (this);
495
  m_pending.clear ();
496
}
497
void 
456
ArpCache::Entry::UpdateSeen (void)
498
ArpCache::Entry::UpdateSeen (void)
457
{
499
{
458
  NS_LOG_FUNCTION (this);
500
  NS_LOG_FUNCTION (this);
(-)a/src/internet/model/arp-cache.h (-2 / +20 lines)
 Lines 151-156   public: Link Here 
151
   */
151
   */
152
  ArpCache::Entry *Add (Ipv4Address to);
152
  ArpCache::Entry *Add (Ipv4Address to);
153
  /**
153
  /**
154
   * \brief Remove an entry.
155
   * \param entry pointer to delete it from the list
156
   */
157
  void Remove (ArpCache::Entry *entry);
158
  /**
154
   * \brief Clear the ArpCache of all entries
159
   * \brief Clear the ArpCache of all entries
155
   */
160
   */
156
  void Flush (void);
161
  void Flush (void);
 Lines 186-191   public: Link Here 
186
     */
191
     */
187
    void MarkWaitReply (Ptr<Packet> waiting);
192
    void MarkWaitReply (Ptr<Packet> waiting);
188
    /**
193
    /**
194
     * \brief Changes the state of this entry to Permanent if it was Alive
195
     */
196
    void MarkPermanent (void);
197
    /**
189
     * \param waiting
198
     * \param waiting
190
     * \return 
199
     * \return 
191
     */
200
     */
 Lines 202-211   public: Link Here 
202
     * \return True if the state of this entry is wait_reply; false otherwise.
211
     * \return True if the state of this entry is wait_reply; false otherwise.
203
     */
212
     */
204
    bool IsWaitReply (void);
213
    bool IsWaitReply (void);
205
214
    /**
215
     * \return True if the state of this entry is permanent; false otherwise.
216
     */
217
    bool IsPermanent (void); 
206
    /**
218
    /**
207
     * \return The MacAddress of this entry
219
     * \return The MacAddress of this entry
208
     */
220
     */
221
    
209
    Address GetMacAddress (void) const;
222
    Address GetMacAddress (void) const;
210
    /**
223
    /**
211
     * \return The Ipv4Address for this entry
224
     * \return The Ipv4Address for this entry
 Lines 228-233   public: Link Here 
228
     */
241
     */
229
    Ptr<Packet> DequeuePending (void);
242
    Ptr<Packet> DequeuePending (void);
230
    /**
243
    /**
244
     * \brief Clear the pending packet list
245
     */
246
    void ClearPendingPacket (void);
247
    /**
231
     * \returns number of retries that have been sent for an ArpRequest
248
     * \returns number of retries that have been sent for an ArpRequest
232
     *  in WaitReply state.
249
     *  in WaitReply state.
233
     */
250
     */
 Lines 248-254   private: Link Here 
248
    enum ArpCacheEntryState_e {
265
    enum ArpCacheEntryState_e {
249
      ALIVE,
266
      ALIVE,
250
      WAIT_REPLY,
267
      WAIT_REPLY,
251
      DEAD
268
      DEAD,
269
      PERMANENT
252
    };
270
    };
253
271
254
    /**
272
    /**

Return to bug 2145