History log of /haiku/src/kits/network/libnetapi/NetworkInterface.cpp
Revision Date Author Comments
# 44fa45df 13-Jun-2022 Augustin Cavalier <waddlesplash@gmail.com>

net/if: Drop ifmediareq and just use the regular ifreq for SIOCGIFMEDIA.

This was introduced into the main API in 2010 (d72ede75fb252c24c8a5fcc39395f9ae1c202322),
but was actually only fully used for the past month (c2a9a890f3ac7795602d11c0edaa20ac2db48202)
when SIOCGIFMEDIA was supported for all *BSD drivers and not just WiFi.
Most userland consumers of this structure did not use it correctly,
as was the case in #17770, and only worked because in the fallback case
the network stack just treated it as if it were an ifreq.

Nothing actually used the ifm_count/ifm_ulist (though tentative APIs
were exposed for it) as noted by previous commits; and the fact that
Haiku's IFM_* declarations are so spartan makes most of the returned
values unintelligible to userland without using FreeBSD compat headers.

If, in the future, we decide to implement ifmedia listing and selection
properly, that should likely be done with separate ioctls instead of
having multi-function ones like this.

This is technically an ABI break, but in practice it should not matter:
ifmediareq::ifm_current aligns with ifreq::ifr_media, so the things
that used this structure like our in-tree code did will continue to work.
Until this past May, the only other field that was usually set was
ifm_active, but in the absence of setting ifm_status all non-Haiku
consumers should ignore it completely.

The only consumer of this ioctl that I know of out of the tree,
wpa_supplicant, still works after these changes.


# fce7f3a7 09-Dec-2020 X512 <danger_mail@list.ru>

integrate AutoDeleter's into pointers

Change-Id: I6c3925a7aec4d0647c76c2a03aad7b08985d7166
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3490
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 9bf9ee38 12-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

Whitespace and style cleanup only.


# 3b7b927d 12-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

libbnetapi: Add BNetworkRoute to replace use of route_entry.

The BNetworkRoute class manages a route_entry and the sockaddr's
associated with it. It replaces the direct use of route_entry in the
BNetworkInterface API.

Using route_entry is fragile and inconvenient as it only holds pointers
to the sockaddr's. When getting a list of routes from the kernel, each
route_entry is set up so that its pointers point into the single flat
buffer that is passed around. Creating a copy of the route_entry and
then deleting the flat buffer makes the pointers in the copy stale.
Returning these route entries therefore always lead to a use-after-free
when they were eventually used.

BNetworkRoute also takes over the code and functionallity of getting
routes from RouteSupport. The corresponding method in BNetworkRoster is
replaced by a static method in BNetworkRoute.

Also distinguish between the default route and gateway of an interface.
GetDefaultRoute() now gets the default BNetworkRoute for the interface
while GetDefaultGateway() gets the associated gateway address within
that default route. Adjust network preferences panel to this change.

Note that we currently only seem to have per interface default routes
and not an actual global default route. This was already the case before
these changes and I did not further investigate what this means.


# 77206143 05-Feb-2015 Axel Dörfler <axeld@pinc-software.de>

Revert "Move getifaddrs to libnetwork again."

This reverts commit 31ea76548a64b232ed10cb444bf84ca1f7e40b0f.

Adrien, please try again without clobbering the otherwise nice
BNetworkInterface API!

Conflicts:
src/kits/network/getifaddrs.cpp


# 31ea7654 20-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

Move getifaddrs to libnetwork again.

* BNetworkInterfaceAddress is moved to libnetwork. It is modified to not
use BNetworkAddress (which is in libbnetapi) and instead use sockaddr
and sockaddr_storage directly. All callers are adjusted to this.
* Some support code is shared between BNetworkInterface and
BNetworkInterfaceAddress, move it to libnetwork but in the BPrivate
namespace.


# 754bbf48 26-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

libnetapi: second pass of style cleanup

* remarks from Axel


# 0bc61543 18-Nov-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Style fixes.
Style fixes pointed out by Axel. I'm rusty, and it shows.
Hope I got it right.
Also moved get_route() into BPrivate.


# 41d42066 18-Nov-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added family parameter to the GetRoutes() API.
Moved common code to a private file.


# 905f910e 16-Nov-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Network route API: Second try (WIP).
Implement BNetworkRoster::GetRoutes() and BNetworkInterface::GetRoutes().
Also implement BNetworkInterface::GetDefaultGateway().
There is code duplication at the moment, and the api only supports IPV4.


# 0e4bbb1b 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* No need to set the family there, the domain is what matters.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40446 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cf93c8c7 10-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* FindAddress(), and FindFirstAddress() now return -1 on failure.
* FindFirstAddress() did actually not specify the family to find, so that the
stack did not have the opportunity to find anything else but the first
address.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 60fed7e0 23-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Moved the shared part of NetServer.h into a new private header.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39597 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2087545c 23-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Added methods to manipulate routes.
* Added AutoConfigure() method.
* Implemented missing Index() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39592 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d72ede75 10-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* We now use a FreeBSD compatible ifmediareq structure for SIOCIFMEDIA, and
SIOCSIFMEDIA.
* Made sure that the two media ioctls are actually forwarded to the driver.
* Added NetworkDevice.cpp to the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39389 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a690e259 17-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* BNetworkInterface must adopt the family from the address, if possible. This
should fix "ifconfig" for IPv6.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 97ef73e0 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Added convenience methods FindAddress(), and FindFirstAddress().
* Added BNetworkInterfaceAddress::Destination() as synonym for Broadcast()
(depending on the configuration, it could be either one).
* Media() will now return -1 in case of an error.
* Added "const" where it makes sense.
* Added convenience functions for AddAddress(), and RemoveAddress() that only
take the actual address.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9de96be3 11-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Added methods to get/set the media/metric.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38024 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb7ce9a3 09-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Renamed DescriptorCloser to FileDescriptorCloser as suggested by Ingo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37995 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c2808ea7 09-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Adapted API as needed, and implemented most of the C++ API - it's completely
untested at this point, though.
* Will port ifconfig, NetworkStatus, and the Network preferences application
later in order to test the API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37988 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf58f252 06-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Adapted headers after Stippi's suggestions - I won't add the const until I
know how I implement that function :-)
* Cleaned up libbnetapi.so Jamfile, removed non-Haiku target code.
* Added empty files to the build to see that the headers are compiling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37942 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9bf9ee3806866886516cbe7b37dea5f8985c7186 12-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

Whitespace and style cleanup only.


# 3b7b927dd01fc96efcda618430851e691ebdb313 12-Apr-2015 Michael Lotz <mmlr@mlotz.ch>

libbnetapi: Add BNetworkRoute to replace use of route_entry.

The BNetworkRoute class manages a route_entry and the sockaddr's
associated with it. It replaces the direct use of route_entry in the
BNetworkInterface API.

Using route_entry is fragile and inconvenient as it only holds pointers
to the sockaddr's. When getting a list of routes from the kernel, each
route_entry is set up so that its pointers point into the single flat
buffer that is passed around. Creating a copy of the route_entry and
then deleting the flat buffer makes the pointers in the copy stale.
Returning these route entries therefore always lead to a use-after-free
when they were eventually used.

BNetworkRoute also takes over the code and functionallity of getting
routes from RouteSupport. The corresponding method in BNetworkRoster is
replaced by a static method in BNetworkRoute.

Also distinguish between the default route and gateway of an interface.
GetDefaultRoute() now gets the default BNetworkRoute for the interface
while GetDefaultGateway() gets the associated gateway address within
that default route. Adjust network preferences panel to this change.

Note that we currently only seem to have per interface default routes
and not an actual global default route. This was already the case before
these changes and I did not further investigate what this means.


# 7720614300ff86e823735adcb96690c822dd60f8 05-Feb-2015 Axel Dörfler <axeld@pinc-software.de>

Revert "Move getifaddrs to libnetwork again."

This reverts commit 31ea76548a64b232ed10cb444bf84ca1f7e40b0f.

Adrien, please try again without clobbering the otherwise nice
BNetworkInterface API!

Conflicts:
src/kits/network/getifaddrs.cpp


# 31ea76548a64b232ed10cb444bf84ca1f7e40b0f 20-Jan-2015 Adrien Destugues <pulkomandy@gmail.com>

Move getifaddrs to libnetwork again.

* BNetworkInterfaceAddress is moved to libnetwork. It is modified to not
use BNetworkAddress (which is in libbnetapi) and instead use sockaddr
and sockaddr_storage directly. All callers are adjusted to this.
* Some support code is shared between BNetworkInterface and
BNetworkInterfaceAddress, move it to libnetwork but in the BPrivate
namespace.


# 754bbf4866278ecd2da2c517560bc90c67a3a6f5 26-Nov-2013 Jérôme Duval <jerome.duval@gmail.com>

libnetapi: second pass of style cleanup

* remarks from Axel


# 0bc615438a8914183d02f7941b60cf025ff2a110 18-Nov-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Style fixes.
Style fixes pointed out by Axel. I'm rusty, and it shows.
Hope I got it right.
Also moved get_route() into BPrivate.


# 41d4206692bec4352e7ea02ddb0222eab6b71884 18-Nov-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Added family parameter to the GetRoutes() API.
Moved common code to a private file.


# 905f910e5364ca9b0e0ca98fe9e35fa6cffe42ed 16-Nov-2013 Stefano Ceccherini <stefano.ceccherini@gmail.com>

Network route API: Second try (WIP).
Implement BNetworkRoster::GetRoutes() and BNetworkInterface::GetRoutes().
Also implement BNetworkInterface::GetDefaultGateway().
There is code duplication at the moment, and the api only supports IPV4.


# 0e4bbb1bee95037551dbff12b6eaf16fbaf631ce 11-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* No need to set the family there, the domain is what matters.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40446 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cf93c8c719932eeaf90cada7e3f57ac79de966cd 10-Feb-2011 Axel Dörfler <axeld@pinc-software.de>

* FindAddress(), and FindFirstAddress() now return -1 on failure.
* FindFirstAddress() did actually not specify the family to find, so that the
stack did not have the opportunity to find anything else but the first
address.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40421 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 60fed7e0773745d919253ada6a83bd1a91213726 23-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Moved the shared part of NetServer.h into a new private header.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39597 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 2087545cc057c6c96cf1b14736e58ba4e4012d4d 23-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* Added methods to manipulate routes.
* Added AutoConfigure() method.
* Implemented missing Index() method.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39592 a95241bf-73f2-0310-859d-f6bbb57e9c96


# d72ede75fb252c24c8a5fcc39395f9ae1c202322 10-Nov-2010 Axel Dörfler <axeld@pinc-software.de>

* We now use a FreeBSD compatible ifmediareq structure for SIOCIFMEDIA, and
SIOCSIFMEDIA.
* Made sure that the two media ioctls are actually forwarded to the driver.
* Added NetworkDevice.cpp to the build.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39389 a95241bf-73f2-0310-859d-f6bbb57e9c96


# a690e25952e477f92930a8bc34d52d2e2ffe2a0b 17-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* BNetworkInterface must adopt the family from the address, if possible. This
should fix "ifconfig" for IPv6.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38177 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 97ef73e074307299dc5d2e6491d6b74f186ba327 12-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Added convenience methods FindAddress(), and FindFirstAddress().
* Added BNetworkInterfaceAddress::Destination() as synonym for Broadcast()
(depending on the configuration, it could be either one).
* Media() will now return -1 in case of an error.
* Added "const" where it makes sense.
* Added convenience functions for AddAddress(), and RemoveAddress() that only
take the actual address.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38060 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 9de96be3757f88e4cdda2c4a5debb82ffad95e39 11-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Added methods to get/set the media/metric.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38024 a95241bf-73f2-0310-859d-f6bbb57e9c96


# cb7ce9a32f228cd69fd910424a7f2b405e2e22e4 09-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Renamed DescriptorCloser to FileDescriptorCloser as suggested by Ingo.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37995 a95241bf-73f2-0310-859d-f6bbb57e9c96


# c2808ea7b2da2e03373962bc413c3c1c73a70e59 09-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Adapted API as needed, and implemented most of the C++ API - it's completely
untested at this point, though.
* Will port ifconfig, NetworkStatus, and the Network preferences application
later in order to test the API.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37988 a95241bf-73f2-0310-859d-f6bbb57e9c96


# bf58f252deedcb8b22e8f9a92ed9a1663f67a58d 06-Aug-2010 Axel Dörfler <axeld@pinc-software.de>

* Adapted headers after Stippi's suggestions - I won't add the const until I
know how I implement that function :-)
* Cleaned up libbnetapi.so Jamfile, removed non-Haiku target code.
* Added empty files to the build to see that the headers are compiling.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37942 a95241bf-73f2-0310-859d-f6bbb57e9c96