INET Framework for OMNeT++/OMNEST
|
Stores a 128-bit IPv6 address in an efficient way. More...
#include <IPv6Address.h>
Public Types | |
enum | Scope { UNSPECIFIED, LOOPBACK, MULTICAST, LINK, SITE, GLOBAL } |
IPv6 address scope (RFC 3513) More... | |
Public Member Functions | |
IPv6Address () | |
Constructor. More... | |
IPv6Address (uint64 hi, uint64 lo) | |
Constructs an IPv6 address from two 64-bit integers. More... | |
IPv6Address (uint32 segment0, uint32 segment1, uint32 segment2, uint32 segment3) | |
Constructs an IPv6 address from four 32-bit integers. More... | |
IPv6Address (const char *addr) | |
Constructor. More... | |
bool | operator< (const IPv6Address &addr) const |
bool | operator> (const IPv6Address &addr) const |
bool | operator== (const IPv6Address &addr) const |
bool | operator!= (const IPv6Address &addr) const |
int | compare (const IPv6Address &addr) const |
Returns -1, 0 or 1. More... | |
bool | tryParse (const char *addr) |
Tries parsing an IPv6 address string into the object. More... | |
bool | tryParseAddrWithPrefix (const char *addr, int &prefixLen) |
Expects a string in the "<address>/<prefixlength>" syntax, parses the address into the object (see tryParse(), and returns the prefix length (a 0..128 integer) in the second argument. More... | |
void | set (const char *addr) |
Sets the IPv6 address. More... | |
std::string | str () const |
Returns the textual representation of the address in the standard notation. More... | |
void | set (uint32 d0, uint32 d1, uint32 d2, uint32 d3) |
Sets the IPv6 address from four 32-bit integers. More... | |
uint32 * | words () |
Returns a pointer to the internal binary representation of the address: four 32-bit words, most significant word first. More... | |
const uint32 * | words () const |
Returns a pointer to the internal binary representation of the address: four 32-bit words, most significant word first. More... | |
Scope | getScope () const |
Get the IPv6 address scope. More... | |
IPv6Address | getPrefix (int prefixLength) const |
Get the IPv6 first prefixLength bits of the address, with the rest set to zero. More... | |
IPv6Address | getSuffix (int prefixLength) const |
Get the last 128-prefixLength bits of the address, with the first bits set to zero. More... | |
const IPv6Address & | setPrefix (const IPv6Address &fromAddr, int prefixLength) |
Overwrites the first prefixLength bits of the address with the bits from the address passed as argument. More... | |
const IPv6Address & | setSuffix (const IPv6Address &fromAddr, int prefixLength) |
Overwrites the last 128-prefixLength bits of the address with the bits from address passed as argument. More... | |
IPv6Address | formSolicitedNodeMulticastAddress () const |
Returns the solicited-node multicast address for this address. More... | |
bool | isSolicitedNodeMulticastAddress () const |
IPv6Address | formSubnetRouterAnycastAddress (int prefixLength) const |
Returns the subnet-router anycast address for this address by setting its suffix (the last 128-prefixLength bits) to all-zeroes. More... | |
bool | matches (const IPv6Address &prefix, int prefixLength) const |
Returns true if the address matches the given prefix. More... | |
bool | isUnspecified () const |
Check if the IPv6 Address is undefined. More... | |
bool | isMulticast () const |
Utility function based on getScope() More... | |
bool | isUnicast () const |
Utility function based on getScope() More... | |
bool | isLoopback () const |
Utility function based on getScope() More... | |
bool | isLinkLocal () const |
Utility function based on getScope() More... | |
bool | isSiteLocal () const |
Utility function based on getScope() More... | |
bool | isGlobal () const |
Utility function based on getScope() More... | |
int | getMulticastScope () const |
Get the 4-bit scope field of an IPv6 multicast address. More... | |
Static Public Member Functions | |
static const char * | scopeName (Scope s) |
Return the string representation of the given scope. More... | |
static void | constructMask (int prefixLength, uint32 *mask) |
Construct a 128-bit mask based on the prefix length. More... | |
static IPv6Address | constructMask (int prefixLength) |
static IPv6Address | formLinkLocalAddress (const InterfaceToken &ident) |
Forms a link-local address using the given interface identifier. More... | |
Static Public Attributes | |
Predefined addresses | |
static const IPv6Address | UNSPECIFIED_ADDRESS |
The unspecified address. More... | |
static const IPv6Address | LOOPBACK_ADDRESS |
The loopback address. More... | |
static const IPv6Address | ALL_NODES_1 |
All-nodes multicast address, scope 1 (interface-local) More... | |
static const IPv6Address | ALL_NODES_2 |
All-nodes multicast address, scope 2 (link-local) More... | |
static const IPv6Address | ALL_ROUTERS_1 |
All-routers multicast address, scope 1 (interface-local) More... | |
static const IPv6Address | ALL_ROUTERS_2 |
All-routers multicast address, scope 2 (link-local) More... | |
static const IPv6Address | ALL_ROUTERS_5 |
All-routers multicast address, scope 5 (site-local) More... | |
static const IPv6Address | SOLICITED_NODE_PREFIX |
The solicited-node multicast address prefix (prefix length = 104) More... | |
static const IPv6Address | LINKLOCAL_PREFIX |
The link-local prefix (fe80::) More... | |
static const IPv6Address | LL_MANET_ROUTERS |
Link-local MANET routers multicast address. More... | |
Protected Member Functions | |
bool | doTryParse (const char *&addr) |
Private Attributes | |
uint32 | d [4] |
Stores a 128-bit IPv6 address in an efficient way.
Complies to RFC 3513, "Internet Protocol Version 6 (IPv6) Addressing Architecture."
IPv6 address scope (RFC 3513)
Enumerator | |
---|---|
UNSPECIFIED | |
LOOPBACK | |
MULTICAST | |
LINK | |
SITE | |
GLOBAL |
|
inline |
Constructor.
Initializes the IPv6 address to ::0 (all-zeroes).
Referenced by getPrefix(), and getSuffix().
Constructs an IPv6 address from two 64-bit integers.
|
inlineexplicit |
Constructor.
Sets the address from the given text representation. See documentation of tryParse() for supported syntax.
|
inline |
Returns -1, 0 or 1.
|
static |
Construct a 128-bit mask based on the prefix length.
Mask should point to an array of four 32-bit words, most significant word first.
Referenced by constructMask(), getPrefix(), getSuffix(), matches(), setPrefix(), and setSuffix().
|
static |
|
protected |
Referenced by tryParse(), and tryParseAddrWithPrefix().
|
static |
Forms a link-local address using the given interface identifier.
Referenced by inet::IPv6NeighbourDiscovery::assignLinkLocalAddress(), inet::IPv6RoutingTable::assignRequiredNodeAddresses(), and inet::FlatNetworkConfigurator6::configureAdvPrefixes().
|
inline |
Returns the solicited-node multicast address for this address.
This function replaces the prefix with FF02:0:0:0:0:1:FF00:0/104.
Referenced by inet::IPv6NeighbourDiscovery::initiateAddressResolution(), inet::IPv6NeighbourDiscovery::initiateDAD(), inet::IPv6NeighbourDiscovery::processARTimeout(), and inet::IPv6NeighbourDiscovery::processDADTimeout().
|
inline |
Returns the subnet-router anycast address for this address by setting its suffix (the last 128-prefixLength bits) to all-zeroes.
See section 2.6.1 of RFC 3513.
int inet::IPv6Address::getMulticastScope | ( | ) | const |
IPv6Address inet::IPv6Address::getPrefix | ( | int | prefixLength | ) | const |
Get the IPv6 first prefixLength bits of the address, with the rest set to zero.
IPv6Address::Scope inet::IPv6Address::getScope | ( | ) | const |
Get the IPv6 address scope.
Referenced by inet::IPv6InterfaceData::addrLess(), inet::sctp::SCTPAssociation::getAddressLevel(), inet::L3AddressResolver::getIPv6AddressFrom(), inet::IPv6NeighbourDiscovery::processRAPrefixInfoForAddrAutoConf(), and inet::xMIPv6::validateType2RH().
IPv6Address inet::IPv6Address::getSuffix | ( | int | prefixLength | ) | const |
Get the last 128-prefixLength bits of the address, with the first bits set to zero.
|
inline |
Utility function based on getScope()
Referenced by inet::FlatNetworkConfigurator6::addOwnAdvPrefixRoutes(), inet::IPv6InterfaceData::addrLess(), inet::FlatNetworkConfigurator6::addStaticRoutes(), inet::IPv6InterfaceData::assignAddress(), inet::PingApp::getAllAddresses(), inet::IPv6RoutingTable::initialize(), and inet::xMIPv6::validateBUMessage().
|
inline |
Utility function based on getScope()
Referenced by inet::L3Address::isLinkLocal(), inet::IPv6NeighbourDiscovery::processRAPrefixInfo(), inet::IPv6NeighbourDiscovery::processRAPrefixInfoForAddrAutoConf(), inet::IPv6::routePacket(), and inet::IPv6NeighbourDiscovery::validateRAPacket().
|
inline |
Utility function based on getScope()
Referenced by inet::IPv6::routePacket().
|
inline |
Utility function based on getScope()
Referenced by inet::IPv6InterfaceData::addMulticastListener(), inet::IPv6::datagramLocalOut(), inet::IPv6::handleMessageFromHL(), inet::L3Address::isMulticast(), inet::IPv6InterfaceData::joinMulticastGroup(), inet::IPv6InterfaceData::leaveMulticastGroup(), inet::IPv6::preroutingFinish(), inet::ICMPv6::processEchoRequest(), inet::UDP::processUDPPacket(), inet::ICMPv6::validateDatagramPromptingError(), inet::IPv6NeighbourDiscovery::validateNAPacket(), and inet::IPv6NeighbourDiscovery::validateNSPacket().
|
inline |
Utility function based on getScope()
|
inline |
Referenced by inet::IPv6::fragmentAndSend().
|
inline |
Utility function based on getScope()
Referenced by inet::IPv6Tunneling::createTunnel(), inet::L3Address::isUnicast(), inet::IPv6NeighbourDiscovery::processNSForTentativeAddress(), inet::xMIPv6::validateBUMessage(), and inet::xMIPv6::validateType2RH().
|
inline |
Check if the IPv6 Address is undefined.
Referenced by inet::IPv6NeighbourDiscovery::assignLinkLocalAddress(), inet::FlatNetworkConfigurator6::configureAdvPrefixes(), inet::xMIPv6::createAndSendBRRMessage(), inet::xMIPv6::createAndSendBUMessage(), inet::IPv6NeighbourDiscovery::createAndSendNSPacket(), inet::IPv6NeighbourDiscovery::determineNextHop(), inet::IPv6::determineOutputInterface(), inet::IPv6::encapsulate(), inet::IPv6Tunneling::encapsulateDatagram(), inet::IPv6::fragmentAndSend(), inet::PingApp::getAllAddresses(), inet::IPv6RoutingTable::getInterfaceByAddress(), inet::L3AddressResolver::getInterfaceIPv6Address(), inet::IPv6::handleMessageFromHL(), inet::L3Address::isUnspecified(), inet::IPv6NeighbourDiscovery::makeTentativeAddressPermanent(), inet::IPv6NeighbourDiscovery::processIPv6Datagram(), inet::IPv6NeighbourDiscovery::processNSForNonTentativeAddress(), inet::IPv6NeighbourDiscovery::processNSForTentativeAddress(), inet::IPv6NeighbourDiscovery::processRAPrefixInfo(), inet::IPv6NeighbourDiscovery::processRAPrefixInfoForAddrAutoConf(), inet::IPv6::resolveMACAddressAndSendPacket(), inet::ICMPv6::sendErrorMessage(), inet::IPv6NeighbourDiscovery::sendSolicitedNA(), inet::xMIPv6::sendTestInit(), str(), inet::IPv6NeighbourDiscovery::validateNSPacket(), and inet::IPv6NeighbourDiscovery::validateRSPacket().
bool inet::IPv6Address::matches | ( | const IPv6Address & | prefix, |
int | prefixLength | ||
) | const |
Returns true if the address matches the given prefix.
Referenced by inet::IPv6NeighbourDiscovery::createAndSendNSPacket(), inet::IPv6RoutingTable::doLongestPrefixMatch(), inet::IPv6RoutingTable::isLocalAddress(), inet::InterfaceTable::isNeighborAddress(), inet::IPv6RoutingTable::isOnLinkAddress(), inet::IPv6RoutingTable::isPrefixPresent(), inet::MultiFieldClassifier::Filter::matches(), inet::L3Address::matches(), inet::IPv6NeighbourDiscovery::processRAPrefixInfo(), inet::IPv6NeighbourDiscovery::processRAPrefixInfoForAddrAutoConf(), and inet::IPv6NeighbourDiscovery::validateNSPacket().
|
inline |
|
inline |
|
inline |
|
inline |
|
static |
Return the string representation of the given scope.
Referenced by inet::IPv6InterfaceData::info().
void inet::IPv6Address::set | ( | const char * | addr | ) |
Sets the IPv6 address.
Given a string.
Referenced by inet::IPv6RoutingTable::configureTunnelFromXML(), and inet::serializer::IPv6Serializer::deserialize().
const IPv6Address & inet::IPv6Address::setPrefix | ( | const IPv6Address & | fromAddr, |
int | prefixLength | ||
) |
Overwrites the first prefixLength bits of the address with the bits from the address passed as argument.
Return value is the object itself.
Referenced by inet::IPv6InterfaceData::autoConfRouterGlobalScopeAddress(), formSolicitedNodeMulticastAddress(), inet::IPv6NeighbourDiscovery::processRAPacket(), inet::IPv6NeighbourDiscovery::processRAPrefixInfo(), and inet::IPv6NeighbourDiscovery::processRAPrefixInfoForAddrAutoConf().
const IPv6Address & inet::IPv6Address::setSuffix | ( | const IPv6Address & | fromAddr, |
int | prefixLength | ||
) |
Overwrites the last 128-prefixLength bits of the address with the bits from address passed as argument.
Return value is the object itself.
Referenced by formLinkLocalAddress(), and formSubnetRouterAnycastAddress().
std::string inet::IPv6Address::str | ( | ) | const |
Returns the textual representation of the address in the standard notation.
Referenced by inet::IPv6InterfaceData::addMulticastListener(), inet::IPv6RoutingTable::doLongestPrefixMatch(), inet::PacketDump::dumpIPv6(), inet::IPv6::encapsulate(), inet::IPv6RoutingTable::getInterfaceByAddress(), getMulticastScope(), inet::IPv6RoutingTable::isLocalAddress(), inet::IPv6InterfaceData::joinMulticastGroup(), inet::IPv6InterfaceData::leaveMulticastGroup(), inet::IPv6RoutingTable::lookupDestCache(), inet::operator<<(), inet::IPv6NeighbourDiscovery::reachabilityConfirmed(), inet::IPv6NeighbourDiscovery::resolveNeighbour(), inet::L3Address::str(), and inet::InterfaceTable::updateLinkDisplayString().
bool inet::IPv6Address::tryParse | ( | const char * | addr | ) |
Tries parsing an IPv6 address string into the object.
Returns true if the string contains a well-formed IPv6 address, and false otherwise. All RFC 3513 notations are accepted (e.g. FEDC:BA98:7654:3210:FEDC:BA98:7654:3210, FF01::101, ::1), plus also "<unspec>" as a synonym for the unspecified address (all-zeroes).
Referenced by set(), and inet::L3Address::tryParse().
bool inet::IPv6Address::tryParseAddrWithPrefix | ( | const char * | addr, |
int & | prefixLen | ||
) |
Expects a string in the "<address>/<prefixlength>" syntax, parses the address into the object (see tryParse(), and returns the prefix length (a 0..128 integer) in the second argument.
The return value is true if the operation was successful, and false if it was not (e.g. no slash in the input string, invalid address syntax, prefix length is out of range, etc.).
Referenced by inet::IPv6RoutingTable::configureInterfaceFromXML().
|
inline |
Returns a pointer to the internal binary representation of the address: four 32-bit words, most significant word first.
Referenced by inet::serializer::SCTPSerializer::deserialize(), inet::doPacking(), inet::doUnpacking(), inet::serializer::IPv6Serializer::serialize(), inet::L3Address::set(), and inet::serializer::Buffer::writeIPv6Address().
|
inline |
Returns a pointer to the internal binary representation of the address: four 32-bit words, most significant word first.
|
static |
All-nodes multicast address, scope 1 (interface-local)
Referenced by inet::IPv6AddressType::getBroadcastAddress(), inet::IPv6InterfaceData::HostMulticastData::info(), and inet::IPv6RoutingTable::isLocalAddress().
|
static |
All-nodes multicast address, scope 2 (link-local)
Referenced by inet::IPv6RoutingTable::configureInterfaceForIPv6(), inet::IPv6RoutingTable::isLocalAddress(), inet::IPv6NeighbourDiscovery::sendSolicitedNA(), and inet::IPv6NeighbourDiscovery::sendUnsolicitedNA().
|
static |
All-routers multicast address, scope 1 (interface-local)
Referenced by inet::IPv6RoutingTable::isLocalAddress().
|
static |
All-routers multicast address, scope 2 (link-local)
Referenced by inet::IPv6RoutingTable::configureInterfaceForIPv6(), inet::IPv6NeighbourDiscovery::createAndSendRSPacket(), and inet::IPv6RoutingTable::isLocalAddress().
|
static |
All-routers multicast address, scope 5 (site-local)
Referenced by inet::IPv6RoutingTable::isLocalAddress().
|
private |
Referenced by compare(), constructMask(), doTryParse(), getMulticastScope(), getPrefix(), getScope(), getSuffix(), matches(), operator==(), setPrefix(), setSuffix(), and str().
|
static |
The link-local prefix (fe80::)
Referenced by inet::IPv6RoutingTable::configureInterfaceForIPv6(), and formLinkLocalAddress().
|
static |
Link-local MANET routers multicast address.
Referenced by inet::IPv6AddressType::getLinkLocalManetRoutersMulticastAddress().
|
static |
The loopback address.
Referenced by inet::ICMPv6::sendErrorMessage().
|
static |
The solicited-node multicast address prefix (prefix length = 104)
Referenced by inet::IPv6RoutingTable::isLocalAddress(), and inet::IPv6NeighbourDiscovery::validateNSPacket().
|
static |
The unspecified address.
Referenced by inet::IPv6InterfaceData::choosePreferredAddress(), inet::IPv6RoutingTable::configureInterfaceForIPv6(), inet::IPv6NeighbourDiscovery::createAndSendRSPacket(), inet::IPv6Tunneling::createTunnel(), inet::IPv6::datagramLocalInHook(), inet::IPv6::endService(), inet::IPv6InterfaceData::getGlobalAddress(), inet::IPv6RoutingTable::getHomeAddress(), inet::IPv6AddressType::getLinkLocalAddress(), inet::IPv6InterfaceData::getLinkLocalAddress(), inet::IPv6AddressType::getUnspecifiedAddress(), inet::IPv6::handleMessageFromHL(), inet::IPv6NeighbourDiscovery::initiateDAD(), inet::IPv6RoutingTable::lookupDestCache(), inet::IPv6Tunneling::numInitStages(), inet::xMIPv6::numInitStages(), inet::IPv6NeighbourDiscovery::processDADTimeout(), inet::IPv6NeighbourDiscovery::selectDefaultRouter(), and inet::IPv6InterfaceData::updateHomeNetworkInfo().