123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #ifndef QNETWORKINTERFACE_H
- #define QNETWORKINTERFACE_H
- #include <QtCore/qshareddata.h>
- #include <QtCore/qscopedpointer.h>
- #include <QtNetwork/qhostaddress.h>
- #ifndef QT_NO_NETWORKINTERFACE
- QT_BEGIN_NAMESPACE
- template<typename T> class QList;
- class QNetworkAddressEntryPrivate;
- class Q_NETWORK_EXPORT QNetworkAddressEntry
- {
- public:
- QNetworkAddressEntry();
- QNetworkAddressEntry(const QNetworkAddressEntry &other);
- #ifdef Q_COMPILER_RVALUE_REFS
- QNetworkAddressEntry &operator=(QNetworkAddressEntry &&other) Q_DECL_NOTHROW { swap(other); return *this; }
- #endif
- QNetworkAddressEntry &operator=(const QNetworkAddressEntry &other);
- ~QNetworkAddressEntry();
- void swap(QNetworkAddressEntry &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
- bool operator==(const QNetworkAddressEntry &other) const;
- inline bool operator!=(const QNetworkAddressEntry &other) const
- { return !(*this == other); }
- QHostAddress ip() const;
- void setIp(const QHostAddress &newIp);
- QHostAddress netmask() const;
- void setNetmask(const QHostAddress &newNetmask);
- int prefixLength() const;
- void setPrefixLength(int length);
- QHostAddress broadcast() const;
- void setBroadcast(const QHostAddress &newBroadcast);
- private:
- QScopedPointer<QNetworkAddressEntryPrivate> d;
- };
- Q_DECLARE_SHARED(QNetworkAddressEntry)
- class QNetworkInterfacePrivate;
- class Q_NETWORK_EXPORT QNetworkInterface
- {
- public:
- enum InterfaceFlag {
- IsUp = 0x1,
- IsRunning = 0x2,
- CanBroadcast = 0x4,
- IsLoopBack = 0x8,
- IsPointToPoint = 0x10,
- CanMulticast = 0x20
- };
- Q_DECLARE_FLAGS(InterfaceFlags, InterfaceFlag)
- QNetworkInterface();
- QNetworkInterface(const QNetworkInterface &other);
- #ifdef Q_COMPILER_RVALUE_REFS
- QNetworkInterface &operator=(QNetworkInterface &&other) Q_DECL_NOTHROW { swap(other); return *this; }
- #endif
- QNetworkInterface &operator=(const QNetworkInterface &other);
- ~QNetworkInterface();
- void swap(QNetworkInterface &other) Q_DECL_NOTHROW { qSwap(d, other.d); }
- bool isValid() const;
- int index() const;
- QString name() const;
- QString humanReadableName() const;
- InterfaceFlags flags() const;
- QString hardwareAddress() const;
- QList<QNetworkAddressEntry> addressEntries() const;
- static int interfaceIndexFromName(const QString &name);
- static QNetworkInterface interfaceFromName(const QString &name);
- static QNetworkInterface interfaceFromIndex(int index);
- static QString interfaceNameFromIndex(int index);
- static QList<QNetworkInterface> allInterfaces();
- static QList<QHostAddress> allAddresses();
- private:
- friend class QNetworkInterfacePrivate;
- QSharedDataPointer<QNetworkInterfacePrivate> d;
- };
- Q_DECLARE_SHARED(QNetworkInterface)
- Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkInterface::InterfaceFlags)
- #ifndef QT_NO_DEBUG_STREAM
- Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, const QNetworkInterface &networkInterface);
- #endif
- QT_END_NAMESPACE
- Q_DECLARE_METATYPE(QNetworkAddressEntry)
- Q_DECLARE_METATYPE(QNetworkInterface)
- #endif
- #endif
|