PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Networking » Net_IPv6 » Manual

Provides function to work with the 'Internet Protocol v6'

Net_IPv6::checkIPv6()

Net_IPv6::checkIPv6() – Validation of IPv6 addresses

Synopsis

require_once 'Net/IPv6.php';

boolean Net_IPv6::checkIPv6 ( string $ip )

Description

Checks an IP for IPv6 compatibility.

Parameter

Return value

boolean - TRUE, if syntax is valid

Note

This function can be called statically.

Net_IPv6::compress()

Net_IPv6::compress() – compress an IPv6 address

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::compress ( string $ip , boolean $force = false )

Description

Compresses an IPv6 address. RFC 2373 allows you to compress zeros in an address to '::'. This function expects an valid IPv6 address and compresses successive zeros to '::'

FF01:0:0:0:0:0:0:101 -> FF01::101
      0:0:0:0:0:0:0:1      -> ::1

By default, the method does not touch an already compressed address and returns the address as is. This happens also in case of an address that is compressed but can be compressed further, for example an address like FF01::0:1 will be returned as is.

Since version 1.2.1, you can change this behavoir to enforce compression by setting $force to true.

Parameter

Return value

string - the compressed IP is an IPv6 address

Note

This function can be called statically.

Net_IPv6::uncompress()

Net_IPv6::uncompress() – Uncompresses an IPv6 address

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::uncompress ( string $ip , boolean $leadingZeros = false )

Description

Uncompresses an IPv6 address. RFC 2373 allows you to compress zeros in an address to '::'. This function expects an valid IPv6 address and expands the '::' to the required zeros.

FF01::101	->  FF01:0:0:0:0:0:0:101
      ::1       ->  0:0:0:0:0:0:0:1

Since version 1.2.1, the method can return the address in a nice format where each part of the address has a fixed length of 4 characters. To enable this, you must set $leadingZeros to true.

Parameter

Return value

string - the uncompressed IP is an IPv6 address

Note

This function can be called statically.

Net_IPv6::getAddressType()

Net_IPv6::getAddressType() – Returns the type of an IP address

Synopsis

require_once 'Net/IPv6.php';

int Net_IPv6::getAddressType ( string $ip )

Description

RFC 1883, Section 2.3 describes several types of addresses in the IPv6 addresse space. This methods tries to find the type of address for the given IP.

Several address types are markers for reserved spaces and as consequence a subject to change.

Parameter

Return value

int - the addresstype

The type can be one of this constants:

Note

This function can be called statically.

Method available since: Release 1.1.0

Net_IPv6::getNetmask()

Net_IPv6::getNetmask() – Calculates the network prefix

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::getNetmask ( string $ip , int $bits = null )

Description

Calculates the network prefix based on the netmask bits.

Parameter

Return value

string - the network prefix

Note

This function can be called statically.

Method available since: Release 1.1.0

Net_IPv6::getNetmaskSpec()

Net_IPv6::getNetmaskSpec() – Returns a possible existing netmask specification at an IP addresse.

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::getNetmaskSpec ( string $ip )

Description

Returns a possible existing netmask specification at an IP addresse.

Parameter

Return value

string - the netmask specification.

Note

This function can be called statically.

Method available since: Release 1.1.0

Net_IPv6::getPrefixLength()

Net_IPv6::getPrefixLength() – Tests for a prefix length specification in the address and returns the prefix length, if exists.

Synopsis

require_once 'Net/IPv6.php';

mixed Net_IPv6::getPrefixLength ( string $ip )

Description

Tests for a prefix length specification in the address and returns the prefix length, if exists.

Parameter

Return value

mixed - the prefix as String or false, if prefix was not found.

Note

This function can be called statically.

Method available since: Release 1.1.0

This function is deprecated. That means that future versions of this package may not support it anymore.

Deprecated in release 1.2.1

Net_IPv6::isInNetmask()

Net_IPv6::isInNetmask() – Checks if an IP is in a specific address space

Synopsis

require_once 'Net/IPv6.php';

boolean Net_IPv6::isInNetmask ( string $ip , string $netmask , int $bits = null )

Description

Checks if an (compressed) IP is in a specific address space. If the IP does not contain the number of netmask bits (for example: F8000::FFFF/16), then you have to use the $bits parameter.

Parameter

Return value

boolean - TRUE, if the IP is in the address space.

Note

This function can be called statically.

Method available since: Release 1.1.0

Net_IPv6::removeNetmaskSpec()

Net_IPv6::removeNetmaskSpec() – Removes the Netmask length specification

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::removeNetmaskSpec ( string $ip )

Description

Removes a possible existing netmask length specification in an IP addresse.

Parameter

Return value

string - the IP without netmask length specification.

Note

This function can be called statically.

Method available since: Release 1.1.0

Net_IPv6::removePrefixLength()

Net_IPv6::removePrefixLength() – Tests for a prefix length specification in the address and removes the prefix length, if exists.

Synopsis

require_once 'Net/IPv6.php';

string Net_IPv6::removePrefixLength ( string $ip )

Description

Tests for a prefix length specification in the address and removes the prefix length, if exists.

Parameter

Return value

string - the address without a prefix length.

Note

This function can be called statically.

Method available since: Release 1.1.0

This function is deprecated. That means that future versions of this package may not support it anymore.

Deprecated in release 1.2.1

Net_IPv6::splitV64()

Net_IPv6::splitV64() – splits an IPv6 address in it IPv6 and IPv4 part

Synopsis

require_once 'Net/IPv6.php';

array Net_IPv6::splitV64 ( string $ip )

Description

Splits an IPv6 address into the IPv6 and a possible IPv4-formated part. RFC 2373 allows you to note the last two parts of an IPv6 address in the IPv4 address format:

0:0:0:0:0:0:13.1.68.3
0:0:0:0:0:FFFF:129.144.52.38

Parameter

Return value

array - key [0] contains the IPv6 part, key [1] the IPv4 formated part

Note

This function can be called statically.