NAME

Geo::Location::IP::Network - IP network details

VERSION

version 0.002

SYNOPSIS

use Geo::Location::IP::Database::Reader;
my $reader = Geo::Location::IP::Database::Reader->new(
  file => '/path/to/ASN.mmdb',
);
eval {
  my $asn_model  = $reader->asn(ip => '1.2.3.4');
  my $ip_address = $asn_model->ip_address;
  my $network    = $ip_address->network;
};

DESCRIPTION

This class contains details about an IP network in a geolocation database.

SUBROUTINES/METHODS

new

my $network = Geo::Location::IP::Network->new(
  address   => '1.2.3.0',
  prefixlen => 24,
);

Creates an IP network object.

network_address

my $network_address = $network->network_address;

Returns the network address as a string.

prefixlen

my $prefixlen = $network->prefixlen;

Returns the network's prefix length as a number.

version

my $version = $network->version;

Returns 4 or 6.

with_prefixlen

my $address = $network->with_prefixlen;

Returns the network and prefix in CIDR notation.

Objects also stringify to their CIDR notation.

DIAGNOSTICS

None.

CONFIGURATION AND ENVIRONMENT

None.

DEPENDENCIES

Requires the Socket module.

INCOMPATIBILITIES

None.

BUGS AND LIMITATIONS

None known.

AUTHOR

Andreas Vögele <voegelas@cpan.org>

LICENSE AND COPYRIGHT

Copyright (C) 2025 Andreas Vögele

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.