diff --git a/src/bin/network/ifconfig/Jamfile b/src/bin/network/ifconfig/Jamfile index 64d6804229..8aa6538fcf 100644 --- a/src/bin/network/ifconfig/Jamfile +++ b/src/bin/network/ifconfig/Jamfile @@ -8,5 +8,5 @@ UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_wlan ] : true ; BinCommand ifconfig : ifconfig.cpp MediaTypes.cpp - : be network bnetapi + : be network bnetapi [ TargetLibstdc++ ] ; diff --git a/src/bin/network/ifconfig/ifconfig.cpp b/src/bin/network/ifconfig/ifconfig.cpp index 6222891340..cfc7c4dc69 100644 --- a/src/bin/network/ifconfig/ifconfig.cpp +++ b/src/bin/network/ifconfig/ifconfig.cpp @@ -367,10 +367,16 @@ configure_wireless(const char* name, char* const* args, int32 argCount) } } else { // list them all - wireless_network network; - uint32 cookie = 0; - while (device.GetNextNetwork(cookie, network) == B_OK) - show_wireless_network(network, verbose); + uint32 networksCount = 0; + wireless_network* networks = NULL; + status_t status = device.GetNetworks(networks, networksCount); + if (status != B_OK) { + fprintf(stderr, "%s: Getting networks failed: %s\n", + kProgramName, strerror(status)); + } + for (uint32 i = 0; i < networksCount; i++) + show_wireless_network(networks[i], verbose); + delete[] networks; } break; } diff --git a/src/kits/network/libnetservices/Geolocation.cpp b/src/kits/network/libnetservices/Geolocation.cpp index e86c5f47c1..340578983d 100644 --- a/src/kits/network/libnetservices/Geolocation.cpp +++ b/src/kits/network/libnetservices/Geolocation.cpp @@ -81,13 +81,14 @@ BGeolocation::LocateSelf(float& latitude, float& longitude) int32 count = 0; while (roster.GetNextInterface(&interfaceCookie, interface) == B_OK) { - uint32 networkCookie = 0; - wireless_network network; - BNetworkDevice device(interface.Name()); // TODO is that the correct way to enumerate devices? - while (device.GetNextNetwork(networkCookie, network) == B_OK) { + uint32 networksCount = 0; + wireless_network* networks = NULL; + device.GetNetworks(networks, networksCount); + for (uint32 i = 0; i < networksCount; i++) { + const wireless_network& network = networks[i]; if (count != 0) query += ','; @@ -101,7 +102,7 @@ BGeolocation::LocateSelf(float& latitude, float& longitude) query << (int)network.noise_level; query += " }"; } - + delete[] networks; } query += "\n\t]\n}\n"; diff --git a/src/tests/kits/net/Jamfile b/src/tests/kits/net/Jamfile index 6f8145f2f6..9ace0b217e 100644 --- a/src/tests/kits/net/Jamfile +++ b/src/tests/kits/net/Jamfile @@ -8,7 +8,7 @@ SimpleTest NetAddressTest : NetAddressTest.cpp SimpleTest NetEndpointTest : NetEndpointTest.cpp : $(TARGET_NETWORK_LIBS) $(HAIKU_NETAPI_LIB) be [ TargetLibsupc++ ] ; -SimpleTest wlan_test : wlan_test.cpp : $(TARGET_NETWORK_LIBS) bnetapi be ; +SimpleTest wlan_test : wlan_test.cpp : $(TARGET_NETWORK_LIBS) bnetapi be [ TargetLibstdc++ ] ; SubInclude HAIKU_TOP src tests kits net cookie ; HaikuSubInclude libnetapi ; diff --git a/src/tests/kits/net/wlan_test.cpp b/src/tests/kits/net/wlan_test.cpp index 80b02b976a..9d48c5f284 100644 --- a/src/tests/kits/net/wlan_test.cpp +++ b/src/tests/kits/net/wlan_test.cpp @@ -108,10 +108,12 @@ main(int argc, char** argv) show(network); } else { // list all - wireless_network network; - uint32 cookie = 0; - while (device.GetNextNetwork(cookie, network) == B_OK) - show(network); + uint32 networksCount = 0; + wireless_network* networks = NULL; + device.GetNetworks(networks, networksCount); + for (uint32 i = 0; i < networksCount; i++) + show(networks[i]); + delete[] networks; } } else usage();