PIP Bugfixes #207
@@ -1180,12 +1180,18 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
# ifdef ANDROID
|
# ifdef ANDROID
|
||||||
struct ifconf ifc;
|
struct ifconf ifc;
|
||||||
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||||
|
if (s == -1) {
|
||||||
|
piCout << "[PIEthernet]"
|
||||||
|
<< "Can`t create socket: %1"_tr("PIEthernet").arg(errorString());
|
||||||
|
return il;
|
||||||
|
}
|
||||||
ifc.ifc_len = 256;
|
ifc.ifc_len = 256;
|
||||||
ifc.ifc_buf = new char[ifc.ifc_len];
|
ifc.ifc_buf = new char[ifc.ifc_len];
|
||||||
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
if (ioctl(s, SIOCGIFCONF, &ifc) < 0) {
|
||||||
piCout << "[PIEthernet]"
|
piCout << "[PIEthernet]"
|
||||||
<< "Can`t get interfaces: %1"_tr("PIEthernet").arg(errorString());
|
<< "Can`t get interfaces: %1"_tr("PIEthernet").arg(errorString());
|
||||||
delete[] ifc.ifc_buf;
|
delete[] ifc.ifc_buf;
|
||||||
|
::close(s);
|
||||||
return il;
|
return il;
|
||||||
}
|
}
|
||||||
int icnt = ifc.ifc_len / sizeof(ifreq);
|
int icnt = ifc.ifc_len / sizeof(ifreq);
|
||||||
@@ -1204,7 +1210,8 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
|
|||||||
if (ci.address == "127.0.0.1") ci.flags |= PIEthernet::ifLoopback;
|
if (ci.address == "127.0.0.1") ci.flags |= PIEthernet::ifLoopback;
|
||||||
il << ci;
|
il << ci;
|
||||||
}
|
}
|
||||||
delete ifc.ifc_buf;
|
delete[] ifc.ifc_buf;
|
||||||
|
::close(s);
|
||||||
# else
|
# else
|
||||||
struct ifaddrs *ret, *cif = 0;
|
struct ifaddrs *ret, *cif = 0;
|
||||||
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
int s = ::socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||||
@@ -1295,8 +1302,10 @@ PINetworkAddress PIEthernet::interfaceAddress(const PIString & interface_) {
|
|||||||
piZeroMemory(ifr);
|
piZeroMemory(ifr);
|
||||||
strcpy(ifr.ifr_name, interface_.dataAscii());
|
strcpy(ifr.ifr_name, interface_.dataAscii());
|
||||||
int s = ::socket(AF_INET, SOCK_DGRAM, 0);
|
int s = ::socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (s != -1) {
|
||||||
ioctl(s, SIOCGIFADDR, &ifr);
|
ioctl(s, SIOCGIFADDR, &ifr);
|
||||||
::close(s);
|
::close(s);
|
||||||
|
}
|
||||||
struct sockaddr_in * sa = (struct sockaddr_in *)&ifr.ifr_addr;
|
struct sockaddr_in * sa = (struct sockaddr_in *)&ifr.ifr_addr;
|
||||||
return PINetworkAddress(uint(sa->sin_addr.s_addr));
|
return PINetworkAddress(uint(sa->sin_addr.s_addr));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user