1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

Kernel: Add interface to read link speed and duplex for NetworkAdapter

Read the appropriate registers for RTL8139, RTL8168 and E1000.
For NE2000 just assume 10mbit full duplex as there is no indicator
for it in the pure NE2000 spec. Mock values for loopback.
This commit is contained in:
Thomas Wagenveld 2021-07-25 20:16:42 +02:00 committed by Gunnar Beutner
parent 238ac8ac25
commit 59fdeec7f5
9 changed files with 98 additions and 0 deletions

View file

@ -42,6 +42,8 @@ struct PacketWithTimestamp : public RefCounted<PacketWithTimestamp> {
class NetworkAdapter : public RefCounted<NetworkAdapter>
, public Weakable<NetworkAdapter> {
public:
static constexpr i32 LINKSPEED_INVALID = -1;
virtual ~NetworkAdapter();
virtual StringView class_name() const = 0;
@ -53,6 +55,12 @@ public:
IPv4Address ipv4_broadcast() const { return IPv4Address { (m_ipv4_address.to_u32() & m_ipv4_netmask.to_u32()) | ~m_ipv4_netmask.to_u32() }; }
IPv4Address ipv4_gateway() const { return m_ipv4_gateway; }
virtual bool link_up() { return false; }
virtual i32 link_speed()
{
// In Mbit/sec.
return LINKSPEED_INVALID;
}
virtual bool link_full_duplex() { return false; }
void set_ipv4_address(const IPv4Address&);
void set_ipv4_netmask(const IPv4Address&);