mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:47:44 +00:00
Userland: Set the mask of a network adapter with ifconfig (#1388)
A new IP address or a new network mask can be specified in the command line arguments of ifconfig to replace the old values of a given network adapter. Additionally, more information is being printed for each adapter.
This commit is contained in:
parent
4c9bb266df
commit
8cf962a102
6 changed files with 155 additions and 49 deletions
|
@ -485,6 +485,14 @@ int IPv4Socket::ioctl(FileDescription&, unsigned request, unsigned arg)
|
|||
adapter->set_ipv4_address(IPv4Address(((sockaddr_in&)ifr->ifr_addr).sin_addr.s_addr));
|
||||
return 0;
|
||||
|
||||
case SIOCSIFNETMASK:
|
||||
if (!Process::current->is_superuser())
|
||||
return -EPERM;
|
||||
if (ifr->ifr_addr.sa_family != AF_INET)
|
||||
return -EAFNOSUPPORT;
|
||||
adapter->set_ipv4_netmask(IPv4Address(((sockaddr_in&)ifr->ifr_netmask).sin_addr.s_addr));
|
||||
return 0;
|
||||
|
||||
case SIOCGIFADDR:
|
||||
if (!Process::current->validate_write_typed(ifr))
|
||||
return -EFAULT;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue