QNetworkInterface: Merge the two sections of code that do SIOCGIFxxx
The separation was accidental due to refactoring. It does not need to exist. Change-Id: I7de033f80b0e4431b7f1ffff13f988adc47d57d5 Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
parent
1bf9cb44e2
commit
8fa44b382f
@ -218,6 +218,27 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa
|
||||
iface = new QNetworkInterfacePrivate;
|
||||
iface->index = ifindex;
|
||||
interfaces << iface;
|
||||
}
|
||||
|
||||
return iface;
|
||||
}
|
||||
|
||||
static QList<QNetworkInterfacePrivate *> interfaceListing()
|
||||
{
|
||||
QList<QNetworkInterfacePrivate *> interfaces;
|
||||
|
||||
int socket;
|
||||
if ((socket = qt_safe_socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
|
||||
return interfaces; // error
|
||||
|
||||
QSet<QByteArray> names = interfaceNames(socket);
|
||||
QSet<QByteArray>::ConstIterator it = names.constBegin();
|
||||
for ( ; it != names.constEnd(); ++it) {
|
||||
ifreq req;
|
||||
memset(&req, 0, sizeof(ifreq));
|
||||
memcpy(req.ifr_name, *it, qMin<int>(it->length() + 1, sizeof(req.ifr_name) - 1));
|
||||
|
||||
QNetworkInterfacePrivate *iface = findInterface(socket, interfaces, req);
|
||||
|
||||
#ifdef SIOCGIFNAME
|
||||
// Get the canonical name
|
||||
@ -246,27 +267,6 @@ static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfa
|
||||
iface->hardwareAddress = iface->makeHwAddress(6, addr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return iface;
|
||||
}
|
||||
|
||||
static QList<QNetworkInterfacePrivate *> interfaceListing()
|
||||
{
|
||||
QList<QNetworkInterfacePrivate *> interfaces;
|
||||
|
||||
int socket;
|
||||
if ((socket = qt_safe_socket(AF_INET, SOCK_STREAM, IPPROTO_IP)) == -1)
|
||||
return interfaces; // error
|
||||
|
||||
QSet<QByteArray> names = interfaceNames(socket);
|
||||
QSet<QByteArray>::ConstIterator it = names.constBegin();
|
||||
for ( ; it != names.constEnd(); ++it) {
|
||||
ifreq req;
|
||||
memset(&req, 0, sizeof(ifreq));
|
||||
memcpy(req.ifr_name, *it, qMin<int>(it->length() + 1, sizeof(req.ifr_name) - 1));
|
||||
|
||||
QNetworkInterfacePrivate *iface = findInterface(socket, interfaces, req);
|
||||
|
||||
// Get the interface broadcast address
|
||||
QNetworkAddressEntry entry;
|
||||
|
Loading…
x
Reference in New Issue
Block a user