| |
---|
| | naip_gethostbyname |
---|
| | havegethostbyname2 |
---|
| | ); |
---|
| | |
---|
| | use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $AUTOLOAD *Zero); |
---|
| | |
---|
| | $VERSION = do { my @r = (q$Revision: 1.52 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; |
---|
| | use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $NoFQDN $AUTOLOAD *Zero); |
---|
| | |
---|
| | $VERSION = do { my @r = (q$Revision: 1.53 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; |
---|
| | |
---|
| | require Exporter; |
---|
| | |
---|
| | @ISA = qw(Exporter); |
---|
| |
---|
| | :aton DEPRECATED ! |
---|
| | :old_nth |
---|
| | :upper |
---|
| | :lower |
---|
| | :nofqdn |
---|
| | ); |
---|
| | |
---|
| | my $ip = new NetAddr::IP::Lite '127.0.0.1'; |
---|
| | or if your prefer |
---|
| |
---|
| | :: = Zeros(); |
---|
| | FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF = Ones(); |
---|
| | FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); |
---|
| | ::FFFF:FFFF = V4net(); |
---|
| | |
---|
| | Will also return an ipV4 or ipV6 representation of a |
---|
| | resolvable Fully Qualified Domanin Name (FQDN). |
---|
| | |
---|
| | =head1 INSTALLATION |
---|
| | |
---|
| | Un-tar the distribution in an appropriate directory and type: |
---|
| |
---|
| | 0xABCDEF, 0b111111000101011110 within the limits |
---|
| | of perl's number resolution |
---|
| | 123456789012 a 'big' bcd number (bigger than perl likes) |
---|
| | and Math::BigInt |
---|
| | |
---|
| | A Fully Qualified Domain Name which returns an ipV4 address or an ipV6 |
---|
| | address, embodied in that order. This previously undocumented feature |
---|
| | may be disabled with: |
---|
| | |
---|
| | use NetAddr::IP::Lite ':nofqdn'; |
---|
| | |
---|
| | If called with no arguments, 'default' is assumed. |
---|
| | |
---|
| | If called with and empty string as the argument, 'undef' is returned; |
---|
| |
---|
| | return undef if hasbits($ip & $tmp); |
---|
| | last; |
---|
| | } |
---|
| | # check for resolvable IPv4 hosts |
---|
| | elsif ($ip !~ /[^a-zA-Z0-9\.-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) { |
---|
| | elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\.-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) { |
---|
| | $ip = ipv4to6($tmp); |
---|
| | last; |
---|
| | } |
---|
| | # check for resolvable IPv6 hosts |
---|
| | elsif ($ip !~ /[^a-zA-Z0-9\.-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) { |
---|
| | elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\.-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) { |
---|
| | $ip = $tmp; |
---|
| | $isV6 = 1; |
---|
| | last; |
---|
| | } |
---|
| |
---|
| | { |
---|
| | NetAddr::IP::Util::upper(); |
---|
| | @_ = grep { $_ ne ':upper' } @_; |
---|
| | } |
---|
| | if (grep { $_ eq ':nofqdn' } @_) |
---|
| | { |
---|
| | $NoFQDN = 1; |
---|
| | @_ = grep { $_ ne ':nofqdn' } @_; |
---|
| | } |
---|
| | NetAddr::IP::Lite->export_to_level(1, @_); |
---|
| | } |
---|
| | |
---|
| | =head1 EXPORT_OK |
---|
| |
---|
| | :aton DEPRECATED |
---|
| | :old_nth |
---|
| | :upper |
---|
| | :lower |
---|
| | :nofqdn |
---|
| | |
---|
| | =head1 AUTHORS |
---|
| | |
---|
| | Luis E. Muñoz E<lt>luismunoz@cpan.orgE<gt>, |
---|
| |
---|
| | |