mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-02-24 00:24:38 +00:00
Kernel/Net: Get the correct interface type in SIOCGIFHWADDR ioctl
When calling ioctl on a socket with SIOCGIFHWADDR, return the correct physical interface type. This value was previously hardcoded to ARPHRD_ETHER (Ethernet), and now can also return ARPHRD_LOOPBACK for the loopback adapter.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
6f9b84a64a
commit
037744e62a
@@ -740,7 +740,16 @@ ErrorOr<void> IPv4Socket::ioctl(OpenFileDescription&, unsigned request, Userspac
|
||||
|
||||
case SIOCGIFHWADDR: {
|
||||
auto mac_address = adapter->mac_address();
|
||||
ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; // FIXME: Query the underlying network interface for it's type
|
||||
switch (adapter->adapter_type()) {
|
||||
case NetworkAdapter::Type::Loopback:
|
||||
ifr.ifr_hwaddr.sa_family = ARPHRD_LOOPBACK;
|
||||
break;
|
||||
case NetworkAdapter::Type::Ethernet:
|
||||
ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
mac_address.copy_to(Bytes { ifr.ifr_hwaddr.sa_data, sizeof(ifr.ifr_hwaddr.sa_data) });
|
||||
return copy_to_user(user_ifr, &ifr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user