NAME
Net::IPAM::Util - A selection of general utility subroutines for Net::IPAM
SYNOPSIS
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
FUNCTIONS
$address_plusplus = incr_n( $address )
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, ...
$address_minusminus = decr_n( $address )
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.
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, ...
$string = inet_ntop_pp( $family, $address )
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.
$address = inet_pton_pp( $family, $string )
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.
AUTHOR
Karl Gaissmaier, <karl.gaissmaier(at)uni-ulm.de>
BUGS
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.
SUPPORT
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
SEE ALSO
Net::IPAM::IP Net::IPAM::Block Net::IPAM::Tree
LICENSE AND COPYRIGHT
This software is copyright (c) 2020-2022 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.