Qt 4.8
|
The QNetworkAddressEntry class stores one IP address supported by a network interface, along with its associated netmask and broadcast address. More...
#include <qnetworkinterface.h>
Public Functions | |
QHostAddress | broadcast () const |
Returns the broadcast address associated with the IPv4 address and netmask. More... | |
QHostAddress | ip () const |
This function returns one IPv4 or IPv6 address found, that was found in a network interface. More... | |
QHostAddress | netmask () const |
Returns the netmask associated with the IP address. More... | |
bool | operator!= (const QNetworkAddressEntry &other) const |
Returns true if this network address entry is different from other. More... | |
QNetworkAddressEntry & | operator= (const QNetworkAddressEntry &other) |
Makes a copy of the QNetworkAddressEntry object other. More... | |
bool | operator== (const QNetworkAddressEntry &other) const |
Returns true if this network address entry is the same as other. More... | |
int | prefixLength () const |
Returns the prefix length of this IP address. More... | |
QNetworkAddressEntry () | |
Constructs an empty QNetworkAddressEntry object. More... | |
QNetworkAddressEntry (const QNetworkAddressEntry &other) | |
Constructs a QNetworkAddressEntry object that is a copy of the object other. More... | |
void | setBroadcast (const QHostAddress &newBroadcast) |
Sets the broadcast IP address of this QNetworkAddressEntry object to newBroadcast. More... | |
void | setIp (const QHostAddress &newIp) |
Sets the IP address the QNetworkAddressEntry object contains to newIp. More... | |
void | setNetmask (const QHostAddress &newNetmask) |
Sets the netmask that this QNetworkAddressEntry object contains to newNetmask. More... | |
void | setPrefixLength (int length) |
Sets the prefix length of this IP address to length. More... | |
~QNetworkAddressEntry () | |
Destroys this QNetworkAddressEntry object. More... | |
Properties | |
QScopedPointer< QNetworkAddressEntryPrivate > | d |
The QNetworkAddressEntry class stores one IP address supported by a network interface, along with its associated netmask and broadcast address.
Each network interface can contain zero or more IP addresses, which in turn can be associated with a netmask and/or a broadcast address (depending on support from the operating system).
This class represents one such group.
Definition at line 60 of file qnetworkinterface.h.
QNetworkAddressEntry::QNetworkAddressEntry | ( | ) |
Constructs an empty QNetworkAddressEntry object.
Definition at line 166 of file qnetworkinterface.cpp.
QNetworkAddressEntry::QNetworkAddressEntry | ( | const QNetworkAddressEntry & | other | ) |
Constructs a QNetworkAddressEntry object that is a copy of the object other.
Definition at line 175 of file qnetworkinterface.cpp.
QNetworkAddressEntry::~QNetworkAddressEntry | ( | ) |
Destroys this QNetworkAddressEntry object.
Definition at line 192 of file qnetworkinterface.cpp.
QHostAddress QNetworkAddressEntry::broadcast | ( | ) | const |
Returns the broadcast address associated with the IPv4 address and netmask.
It can usually be derived from those two by setting to 1 the bits of the IP address where the netmask contains a 0. (In other words, by bitwise-OR'ing the IP address with the inverse of the netmask)
This member is always empty for IPv6 addresses, since the concept of broadcast has been abandoned in that system in favor of multicast. In particular, the group of hosts corresponding to all the nodes in the local network can be reached by the "all-nodes" special multicast group (address FF02::1).
Definition at line 326 of file qnetworkinterface.cpp.
Referenced by operator<<().
QHostAddress QNetworkAddressEntry::ip | ( | ) | const |
This function returns one IPv4 or IPv6 address found, that was found in a network interface.
Definition at line 223 of file qnetworkinterface.cpp.
Referenced by QNetworkInterface::allAddresses(), interfaceListing(), interfaceListingWinXP(), isBypassed(), multicastMembershipHelper(), QNativeSocketEnginePrivate::nativeMulticastInterface(), QNativeSocketEnginePrivate::nativeSetMulticastInterface(), operator<<(), and setNetmask().
QHostAddress QNetworkAddressEntry::netmask | ( | ) | const |
Returns the netmask associated with the IP address.
The netmask is expressed in the form of an IP address, such as 255.255.0.0.
For IPv6 addresses, the prefix length is converted to an address where the number of bits set to 1 is equal to the prefix length. For a prefix length of 64 bits (the most common value), the netmask will be expressed as a QHostAddress holding the address FFFF:FFFF:FFFF:FFFF::
Definition at line 250 of file qnetworkinterface.cpp.
Referenced by operator<<().
|
inline |
Returns true if this network address entry is different from other.
Definition at line 68 of file qnetworkinterface.h.
QNetworkAddressEntry & QNetworkAddressEntry::operator= | ( | const QNetworkAddressEntry & | other | ) |
Makes a copy of the QNetworkAddressEntry object other.
Definition at line 183 of file qnetworkinterface.cpp.
bool QNetworkAddressEntry::operator== | ( | const QNetworkAddressEntry & | other | ) | const |
Returns true if this network address entry is the same as other.
Definition at line 200 of file qnetworkinterface.cpp.
int QNetworkAddressEntry::prefixLength | ( | ) | const |
Returns the prefix length of this IP address.
This function returns -1 if the prefix length could not be determined (i.e., netmask() returns a null QHostAddress()).
Definition at line 288 of file qnetworkinterface.cpp.
Referenced by isBypassed().
void QNetworkAddressEntry::setBroadcast | ( | const QHostAddress & | newBroadcast | ) |
Sets the broadcast IP address of this QNetworkAddressEntry object to newBroadcast.
Definition at line 335 of file qnetworkinterface.cpp.
Referenced by convertFlags(), and interfaceListing().
void QNetworkAddressEntry::setIp | ( | const QHostAddress & | newIp | ) |
Sets the IP address the QNetworkAddressEntry object contains to newIp.
Definition at line 232 of file qnetworkinterface.cpp.
Referenced by convertFlags(), interfaceListing(), interfaceListingWin2k(), and interfaceListingWinXP().
void QNetworkAddressEntry::setNetmask | ( | const QHostAddress & | newNetmask | ) |
Sets the netmask that this QNetworkAddressEntry object contains to newNetmask.
Setting the netmask also sets the prefix length to match the new netmask.
Definition at line 262 of file qnetworkinterface.cpp.
Referenced by convertFlags(), interfaceListing(), interfaceListingWin2k(), and interfaceListingWinXP().
void QNetworkAddressEntry::setPrefixLength | ( | int | length | ) |
Sets the prefix length of this IP address to length.
Setting the prefix length also sets the netmask (see netmask()).
Definition at line 308 of file qnetworkinterface.cpp.
Referenced by interfaceListingWinXP().
|
private |
Definition at line 83 of file qnetworkinterface.h.
Referenced by broadcast(), ip(), netmask(), operator=(), operator==(), prefixLength(), setBroadcast(), setIp(), setNetmask(), and setPrefixLength().