Bug 588 - "New" Ipv4: cannot change address
"New" Ipv4: cannot change address
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: internet
pre-release
All All
: P5 major
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-11 07:28 UTC by Francesco Malandrino
Modified: 2009-06-19 11:08 UTC (History)
3 users (show)

See Also:


Attachments
untested patch to fix (7.56 KB, patch)
2009-06-14 00:43 UTC, Tom Henderson
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Francesco Malandrino 2009-06-11 07:28:50 UTC
The previous Ipv4 object had SetAddress and SetMask methods that could be used to change the address.
The current seems to lack them, and this is critical when adding an interface/an address is not an option.
Comment 1 Tom Henderson 2009-06-14 00:42:18 UTC
API proposal:

--- a/src/node/ipv4.h   Sat Jun 13 14:59:35 2009 -0700
+++ b/src/node/ipv4.h   Sat Jun 13 15:35:17 2009 -0700
@@ -159,9 +159,9 @@ public:
   /**
    * \param interface Interface number of an Ipv4 interface
    * \param address Ipv4InterfaceAddress address to associate with the underlying Ipv4 interface
-   * \returns The address index of the newly-added address
+   * \returns true if the operation succeeded
    */
-  virtual uint32_t AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
+  virtual bool AddAddress (uint32_t interface, Ipv4InterfaceAddress address) = 0;
 
   /**
    * \param interface Interface number of an Ipv4 interface
@@ -170,11 +170,26 @@ public:
   virtual uint32_t GetNAddresses (uint32_t interface) const = 0;
 
   /**
+   * Because addresses can be removed, the addressIndex is not guaranteed
+   * to be static across calls to this method.
+   * 
    * \param interface Interface number of an Ipv4 interface
    * \param addressIndex index of Ipv4InterfaceAddress 
    * \returns the Ipv4InterfaceAddress associated to the interface and addresIndex
    */
   virtual Ipv4InterfaceAddress GetAddress (uint32_t interface, uint32_t addressIndex) const = 0;
+
+  /**
+   * Remove the address at addressIndex on named interface.  The addressIndex
+   * for all higher indices will decrement by one after this method is called;
+   * so, for example, to remove 5 addresses from an interface i, one could
+   * call RemoveAddress (i, 0); 5 times.  
+   * 
+   * \param interface Interface number of an Ipv4 interface
+   * \param addressIndex index of Ipv4InterfaceAddress to remove 
+   * \returns true if the operation succeeded
+   */
+  virtual bool RemoveAddress (uint32_t interface, uint32_t addressIndex) = 0;

  
Comment 2 Tom Henderson 2009-06-14 00:43:43 UTC
Created attachment 465 [details]
untested patch to fix
Comment 3 Mathieu Lacage 2009-06-14 02:23:25 UTC
+1
Comment 4 Tom Henderson 2009-06-19 11:08:58 UTC
changeset 55948d1baa64