The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

BGPmon::Filter::Prefix

This module is an object that keeps track of an IPv4 or IPv6 prefix. It can compare two different prefixes and find if they're equivilent, if one is more specific than the other, or if one is less specific than the other.

SYNOPSIS

use BGPmon::Filter::Prefix.pm

#To make an object with an IPv4 address, the first argument must be 4. #If you want to compare it with other IPv4 prefixes and return true when #comparing for matches with more specific prefixes, the last argument must #be a posive number. my $ipv4_prefix = new BGPmon::Filter::Prefix(4, "192.168.1.0/24", 1);

#To make an object with an IPv6 address, the first argument must be 6. #If you want to compare it with other IPv6 prefixes and return true when #comparing for matches with less specific prefixes, the last argument must #be 0. my $ipv6_prefix = new BGPmon::Filter::Prefix(6, "2000:0a00::/32", 0);

#To compare two prefixes, take the object and pass in the prefix you want to #compare it to.

#The following will return true since we're passing in a more specific prefix. my $ret_val = $ipv4_prefix->matches("192.168.1.128/25"); # $ret_val will be 1

#The following will return true since we're passing in a less specific prefix. #my $ret_val6 = $ipv6_prefix->matches("2000::/16"); # $ret_val6 will be 1

EXPORT

new matches getVersion isV6 isV4 toString

SUBROUTINES/METHODS

new

This makes a new object. You must pass in three arguments:

The version - 4 or 6

The prefix - e.g., "192.168.1.0/24"

The boolean for more specific matching - e.g., 1 for true, 0 for false

To make an object that is for an IPv4 address of "192.168.1.0/24" that wants to filter more specific or equivilent prefixes, make the object with the following:

my $ipv4 = new BGPmon::Filter::Prefix.pm(4, "192.168.1.0/24", 1);

        if($self->{prefix} eq $partner->{prefix} and $self->{moreSpecific} eq $partner->{moreSpecific}){
                return TRUE;
        }
        return FALSE;
}
=end

matches

This will take in another prefix of the same type and test if the prefix is equivilent, more specific, or less specific.

Note that if the object is made with the "more specific" set at true, then this will return true if the given prefix is more specific or equivilent.

INPUT: A prefix of the same type to be matched to, e.g, "192.168.1.128/25" OUTPUT: 1 - true, 0 - false

toString

Will return a string that can be printed in human readable form, e.g.,

192.168.1.0/24 ms

ms - more specific ls - less specific

INPUT: (none) OUTPUT: A string of characters with information about the object.

getVersion

Returns the version of IP the prefix is : 4 or 6

isV6

Tests to see if the version specified is of type IPv6

INPUT: (none) OUTPUT: 1 - true, 0 - false

isV4

Tests to see if the version specified is of type IPv4

INPUT: (none) OUTPUT: 1 - true, 0 - false

AUTHOR

M. Lawrence Weikum <mweikum@rams.colostate.edu>

BUGS

Please report any bugs or feature request to bgpmon at netsec.colostate.edu or through the web interface at at http://bgpmon.netsec.colostate.edu.

SUPPORT

You can find documentation on this module with the perldoc command.

        perldoc BGPmon::Filter::Prefix

LICENSE AND COPYRIGHT

Copyright (c) 2012 Colorado State University

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\

File: Prefix.pm Authors: M. Lawrence Weikum Date: 6 September 2012

1 POD Error

The following errors were encountered while parsing the POD:

Around line 130:

Unknown directive: =comment