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       inluding confederation extentions.
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 a
69           reference to the newly created object. The first parameter may be
70           either:
71
72           ARRAY_REF
73               An array ref containing AS numbers inteperted as an
74               AS_PATH_SEQUENCE.
75
76           SCALAR
77               A string with AS numbers seperated by spaces
78               (AS_PATH_SEQUANCE).  AS_PATH_SETs is written using "{}" with
79               "," to seperate AS numbers.  AS_PATH_CONFED_* is writen
80               equally, 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 an 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 count as one BGP
116           hop.
117
118       as_string()
119           Returns the path as a string in same notation as the constructor
120           accept.
121
122       cleanup()
123           Reduce the path by removing meaningless AS_PATH elements (empty
124           sets or sequences) and joining neighbour elements of 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 seperated AS numbers. If
138           string has "()" arround, prepend_confed will be used instead.
139
140       prepend_confed(ARRAY)
141       prepend_confed(SCALAR)
142           Prepends one or more confederation AS numbers to the path as given
143           as arguments, either as an array of AS numbers or as a string with
144           space seperated AS numbers. "()" arround the string is ignored.
145
146       aggregate(ASPath)
147       aggregate(ARRAY)
148           Aggregates the current ASPath with the ASPath(s) given as argument.
149           If invoked as class method, aggregate all ASPaths given as
150           argument.
151
152           To aggregate means to find the longest common substring (of the
153           paths of all objects that should be aggregated) and keep them, but
154           replacing the non-common substrings with AS_SET segments. Currently
155           only the longest common normal and confederation head will be found
156           and the remaing will be left as an AS_SET and AS_CONFED_SET.
157
158           Returns the aggregated object. The objects self are not modified.
159

SEE ALSO

161       RFC 1771, RFC 1997, Net::BGP, Net::BGP::Process, Net::BGP::Peer,
162       Net::BGP::Notification, Net::BGP::NLRI, Net::BGP::Update
163

AUTHOR

165       Martin Lorensen <bgp@martin.lorensen.dk>
166
167
168
169perl v5.28.1                      2015-01-27               Net::BGP::ASPath(3)
Impressum