git-svn-id: svn://db.shs.com.ru/pip@778 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2019-04-16 13:48:13 +00:00
parent c6376002ed
commit 10b70f5acf
8 changed files with 88 additions and 30 deletions

View File

@@ -1110,17 +1110,19 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
PIStringList inl;
struct ifreq ir;
for (int i = 0; i < icnt; ++i) {
ci.flags = 0;
PIString in = PIStringAscii(ifc.ifc_req[i].ifr_name);
if (in.isEmpty()) continue;
ci.name = in;
strcpy(ir.ifr_name, in.dataAscii());
if (ioctl(s, SIOCGIFHWADDR, &ir) == 0)
ci.mac = macFromBytes(PIByteArray(ir.ifr_hwaddr.sa_data, 6));
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);
ioctl(s, SIOCGIFMTU, &ci.mtu);
if (ci.address == "127.0.0.1") ci.flags |= PIEthernet::ifLoopback;
il << ci;
}
delete ifc.ifc_buf;