1Net::BGP::ASPath(3)   User Contributed Perl Documentation  Net::BGP::ASPath(3)
2
3
4

NAME

6       "Net::BGP::ASPath" - Class encapsulating BGP-4 AS Path information
7

SYNOPSIS

9           use Net::BGP::ASPath;
10
11           # Constructor
12           $aspath  = Net::BGP::ASPath->new(undef, { as4 => 1 });
13           $aspath2 = Net::BGP::ASPath->new([65001,65002]);
14           $aspath3 = Net::BGP::ASPath->new("(65001 65002) 65010");
15           $aspath4 = Net::BGP::ASPath->new("65001 {65011,65010}");
16
17           # Object Copy
18           $clone   = $aspath->clone();
19
20           # Modifiers;
21           $aspath  = $aspath->prepend(64999);
22           $aspath  = $aspath->prepend("64999 65998");
23           $aspath  = $aspath->prepend([64999,65998]);
24
25           $aspath  = $aspath->prepend("(64999 65998)");
26           $aspath  = $aspath->prepend_confed("64999 65998");
27
28           $aspath += "65001 65002";    # Same as $aspath->prepend("65001 65002")
29
30           $aspath5 = $aspath->striped; # New object
31           $aspath  = $aspath->strip;   # Same modified
32
33           $aspath  = $aspath->cleanup  # Same modified
34
35           # Aggregation
36           $aspath  = $aspath1->aggregate($aspath2,$aspath3);
37           $aspath  = Net::BGP::ASPath->aggregate($aspath1,$aspath2,$aspath3);
38
39
40           # Accessor Methods
41           $length    = $aspath->length;
42           $string    = $aspath->as_string;
43           $array_ref = $aspath->asarray
44
45           # In context
46           $string    = "The AS path is: " . $aspath;
47           $firstas   = $aspath[0];
48
49           # Length comparisons
50           if ($aspath < $aspath2) { ... };
51           if ($aspath > $aspath2) { ... };
52           if ($aspath == $aspath2) { ... };
53           if ($aspath != $aspath2) { ... };
54           @sorted = sort { $a <=> $b } ($aspath, $aspath2, $aspath3, $aspath4);
55
56           # Path comparisons
57           if ($aspath eq $aspath2) { ... };
58           if ($aspath ne $aspath2) { ... };
59

DESCRIPTION

61       This module encapsulates the data contained in a BGP-4 AS_PATH,
62       including confederation extensions.
63

CONSTRUCTOR

65       new() - create a new "Net::BGP::ASPath" object
66               $aspath = Net::BGP::ASPath->new( PATHDATA, OPTIONS );
67
68           This is the constructor for "Net::BGP::ASPath" objects. It returns
69           a reference to the newly created object. The first parameter may be
70           either:
71
72           ARRAY_REF
73               An array ref containing AS numbers interpreted as an
74               AS_PATH_SEQUENCE.
75
76           SCALAR
77               A string with AS numbers separated by spaces
78               (AS_PATH_SEQUANCE).  AS_PATH_SETs are written using "{}" with
79               "," to separate AS numbers.  AS_PATH_CONFED_* is written
80               similarly, but encapsulated in "()".
81
82           "Net::BGP::ASPath"
83               Another ASPath object, in which case a clone is constructed.
84
85           "undef"
86               This will create the ASPath object with empty contents.
87
88           Following the PATHDATA, the OPTIONS may be specified.  Currently
89           the only valid option is c<as4>, which, if true, builds ASPath
90           objects usable for talking to a peer that supports 32 bit ASNs.
91           False, or the default value, assumes that the peer does not support
92           32 bit ASNs, which affects the decode routines.  Note that the
93           encode routines are not dependent upon this option.
94
95           Basically, if as4 is true, AS_PATH is populated from messages
96           assuming 4 byte ASNs and AS4_PATH is not used.  Encoded AS_PATH
97           attributes also assume a 4 byte ASN.
98
99           If as4 is false, AS_PATH is populated from messages assuming 2 byte
100           ASNs, and, if available, AS4_PATH is used to replace occurences of
101           23456 when possible when outputing to user-readable formats.
102           Encoding routines will also allow output of AS4_PATH objects when
103           appropriate.
104

OBJECT COPY

106       clone() - clone a "Net::BGP::ASPath" object
107               $clone = $aspath->clone();
108
109           This method creates an exact copy of the "Net::BGP::ASPath" object.
110

ACCESSOR METHODS

112       length()
113           Return the path-length used in BGP path selection. This is the sum
114           of the lengths of all AS_PATH elements. This does however not
115           include AS_PATH_CONFED_* elements and AS_SEGMENTS which count as
116           one BGP hop.
117
118       as_string()
119           Returns the path as a string in same notation that the constructor
120           accepts.
121
122       cleanup()
123           Reduce the path by removing meaningless AS_PATH elements (empty
124           sets or sequences) and joining neighbor elements of the same _SET
125           type.
126
127       strip()
128           Strips AS_CONFED_* segments from the path.
129
130       striped()
131           Returns a strip() 'ed clone() of the path.
132
133       prepend(ARRAY)
134       prepend(SCALAR)
135           Strips AS_CONFED_* segments from the path and prepends one or more
136           AS numbers to the path as given as arguments, either as an array of
137           AS numbers or as a string with space separated AS numbers. If the
138           string has "()" surrounding it, prepend_confed will be used
139           instead.
140
141       prepend_confed(ARRAY)
142       prepend_confed(SCALAR)
143           Prepends one or more confederation AS numbers to the path as given
144           as arguments, either as an array of AS numbers or as a string with
145           space separated AS numbers. "()" around the string is ignored.
146
147       aggregate(ASPath)
148       aggregate(ARRAY)
149           Aggregates the current ASPath with the ASPath(s) given as argument.
150           If invoked as a class method, aggregate all ASPaths given as
151           argument.
152
153           To aggregate means to find the longest common substring (of the
154           paths of all objects that should be aggregated) and keep them, but
155           replacing the non-common substrings with AS_SET segments. Currently
156           only the longest common normal and confederation head will be found
157           and the remaining will be left as an AS_SET and AS_CONFED_SET.
158
159           Returns the aggregated object. The objects themselves are not
160           modified.
161

SEE ALSO

163       Net::BGP
164       Net::BGP::Process
165       Net::BGP::Peer
166       Net::BGP::Update
167       Net::BGP::Refresh
168       Net::BGP::NLRI
169       Net::BGP::Notification
170

AUTHOR

172       Martin Lorensen <bgp@martin.lorensen.dk>
173
174
175
176perl v5.34.0                      2022-01-21               Net::BGP::ASPath(3)
Impressum