diff options
Diffstat (limited to 'src/network/kernel/qnetworkinterface_symbian.cpp')
-rw-r--r-- | src/network/kernel/qnetworkinterface_symbian.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp index d3aafa3..bec2dc3 100644 --- a/src/network/kernel/qnetworkinterface_symbian.cpp +++ b/src/network/kernel/qnetworkinterface_symbian.cpp @@ -69,14 +69,14 @@ static QNetworkInterface::InterfaceFlags convertFlags( const TSoInetInterfaceInf flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0); // We do not have separate flag for running in Symbian OS flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0); - flags |= (aInfo.iFeatures&KIfCanBroadcast) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0); + flags |= (aInfo.iFeatures&KIfCanBroadcast) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0); flags |= (aInfo.iFeatures&KIfIsLoopback) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0); flags |= (aInfo.iFeatures&KIfIsPointToPoint) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0); flags |= (aInfo.iFeatures&KIfCanMulticast) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0); return flags; } -QString qstringFromDesc( const TDesC& aData ) +QString qstringFromDesc( const TDesC& aData ) { return QString::fromUtf16(aData.Ptr(), aData.Length()); } @@ -85,20 +85,20 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() { TInt err( KErrNone ); QList<QNetworkInterfacePrivate *> interfaces; - + // Connect to Native socket server RSocketServ socketServ; err = socketServ.Connect(); if( err ) return interfaces; - + // Open dummy socket for interface queries RSocket socket; err = socket.Open( socketServ, _L("udp")); if( err ) { socketServ.Close(); - return interfaces; + return interfaces; } // Ask socket to start enumerating interfaces @@ -107,8 +107,8 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() { socket.Close(); socketServ.Close(); - return interfaces; - } + return interfaces; + } int ifindex = 0; TPckgBuf<TSoInetInterfaceInfo> infoPckg; @@ -118,74 +118,74 @@ static QList<QNetworkInterfacePrivate *> interfaceListing() // Do not include IPv6 addresses because netmask and broadcast address cannot be determined correctly if( info.iName != KNullDesC && info.iAddress.IsV4Mapped() ) { - TName address; - QNetworkAddressEntry entry; - QNetworkInterfacePrivate *iface = 0; - - iface = new QNetworkInterfacePrivate; + TName address; + QNetworkAddressEntry entry; + QNetworkInterfacePrivate *iface = 0; + + iface = new QNetworkInterfacePrivate; iface->index = ifindex++; interfaces << iface; iface->name = qstringFromDesc( info.iName ); iface->flags = convertFlags( info ); - + if( /*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec ) { - for ( TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++ ) + for ( TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++ ) { address.AppendNumFixedWidth(info.iHwAddr[i], EHex, 2); if( ( i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen() ) address.Append( _L(":") ); - } - address.UpperCase(); + } + address.UpperCase(); iface->hardwareAddress = qstringFromDesc( address ); } - + // Get the address of the interface info.iAddress.Output(address); - entry.setIp( QHostAddress( qstringFromDesc( address ) ) ); + entry.setIp( QHostAddress( qstringFromDesc( address ) ) ); - // Get the interface netmask - // TODO: For some reason netmask is always 0.0.0.0 + // Get the interface netmask + // TODO: For some reason netmask is always 0.0.0.0 //info.iNetMask.Output(address); - //entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) ); - + //entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) ); + // Workaround: Let Symbian determine netmask based on IP address class // TODO: works only for IPv4 TInetAddr netmask; netmask.NetMask( info.iAddress ); netmask.Output(address); - entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) ); - + entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) ); + // Get the interface broadcast address - if (iface->flags & QNetworkInterface::CanBroadcast) + if (iface->flags & QNetworkInterface::CanBroadcast) { // For some reason broadcast address is always 0.0.0.0 // info.iBrdAddr.Output(address); - // entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) ); - + // entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) ); + // Workaround: Let Symbian determine broadcast address based on IP address // TODO: works only for IPv4 TInetAddr broadcast; - broadcast.NetBroadcast( info.iAddress ); + broadcast.NetBroadcast( info.iAddress ); broadcast.Output(address); entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) ); } - + // Add new entry to interface address entries - iface->addressEntries << entry; - -#if defined(QNETWORKINTERFACE_DEBUG) + iface->addressEntries << entry; + +#if defined(QNETWORKINTERFACE_DEBUG) 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\ - hwaddress = %s", + hwaddress = %s", iface->name.toLatin1().constData(), iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast, iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast, entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(), - iface->hardwareAddress.toLatin1().constData()); -#endif + iface->hardwareAddress.toLatin1().constData()); +#endif } } |