NAME
NetAddr::IP::Constants - Magic number constants for NetAddr::IP
VERSION
version 4.080_02
SYNOPSIS
use NetAddr::IP::Constants qw($IPV6_BITS $IPV4_BITS $IPV4_OFFSET);
DESCRIPTION
Provides named constants for magic numbers used throughout the NetAddr::IP family of modules. Importing by name avoids polluting the caller namespace with abbreviations and ensures that each constant resolves at compile time.
All constants are our variables and may be overridden by the caller if needed, but doing so is unsupported.
NAME
NetAddr::IP::Constants - Magic number constants for NetAddr::IP
CONSTANTS
- DEFAULT_NETLIMIT_EXP
-
Power-of-two exponent for the default netlimit. The default is C<2**16 = 65536> networks. Value: C<16>. - IPV4_BITS
-
IPv4 address width in bits. Value: C<32>. RFC 791 s2.1. - IPV4_OFFSET
-
Offset of the IPv4-in-IPv6 mapped address in the 128-bit representation. Value: C<96> (i.e. C<IPV6_BITS - IPV4_BITS>). RFC 4291 s2.5.5 (dual-stack, V4-mapped, V4-compatible). - IPV6_BITS
-
IPv6 address width in bits. Value: C<128>. RFC 4291 s2.1. - MAX_BCD_DIGITS
-
Maximum number of BCD digits that can represent a 128-bit value. Value: C<40> (i.e. C<ceil(128 * log10(2))>). - MAX_NETLIMIT_EXP
-
Power-of-two exponent for the maximum netlimit. The maximum is C<2**24 = 16777216> networks. Value: C<24>. - MAX_OCTET
-
Maximum value of a single IPv4 octet. Value: C<255> (C<0xff>). RFC 791 s2.1. - MAX_SHIFTLEFT
-
Maximum number of bits that can be shifted by C<shiftleft()>. Value: C<128> (i.e. C<IPV6_BITS>). - OCTET_BITS
-
Number of bits in a single IPv4 octet. Value: C<8>. RFC 791 s2.1. - OCTET_COUNT
-
Number of octets in an IPv4 address. Value: C<4>. RFC 791 s2.1. - PACKED_BCD_BYTES
-
Size of a packed BCD string holding B<MAX_BCD_DIGITS> digits. Value: C<20> (C<40/2>, two digits per byte). - RFC3021_THRESHOLD
-
Point-to-point network boundary. Networks of length /127 or /31 are treated as having exactly two usable addresses per RFC 3021. Value: C<127> (i.e. C<IPV6_BITS - 1>). - V4_PACKED_BYTES
-
Size of a packed IPv4 address in bytes. Value: C<4> (C<32/8>). RFC 791 s2.1. - V6_PACKED_BYTES
-
Size of a packed IPv6 address in bytes. Value: C<16> (C<128/8>). RFC 4291 s2.1.
EXPORTS
Nothing is exported by default. Use explicit import tags:
use NetAddr::IP::Constants qw(:all);
or import individual constants:
use NetAddr::IP::Constants qw($IPV6_BITS $IPV4_BITS);
AUTHORS
Dean Hamstead <dean@fragfest.com.au>
Luis E. Muñoz <luismunoz@cpan.org>
Michael Robinton <miker@cpan.org>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2026 by Dean Hamstead.
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991