diff --git a/kernel/kernel/Networking/NetworkSocket.cpp b/kernel/kernel/Networking/NetworkSocket.cpp index ce6486e0..b3fb906b 100644 --- a/kernel/kernel/Networking/NetworkSocket.cpp +++ b/kernel/kernel/Networking/NetworkSocket.cpp @@ -95,6 +95,14 @@ namespace Kernel memcpy(ifreq->ifr_ifru.ifru_hwaddr.sa_data, &mac_address, sizeof(mac_address)); return 0; } + case SIOCGIFNAME: + { + auto& ifrn_name = ifreq->ifr_ifrn.ifrn_name; + ASSERT(m_interface->name().size() < sizeof(ifrn_name)); + memcpy(ifrn_name, m_interface->name().data(), m_interface->name().size()); + ifrn_name[m_interface->name().size()] = '\0'; + return 0; + } default: return BAN::Error::from_errno(EINVAL); } diff --git a/userspace/libraries/LibC/include/net/if.h b/userspace/libraries/LibC/include/net/if.h index ceb61d4c..84f00e84 100644 --- a/userspace/libraries/LibC/include/net/if.h +++ b/userspace/libraries/LibC/include/net/if.h @@ -19,6 +19,10 @@ struct if_nameindex struct ifreq { + union { + char ifrn_name[IF_NAMESIZE]; + } ifr_ifrn; + union { struct sockaddr ifru_addr; struct sockaddr ifru_netmask; @@ -35,6 +39,7 @@ struct ifreq #define SIOCGIFGWADDR 5 /* Get gateway address */ #define SIOCSIFGWADDR 6 /* Set gateway address */ #define SIOCGIFHWADDR 7 /* Get hardware address */ +#define SIOCGIFNAME 8 /* Get interface name */ void if_freenameindex(struct if_nameindex* ptr); char* if_indextoname(unsigned ifindex, char* ifname);