NAME

Net::Silk::IPAddr - SiLK IP addresses

SYNOPSIS

  use Net::Silk::IPAddr;

  my $ipv4 = Net::Silk::IPAddr->new("1.2.3.4");
  my $ipv6 = Net::Silk::IPAddr->new("::ffff:1.2.3.4");

  $ipv4->is_ipv6; # false
  $ipv6->is_ipv6; # true

  $ipv4 = Net::Silk::IPv4Addr->new("::ffff:1.2.3.4");
  $ipv6 = Net::Silk::IPv6Addr->new("1.2.3.4");

  $ipv4->is_ipv6; # false
  $ipv6->is_ipv6; # true

  my $ip = $ipv4->mask('255.255.255.0');

DESCRIPTION

Net::Silk::IPAddr represents an IPv4 or IPv6 address. These manifest as the subclasses Net::Silk::IPv4Addr and Net::Silk::IPv6Addr, respectively.

METHODS

new($spec)

Returns an IP address object. The given spec can be a string representation of the address or another IP address object. Returns either a Net::Silk::IPv4Addr or a Net::Silk::IPv6Addr if the string appears to be an IPv6 address and SILK_IPV6_ENABLED is true.

str()

Returns the string representation of this IP address. This method is tied to the "" operator.

padded()

Returns the zero-padded string representation of this IP address.

octets()

Returns a list of octets representing this IP address.

num()

Returns the integer representation of this IP address.

is_ipv6()

Returns true if this is a Net::Silk::IPv6Addr.

as_ipv4()

Return a Net::Silk::IPv4Addr representation of this address if possible.

as_ipv6()

Return a Net::Silk::IPv6Addr representation of this address.

mask($mask)

Return a copy of this address masked by the provided IP address mask.

country_code()

Return the two character country code associated with this address if available.

IPv4 METHODS

from_int()

Return an IPv4 address from the given integer. Also accepts hex string representations, e.g. "0xffffffff"

mask_prefix()

Return a copy of this address masked by the CIDR prefix bits. All bits below the prefixth bit will be set to zero. The maximum value for prefix is 32 for IPv4.

IPv6 METHODS

from_int()

Return an IPv6 address from the given integer. Also accepts a hex string representation, e.g. "0xffff01020304"

mask_prefix()

Return a copy of this address masked by the given CIDR prefix bits. All bits below the prefixth bit will be set to zero. The maximum value for prefix is 128 for IPv6.

OPERATORS

The following operators are overloaded and work with Net::Silk::IPAddr objects:

  ""              0+
  -=              -
  +=              +
  >               gt
  <               lt
  >=              ge
  <=              le
  ==              eq
  !=              ne
  <=>             cmp
  &               |
  =               bool
  <<              >>
  <<=             >>=
  ~

SEE ALSO

Net::Silk, Net::Silk::RWRec, Net::Silk::IPSet, Net::Silk::Bag, Net::Silk::Pmap, Net::Silk::IPWildcard, Net::Silk::Range, Net::Silk::CIDR, Net::Silk::TCPFlags, Net::Silk::ProtoPort, Net::Silk::File, Net::Silk::Site, silk(7)

COPYRIGHT & LICENSE

Copyright (C) 2011-2016 by Carnegie Mellon University

Use of the Net-Silk library and related source code is subject to the terms of the following licenses:

GNU General Public License (GPL) Rights pursuant to Version 2, June 1991 Government Purpose License Rights (GPLR) pursuant to DFARS 252.227.7013

NO WARRANTY

See GPL.txt and LICENSE.txt for more details.