Net::IPAM::Util - A selection of general utility subroutines for Net::IPAM
use Net::IPAM::Util qw(incr_n inet_ntop_pp inet_pton_pp); $n = incr_n("\x0a\x00\x00\x01"); # 10.0.0.2 $n = incr_n( pack( 'n8', 0x2001, 0xdb8, 0, 0, 0, 0, 0, 1 ) ); # 2001:db8::2 $n = decr_n("\x0a\x00\x00\x01"); # 10.0.0.0 $n = decr_n( pack( 'n8', 0x2001, 0xdb8, 0, 0, 0, 0, 0, 1 ) ); # 2001:db8:: $n = inet_pton_pp( AF_INET6, '2001:db8::fe1' ); say inet_ntop_pp( AF_INET, "\x0a\x00\x00\x01" ); # 10.0.0.1
Increment a packed IPv4 or IPv6 address in network byte order. Returns undef on overflow.
This increment function is needed in Net::IPAM::IP and Net::IPAM::Block for transparent handling of IPv4 and IPv6 addresses and blocks.
No need for Math::BigInt, this pure perl algorithm works for all uint_n in network byte order, where n is a multiple of 32: uint_32, uint_64, uint_96, uint_128, ...
Decrement a packed IPv4 or IPv6 address in network byte order. Returns undef on underflow.
This decrement function is needed in Net::IPAM::IP and Net::IPAM::Block for transparent handling of IPv4 and IPv6 addresses and blocks.
A pure perl implementation for (buggy) Socket::inet_ntop.
Takes an address family (AF_INET or AF_INET6) and a packed binary address structure and translates it into a human-readable textual representation of the address.
AF_INET
AF_INET6
A pure perl implementation for (buggy) Socket::inet_pton.
Takes an address family (AF_INET or AF_INET6) and a string containing a textual representation of an address in that family and translates that to an packed binary address structure.
Karl Gaissmaier, <karl.gaissmaier(at)uni-ulm.de>
<karl.gaissmaier(at)uni-ulm.de>
Please report any bugs or feature requests to bug-net-ipam-util at rt.cpan.org, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net-IPAM-Util. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-net-ipam-util at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Net::IPAM::Util
You can also look for information at:
on github
TODO
Net::IPAM::IP Net::IPAM::Block Net::IPAM::Tree
This software is copyright (c) 2020 by Karl Gaissmaier.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Net::IPAM::IP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::IPAM::IP
CPAN shell
perl -MCPAN -e shell install Net::IPAM::IP
For more information on module installation, please visit the detailed CPAN module installation guide.