[haiku-commits] r37990 - haiku/trunk/src/add-ons/kernel/network/stack

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 9 Aug 2010 19:08:41 +0200 (CEST)

Author: axeld
Date: 2010-08-09 19:08:41 +0200 (Mon, 09 Aug 2010)
New Revision: 37990
Changeset: http://dev.haiku-os.org/changeset/37990

Modified:
   haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp
Log:
* Made the work-around that Atis added to ifconfig and the net_server
  in order to be able to use SIOCSIFADDR (and friends) on a net yet added
  family superfluous; we now add a new address when needed on the fly.


Modified: haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp 2010-08-09 
16:39:43 UTC (rev 37989)
+++ haiku/trunk/src/add-ons/kernel/network/stack/interfaces.cpp 2010-08-09 
17:08:41 UTC (rev 37990)
@@ -746,14 +746,27 @@
                                                        address->local, 
(sockaddr*)&newAddress))
                                                break;
                                }
+                               
+                               if (address == NULL)
+                                       return B_BAD_VALUE;
                        } else {
                                // Just use the first address for this family
                                address = _FirstForFamily(domain->family);
+                               if (address == NULL) {
+                                       // Create new on the fly
+                                       address = new(std::nothrow) 
InterfaceAddress(this, domain);
+                                       if (address == NULL)
+                                               return B_NO_MEMORY;
+
+                                       status_t status = AddAddress(address);
+                                       if (status != B_OK)
+                                               return status;
+
+                                       // Note, even if setting the address 
failed, the empty
+                                       // address added here will still be 
added to the interface.
+                               }
                        }
 
-                       if (address == NULL)
-                               return B_BAD_VALUE;
-
                        return _ChangeAddress(locker, address, option,
                                *address->AddressFor(option),
                                option != SIOCDIFADDR ? (sockaddr*)&newAddress 
: NULL);


Other related posts:

  • » [haiku-commits] r37990 - haiku/trunk/src/add-ons/kernel/network/stack - axeld