fix: SIOCGIFNETMASK reads ifr_addr instead of ifr_netmask

This commit is contained in:
2026-08-05 23:25:59 +03:00
parent 367c2e6447
commit 580ee2eb11
+1 -1
View File
@@ -1206,7 +1206,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
strcpy(ir.ifr_name, in.dataAscii());
if (ioctl(s, SIOCGIFHWADDR, &ir) == 0) ci.mac = macFromBytes(PIByteArray(ir.ifr_hwaddr.sa_data, 6));
if (ioctl(s, SIOCGIFADDR, &ir) >= 0) ci.address = getSockAddr(&ir.ifr_addr);
if (ioctl(s, SIOCGIFNETMASK, &ir) >= 0) ci.netmask = getSockAddr(&ir.ifr_addr);
if (ioctl(s, SIOCGIFNETMASK, &ir) >= 0) ci.netmask = getSockAddr(&ir.ifr_netmask);
ioctl(s, SIOCGIFMTU, &ci.mtu);
if (ci.address == "127.0.0.1") ci.flags |= PIEthernet::ifLoopback;
il << ci;