Net_IPv6
[ class tree: Net_IPv6 ] [ index: Net_IPv6 ] [ all elements ]

Class: Net_IPv6

Source Location: /Net_IPv6-1.3.0b3/Net/IPv6.php

Class Overview


Class to validate and to work with IPv6 addresses.


Author(s):

Version:

  • Release: 1.1.0RC5

Copyright:

  • 2003-2010 The PHP Group

Methods


Inherited Variables

Inherited Methods


Class Details

[line 135]
Class to validate and to work with IPv6 addresses.


[ Top ]


Method Detail

checkIPv6   [line 879]

Boolean checkIPv6( String $ip)

Checks an IPv6 address

Checks if the given IP is IPv6-compatible

  • Return: true if $ip is an IPv6 address
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-address

[ Top ]

compress   [line 675]

String compress( String $ip, [boolean $force = false])

Compresses an IPv6 address

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

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

When $ip is an already compressed address and $force is false, the method returns the value as is, even if the address can be compressed further.

Example: FF01::0:1 -> FF01::0:1

To enforce maximum compression, you can set the second argument $force to true.

Example: FF01::0:1 -> FF01::1

  • Return: the compressed IPv6-address (hex format)
  • Author: elfrink at introweb dot nl
  • See: Uncompress()
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-address (hex format)
boolean   $force   —  if true the address will be compressed as best as possible (since 1.2.0)

[ Top ]

getAddressType   [line 428]

int getAddressType( String $ip)

Returns the type of an IPv6 address.

RFC 2373, Section 2.3 describes several types of addresses in the IPv6 address space. Several address types are markers for reserved spaces and as a consequence are subject to change.


Parameters:

String   $ip   —  the IP address in Hex format, compressed IPs are allowed

[ Top ]

getNetmask   [line 295]

String getNetmask( String $ip, [int $bits = null])

Calculates the network prefix based on the netmask bits.
  • Return: the network prefix
  • Since: 1.1.0
  • Access: public

Parameters:

String   $ip   —  the (compressed) IP in Hex format
int   $bits   —  if the number of netmask bits is not part of the IP you must provide the number of bits

[ Top ]

getNetmaskSpec   [line 239]

String getNetmaskSpec( String $ip)

Returns a possible existing prefix length/netmask specification on an IP address.
  • Return: the netmask spec
  • Since: 1.1.0
  • Access: public

Parameters:

String   $ip   —  the (compressed) IP as Hex representation

[ Top ]

getPrefixLength   [line 265]

Mixed getPrefixLength( String $ip)

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

The method is technically identical to getNetmaskSpec() and will be dropped in a future release.

  • Return: the prefix as String or false, if no prefix was found
  • Deprecated:
  • Access: public

Parameters:

String   $ip   —  a valid ipv6 address

[ Top ]

isCompressible   [line 800]

Boolean isCompressible( String $ip)

Checks, if an IPv6 address can be compressed
  • Return: true, if address can be compressed
  • Author: Manuel Schmitt
  • Since: 1.2.0b
  • Access: public

Parameters:

String   $ip   —  a valid IPv6 address

[ Top ]

isInNetmask   [line 345]

boolean isInNetmask( String $ip, String $netmask, [int $bits = null])

Checks if an (compressed) IP is in a specific address space.

If the IP does not contain the number of netmask bits (F8000::FFFF/16) then you have to use the $bits parameter.

  • Return: true if $ip is in the netmask
  • Since: 1.1.0
  • Access: public

Parameters:

String   $ip   —  the IP to check (eg. F800::FFFF)
String   $netmask   —  the netmask (eg F800::)
int   $bits   —  the number of netmask bits to compare, if not given in $ip

[ Top ]

parseAddress   [line 994]

Array parseAddress( String $ipToParse, [String $bits = null])

Returns the lowest and highest IPv6 address for a given IP and netmask specification

The netmask may be a part of the $ip or the number of netmask bits is provided via $bits

The result is an indexed array. The key 'start' contains the lowest possible IP address. The key 'end' the highest address.

  • Return: ['start', 'end'] the lowest and highest IPv6 address
  • Author: Nicholas Williams
  • Access: public

Parameters:

String   $ipToParse   —  the IPv6 address
String   $bits   —  the optional count of netmask bits

[ Top ]

recommendedFormat   [line 773]

String recommendedFormat( String $ip)

Represent IPv6 address in RFC5952 format.
  • Return: the recommended representation of IPv6-address (hex format)
  • Author: koyama at hoge dot org
  • See: Net_IPv6::compress()
  • Todo: This method may become a part of compress() in a further releases
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-address (hex format)

[ Top ]

removeNetmaskSpec   [line 187]

String removeNetmaskSpec( String $ip)

Removes a possible existing prefix length/ netmask specification at an IP address.
  • Return: the IP without netmask length
  • Since: 1.1.0
  • Access: public

Parameters:

String   $ip   —  the (compressed) IP as Hex representation

[ Top ]

removePrefixLength   [line 213]

String removePrefixLength( String $ip)

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

The method is technically identical to removeNetmaskSpec() and will be dropped in a future release.


Parameters:

String   $ip   —  a valid ipv6 address

[ Top ]

separate   [line 149]

Array separate( String $ip)

Separates an IPv6 address into the address and a prefix length part
  • Return: the first element is the IP, the second the prefix length
  • Since: 1.2.0
  • Access: public

Parameters:

String   $ip   —  the (compressed) IP as Hex representation

[ Top ]

SplitV64   [line 831]

Array SplitV64( String $ip, [Boolean $uncompress = true])

Splits an IPv6 address into the IPv6 and a possible IPv4 part

RFC 2373 allows you to note the last two parts of an IPv6 address as an IPv4 compatible address

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

  • Return: [0] contains the IPv6 part, [1] the IPv4 part (hex format)
  • Author: Alexander Merz <alexander.merz@web.de>
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-address (hex format)
Boolean   $uncompress   —  if true, the address will be uncompressed before processing

[ Top ]

uncompress   [line 529]

String uncompress( String $ip, [Boolean $leadingZeros = false])

Uncompresses an IPv6 address

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

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

  • Return: the uncompressed IPv6-address (hex format)
  • Author: Pascal Uhlmann
  • See: Compress()
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-address (hex format)
Boolean   $leadingZeros   —  if true, leading zeros are added to each block of the address (FF01::101 -> FF01:0000:0000:0000:0000:0000:0000:0101)

[ Top ]

_bin2Ip   [line 1081]

String _bin2Ip( String $bin)

Converts an IPv6 address from Binary into Hex representation.
  • Return: the uncompressed Hex representation
  • Since: 1.1.0
  • Access: protected

Parameters:

String   $bin   —  the IP address as binary

[ Top ]

_ip2Bin   [line 1050]

String _ip2Bin( String $ip)

Converts an IPv6 address from Hex into Binary representation.
  • Return: the binary representation
  • Since: 1.1.0
  • Access: protected

Parameters:

String   $ip   —  the IP to convert (a:b:c:d:e:f:g:h), compressed IPs are allowed

[ Top ]


Documentation generated on Thu, 27 Jul 2017 22:30:01 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.