NAME
Net::BGP::ASPath - Class encapsulating BGP-4 AS Path information
SYNOPSIS
use Net::BGP::ASPath;
# Constructor
$aspath = Net::BGP::ASPath->new();
$aspath2 = Net::BGP::ASPath->new([65001,65002]);
$aspath3 = Net::BGP::ASPath->new("(65001 65002) 65010");
$aspath4 = Net::BGP::ASPath->new("65001 {65011,65010}");
# Object Copy
$clone = $aspath->clone();
# Modifiers;
$aspath = $aspath->prepend(64999);
$aspath = $aspath->prepend("64999 65998");
$aspath = $aspath->prepend([64999,65998]);
$aspath = $aspath->prepend("(64999 65998)");
$aspath = $aspath->prepend_confed("64999 65998");
$aspath += "65001 65002"; # Same as $aspath->prepend("65001 65002")
$aspath5 = $aspath->striped; # New object
$aspath = $aspath->strip; # Same modified
$aspath = $aspath->cleanup # Same modified
# Aggregation
$aspath = $aspath1->aggregate($aspath2,$aspath3);
$aspath = Net::BGP::ASPath->aggregate($aspath1,$aspath2,$aspath3);
# Accessor Methods
$length = $aspath->length;
$string = $aspath->asstring;
$array_ref = $aspath->asarray
# In context
$string = "The AS path is: " . $aspath;
$firstas = $aspath[0];
# Length comparisons
if ($aspath < $aspath2) { ... };
if ($aspath > $aspath2) { ... };
if ($aspath == $aspath2) { ... };
if ($aspath != $aspath2) { ... };
@sorted = sort { $a <=> $b } ($aspath, $aspath2, $aspath3, $aspath4);
# Path comparisons
if ($aspath eq $aspath2) { ... };
if ($aspath ne $aspath2) { ... };
DESCRIPTION
This module encapsulates the data contained in a BGP-4 AS_PATH, inluding confederation extentions.
CONSTRUCTOR
- new() - create a new Net::BGP::ASPath object
-
$aspath = Net::BGP::ASPath->new( PATHDATA );
This is the constructor for Net::BGP::ASPath objects. It returns a reference to the newly created object. The parameter may be either:
- ARRAY
-
An array of AS numbers inteperted as an AS_PATH_SEQUENCE.
- SCALAR
-
A string with AS numbers seperated by spaces (AS_PATH_SEQUANCE). AS_PATH_SETs is written using "{}" with "," to seperate AS numbers. AS_PATH_CONFED_* is writen equally, but encapsulated in "()".
- Net::BGP::ASPath
-
Another ASPath object, in which case a clone is constructed.
OBJECT COPY
- clone() - clone a Net::BGP::ASPath object
-
$clone = $aspath->clone();
This method creates an exact copy of the Net::BGP::ASPath object.
ACCESSOR METHODS
- length()
-
Return the path-length used in BGP path selection. This is the sum of the lengths of all AS_PATH elements. This does however not include AS_PATH_CONFED_* elements.
- asstring()
-
Returns the path as a string in same notation as the constructor accept.
- cleanup()
-
Reduce the path by removing meaningless AS_PATH elements (empty sets or sequences) and joining neighbour elements of same _SET type.
- strip()
-
Strips AS_CONFED_* segments from the path.
- striped()
-
Returns a strip() 'ed clone() of the path.
- prepend(ARRAY)
- prepend(SCALAR)
-
Strips AS_CONFED_* segments from the path and prepends one or more AS numbers to the path as given as arguments, either as an array of AS numbers or as a string with space seperated AS numbers. If string has "()" arround, prepend_confed will be used instead.
- prepend_confed(ARRAY)
- prepend_confed(SCALAR)
-
Prepends one or more confederation AS numbers to the path as given as arguments, either as an array of AS numbers or as a string with space seperated AS numbers. "()" arround the string is ignored.
- aggregate(ASPath)
- aggregate(ARRAY)
-
Aggregates the current ASPath with the ASPath(s) given as argument. If invoked as class method, aggregate all ASPaths given as argument.
To aggregate means to find the longest common substring (of the paths of all objects that should be aggregated) and keep them, but replacing the non-common substrings with AS_SET segments. Currently only the longest common normal and confederation head will be found and the remaing will be left as an AS_SET and AS_CONFED_SET.
Returns the aggregated object. The objects self are not modified.
SEE ALSO
RFC 1771, RFC 1997, Net::BGP, Net::BGP::Process, Net::BGP::Peer, Net::BGP::Notification, Net::BGP::NLRI, Net::BGP::Update
AUTHOR
Martin Lorensen <bgp@martin.lorensen.dk>