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

(-)a/src/internet-stack/ipv4-interface.cc (-5 / +7 lines)
 Lines 262-274   Ipv4Interface::GetNAddresses (void) cons Link Here 
262
  return m_ifaddrs.size();
262
  return m_ifaddrs.size();
263
}
263
}
264
264
265
uint32_t
265
bool
266
Ipv4Interface::AddAddress (Ipv4InterfaceAddress addr)
266
Ipv4Interface::AddAddress (Ipv4InterfaceAddress addr)
267
{
267
{
268
  NS_LOG_FUNCTION_NOARGS ();
268
  NS_LOG_FUNCTION_NOARGS ();
269
  uint32_t index = m_ifaddrs.size ();
270
  m_ifaddrs.push_back (addr);
269
  m_ifaddrs.push_back (addr);
271
  return index;
270
  return true;
272
}
271
}
273
272
274
Ipv4InterfaceAddress
273
Ipv4InterfaceAddress
 Lines 292-298   Ipv4Interface::GetAddress (uint32_t inde Link Here 
292
  return (addr);  // quiet compiler
291
  return (addr);  // quiet compiler
293
}
292
}
294
293
295
void
294
Ipv4InterfaceAddress
296
Ipv4Interface::RemoveAddress (uint32_t index)
295
Ipv4Interface::RemoveAddress (uint32_t index)
297
{
296
{
298
  NS_LOG_FUNCTION_NOARGS ();
297
  NS_LOG_FUNCTION_NOARGS ();
 Lines 306-317   Ipv4Interface::RemoveAddress (uint32_t i Link Here 
306
    {
305
    {
307
      if (tmp  == index)
306
      if (tmp  == index)
308
        {
307
        {
308
          Ipv4InterfaceAddress addr = *i;
309
          m_ifaddrs.erase (i);
309
          m_ifaddrs.erase (i);
310
          return;
310
          return addr;
311
        }
311
        }
312
       ++tmp;
312
       ++tmp;
313
    }
313
    }
314
  NS_ASSERT_MSG (false, "Address " << index << " not found");
314
  NS_ASSERT_MSG (false, "Address " << index << " not found");
315
  Ipv4InterfaceAddress addr;
316
  return (addr);  // quiet compiler
315
}
317
}
316
318
317
}; // namespace ns3
319
}; // namespace ns3
(-)a/src/internet-stack/ipv4-interface.h (-4 / +5 lines)
 Lines 125-133   public: Link Here 
125
125
126
  /**
126
  /**
127
   * \param address The Ipv4InterfaceAddress to add to the interface
127
   * \param address The Ipv4InterfaceAddress to add to the interface
128
   * \returns The index of the newly-added Ipv4InterfaceAddress
128
   * \returns true if succeeded
129
   */
129
   */
130
  uint32_t AddAddress (Ipv4InterfaceAddress address);
130
  bool AddAddress (Ipv4InterfaceAddress address);
131
131
132
  /**
132
  /**
133
   * \param index Index of Ipv4InterfaceAddress to return
133
   * \param index Index of Ipv4InterfaceAddress to return
 Lines 141-149   public: Link Here 
141
  uint32_t GetNAddresses (void) const;
141
  uint32_t GetNAddresses (void) const;
142
142
143
  /**
143
  /**
144
   * \param index index of Ipv4InterfaceAddress to remove from address list.
144
   * \param index Index of Ipv4InterfaceAddress to remove
145
   * \returns The Ipv4InterfaceAddress address whose index is index 
145
   */
146
   */
146
  void RemoveAddress (uint32_t index);
147
  Ipv4InterfaceAddress RemoveAddress (uint32_t index);
147
148
148
protected:
149
protected:
149
  virtual void DoDispose (void);
150
  virtual void DoDispose (void);
(-)a/src/internet-stack/ipv4-l3-protocol.cc (-3 / +20 lines)
 Lines 736-752   Ipv4L3Protocol::LocalDeliver (Ptr<const Link Here 
736
    }
736
    }
737
}
737
}
738
738
739
uint32_t 
739
bool
740
Ipv4L3Protocol::AddAddress (uint32_t i, Ipv4InterfaceAddress address)
740
Ipv4L3Protocol::AddAddress (uint32_t i, Ipv4InterfaceAddress address)
741
{
741
{
742
  NS_LOG_FUNCTION (this << i << address);
742
  NS_LOG_FUNCTION (this << i << address);
743
  Ptr<Ipv4Interface> interface = GetInterface (i);
743
  Ptr<Ipv4Interface> interface = GetInterface (i);
744
  uint32_t index = interface->AddAddress (address);
744
  bool retVal = interface->AddAddress (address);
745
  if (m_routingProtocol != 0)
745
  if (m_routingProtocol != 0)
746
    {
746
    {
747
      m_routingProtocol->NotifyAddAddress (i, address);
747
      m_routingProtocol->NotifyAddAddress (i, address);
748
    }
748
    }
749
  return index;
749
  return retVal;
750
}
750
}
751
751
752
Ipv4InterfaceAddress 
752
Ipv4InterfaceAddress 
 Lines 763-768   Ipv4L3Protocol::GetNAddresses (uint32_t Link Here 
763
  NS_LOG_FUNCTION (this << interface);
763
  NS_LOG_FUNCTION (this << interface);
764
  Ptr<Ipv4Interface> iface = GetInterface (interface);
764
  Ptr<Ipv4Interface> iface = GetInterface (interface);
765
  return iface->GetNAddresses ();
765
  return iface->GetNAddresses ();
766
}
767
768
bool
769
Ipv4L3Protocol::RemoveAddress (uint32_t i, uint32_t addressIndex)
770
{
771
  NS_LOG_FUNCTION (this << i << addressIndex);
772
  Ptr<Ipv4Interface> interface = GetInterface (i);
773
  Ipv4InterfaceAddress address = interface->RemoveAddress (addressIndex);
774
  if (address != Ipv4InterfaceAddress ())
775
    {
776
      if (m_routingProtocol != 0)
777
        {
778
          m_routingProtocol->NotifyRemoveAddress (i, address);
779
        }
780
      return true;
781
    }
782
  return false;
766
}
783
}
767
784
768
void 
785
void 
(-)a/src/internet-stack/ipv4-l3-protocol.h (-1 / +2 lines)
 Lines 142-150   public: Link Here 
142
  int32_t GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const;
142
  int32_t GetInterfaceForPrefix (Ipv4Address addr, Ipv4Mask mask) const;
143
  int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
143
  int32_t GetInterfaceForDevice (Ptr<const NetDevice> device) const;
144
144
145
  uint32_t AddAddress (uint32_t i, Ipv4InterfaceAddress address);
145
  bool AddAddress (uint32_t i, Ipv4InterfaceAddress address);
146
  Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
146
  Ipv4InterfaceAddress GetAddress (uint32_t interfaceIndex, uint32_t addressIndex) const;
147
  uint32_t GetNAddresses (uint32_t interface) const;
147
  uint32_t GetNAddresses (uint32_t interface) const;
148
  bool RemoveAddress (uint32_t interfaceIndex, uint32_t addressIndex);
148
149
149
  void SetMetric (uint32_t i, uint16_t metric);
150
  void SetMetric (uint32_t i, uint16_t metric);
150
  uint16_t GetMetric (uint32_t i) const;
151
  uint16_t GetMetric (uint32_t i) const;
(-)a/src/node/ipv4-interface-address.h (+15 lines)
 Lines 77-86   private: Link Here 
77
77
78
  InterfaceAddressScope_e m_scope;   
78
  InterfaceAddressScope_e m_scope;   
79
  bool m_secondary;        // For use in multihoming
79
  bool m_secondary;        // For use in multihoming
80
81
  friend bool operator == (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
82
  friend bool operator != (Ipv4InterfaceAddress const &a, Ipv4InterfaceAddress const &b);
80
};
83
};
81
84
82
std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr);
85
std::ostream& operator<< (std::ostream& os, const Ipv4InterfaceAddress &addr);
83
86
87
inline bool operator == (const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
88
{
89
  return (a.m_local == b.m_local && a.m_mask == b.m_mask &&
90
    a.m_broadcast == b.m_broadcast && a.m_scope == b.m_scope && a.m_secondary == b.m_secondary);
91
}
92
inline bool operator != (const Ipv4InterfaceAddress &a, const Ipv4InterfaceAddress &b)
93
{
94
  return (a.m_local != b.m_local || a.m_mask != b.m_mask ||
95
    a.m_broadcast != b.m_broadcast || a.m_scope != b.m_scope || a.m_secondary != b.m_secondary);
96
}
97
98
84
} // namespace ns3
99
} // namespace ns3
85
100
86
#endif /* IPV4_ADDRESS_H */
101
#endif /* IPV4_ADDRESS_H */
(-)a/src/node/ipv4.h (-2 / +17 lines)
 Lines 159-167   public: Link Here 
159
  /**
159
  /**
160
   * \param interface Interface number of an Ipv4 interface
160
   * \param interface Interface number of an Ipv4 interface
161
   * \param address Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface
161
   * \param address Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface
162
   * \returns The address index of the newly-added address
162
   * \returns true if the operation succeeded
163
   */
163
   */
164
  virtual uint32_t AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
164
  virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
165
165
166
  /**
166
  /**
167
   * \param interface Interface number of an Ipv4 interface
167
   * \param interface Interface number of an Ipv4 interface
 Lines 170-180   public: Link Here 
170
  virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
170
  virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
171
171
172
  /**
172
  /**
173
   * Because addresses can be removed, the addressIndex is not guaranteed
174
   * to be static across calls to this method.
175
   * 
173
   * \param interface Interface number of an Ipv4 interface
176
   * \param interface Interface number of an Ipv4 interface
174
   * \param addressIndex index of Ipv4InterfaceAddress 
177
   * \param addressIndex index of Ipv4InterfaceAddress 
175
   * \returns the Ipv4InterfaceAddress associated to the interface and addresIndex
178
   * \returns the Ipv4InterfaceAddress associated to the interface and addresIndex
176
   */
179
   */
177
  virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
180
  virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
181
182
  /**
183
   * Remove the address at addressIndex on named interface.  The addressIndex
184
   * for all higher indices will decrement by one after this method is called;
185
   * so, for example, to remove 5 addresses from an interface i, one could
186
   * call RemoveAddress (i, 0); 5 times.  
187
   * 
188
   * \param interface Interface number of an Ipv4 interface
189
   * \param addressIndex index of Ipv4InterfaceAddress to remove 
190
   * \returns true if the operation succeeded
191
   */
192
  virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;
178
193
179
  /**
194
  /**
180
   * \param interface The interface number of an Ipv4 interface
195
   * \param interface The interface number of an Ipv4 interface

Return to bug 588