Net::BGP::Update(3)

πŸ“¦
version 0.18 Β· 4 versions
, in epel 9

πŸ’… Net::BGP::Update β€” the manual page (Perl, User Contributed Perl Documentation, Net::BGP::Update(3)) πŸ¦‹

okay so bestie, gather round, because this one is genuinely iconic β€” it's the Net::BGP::Update module, and it's the class that encapsulates a BGP-4 UPDATE message. yes, the whole thing. every field. let's go ✨


🌸 NAME 🌸

"Net::BGP::Update" β€” a class that encapsulates a BGP-4 UPDATE message. that's it, that's the vibe. πŸ‘‘


⭐ SYNOPSIS ⭐

first things first, you gotta pull in the origin constants:

use Net::BGP::Update qw( :origin );

the constructor, in all its glory, with every single parameter you can pass:

# Constructor
$update = Net::BGP::Update->new(
    NLRI            => [ qw( 10/8 172.168/16 ) ],
    Withdraw        => [ qw( 192.168.1/24 172.10/16 192.168.2.1/32 ) ],
    # For Net::BGP::NLRI
    Aggregator      => [ 64512, '10.0.0.1' ],
    AsPath          => [ 64512, 64513, 64514 ],
    AtomicAggregate => 1,
    Communities     => [ qw( 64512:10000 64512:10001 ) ],
    LocalPref       => 100,
    MED             => 200,
    NextHop         => '10.0.0.1',
    Origin          => INCOMPLETE,
);

construction from an NLRI object, for when you already have one lying around:

# Construction from a NLRI object:
$nlri = Net::BGP::NLRI->new( ... );
$update = Net::BGP::Update->new($nlri,$nlri_ref,$withdrawn_ref);

object copy, because sometimes you need a twin:

# Object Copy
$clone = $update->clone();

accessor methods, the little getter/setter besties:

# Accessor Methods
$nlri_ref         = $update->nlri($nlri_ref);
$withdrawn_ref    = $update->withdrawn($withdrawn_ref);
$prefix_hash_ref  = $update->ashash;

comparison, yes you can literally just compare them with string operators:

# Comparison
if ($update1 eq $update2) { ... }
if ($update1 ne $update2) { ... }

πŸŽ€ DESCRIPTION πŸŽ€

so this module encapsulates all the data contained in a BGP-4 UPDATE message. it hands you a constructor, plus accessor methods for each of the message fields and the well-known path attributes of an UPDATE. 🫢

here's the flow, because it ate: whenever a Net::BGP::Peer wants to send an UPDATE message to its peer, it does it by passing a "Net::BGP::Update" object to the peer object's update() method. and the other direction? when the peer receives an UPDATE message from its peer, the UPDATE callback gets called and gets handed a reference to a "Net::BGP::Update" object. then your callback function can go examine the UPDATE message fields using the accessor methods. main character energy on both ends of the wire, fr fr. πŸ’…


🌈 CONSTRUCTOR 🌈

new() β€” create a new "Net::BGP::Update" object ✨

$update = Net::BGP::Update->new(
    NLRI            => [ qw( 10/8 172.168/16 ) ],
    Withdraw        => [ qw( 192.168.1/24 172.10/16 192.168.2.1/32 ) ],
    # For Net::BGP::NLRI
    Aggregator      => [ 64512, '10.0.0.1' ],
    AsPath          => [ 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::Update" objects, and it returns a reference to the freshly created object. 🎁 you pass it named parameters β€” here's the thing, the semantics of each path attribute live over in RFC 1771, so go read that if you want the deep lore.

lowkey there's an alternative route too β€” you can construct an object from a Net::BGP::NLRI object instead:
$nlri = Net::BGP::NLRI->new( ... );
$nlri_ref = [ qw( 10/8 172.168/16 ) ];
$withdrawn_ref = [ qw( 192.168.1/24 172.10/16 192.168.2.1/32 ) ];
$update = Net::BGP::Update->new($nlri,$nlri_ref,$withdrawn_ref);

and important: the NLRI object will not be modified in any way. no cap, it stays untouched. πŸ™ˆ


🌸 NLRI

this parameter corresponds to the Network Layer Reachability Information (NLRI) field of an UPDATE message. it represents the route(s) being advertised in this particular UPDATE. πŸ›£οΈ

it's expressed as an array reference of route prefixes, encoded in a special format as perl strings: XXX.XXX.XXX.XXX/XX. the part before the slash is a dotted-decimal notation IP prefix β€” and you only need to specify as many octets as are significant according to the mask. the part after the slash is the mask, an integer in the range [0,32] telling you how many bits are significant in the prefix. πŸ”’

at least one of either the NLRI or Withdraw parameters is mandatory and must always be provided to the constructor. both being optional is not a thing, bestie. ⚠️

πŸ’œ Withdraw

this parameter corresponds to the Withdrawn Routes field of an UPDATE message. it represents route(s) that were advertised by a previous UPDATE message and are now being withdrawn by this one. πŸ’” it's expressed in exactly the same way as the NLRI parameter.

same rule, and yes it's serious: at least one of either the NLRI or Withdraw parameters is mandatory and must always be provided to the constructor. 🫑

πŸ¦‹ OBJECT COPY πŸ¦‹

clone() β€” clone a "Net::BGP::Update" object

$clone = $update->clone();

this method creates an exact copy of the "Net::BGP::Update object", with Withdrawn Routes, Path Attributes, and NLRI fields all matching those of the original object. πŸͺž

why do you care? because it's useful for propagating a modified UPDATE message when the original object needs to remain unchanged. keep the original, send out the remix. iconic behavior honestly. πŸ’…


πŸ’– ACCESSOR METHODS πŸ’–

nlri()

withdrawn()

these accessor methods return the value(s) of the associated UPDATE message field if you call them with no arguments. 🎯 if you do call them with arguments, they set the associated field. the representation of the parameters and the return values is exactly the same as described for the corresponding named constructor parameters above. no surprises, no plot twists.

ashash()

this method returns a hash reference indexed on the prefixes found in the NLRI and Withdraw fields. πŸ”‘

withdrawn networks are set to "undef", while NLRI prefixes all have the same reference to the Net::BGP::NLRI object matching the Update object itself. yes, the same reference β€” not a copy. bestie behavior. 🫢


🧚 EXPORTS 🧚

this module does not export anything. that's the whole section. nothing. zero. nada. (except those :origin tags you asked for in the use line, obviously.) 😌


🌟 SEE ALSO 🌟

go check out the whole friend group:

  • Net::BGP
  • Net::BGP::Process
  • Net::BGP::Peer
  • Net::BGP::Refresh
  • Net::BGP::ASPath
  • Net::BGP::NLRI
  • Net::BGP::Notification

πŸ‘‘ AUTHOR πŸ‘‘

Stephen J. Scheck <sscheck@cpan.org> β€” the legend who wrote this. 🫑


and that's the page, bestie! ✨ this version came to you from perl v5.32.1, dated 2021-12-02 β€” so yes, it's got a little vintage charm, but it still slays. go route some packets, you absolute icon. πŸ’…πŸŽ€πŸ¦‹πŸ”₯

πŸ“¦ where this page comes from