diff options
author | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-07-08 15:20:00 (GMT) |
---|---|---|
committer | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-07-24 09:18:59 (GMT) |
commit | 1401d0a8b232278f5f07c9c34ed537885e7f17e2 (patch) | |
tree | 43ab65592b965797ea8a5be6502df48f80bd64a0 /src/network/kernel | |
parent | cf66c667a97c0079141eb3f2d9e997b7378ae792 (diff) | |
download | Qt-1401d0a8b232278f5f07c9c34ed537885e7f17e2.zip Qt-1401d0a8b232278f5f07c9c34ed537885e7f17e2.tar.gz Qt-1401d0a8b232278f5f07c9c34ed537885e7f17e2.tar.bz2 |
For some reason interface info on Symbian will not
give neither correct netmask nor broadcast address.
But, experiments show that route info can be used to
obtain netmask. Then is easy to calculate broadcast
address.
Idea is to match interface and destination address from
routeinfo entry, and then to use given netmask.
"Machines take me by surprise with great frequency."
Alan Turing(1912 - 1954)
Diffstat (limited to 'src/network/kernel')
-rw-r--r-- | src/network/kernel/qnetworkinterface_symbian.cpp | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp index 59f1c02..e3a282f 100644 --- a/src/network/kernel/qnetworkinterface_symbian.cpp +++ b/src/network/kernel/qnetworkinterface_symbian.cpp @@ -175,7 +175,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() iface->addressEntries << entry; #if defined(QNETWORKINTERFACE_DEBUG) - qDebug("\n Found network interface %s, interface flags:\n\ + printf("\n Found network interface %s, interface flags:\n\ IsUp = %d, IsRunning = %d, CanBroadcast = %d,\n\ IsLoopBack = %d, IsPointToPoint = %d, CanMulticast = %d, \n\ ip = %s, netmask = %s, broadcast = %s,\n\ @@ -188,8 +188,65 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() #endif } } + + // we will try to use routing info to detect more precisely + // netmask and then ::postProcess() should calculate + // broadcast addresses + + // use dummy socket to start enumerating routes + err = socket.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl); + if( err ) + { + socket.Close(); + socketServ.Close(); + // return what we have + // up to this moment + return interfaces; + } + + TSoInetRouteInfo routeInfo; + TPckg<TSoInetRouteInfo> routeInfoPkg(routeInfo); + while(socket.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone) + { + TName address; + + // get interface address + routeInfo.iIfAddr.Output(address); + QHostAddress ifAddr(qstringFromDesc(address)); + if(ifAddr.isNull()) + continue; + + routeInfo.iDstAddr.Output(address); + QHostAddress destination(qstringFromDesc(address)); + if(destination.isNull() || destination != ifAddr) + continue; + + // search interfaces + for(int ifindex = 0; ifindex < interfaces.size(); ++ifindex) { + QNetworkInterfacePrivate *iface = interfaces.at(ifindex); + for(int eindex = 0; eindex < iface->addressEntries.size(); ++eindex) { + QNetworkAddressEntry entry = iface->addressEntries.at(eindex); + if(entry.ip() != ifAddr) { + continue; + } else { + routeInfo.iNetMask.Output(address); + QHostAddress netmask(qstringFromDesc(address)); + entry.setNetmask(netmask); + // NULL boradcast address for + // ::postProcess to have effect + entry.setBroadcast(QHostAddress()); + iface->addressEntries.replace(eindex, entry); +// printf("for %s netmask = %s and destination = %s ; type = %d; state = %d; metric = %d \n", +// ifAddr.toString().toLatin1().constData(), netmask.toString().toLatin1().constData(), destination.toString().toLatin1().constData(), +// routeInfo.iType, routeInfo.iState, routeInfo.iMetric); + } + } + } + } + socket.Close(); - socketServ.Close(); + socketServ.Close(); + return interfaces; } |