NAME
Net::BGP::NLRI - Class encapsulating BGP-4 NLRI information
SYNOPSIS
use Net::BGP::NLRI qw( :origin );
# Constructor
$nlri = Net::BGP::NLRI->new(
Aggregator => [ 64512, '10.0.0.1' ],
AtomicAggregate => 1,
AsPath => Net::BGP::ASPath->new("64512 64513 64514"),
Communities => [ qw( 64512:10000 64512:10001 ) ],
LocalPref => 100,
MED => 200,
NextHop => '10.0.0.1',
Origin => INCOMPLETE,
);
# Object Copy
$clone = $nlri->clone();
# Accessor Methods
$aggregator_ref = $nlri->aggregator($aggregator_ref);
$atomic_aggregate = $nlri->atomic_aggregate($atomic_aggregate);
$as_path = $nlri->as_path($as_path);
$communities_ref = $nlri->communities($communities_ref);
$local_pref = $nlri->local_pref($local_pref);
$med = $nlri->med($med);
$next_hop = $nlri->next_hop($next_hop);
$origin = $nlri->origin($origin);
$string = $nlri->asstring;
# Preference comparisons
if ($nlri1 < $nlri2) { ... };
if ($nlri1 > $nlri2) { ... };
if ($nlri1 == $nlri2) { ... };
if ($nlri1 != $nlri2) { ... };
@sorted = sort { $a <=> $b } ($nlri1, $nlri2, $nlri3, ... );
# Comparison
if ($nlri1 eq $nlri2) { ... };
if ($nlri1 ne $nlri2) { ... };
DESCRIPTION
This module encapsulates the data used by BGP-4 to represent network reachability information. It provides a constructor, and accessor methods for each of the well-known path attributes. An BGP-4 UPDATE message includes this information along with a list of networks for which the information should be used (and a list of network no longer accessible). See Net::BGP::Update for more infomration.
CONSTRUCTOR
new() - create a new Net::BGP::NLRI object
$nlri = Net::BGP::NLRI->new(
Aggregator => [ 64512, '10.0.0.1' ],
AsPath => Net::BGP::ASPath->new("64512 64513 64514"),
AtomicAggregate => 1,
Communities => [ qw( 64512:10000 64512:10001 ) ],
LocalPref => 100,
MED => 200,
NextHop => '10.0.0.1',
Origin => INCOMPLETE,
);
This is the constructor for Net::BGP::NLRI objects. It returns a reference to the newly created object. The following named parameters may be passed to the constructor. See RFC 1771 for the semantics of each path attribute.
Aggregator
This parameter corresponds to the AGGREGATOR path attribute. It is expressed as an array reference, the first element of which is the AS number (in the range of an 16-bit unsigned integer) of the route aggregator, and the second element is the aggregator's IP address expressed in dotted-decimal notation as a string. It may be omitted, in which case no AGGREGATOR path attribute will be attached to the UPDATE message.
AsPath
This parameter corresponds to the AS_PATH path attribute. The AS_PATH is expressed as an Net::BGP::ASPath object. If expressed otherwise, a Net::BGP::ASPath object is tried constructed using the argument.
AtomicAggregate
This parameter corresponds to the ATOMIC_AGGREGATE path attribute. It is a boolean value so any value which perl interprets as true/false may be used. It may be omitted, in which case no ATOMIC_AGGREGATE path attribute will be attached to the UPDATE message.
Communities
This parameter corresponds to the COMMUNITIES attribute defined in RFC 1997. It is expressed as an array reference of communities which apply to the route(s). The communities are encoded in a special format: AAAA:CCCC, where AAAA corresponds to the 16-bit unsigned integer AS number, and CCCC is a 16-bit unsigned integer of arbitrary value. But see RFC 1997 for the semantics of several reserved community values. This attribute may be omitted, in which case no COMMUNITIES attribute will be attached to the UPDATE message.
LocalPref
This parameter corresponds to the LOCAL_PREF path attribute. It is expressed as a 32-bit unsigned integer scalar value. It may be omitted, in which case no LOCAL_PREF path attribute will be attached to the UPDATE message.
MED
This parameter corresponds to the MULTI_EXIT_DISC path attribute. It is expressed as a 32-bit unsigned integer scalar value. It may be omitted, in which case no MULTI_EXIT_DISC path attribute will be attached to the UPDATE message.
NextHop
This parameter corresponds to the NEXT_HOP path attribute. It is expressed as a dotted-decimal IP address as a perl string. This path attribute is mandatory and the parameter must always be provided to the constructor.
Origin
This parameter corresponds to the ORIGIN path attribute. It is expressed as an integer scalar value, which can take the following enumerated values: IGP, EGP, or INCOMPLETE. The preceding symbols can be imported into the program namespace individually or by the :origin export tag. This path attribute is mandatory and the parameter must always be provided to the constructor.
OBJECT COPY
clone() - clone a Net::BGP::NLRI object
$clone = $nlri->clone();
This method creates an exact copy of the Net::BGP::NLRI object with Path Attributes fields matching those of the original object.
ACCESSOR METHODS
aggregator()
as_path()
atomic_aggregate()
communities()
local_pref()
med()
next_hop()
origin()
These accessor methods return the value(s) of the associated path attribute fields if called with no arguments. If called with arguments, they set the associated field. The representation of parameters and return values is the same as described for the corresponding named constructor parameters above.
asstring()
This accessor method returns a print-friendly string with some, but not all, of the information containted in the object.
EXPORTS
The module exports the following symbols according to the rules and conventions of the Exporter module.
:origin IGP, EGP, INCOMPLETE
SEE ALSO
RFC 1771, RFC 1997, Net::BGP, Net::BGP::Process, Net::BGP::Peer, Net::BGP::Notification, Net::BGP::ASPath, Net::BGP::Update
AUTHOR
Stephen J. Scheck <sscheck@cpan.org>