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

Class: Net_IPv6

Source Location: /Net_IPv6-1.3.0b1/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 864]

Boolean checkIPv6( String $ip)

Checks an IPv6 adress

Checks if the given IP is IPv6-compatible

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

Parameters:

String   $ip   —  a valid IPv6-adress

[ Top ]

compress   [line 675]

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

Compresses an IPv6 adress

RFC 2373 allows you to compress zeros in an adress to '::'. This function expects an valid IPv6 adress 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

Whe $ip is an already compressed adress the methode returns the value as is, also if the adress 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-adress (hex format)
  • Author: elfrink at introweb dot nl
  • See: Uncompress()
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-adress (hex format)
boolean   $force   —  if true the adress will be compresses 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 addresse space. Several addresse types are markers for reserved spaces and as consequence a 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 addresse.
  • 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 792]

Boolean isCompressible( String $ip)

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

Parameters:

String   $ip   —  a valid IPv6 adress

[ 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 contains 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 975]

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 netwask bits is provided via $bits

The result is an indexed array. The key 'start' contains the lowest possible IP adress. 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 764]

String recommendedFormat( String $ip)

Represent IPv6 address in RFC5952 format.
  • Return: the recommended representation of IPv6-adress (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-adress (hex format)

[ Top ]

removeNetmaskSpec   [line 187]

String removeNetmaskSpec( String $ip)

Removes a possible existing prefix length/ netmask specification at an IP addresse.
  • 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 820]

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

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

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

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)
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-adress (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 adress

RFC 2373 allows you to compress zeros in an adress to '::'. This function expects an valid IPv6 adress 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-adress (hex format)
  • Author: Pascal Uhlmann
  • See: Compress()
  • Access: public

Parameters:

String   $ip   —  a valid IPv6-adress (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 1062]

String _bin2Ip( String $bin)

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

Parameters:

String   $bin   —  the IP address as binary

[ Top ]

_ip2Bin   [line 1031]

String _ip2Bin( String $ip)

Converts an IPv6 address from Hex into Binary representation.
  • Return: the binary representation
  • 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 Mon, 11 Mar 2019 16:02:23 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.