Index: /trunk/src/network/kernel/kernel.pri
===================================================================
--- /trunk/src/network/kernel/kernel.pri	(revision 159)
+++ /trunk/src/network/kernel/kernel.pri	(revision 160)
@@ -23,4 +23,5 @@
 unix:SOURCES += kernel/qhostinfo_unix.cpp kernel/qnetworkinterface_unix.cpp
 win32:SOURCES += kernel/qhostinfo_win.cpp kernel/qnetworkinterface_win.cpp
+os2:SOURCES += kernel/qhostinfo_os2.cpp kernel/qnetworkinterface_os2.cpp
 
 mac:LIBS+= -framework SystemConfiguration
Index: /trunk/src/network/kernel/qhostinfo_os2.cpp
===================================================================
--- /trunk/src/network/kernel/qhostinfo_os2.cpp	(revision 160)
+++ /trunk/src/network/kernel/qhostinfo_os2.cpp	(revision 160)
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** Copyright (C) 2009 netlabs.org. OS/2 parts.
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//#define QHOSTINFO_DEBUG
+
+static const int RESOLVER_TIMEOUT = 2000;
+
+#include "qt_os2.h"
+#include "qplatformdefs.h"
+
+#include "qhostinfo_p.h"
+#include "qiodevice.h"
+#include <qbytearray.h>
+#include <qlibrary.h>
+#include <qurl.h>
+#include <qfile.h>
+
+extern "C" {
+#include <sys/types.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <resolv.h>
+}
+
+#include <qmutex.h>
+QT_BEGIN_NAMESPACE
+Q_GLOBAL_STATIC(QMutex, getHostByNameMutex)
+QT_END_NAMESPACE
+
+QT_BEGIN_NAMESPACE
+
+// Almost always the same. If not, specify in qplatformdefs.h.
+#if !defined(QT_SOCKOPTLEN_T)
+# define QT_SOCKOPTLEN_T QT_SOCKLEN_T
+#endif
+
+QHostInfo QHostInfoAgent::fromName(const QString &hostName)
+{
+    QHostInfo results;
+    results.setHostName(hostName);
+
+#if defined(QHOSTINFO_DEBUG)
+    qDebug("QHostInfoAgent::fromName(%s) looking up...",
+           hostName.toLatin1().constData());
+#endif
+
+    QHostAddress address;
+    if (address.setAddress(hostName)) {
+        // Reverse lookup
+        in_addr_t inetaddr = inet_addr(hostName.toLatin1().constData());
+        struct hostent *ent = gethostbyaddr((const char *)&inetaddr, sizeof(inetaddr), AF_INET);
+        if (!ent) {
+            results.setError(QHostInfo::HostNotFound);
+            results.setErrorString(tr("Host not found"));
+            return results;
+        }
+        results.setHostName(QString::fromLatin1(ent->h_name));
+    }
+
+    // Fall back to gethostbyname for platforms that don't define
+    // getaddrinfo. gethostbyname does not support IPv6, and it's not
+    // reentrant on all platforms. For now this is okay since we only
+    // use one QHostInfoAgent, but if more agents are introduced, locking
+    // must be provided.
+    QMutexLocker locker(::getHostByNameMutex());
+    hostent *result = gethostbyname(hostName.toLatin1().constData());
+    if (result) {
+        if (result->h_addrtype == AF_INET) {
+            QList<QHostAddress> addresses;
+            for (char **p = result->h_addr_list; *p != 0; p++) {
+                QHostAddress addr;
+                addr.setAddress(ntohl(*((quint32 *)*p)));
+                if (!addresses.contains(addr))
+                    addresses.prepend(addr);
+            }
+            results.setAddresses(addresses);
+        } else {
+            results.setError(QHostInfo::UnknownError);
+            results.setErrorString(tr("Unknown address type"));
+        }
+    } else if (h_errno == HOST_NOT_FOUND || h_errno == NO_DATA
+               || h_errno == NO_ADDRESS) {
+        results.setError(QHostInfo::HostNotFound);
+        results.setErrorString(tr("Host not found"));
+    } else {
+        results.setError(QHostInfo::UnknownError);
+        results.setErrorString(tr("Unknown error"));
+    }
+
+#if defined(QHOSTINFO_DEBUG)
+    if (results.error() != QHostInfo::NoError) {
+        qDebug("QHostInfoAgent::fromName(): error #%d %s",
+               h_errno, results.errorString().toLatin1().constData());
+    } else {
+        QString tmp;
+        QList<QHostAddress> addresses = results.addresses();
+        for (int i = 0; i < addresses.count(); ++i) {
+            if (i != 0) tmp += ", ";
+            tmp += addresses.at(i).toString();
+        }
+        qDebug("QHostInfoAgent::fromName(): found %i entries for \"%s\": {%s}",
+               addresses.count(), hostName.toLatin1().constData(),
+               tmp.toLatin1().constData());
+    }
+#endif
+    return results;
+}
+
+QString QHostInfo::localHostName()
+{
+    char hostName[512];
+    if (gethostname(hostName, sizeof(hostName)) == -1)
+        return QString();
+    hostName[sizeof(hostName) - 1] = '\0';
+    return QString::fromLocal8Bit(hostName);
+}
+
+QString QHostInfo::localDomainName()
+{
+    // We have to call res_init to be sure that _res was initialized
+    // So, for systems without getaddrinfo (which is thread-safe), we lock the mutex too
+    {
+        QMutexLocker locker(::getHostByNameMutex());
+        if ((_res.options & RES_INIT) || res_init() == 0) {
+            QString domainName = QUrl::fromAce(_res.defdname);
+            if (domainName.isEmpty())
+                domainName = QUrl::fromAce(_res.dnsrch[0]);
+            return domainName;
+        }
+    }
+
+    // nothing worked, try doing it by ourselves:
+    QFile resolvconf;
+    QByteArray etc = qgetenv("ETC");
+    if (etc.isEmpty()) {
+        etc = "x:\\MPTN\\ETC";
+        ULONG boot = 0;
+        DosQuerySysInfo(QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PVOID)boot, sizeof(boot));
+        etc[0] = (char)(boot + 'A' - 1);
+    }
+    // currently, resolv takes precedence over resolv2 assuming that resolv
+    // is created for PPP connections and therefore should override resolv2
+    // which is created for permanent LAN connections.
+    resolvconf.setFileName(QFile::decodeName(etc) + QLatin1String("\\resolv"));
+    if (!resolvconf.exists())
+        resolvconf.setFileName(QFile::decodeName(etc)+ QLatin1String("\\resolv2"));
+
+    if (!resolvconf.open(QIODevice::ReadOnly))
+        return QString();       // failure
+
+    QString domainName;
+    while (!resolvconf.atEnd()) {
+        QByteArray line = resolvconf.readLine().trimmed();
+        if (line.startsWith("domain "))
+            return QUrl::fromAce(line.mid(sizeof "domain " - 1).trimmed());
+
+        // in case there's no "domain" line, fall back to the first "search" entry
+        if (domainName.isEmpty() && line.startsWith("search ")) {
+            QByteArray searchDomain = line.mid(sizeof "search " - 1).trimmed();
+            int pos = searchDomain.indexOf(' ');
+            if (pos != -1)
+                searchDomain.truncate(pos);
+            domainName = QUrl::fromAce(searchDomain);
+        }
+    }
+
+    // return the fallen-back-to searched domain
+    return domainName;
+}
+
+QT_END_NAMESPACE
Index: /trunk/src/network/kernel/qnetworkinterface_os2.cpp
===================================================================
--- /trunk/src/network/kernel/qnetworkinterface_os2.cpp	(revision 160)
+++ /trunk/src/network/kernel/qnetworkinterface_os2.cpp	(revision 160)
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** Copyright (C) 2009 netlabs.org. OS/2 parts.
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Nokia.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qset.h"
+#include "qnetworkinterface.h"
+#include "qnetworkinterface_p.h"
+#include "qalgorithms.h"
+
+#ifndef QT_NO_NETWORKINTERFACE
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <sys/sockio.h>
+#include <net/if.h>
+
+#include <qplatformdefs.h>
+
+QT_BEGIN_NAMESPACE
+
+static QHostAddress addressFromSockaddr(sockaddr *sa)
+{
+    QHostAddress address;
+    if (!sa)
+        return address;
+
+    if (sa->sa_family == AF_INET)
+        address.setAddress(htonl(((sockaddr_in *)sa)->sin_addr.s_addr));
+    return address;
+
+}
+
+static QNetworkInterface::InterfaceFlags convertFlags(uint rawFlags)
+{
+    QNetworkInterface::InterfaceFlags flags = 0;
+    flags |= (rawFlags & IFF_UP) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0);
+    flags |= (rawFlags & IFF_RUNNING) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0);
+    flags |= (rawFlags & IFF_BROADCAST) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);
+    flags |= (rawFlags & IFF_LOOPBACK) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);
+#ifdef IFF_POINTOPOINT //cygwin doesn't define IFF_POINTOPOINT
+    flags |= (rawFlags & IFF_POINTOPOINT) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);
+#endif
+
+#ifdef IFF_MULTICAST
+    flags |= (rawFlags & IFF_MULTICAST) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);
+#endif
+    return flags;
+}
+
+static const int STORAGEBUFFER_GROWTH = 256;
+
+static QSet<QByteArray> interfaceNames(int socket)
+{
+    QSet<QByteArray> result;
+    QByteArray storageBuffer;
+    struct ifconf interfaceList;
+
+    forever {
+        // grow the storage buffer
+        storageBuffer.resize(storageBuffer.size() + STORAGEBUFFER_GROWTH);
+        interfaceList.ifc_buf = storageBuffer.data();
+        interfaceList.ifc_len = storageBuffer.size();
+
+        // get the interface list
+        if (::ioctl(socket, SIOCGIFCONF, &interfaceList) >= 0) {
+            if (int(interfaceList.ifc_len + sizeof(ifreq) + 64) < storageBuffer.size()) {
+                // if the buffer was big enough, break
+                storageBuffer.resize(interfaceList.ifc_len);
+                break;
+            }
+        } else {
+            // internal error
+            return result;
+        }
+        if (storageBuffer.size() > 100000) {
+            // out of space
+            return result;
+        }
+    }
+
+    int interfaceCount = interfaceList.ifc_len / sizeof(ifreq);
+    for (int i = 0; i < interfaceCount; ++i) {
+        QByteArray name = QByteArray(interfaceList.ifc_req[i].ifr_name);
+        if (!name.isEmpty())
+            result << name;
+    }
+
+    return result;
+}
+
+static QNetworkInterfacePrivate *findInterface(int socket, QList<QNetworkInterfacePrivate *> &interfaces,
+                                               struct ifreq &req)
+{
+    QNetworkInterfacePrivate *iface = 0;
+    int ifindex = 0;
+
+    // Search by name
+    QList<QNetworkInterfacePrivate *>::Iterator if_it = interfaces.begin();
+    for ( ; if_it != interfaces.end(); ++if_it)
+        if ((*if_it)->name == QLatin1String(req.ifr_name)) {
+            // existing interface
+            iface = *if_it;
+            break;
+        }
+
+    if (!iface) {
+        // new interface, create data:
+        iface = new QNetworkInterfacePrivate;
+        iface->index = ifindex;
+        interfaces << iface;
+
+#ifdef SIOCGIFNAME
+        // Get the canonical name
+        QByteArray oldName = req.ifr_name;
+        if (::ioctl(socket, SIOCGIFNAME, &req) >= 0) {
+            iface->name = QString::fromLatin1(req.ifr_name);
+
+            // reset the name:
+            memcpy(req.ifr_name, oldName, qMin<int>(oldName.length() + 1, sizeof(req.ifr_name) - 1));
+        } else
+#endif
+	{
+            // use this name anyways
+            iface->name = QString::fromLatin1(req.ifr_name);
+        }
+
+        // Get interface flags
+        if (::ioctl(socket, SIOCGIFFLAGS, &req) >= 0) {
+            iface->flags = convertFlags(req.ifr_flags);
+        }
+
+#ifdef SIOCGIFHWADDR
+        // Get the HW address
+        if (::ioctl(socket, SIOCGIFHWADDR, &req) >= 0) {
+            uchar *addr = (uchar *)&req.ifr_addr;
+            iface->hardwareAddress = iface->makeHwAddress(6, addr);
+        }
+#endif
+    }
+
+    return iface;
+}
+
+static QList<QNetworkInterfacePrivate *> interfaceListing()
+{
+    QList<QNetworkInterfacePrivate *> interfaces;
+
+    int socket;
+    if ((socket = ::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;
+        if (iface->flags & QNetworkInterface::CanBroadcast) {
+            if (::ioctl(socket, SIOCGIFBRDADDR, &req) >= 0) {
+                sockaddr *sa = &req.ifr_addr;
+                if (sa->sa_family == AF_INET)
+                    entry.setBroadcast(addressFromSockaddr(sa));
+            }
+        }
+
+        // Get the interface netmask
+        if (::ioctl(socket, SIOCGIFNETMASK, &req) >= 0) {
+            sockaddr *sa = &req.ifr_addr;
+	    entry.setNetmask(addressFromSockaddr(sa));
+        }
+
+        // Get the address of the interface
+        if (::ioctl(socket, SIOCGIFADDR, &req) >= 0) {
+            sockaddr *sa = &req.ifr_addr;
+            entry.setIp(addressFromSockaddr(sa));
+        }
+
+        iface->addressEntries << entry;
+    }
+
+    ::close(socket);
+    return interfaces;
+}
+
+QList<QNetworkInterfacePrivate *> QNetworkInterfaceManager::scan()
+{
+    return interfaceListing();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_NETWORKINTERFACE
Index: /trunk/src/network/network.pro
===================================================================
--- /trunk/src/network/network.pro	(revision 159)
+++ /trunk/src/network/network.pro	(revision 160)
@@ -2,4 +2,7 @@
 
 TARGET   = QtNetwork
+
+os2:TARGET_SHORT = QtNet
+
 QPRO_PWD = $$PWD
 DEFINES += QT_BUILD_NETWORK_LIB QT_NO_USING_NAMESPACE
