2017 © Pedro Peláez
 

project ip-util

IPv4 and IPv6 Address/Network parsing utility classes

image

librenms/ip-util

IPv4 and IPv6 Address/Network parsing utility classes

  • Tuesday, May 29, 2018
  • by murrant
  • Repository
  • 3 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 14 % Grown

The README.md

CI, (*1)

IPUtil

IPv4 and IPv6 Address/Network parsing utility classes, (*2)

Requirements PHP 5.6+, (*3)

Does not require bcmath or gmp., (*4)

Built for use in LibreNMS - Network Monitoring Software., (*5)

Usage

Create a new IP instance

try {
    $ip = new IP('192.168.1.1');
    // or
    $ip = IP::parse('192.168.1.1');
} catch (InvalidIpException $e) {
    //
}

Check if a given string is a valid IP

IP::isValid('192.168.1.333');

You may specifically require IPv4 or IPv6 by using those classes directly:, (*6)

$ip = IPv4::parse('192.168.1.1');
$ip = IPv6::parse('2600::');

IPv4::isValid('192.168.1.1');
IPv6::isValid('2600::');

Access the parsed IP

echo $ip; // print nicely formated IP with cidr/prefix

echo $ip->address; // print just the address
echo $ip->cidr; // print the prefix length

echo $ip->compressed(); // Compresses IP addresses for easy reading
echo $ip->uncompressed(); // Uncompresses IP addresses for easy parsing

Handle network operations:

if ($ip->inNetwork('192.168.1.1/24')) {
    echo $ip->getNetwork();
}

Parse from Hex (useful for SNMP)

$ip = IP::fromHexString('c0a801fe');

License

Copyright (C) 2017-2018 Tony Murray, (*7)

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version., (*8)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details., (*9)

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/., (*10)

LICENSE contains a copy of the full GPLv3 licensing conditions., (*11)

The Versions

29/05 2018

dev-master

9999999-dev http://www.librenms.org/

IPv4 and IPv6 Address/Network parsing utility classes

  Sources   Download

GPL-3.0-or-later

The Requires

  • php >=5.6.4

 

The Development Requires

ip ipv6 ipv4 subnet network cidr ip-tools

29/05 2018

1.3

1.3.0.0 http://www.librenms.org/

IPv4 and IPv6 Address/Network parsing utility classes

  Sources   Download

GPL-3.0-or-later

The Requires

  • php >=5.6.4

 

The Development Requires

ip ipv6 ipv4 subnet network cidr ip-tools

16/05 2018

1.2

1.2.0.0 http://www.librenms.org/

IPv4 and IPv6 Address/Network parsing utility classes

  Sources   Download

GPL-3.0-or-later

The Requires

  • php >=5.6.4

 

The Development Requires

ip ipv6 ipv4 subnet network cidr ip-tools

08/05 2018

1.1

1.1.0.0 http://www.librenms.org/

IPv4 and IPv6 Address/Network parsing utility classes

  Sources   Download

GPL-3.0-or-later

The Requires

  • php >=5.6.4

 

The Development Requires

ip ipv6 ipv4 subnet network cidr ip-tools

08/05 2018

1.0

1.0.0.0 http://www.librenms.org/

IPv4 and IPv6 Address/Network parsing utility classes

  Sources   Download

GPL-3.0-or-later

The Requires

  • php >=5.6.4

 

The Development Requires

ip ipv6 ipv4 subnet network cidr ip-tools