NAME

Net::Silk::IPWildcard - SiLK IP wildcard class

SYNOPSIS

  use Net::Silk::IPWildcard;

  my $w = Net::Silk::IPWildcard->new('1.2.3.0/24');
  $w->contains('1.2.3.4'); # true
  
  while (my $ip = <$w>) {
    ...
  }

  my $iter = $w->iter_cidr;
  while (my $cidr = $iter->()) {
    my($ip, $prefix) = @$cidr;
    ...
  }

DESCRIPTION

Net::Silk::IPWildcard objects represent a range or block of IP addresses.

METHODS

new($spec)

Returns a new Net::Silk::IPWildcard object. The provide spec can be a Net::Silk::IPAddr object, another wildcard object, a IP CIDR string, an integer, an integer with a CIDR designation, or an entry in SiLK wildcard notation. In SiLK wildcard notation, a wildcard is represented as an IP address in canonical form with each octet (IPv4) or hexadectet (IPv6) represented by one of following: a value, a range of values, a comma separated list of values and ranges, or the character 'x' used to represent the entire octet or hexadectet.

Some examples of valid strings:

  '1.2.3.0/24'
  'ff80::/16'
  '1.2.3.4'
  '::ffff:0102:0304'
  '16909056'
  '16909056/24'
  '1.2.3.x'
  '1:2:3:4:5:6:7:x'
  '1.2,3.4,5.6,7'
  '1.2.3.0-255'
  '::2-4'
  '1-2:3-4:5-6:7-8:9-a:b-c:d-e:0-ffff'
cardinality()

Return the number of addresses represented by this IPWildcard.

contains($ip)

Returns true if the given IP address is contained within this Wildcard. The given IP address can be a string or Net::Silk::IPAddr.

is_ipv6()

Returns true if this wildcard is IPv6 enabled.

iter()

Return a sub ref iterator that returns each Net::Silk::IPAddr represented by this wildcard. In list context this will slurp all addresses.

iter_cidr()

Return a sub ref iterator that returns a Net::Silk::CIDR object for each CIDR block contained in this wildcard.

iter_ranges()

Return a sub ref iterator that returns a Net::Silk::Range object for each IP range contained in this wildcard.

OPERATORS

The IO operator <> works with Net::Silk::IPWildcard objects, returning each address in the wildcard space.

SEE ALSO

Net::Silk, Net::Silk::RWRec, Net::Silk::IPSet, Net::Silk::Bag, Net::Silk::Pmap, Net::Silk::Range, Net::Silk::CIDR, Net::Silk::IPAddr, 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.