Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-33911

In Android: QNetworkAddressEntry::netmask() gives no value

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 4.8.6, 5.1.1
    • Fix Version/s: 5.2.1
    • Component/s: Network
    • Labels:
      None
    • Platform/s:
      Android
    • Commits:
      e82951611c6d965cc8ef9cbf4ee7fbccf615bb3f a0930d007c01423daebc5c63fbf8635a8b394fd7

      Description

      The problem is that the Netmask of the network interface is not reported by QNetworkAddressEntry::netmask() when using Android. Also QNetworkAddressEntry::prefixLength() gives a value of -1, indicating error.

      The same test program (NetInterfView) works perfect in Linux desktop for booth Qt4.8 and Qt5.1.1.
      In Android it fails for Qt5.1.1 both in the emulator and when using a real Nexus7 with Android 4.3.

      The test program has been attached, and the main part of it is:

      void MainWindow::on_interfButton_clicked()
      {
          QString text;
          QList<QNetworkInterface>  intfList = QNetworkInterface::allInterfaces();
          int  intfListLen = intfList.size();
          for (int i = 0; i < intfListLen; ++i) {
              QNetworkInterface  interface = intfList.at(i);
              QNetworkInterface::InterfaceFlags  flags = interface.flags();
              if (!flags.testFlag( QNetworkInterface::IsUp)
              || flags.testFlag( QNetworkInterface::IsPointToPoint))
                  continue;
      
              QList<QNetworkAddressEntry>  entries = interface.addressEntries();
              int  entriesLen = entries.size();
              for (int j = 0; j < entriesLen; ++j) {
                   QNetworkAddressEntry entry = entries.at(j);
                  QAbstractSocket::NetworkLayerProtocol  prot = entry.ip().protocol();
                  if ((prot != QAbstractSocket::IPv4Protocol) && (prot != QAbstractSocket::IPv6Protocol))
                      continue;
      
                  text += interface.name() + "  ip=" + entry.ip().toString()
                         + " mask=" + entry.netmask().toString();
                  if (entry.prefixLength() < 0) {
                      // TODO MW: This seemes like a bug in android/qt, any workaround?
                      text += "  Bad netmask";
                  }
                  text += "\n\n";
              }
          }
      
          ui->textEdit->setPlainText(text);
      }
      

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            stromme Christian
            Reporter:
            micwik Michael Wiklund
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes