NAME

Net::Silk::Pmap - SiLK Prefix Map interface

SYNOPSIS

use Net::Silk::Pmap;
use Net::Silk::IPSet;

my $addys  = Net::Silk::IPSet->load("netblocks.set");
my $labels = Net::Silk::Pmap->load("services.pmap");

while (my $ip = <$addys>) {
  my $svc = $labels{$ip}; # or $labels->get($ip)
  print "$ip $svc" unless $svc eq 'unknown';
}

while (my $block = <$labels>) {
  my($lo, $hi, $label) = @$block;
  my $block = Net::Silk::IPSet->new("$lo-$hi");
  if ($block && $addys) {
    print "$lo-$hi $label\n";
  }
}

DESCRIPTION

Net::Silk::Pmap objects are an interface to SiLK Prefix Maps. Prefix maps are an immutable mapping from IP addresses or protocol/port pairs to labels. Pmaps are created from SiLK prefix map files as created by rwpmapbuild(1).

METHODS

load($pmap_file)

Returns a new Net::Silk::Pmap::IP or Net::Silk::Pmap::PP object, depending on whether the given file uses IP addresses or protocol/port pairs for keys.

get($proto, $port)
get($ip_or_pp)

Returns the label for the given IP address or protocol/port pair. For the single argument version, the key can be a Net::Silk::IPAddr object or a Net::Silk::ProtoPort object, or a string representation of either.

iter()

Returns a sub ref iterator. Each invocation returns an array reference containing low, high, and label. Low and high are the range values for which the label applies, returned as Net::Silk::IPAddr or Net::Silk::ProtoPort objects depending on the type of pmap file. Using the IO operator <> on the pmap reference will also iterate over low/high/label values.

iter_vals()

Returns a sub ref iterator that returns each label value in the pmap.

iter_keys()

Returns a sub ref iterator that returns an array reference containing the low and high value for each range present in the pmap.

invert()

For an IP address pmap, return a hash that maps labels to Net::Silk::IPSet objects representing the all of the IP ranges for that label. For a protocol/port pmap, return a hash mapping labels to a list of all the proto/port ranges for that label.

OPERATORS

The IO operator <> works on Net::Silk::Pmap references, returning the same results as the iterator returned from the iter() method.

TIED HASH

The pmap reference can be treated as a hash reference, so that $pmap->{$key}, keys %$pmap, etc, work as expected.

SEE ALSO

Net::Silk, Net::Silk::RWRec, Net::Silk::IPSet, Net::Silk::IPWildcard, Net::Silk::Bag, Net::Silk::IPAddr, Net::Silk::TCPFlags, Net::Silk::ProtoPort, Net::Silk::File, Net::Silk::Site, rwpmapbuild(1), silk(7)

COPYRIGHT & LICENSE

Copyright (C) 2011-2015 by Carnegie Mellon University

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

GNU 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.