Fix problem with QNetworkAddressEntry returning a invalid netmask.

The ip address should be set before the netmask. The reason for this is
that QNetworkAddressEntry::setNetmask() compares the protocol of the
netmask and the ip, if they don't match the netmask won't be set.

Task-number: QTBUG-33911
Change-Id: Ic344b3653c5dfdc5df912dee16e4dbe069d57d24
Reviewed-by: Peter Hartmann <phartmann@blackberry.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Christian Strømme 2013-11-27 15:04:09 +01:00 committed by The Qt Project
parent 76580659e6
commit e82951611c

View File

@ -277,18 +277,18 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
} }
} }
// Get the interface netmask
if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
sockaddr *sa = &req.ifr_addr;
entry.setNetmask(addressFromSockaddr(sa));
}
// Get the address of the interface // Get the address of the interface
if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) { if (qt_safe_ioctl(socket, SIOCGIFADDR, &req) >= 0) {
sockaddr *sa = &req.ifr_addr; sockaddr *sa = &req.ifr_addr;
entry.setIp(addressFromSockaddr(sa)); entry.setIp(addressFromSockaddr(sa));
} }
// Get the interface netmask
if (qt_safe_ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
sockaddr *sa = &req.ifr_addr;
entry.setNetmask(addressFromSockaddr(sa));
}
iface->addressEntries << entry; iface->addressEntries << entry;
} }