bgp4r 0.0.12 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +21 -15
- data/bgp/common.rb +13 -12
- data/bgp/iana.rb +28 -205
- data/bgp/io.rb +0 -1
- data/bgp/messages/capability.rb +1 -1
- data/bgp/messages/message.rb +1 -1
- data/bgp/messages/open.rb +1 -1
- data/bgp/messages/route_refresh.rb +4 -7
- data/bgp/messages/update.rb +9 -6
- data/bgp/misc/live_feed.rb +1 -2
- data/bgp/neighbor/add_path_cap.rb +14 -13
- data/bgp/neighbor/neighbor.rb +30 -18
- data/bgp/nlris/inet.rb +9 -11
- data/bgp/nlris/label.rb +1 -1
- data/bgp/nlris/labeled.rb +31 -4
- data/bgp/nlris/nlri.rb +23 -183
- data/bgp/nlris/nsap.rb +101 -0
- data/bgp/nlris/prefix.rb +162 -24
- data/bgp/nlris/rd.rb +1 -1
- data/bgp/nlris/vpn.rb +23 -5
- data/bgp/optional_parameters/add_path.rb +11 -37
- data/bgp/optional_parameters/as4.rb +1 -1
- data/bgp/optional_parameters/capability.rb +1 -11
- data/bgp/optional_parameters/dynamic.rb +1 -1
- data/bgp/optional_parameters/graceful_restart.rb +35 -22
- data/bgp/optional_parameters/mbgp.rb +23 -37
- data/bgp/optional_parameters/orf.rb +1 -1
- data/bgp/optional_parameters/route_refresh.rb +1 -1
- data/bgp/orfs/prefix_orf.rb +3 -6
- data/bgp/path_attributes/aggregator.rb +1 -1
- data/bgp/path_attributes/as_path.rb +1 -1
- data/bgp/path_attributes/atomic_aggregate.rb +1 -1
- data/bgp/path_attributes/cluster_list.rb +1 -1
- data/bgp/path_attributes/communities.rb +1 -1
- data/bgp/path_attributes/extended_communities.rb +1 -1
- data/bgp/path_attributes/extended_community.rb +55 -26
- data/bgp/path_attributes/local_pref.rb +1 -1
- data/bgp/path_attributes/mp_reach.rb +178 -76
- data/bgp/path_attributes/mp_unreach.rb +11 -67
- data/bgp/path_attributes/multi_exit_disc.rb +1 -1
- data/bgp/path_attributes/next_hop.rb +1 -1
- data/bgp/path_attributes/origin.rb +1 -1
- data/bgp/path_attributes/originator_id.rb +1 -1
- data/bgp/path_attributes/path_attribute.rb +1 -1
- data/bgp4r.gemspec +130 -183
- data/examples/routegen +0 -1
- data/examples/test.rb +15 -0
- data/examples/test2.rb +116 -0
- data/examples/unit-testing/{malformed_update.rb → malformed_update_test.rb} +6 -6
- data/examples/unit-testing/{no_export.rb → no_export_test.rb} +6 -6
- data/examples/unit-testing/{prepend_aspath.rb → prepend_aspath_test.rb} +6 -6
- data/test/functional/add_path_test.rb +32 -0
- data/test/helpers/server.rb +11 -4
- data/test/{common_test.rb → unit/common_test.rb} +7 -10
- data/test/{iana_test.rb → unit/iana_test.rb} +7 -6
- data/test/{messages → unit/messages}/capability_test.rb +26 -9
- data/test/{messages → unit/messages}/route_refresh_test.rb +4 -4
- data/test/{messages → unit/messages}/update_test.rb +28 -17
- data/test/{neighbor → unit/neighbor}/add_path_cap_test.rb +41 -0
- data/test/{neighbor → unit/neighbor}/neighbor_test.rb +31 -13
- data/test/unit/nlris/labeled_test.rb +30 -0
- data/test/unit/nlris/nlri_test.rb +103 -0
- data/test/unit/nlris/nsap_test.rb +80 -0
- data/test/unit/nlris/prefix_test.rb +136 -0
- data/test/{optional_parameters → unit/optional_parameters}/capability_test.rb +0 -5
- data/test/unit/optional_parameters/graceful_restart_test.rb +41 -0
- data/test/{optional_parameters → unit/optional_parameters}/mbgp_test.rb +20 -0
- data/test/unit/path_attributes/aigp.rb +59 -0
- data/test/{path_attributes → unit/path_attributes}/extended_communities_test.rb +4 -0
- data/test/{path_attributes → unit/path_attributes}/extended_community_test.rb +9 -0
- data/test/unit/path_attributes/mp_reach_test.rb +563 -0
- data/test/{path_attributes → unit/path_attributes}/path_attribute_test.rb +1 -1
- metadata +128 -136
- data/examples/unit-testing/test.rb +0 -82
- data/examples/unit-testing/test1.rb +0 -82
- data/examples/unit-testing/test2.rb +0 -44
- data/test/nlris/ext_nlri_test.rb +0 -32
- data/test/nlris/nlri_test.rb +0 -130
- data/test/optional_parameters/graceful_restart_test.rb +0 -24
- data/test/path_attributes/mp_reach_test.rb +0 -305
- /data/examples/unit-testing/{unknown_transitive_attr.rb → unknown_transitive_attr_test.rb} +0 -0
- /data/test/{misc → functional}/live_feed_test.rb +0 -0
- /data/test/{messages → unit/messages}/keepalive_test.rb +0 -0
- /data/test/{messages → unit/messages}/markers_test.rb +0 -0
- /data/test/{messages → unit/messages}/message_test.rb +0 -0
- /data/test/{messages → unit/messages}/notification_test.rb +0 -0
- /data/test/{messages → unit/messages}/open_test.rb +0 -0
- /data/test/{nlris → unit/nlris}/inet_test.rb +0 -0
- /data/test/{nlris/labeled_test.rb → unit/nlris/label_test.rb} +0 -0
- /data/test/{nlris → unit/nlris}/rd_test.rb +0 -0
- /data/test/{optional_parameters → unit/optional_parameters}/add_path_test.rb +0 -0
- /data/test/{optional_parameters → unit/optional_parameters}/as4_test.rb +0 -0
- /data/test/{optional_parameters → unit/optional_parameters}/dynamic_test.rb +0 -0
- /data/test/{optional_parameters → unit/optional_parameters}/optional_parameter_test.rb +0 -0
- /data/test/{optional_parameters → unit/optional_parameters}/orf_test.rb +0 -0
- /data/test/{optional_parameters → unit/optional_parameters}/route_refresh_test.rb +0 -0
- /data/test/{orfs → unit/orfs}/prefix_orf_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/aggregator_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/as_path_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/atomic_aggregate_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/attribute_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/cluster_list_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/communities_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/local_pref_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/mp_unreach_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/multi_exit_disc_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/next_hop_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/origin_test.rb +0 -0
- /data/test/{path_attributes → unit/path_attributes}/originator_id_test.rb +0 -0
data/README.rdoc
CHANGED
@@ -26,15 +26,18 @@ while a Path_attribute object or Nlri object is added to an Update object.
|
|
26
26
|
:version=> 4,
|
27
27
|
:my_as=> 100,
|
28
28
|
:remote_addr => '192.168.1.200',
|
29
|
-
:local_addr => '192.168.1.5',
|
30
29
|
:id=> '1.1.1.1',
|
31
30
|
:holdtime=> 20
|
32
31
|
|
33
|
-
neighbor.
|
34
|
-
neighbor.
|
35
|
-
neighbor.
|
36
|
-
neighbor.
|
37
|
-
neighbor.
|
32
|
+
neighbor.capability_mbgp_ipv4_unicast
|
33
|
+
neighbor.capability_mbgp_ipv4_multicast
|
34
|
+
neighbor.capability_mbgp_ipv4_mpls_vpn_unicast
|
35
|
+
neighbor.capability_mbgp_ipv6_mpls_vpn_multicast
|
36
|
+
neighbor.capability_mbgp_nsap_mpls_vpn_unicast
|
37
|
+
neighbor.capability_mbgp_nsap_unicast
|
38
|
+
neighbor.capability_route_refresh
|
39
|
+
neighbor.capability_route_refresh 128
|
40
|
+
neighbor.capability_four_byte_as
|
38
41
|
|
39
42
|
|
40
43
|
= Ruby classes representing BGP messages, attributes, and nlri
|
@@ -90,21 +93,24 @@ while a Path_attribute object or Nlri object is added to an Update object.
|
|
90
93
|
:version=> 4,
|
91
94
|
:my_as=> 100,
|
92
95
|
:remote_addr => '192.168.1.200',
|
93
|
-
:local_addr => '192.168.1.5',
|
94
96
|
:id=> '1.1.1.1', :holdtime=> 20
|
95
97
|
|
96
98
|
==== Set its capabilities:
|
97
99
|
|
98
|
-
neighbor.
|
99
|
-
neighbor.
|
100
|
-
neighbor.
|
101
|
-
neighbor.
|
102
|
-
neighbor.
|
100
|
+
neighbor.capability_mbgp_ipv4_unicast
|
101
|
+
neighbor.capability_mbgp_ipv4_multicast
|
102
|
+
neighbor.capability_mbgp_ipv4_mpls_vpn_unicast
|
103
|
+
neighbor.capability_mbgp_ipv6_mpls_vpn_multicast
|
104
|
+
neighbor.capability_mbgp_nsap_mpls_vpn_unicast
|
105
|
+
neighbor.capability_mbgp_nsap_unicast
|
106
|
+
neighbor.capability_route_refresh
|
107
|
+
neighbor.capability_route_refresh 128
|
108
|
+
neighbor.capability_four_byte_as
|
103
109
|
|
104
110
|
|
105
111
|
==== Start peering:
|
106
112
|
|
107
|
-
neighbor.start :auto_retry
|
113
|
+
neighbor.start :auto_retry=> true
|
108
114
|
|
109
115
|
==== Build an BGP Update object made up of a Path_attribute and a Nlri objects:
|
110
116
|
|
@@ -229,7 +235,7 @@ Source code is hosted on github.
|
|
229
235
|
|
230
236
|
==== Install the gem
|
231
237
|
|
232
|
-
|
238
|
+
sudo gem install bgp4r
|
233
239
|
|
234
240
|
== Requirements
|
235
241
|
|
@@ -247,4 +253,4 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
247
253
|
GNU General Public License for more details.
|
248
254
|
|
249
255
|
You should have received a copy of the GNU General Public License
|
250
|
-
along with BGP4R. If not, see <http://www.gnu.org/licenses/>.
|
256
|
+
along with BGP4R. If not, see <http://www.gnu.org/licenses/>.
|
data/bgp/common.rb
CHANGED
@@ -13,6 +13,19 @@
|
|
13
13
|
# You should have received a copy of the GNU General Public License
|
14
14
|
# along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
+
module Kernel
|
17
|
+
alias :require_orig :require
|
18
|
+
|
19
|
+
def my_caller(caller)
|
20
|
+
caller.split('/')
|
21
|
+
end
|
22
|
+
|
23
|
+
def require(*args)
|
24
|
+
#puts format("%-20s : %s", "require '#{args}'", caller[0])
|
25
|
+
require_orig(*args)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
16
29
|
require 'ipaddr'
|
17
30
|
require 'logger'
|
18
31
|
|
@@ -31,18 +44,6 @@ class IPAddr
|
|
31
44
|
end
|
32
45
|
end
|
33
46
|
|
34
|
-
#TODO: if not used, get rid of it.
|
35
|
-
def self.new_nlri4(arg)
|
36
|
-
if arg.is_a?(String) and arg.is_packed?
|
37
|
-
arg +=([0]*3).pack('C*')
|
38
|
-
plen, *nlri = arg.unpack('CC4')
|
39
|
-
ipaddr = nlri.collect { |n| n.to_s }.join('.') + "/" + plen .to_s
|
40
|
-
IPAddr.new(ipaddr)
|
41
|
-
else
|
42
|
-
IPAddr.new(arg)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
47
|
def mlen
|
47
48
|
@_jme_mlen_ ||= _mlen_
|
48
49
|
end
|
data/bgp/iana.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# Copyright 2008,
|
2
|
+
# Copyright 2008-2009, 2011 Jean-Michel Esnault.
|
3
3
|
# All rights reserved.
|
4
4
|
# See LICENSE.txt for permissions.
|
5
5
|
#
|
@@ -20,39 +20,40 @@
|
|
20
20
|
# along with BGP4R. If not, see <http://www.gnu.org/licenses/>.
|
21
21
|
#++
|
22
22
|
|
23
|
-
|
23
|
+
#
|
24
|
+
# http://www.iana.org/assignments/address-family-numbers/
|
25
|
+
#
|
24
26
|
module IANA
|
25
|
-
def self.afi(afi)
|
26
|
-
case afi
|
27
|
-
when AFI::IP ; 'IPv4'
|
28
|
-
when AFI::IP6 ; 'IPv6'
|
29
|
-
else
|
30
|
-
''
|
31
|
-
end
|
32
|
-
end
|
33
27
|
def self.afi?(arg)
|
34
|
-
|
35
|
-
@h_afis[arg]
|
28
|
+
afis[arg]
|
36
29
|
end
|
37
|
-
def self.
|
30
|
+
def self.afi(arg)
|
31
|
+
arg.is_a?(Fixnum) ? arg : afis[arg]
|
32
|
+
end
|
33
|
+
def self.safi(arg)
|
34
|
+
arg.is_a?(Fixnum) ? arg : safis[arg]
|
35
|
+
end
|
36
|
+
def self.safis
|
38
37
|
@h_safis ||= SAFI.set_h_safis
|
39
|
-
@h_safis[arg]
|
40
38
|
end
|
41
|
-
def self.
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
def self.afis
|
40
|
+
@h_afis ||= AFI.set_h_afis
|
41
|
+
end
|
42
|
+
def self.safi?(arg)
|
43
|
+
case arg
|
44
|
+
when SAFI::UNICAST ; 'Unicast'
|
45
|
+
when SAFI::MULTICAST ; 'Multicast'
|
45
46
|
when SAFI::LABEL_NLRI ; 'Labeled NLRI'
|
46
47
|
when SAFI::MCAST_VPN ; 'Multicast VPN'
|
47
48
|
when SAFI::MPLS_VPN_UNICAST ; 'Labeled VPN Unicast'
|
48
49
|
when SAFI::MPLS_VPN_Multicast ; 'Labeled VPN Multicast'
|
49
50
|
else
|
50
|
-
|
51
|
+
safis[arg]
|
51
52
|
end
|
52
53
|
end
|
53
54
|
module AFI
|
54
|
-
|
55
|
-
|
55
|
+
IPv4 = 1
|
56
|
+
IPv6 = 2
|
56
57
|
NSAP = 3
|
57
58
|
HDLC = 4
|
58
59
|
BBN = 5
|
@@ -79,9 +80,8 @@ module IANA
|
|
79
80
|
def self.set_h_afis
|
80
81
|
h_afis = Hash.new
|
81
82
|
constants.each do |c|
|
82
|
-
h_afis.store(c.downcase.to_sym, const_get(c))
|
83
|
-
h_afis.store(const_get(c), c.split('_').collect { |w| w }.join(' '))
|
84
|
-
# h_afis.store(const_get(c), c.downcase.to_sym)
|
83
|
+
h_afis.store(c.to_s.downcase.to_sym, const_get(c))
|
84
|
+
h_afis.store(const_get(c), c.to_s.split('_').collect { |w| w }.join(' '))
|
85
85
|
end
|
86
86
|
h_afis
|
87
87
|
end
|
@@ -90,13 +90,13 @@ module IANA
|
|
90
90
|
def self.set_h_safis
|
91
91
|
h_safis = Hash.new
|
92
92
|
constants.each do |c|
|
93
|
-
h_safis.store(c.downcase.to_sym, const_get(c))
|
94
|
-
h_safis.store(const_get(c), c.split('_').collect { |w| w }.join(' '))
|
93
|
+
h_safis.store(c.to_s.downcase.to_sym, const_get(c))
|
94
|
+
h_safis.store(const_get(c), c.to_s.split('_').collect { |w| w }.join(' '))
|
95
95
|
end
|
96
96
|
h_safis
|
97
97
|
end
|
98
|
-
|
99
|
-
|
98
|
+
UNICAST = 1
|
99
|
+
MULTICAST = 2
|
100
100
|
LABEL_NLRI = 4
|
101
101
|
MCAST_VPN = 5
|
102
102
|
MULTI_SEGMENT_PW_NLRI = 6
|
@@ -115,180 +115,3 @@ module IANA
|
|
115
115
|
VPN_AUTO_DISCOVERY = 140
|
116
116
|
end
|
117
117
|
end
|
118
|
-
|
119
|
-
__END__
|
120
|
-
|
121
|
-
http://www.iana.org/assignments/address-family-numbers/
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
Registry:
|
126
|
-
Number Description Reference
|
127
|
-
---------- ---------------------------------------------------------------- -----------------
|
128
|
-
0 Reserved
|
129
|
-
1 IP (IP version 4)
|
130
|
-
2 IP6 (IP version 6)
|
131
|
-
3 NSAP
|
132
|
-
4 HDLC (8-bit multidrop)
|
133
|
-
5 BBN 1822
|
134
|
-
6 802 (includes all 802 media plus Ethernet "canonical format")
|
135
|
-
7 E.163
|
136
|
-
8 E.164 (SMDS, Frame Relay, ATM)
|
137
|
-
9 F.69 (Telex)
|
138
|
-
10 X.121 (X.25, Frame Relay)
|
139
|
-
11 IPX
|
140
|
-
12 Appletalk
|
141
|
-
13 Decnet IV
|
142
|
-
14 Banyan Vines
|
143
|
-
15 E.164 with NSAP format subaddress [UNI-3.1][Malis]
|
144
|
-
16 DNS (Domain Name System)
|
145
|
-
17 Distinguished Name [Lynn]
|
146
|
-
18 AS Number [Lynn]
|
147
|
-
19 XTP over IP version 4 [Saul]
|
148
|
-
20 XTP over IP version 6 [Saul]
|
149
|
-
21 XTP native mode XTP [Saul]
|
150
|
-
22 Fibre Channel World-Wide Port Name [Bakke]
|
151
|
-
23 Fibre Channel World-Wide Node Name [Bakke]
|
152
|
-
24 GWID [Hegde]
|
153
|
-
25 AFI for L2VPN information [RFC4761]
|
154
|
-
26-16383 Unassigned
|
155
|
-
16384 EIGRP Common Service Family [Savage]
|
156
|
-
16385 EIGRP IPv4 Service Family [Savage]
|
157
|
-
16386 EIGRP IPv6 Service Family [Savage]
|
158
|
-
16387-32767 Unassigned
|
159
|
-
32768-65534 Unassigned
|
160
|
-
65535 Reserved
|
161
|
-
|
162
|
-
|
163
|
-
http://www.iana.org/assignments/safi-namespace
|
164
|
-
|
165
|
-
|
166
|
-
Registries included below
|
167
|
-
- SAFI Values
|
168
|
-
|
169
|
-
|
170
|
-
Registry Name: SAFI Values
|
171
|
-
Reference: [RFC4760]
|
172
|
-
Range Registration Procedures Note
|
173
|
-
--------- --------------------------------------------------- --------------------
|
174
|
-
1-63 Standards Action or Early Allocation policy
|
175
|
-
64-127 First Come First Served
|
176
|
-
128-240 Some recognized assignments below, others Reserved
|
177
|
-
241-254 Reserved for Private Use Not to be assigned
|
178
|
-
|
179
|
-
Registry:
|
180
|
-
Value Description Reference
|
181
|
-
------- ---------------------------------------------- ---------
|
182
|
-
0 Reserved [RFC4760]
|
183
|
-
|
184
|
-
1 Network Layer Reachability Information used [RFC4760]
|
185
|
-
for unicast forwarding
|
186
|
-
|
187
|
-
2 Network Layer Reachability Information used [RFC4760]
|
188
|
-
for multicast forwarding
|
189
|
-
|
190
|
-
3 Reserved [RFC4760]
|
191
|
-
|
192
|
-
4 Network Layer Reachability Information (NLRI) [RFC3107]
|
193
|
-
with MPLS Labels
|
194
|
-
|
195
|
-
5 MCAST-VPN [draft-ietf-l3vpn-2547bis-mcast-bgp]
|
196
|
-
(TEMPORARY - Expires 2009-06-19)
|
197
|
-
|
198
|
-
6 Network Layer Reachability Information used [draft-ietf-pwe3-dynamic-ms-pw]
|
199
|
-
for Dynamic Placement of Multi-Segment
|
200
|
-
Pseudowires
|
201
|
-
(TEMPORARY - Expires 2009-08-23)
|
202
|
-
|
203
|
-
7 Encapsulation SAFI [RFC-ietf-softwire-encaps-safi-05.txt]
|
204
|
-
|
205
|
-
8-63 Unassigned
|
206
|
-
|
207
|
-
64 Tunnel SAFI [Nalawade]
|
208
|
-
|
209
|
-
65 Virtual Private LAN Service (VPLS) [RFC4761]
|
210
|
-
|
211
|
-
66 BGP MDT SAFI [Nalawade]
|
212
|
-
|
213
|
-
67 BGP 4over6 SAFI [Cui]
|
214
|
-
|
215
|
-
68 BGP 6over4 SAFI [Cui]
|
216
|
-
|
217
|
-
69 Layer-1 VPN auto-discovery information [RFC-ietf-l1vpn-bgp-auto-discovery-05.txt]
|
218
|
-
|
219
|
-
70-127 Unassigned
|
220
|
-
|
221
|
-
128 MPLS-labeled VPN address [RFC4364]
|
222
|
-
|
223
|
-
129 Multicast for BGP/MPLS IP Virtual Private [RFC2547]
|
224
|
-
Networks (VPNs)
|
225
|
-
|
226
|
-
130-131 Reserved [RFC4760]
|
227
|
-
|
228
|
-
132 Route Target constrains [RFC4684]
|
229
|
-
|
230
|
-
133 Dissemination of flow specification rules [draft-marques-idr-flow-spec]
|
231
|
-
|
232
|
-
134 Dissemination of flow specification rules [draft-marques-idr-flow-spec]
|
233
|
-
|
234
|
-
135-139 Reserved [RFC4760]
|
235
|
-
|
236
|
-
140 VPN auto-discovery [draft-ietf-l3vpn-bgpvpn-auto]
|
237
|
-
|
238
|
-
141-240 Reserved [RFC4760]
|
239
|
-
|
240
|
-
241-254 Private Use [RFC4760]
|
241
|
-
|
242
|
-
255 Reserved [RFC4760]
|
243
|
-
|
244
|
-
|
245
|
-
References
|
246
|
-
----------
|
247
|
-
[RFC2547] E. Rosen and Y. Rekhter, "BGP/MPLS VPNs", RFC 2547, March 1999.
|
248
|
-
|
249
|
-
[RFC3107] Y. Rekhter and E. Rosen, "Carrying Label Information in
|
250
|
-
BGP-4", RFC 3107, May 2001.
|
251
|
-
|
252
|
-
[RFC4364] E. Rosen and Y. Rekhter, "BGP/MPLS IP VPNs", RFC 4364, February 2006.
|
253
|
-
|
254
|
-
[RFC4684] P. Marques, R. Bonica, L. Fang, L. Martini, R. Raszuk, K. Patel
|
255
|
-
and J. Guichard, "Constrained VPN Route Distribution", RFC 4684,
|
256
|
-
November 2006.
|
257
|
-
|
258
|
-
[RFC4760] T. Bates, R. Chandra, D. Katz and Y. Rekhter, "Multiprotocol
|
259
|
-
Extensions for BGP-4", RFC 4760, January 2007.
|
260
|
-
|
261
|
-
[RFC4761] K. Kompella and Y. Rekhter, "Virtual Private LAN Service
|
262
|
-
(VPLS) Using BGP for Auto-discovery and Signaling", RFC 4761,
|
263
|
-
January 2007.
|
264
|
-
|
265
|
-
[RFC-ietf-l1vpn-bgp-auto-discovery-05.txt]
|
266
|
-
H. Brahim, D. Fedyk, Y. Rekhter, "BGP-based Auto-Discovery for
|
267
|
-
Layer-1 VPNs", RFC XXXX, Month Year.
|
268
|
-
|
269
|
-
[draft-ietf-l3vpn-bgpvpn-auto] Work in progress
|
270
|
-
|
271
|
-
[draft-ietf-pwe3-dynamic-ms-pw] Work in progress
|
272
|
-
|
273
|
-
[draft-marques-idr-flow-spec] Work in progress
|
274
|
-
|
275
|
-
[draft-ietf-l3vpn-2547bis-mcast-bgp] Work in progress
|
276
|
-
|
277
|
-
[RFC-ietf-softwire-encaps-safi-05.txt]
|
278
|
-
P. Mohapatra, E. Rosen, "BGP Encapsulation SAFI and BGP Tunnel
|
279
|
-
Encapsulation Attribute", RFC XXXX, Month Year.
|
280
|
-
|
281
|
-
People
|
282
|
-
------
|
283
|
-
[Bates] Tony Bates, <tbates&cisco.com>, July 2000.
|
284
|
-
|
285
|
-
[Cui] Yong Cui, <cuiyong&tsinghua.edu.cn>, 15 August 2006, 20 September 2006.
|
286
|
-
|
287
|
-
[Nalawade] Gargi Nalawade, <gargi&cisco.com>, January 2004.
|
288
|
-
(draft-nalawade-kapoor-tunnel-safi-01.txt)
|
289
|
-
(draft-nalawade-idr-mdt-safi-00.txt), February 2004.
|
290
|
-
|
291
|
-
(created 2000-07)
|
292
|
-
|
293
|
-
[]
|
294
|
-
|
data/bgp/io.rb
CHANGED
data/bgp/messages/capability.rb
CHANGED
data/bgp/messages/message.rb
CHANGED
data/bgp/messages/open.rb
CHANGED
@@ -87,7 +87,6 @@ class Orf
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
|
90
|
-
#FIXME: Unit-test
|
91
90
|
class Orf_route_refresh < Message
|
92
91
|
|
93
92
|
attr_accessor :orfs
|
@@ -116,11 +115,11 @@ class Orf_route_refresh < Message
|
|
116
115
|
end
|
117
116
|
|
118
117
|
def afi
|
119
|
-
IANA.afi(@afi)
|
118
|
+
IANA.afi?(@afi)
|
120
119
|
end
|
121
120
|
|
122
121
|
def safi
|
123
|
-
IANA.safi(@safi)
|
122
|
+
IANA.safi?(@safi)
|
124
123
|
end
|
125
124
|
|
126
125
|
def afi=(val)
|
@@ -149,9 +148,7 @@ class Orf_route_refresh < Message
|
|
149
148
|
def parse(s)
|
150
149
|
@afi, reserved, @safi, orfs= super(s).unpack('nCCa*')
|
151
150
|
while orfs.size>0
|
152
|
-
#puts "orfs before factory: #{orfs.unpack('H*')}"
|
153
151
|
@orfs << Orf.factory(orfs.is_packed)
|
154
|
-
#puts "orfs after factory: #{orfs.unpack('H*')}"
|
155
152
|
end
|
156
153
|
end
|
157
154
|
|
@@ -162,7 +159,7 @@ class Orf_route_refresh < Message
|
|
162
159
|
def to_s
|
163
160
|
msg = self.encode
|
164
161
|
"ORF Route Refresh (#{ROUTE_REFRESH}), length: #{msg.size}\n" +
|
165
|
-
"AFI #{IANA.afi(@afi)} (#{@afi}), SAFI #{IANA.safi(@safi)} (#{@safi}):\n" +
|
162
|
+
"AFI #{IANA.afi?(@afi)} (#{@afi}), SAFI #{IANA.safi?(@safi)} (#{@safi}):\n" +
|
166
163
|
@orfs.collect { |orf| orf.to_s}.join("\n")
|
167
164
|
end
|
168
165
|
|
@@ -178,4 +175,4 @@ class Orf_route_refresh < Message
|
|
178
175
|
|
179
176
|
end
|
180
177
|
|
181
|
-
end
|
178
|
+
end
|
data/bgp/messages/update.rb
CHANGED
@@ -55,7 +55,7 @@ class BGP::Update < BGP::Message
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
def initialize(*args)
|
58
|
+
def initialize(*args, &block)
|
59
59
|
@nlri, @path_attribute, @withdrawn=nil,nil,nil
|
60
60
|
@session_info = Info.new
|
61
61
|
if args[0].is_a?(String) and args[0].is_packed?
|
@@ -70,6 +70,11 @@ class BGP::Update < BGP::Message
|
|
70
70
|
@msg_type=UPDATE
|
71
71
|
set(*args)
|
72
72
|
end
|
73
|
+
if block
|
74
|
+
@path_attribute ||= Path_attribute.new
|
75
|
+
@nlri ||= Nlri.new
|
76
|
+
instance_eval(&block)
|
77
|
+
end
|
73
78
|
end
|
74
79
|
|
75
80
|
def set(*args)
|
@@ -80,8 +85,6 @@ class BGP::Update < BGP::Message
|
|
80
85
|
self.path_attribute = arg
|
81
86
|
elsif arg.is_a?(Nlri)
|
82
87
|
self.nlri = arg
|
83
|
-
elsif arg.is_a?(Ext_Nlri)
|
84
|
-
self.nlri = arg
|
85
88
|
end
|
86
89
|
}
|
87
90
|
end
|
@@ -155,8 +158,6 @@ class BGP::Update < BGP::Message
|
|
155
158
|
p e
|
156
159
|
raise
|
157
160
|
end
|
158
|
-
elsif val.is_a?(Ext_Nlri)
|
159
|
-
@nlri = val
|
160
161
|
elsif val.is_a?(Nlri)
|
161
162
|
val.to_s.split.each { |n| self << n }
|
162
163
|
else
|
@@ -192,10 +193,12 @@ class BGP::Update < BGP::Message
|
|
192
193
|
end
|
193
194
|
end
|
194
195
|
|
196
|
+
private
|
197
|
+
|
195
198
|
def encoded_nlri
|
196
199
|
@nlri.encode if @nlri
|
197
200
|
end
|
198
201
|
|
199
202
|
end
|
200
203
|
|
201
|
-
load "../../test/messages/#{ File.basename($0.gsub(/.rb/,'_test.rb'))}" if __FILE__ == $0
|
204
|
+
load "../../test/unit/messages/#{ File.basename($0.gsub(/.rb/,'_test.rb'))}" if __FILE__ == $0
|
data/bgp/misc/live_feed.rb
CHANGED
@@ -48,7 +48,7 @@ module BGP
|
|
48
48
|
return false unless speaker and peer
|
49
49
|
case sr
|
50
50
|
when :recv, 'recv'
|
51
|
-
speaker.has?(:recv, afi, safi) && peer.has?(:send, afi, safi)
|
51
|
+
speaker.has?(:recv, afi, safi) && peer.has?(:send, afi, safi)
|
52
52
|
when :send, 'send'
|
53
53
|
speaker.has?(:send, afi, safi) && peer.has?(:recv, afi, safi)
|
54
54
|
else
|
@@ -66,14 +66,14 @@ module BGP
|
|
66
66
|
def method_missing(name, *args, &block)
|
67
67
|
if (/^(send|recv)_(ipv4|ipv6|inet|inet6)_(.+)\?$/ =~ name.to_s)
|
68
68
|
case $2
|
69
|
-
when 'ipv4', 'inet' ; afi = IANA.afi?(:
|
70
|
-
when 'ipv6', 'inet6' ; afi = IANA.afi?(:
|
69
|
+
when 'ipv4', 'inet' ; afi = IANA.afi?(:ipv4)
|
70
|
+
when 'ipv6', 'inet6' ; afi = IANA.afi?(:ipv6)
|
71
71
|
else
|
72
72
|
super
|
73
73
|
end
|
74
74
|
case $3
|
75
|
-
when 'unicast' ; safi = IANA.safi?(:
|
76
|
-
when 'multicast' ; safi = IANA.safi?(:
|
75
|
+
when 'unicast' ; safi = IANA.safi?(:unicast)
|
76
|
+
when 'multicast' ; safi = IANA.safi?(:multicast)
|
77
77
|
when 'mpls_vpn_unicast' ; safi = IANA.safi?(:mpls_vpn_unicast)
|
78
78
|
when 'mpls_vpn_multicast' ; safi = IANA.safi?(:mpls_vpn_multicast)
|
79
79
|
else
|
@@ -85,16 +85,17 @@ module BGP
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
private
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
def def_method(name, action, afi, safi)
|
91
|
+
return if respond_to? :name
|
92
|
+
self.class.instance_eval do
|
93
|
+
define_method("#{name}") do
|
94
|
+
path_id? action, afi, safi
|
95
|
+
end
|
94
96
|
end
|
97
|
+
__send__ name
|
95
98
|
end
|
96
|
-
__send__ name
|
97
|
-
end
|
98
99
|
|
99
100
|
end
|
100
101
|
|
@@ -122,4 +123,4 @@ module BGP
|
|
122
123
|
|
123
124
|
end
|
124
125
|
|
125
|
-
load "../../test/neighbor/#{ File.basename($0.gsub(/.rb/,'_test.rb'))}" if __FILE__ == $0
|
126
|
+
load "../../test/unit/neighbor/#{ File.basename($0.gsub(/.rb/,'_test.rb'))}" if __FILE__ == $0
|
data/bgp/neighbor/neighbor.rb
CHANGED
@@ -27,7 +27,6 @@ require 'bgp/io'
|
|
27
27
|
require 'bgp/neighbor/add_path_cap'
|
28
28
|
|
29
29
|
module BGP
|
30
|
-
|
31
30
|
class Neighbor
|
32
31
|
include Observable
|
33
32
|
|
@@ -46,12 +45,7 @@ module BGP
|
|
46
45
|
def initialize(*args)
|
47
46
|
@opt_parms = []
|
48
47
|
if args.size==1 and args[0].is_a?(Hash)
|
49
|
-
|
50
|
-
@my_as = args[0][:my_as] if args[0][:my_as]
|
51
|
-
@holdtime = args[0][:holdtime] if args[0][:holdtime]
|
52
|
-
@id = args[0][:id] if args[0][:id]
|
53
|
-
@remote_addr = args[0][:remote_addr] if args[0][:remote_addr]
|
54
|
-
@local_addr = args[0][:local_addr] if args[0][:local_addr]
|
48
|
+
set args[0]
|
55
49
|
else
|
56
50
|
@version, @my_as, @holdtime, @id, @remote_addr, @local_addr = args
|
57
51
|
end
|
@@ -63,22 +57,20 @@ module BGP
|
|
63
57
|
event_dispatch
|
64
58
|
end
|
65
59
|
|
60
|
+
def set(h)
|
61
|
+
[:version, :my_as, :holdtime, :id, :remote_addr, :local_addr].each do |name|
|
62
|
+
instance_variable_set("@#{name}", h[name]) if h.has_key?(name)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
66
|
[:Idle, :Established, :OpenRecv, :OpenConfirm, :Active, :OpenSent].each do |state|
|
67
67
|
define_method("is_#{state.to_s.downcase}?") do
|
68
68
|
@state == state
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
# FIXME:
|
73
|
-
# neighbor.add_capability
|
74
|
-
# neighbor.remove_capability
|
75
|
-
# neighbor.capability :as4_byte | :as4 | :as4byte
|
76
|
-
# neighbor.capability :route_refresh, :rr
|
77
|
-
# neighbor.capability :route_refresh, 128
|
78
|
-
# neighbor.capability :mbgp, :ipv4, :unicast
|
79
|
-
# neighbor.capability :mbgp, :ipv4, :multicast
|
80
|
-
|
81
72
|
def capability(*args)
|
73
|
+
|
82
74
|
@opt_parms << if args[0].is_a?(Symbol)
|
83
75
|
case args[0]
|
84
76
|
when :route_refresh, :rr
|
@@ -99,6 +91,25 @@ module BGP
|
|
99
91
|
end
|
100
92
|
end
|
101
93
|
alias :add_cap :capability
|
94
|
+
|
95
|
+
def method_missing(name, *args, &block)
|
96
|
+
if name.to_s =~ /^(capability|add_capability)_(.+)$/
|
97
|
+
r = $2.dup
|
98
|
+
@opt_parms << if r =~ /mbgp_(.+)/
|
99
|
+
OPT_PARM::CAP::Mbgp.send $1
|
100
|
+
elsif r =~ /(rr|route_refresh)/
|
101
|
+
OPT_PARM::CAP::Route_refresh.new( *args)
|
102
|
+
elsif r =~ /(4byte_as|as4byte|four_(byte|octet)_as)/
|
103
|
+
OPT_PARM::CAP::As4.new(@my_as)
|
104
|
+
elsif r =~ /(gr|graceful_restart)/
|
105
|
+
OPT_PARM::CAP::Graceful_restart.new( *args)
|
106
|
+
else
|
107
|
+
super
|
108
|
+
end
|
109
|
+
else
|
110
|
+
super
|
111
|
+
end
|
112
|
+
end
|
102
113
|
|
103
114
|
def state
|
104
115
|
"#{@state}"
|
@@ -110,7 +121,7 @@ module BGP
|
|
110
121
|
@restart_thread = Thread.new do
|
111
122
|
Thread.current['name']='restart'
|
112
123
|
loop do
|
113
|
-
|
124
|
+
start if @state == :Idle
|
114
125
|
sleep(4)
|
115
126
|
end
|
116
127
|
end
|
@@ -213,6 +224,7 @@ module BGP
|
|
213
224
|
def stop
|
214
225
|
@socket.close if defined?(@socket) and not @socket.closed?
|
215
226
|
clean
|
227
|
+
@open=nil
|
216
228
|
new_state :Idle, "Disable"
|
217
229
|
end
|
218
230
|
|
@@ -334,4 +346,4 @@ module BGP
|
|
334
346
|
|
335
347
|
end
|
336
348
|
|
337
|
-
load "../../test/neighbor/#{ File.basename($0.gsub(/.rb/,'_test.rb'))}" if __FILE__ == $0
|
349
|
+
load "../../test/unit/neighbor/#{ File.basename($0.gsub(/.rb/,'_test.rb'))}" if __FILE__ == $0
|