diff --git a/headers/os/net/NetworkDevice.h b/headers/os/net/NetworkDevice.h index 6dbf194f01..5b46a07f01 100644 --- a/headers/os/net/NetworkDevice.h +++ b/headers/os/net/NetworkDevice.h @@ -31,6 +31,7 @@ public: void SetTo(const char* name); const char* Name() const; + uint32 Index() const; uint32 Flags() const; bool HasLink() const; diff --git a/src/kits/network/libnetapi/NetworkDevice.cpp b/src/kits/network/libnetapi/NetworkDevice.cpp index 15da58a5f5..a500861743 100644 --- a/src/kits/network/libnetapi/NetworkDevice.cpp +++ b/src/kits/network/libnetapi/NetworkDevice.cpp @@ -137,6 +137,17 @@ BNetworkDevice::Name() const } +uint32 +BNetworkDevice::Index() const +{ + ifreq request; + if (do_request(request, Name(), SIOCGIFINDEX) != B_OK) + return 0; + + return request.ifr_index; +} + + uint32 BNetworkDevice::Flags() const {