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
@@ -0,0 +1,80 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2011 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of BGP4R.
|
8
|
+
#
|
9
|
+
# BGP4R is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# BGP4R is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with BGP4R. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'bgp/nlris/nsap'
|
24
|
+
|
25
|
+
require 'test/unit'
|
26
|
+
|
27
|
+
class Nsap_Test < Test::Unit::TestCase
|
28
|
+
include BGP
|
29
|
+
def test_new
|
30
|
+
nsap = Nsap.new
|
31
|
+
assert_equal( '49.0000.0000.0000.0000.0000.0000.0000.0000.0000.00', nsap.to_s)
|
32
|
+
assert_equal('4900000000000000000000000000000000000000', nsap.to_shex)
|
33
|
+
|
34
|
+
nsap = Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.bb/160')
|
35
|
+
assert_equal('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.bb', nsap.to_s)
|
36
|
+
assert_equal('49010203040506060809101112131415161718bb', nsap.to_shex)
|
37
|
+
|
38
|
+
nsap = Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00/152')
|
39
|
+
assert_equal('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00', nsap.to_s)
|
40
|
+
assert_equal('49010203040506060809101112131415161718', nsap.to_shex)
|
41
|
+
|
42
|
+
nsap = Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00/96')
|
43
|
+
assert_equal('49.0102.0304.0506.0608.0910.1100.0000.0000.0000.00', nsap.to_s)
|
44
|
+
nsap = Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00/48')
|
45
|
+
assert_equal('49.0102.0304.0500.0000.0000.0000.0000.0000.0000.00', nsap.to_s)
|
46
|
+
nsap = Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00/24')
|
47
|
+
assert_equal('490102', nsap.to_shex)
|
48
|
+
assert_equal('49.0102.0000.0000.0000.0000.0000.0000.0000.0000.00', nsap.to_s)
|
49
|
+
nsap = Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00/16')
|
50
|
+
assert_equal('49.0100.0000.0000.0000.0000.0000.0000.0000.0000.00', nsap.to_s)
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_new_ntoh
|
55
|
+
nsap = Nsap.new_ntoh(Nsap.new.encode)
|
56
|
+
assert_equal('49.0000.0000.0000.0000.0000.0000.0000.0000.0000.00', nsap.to_s)
|
57
|
+
assert_equal('4900000000000000000000000000000000000000', nsap.to_shex)
|
58
|
+
nsap = Nsap.new_ntoh(Nsap.new('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.bb').encode)
|
59
|
+
assert_equal('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.bb', nsap.to_s)
|
60
|
+
assert_equal('49010203040506060809101112131415161718bb', nsap.to_shex)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_new_nsap
|
64
|
+
nsap = Nsap.new_nsap('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.ff')
|
65
|
+
assert_equal('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00', nsap.to_s)
|
66
|
+
assert_equal(152, nsap.mlen)
|
67
|
+
nsap = Nsap.new_nsap('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.ff/160')
|
68
|
+
assert_equal('49.0102.0304.0506.0608.0910.1112.1314.1516.1718.00', nsap.to_s)
|
69
|
+
assert_equal(152, nsap.mlen)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_iso_ip_mapped
|
73
|
+
addr = Iso_ip_mapped.new('10.0.0.1')
|
74
|
+
assert_equal('470006010a00000100', addr.to_shex)
|
75
|
+
assert_equal('10.0.0.1', addr.to_s)
|
76
|
+
addr = Iso_ip_mapped.new('2011:13:11::64')
|
77
|
+
assert_equal('3500002011001300110000000000000000006400', addr.to_shex)
|
78
|
+
assert_equal('2011:13:11::64', addr.to_s)
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,136 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008, 2009 Jean-Michel Esnault.
|
3
|
+
# All rights reserved.
|
4
|
+
# See LICENSE.txt for permissions.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# This file is part of BGP4R.
|
8
|
+
#
|
9
|
+
# BGP4R is free software: you can redistribute it and/or modify
|
10
|
+
# it under the terms of the GNU General Public License as published by
|
11
|
+
# the Free Software Foundation, either version 3 of the License, or
|
12
|
+
# (at your option) any later version.
|
13
|
+
#
|
14
|
+
# BGP4R is distributed in the hope that it will be useful,
|
15
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
+
# GNU General Public License for more details.
|
18
|
+
#
|
19
|
+
# You should have received a copy of the GNU General Public License
|
20
|
+
# along with BGP4R. If not, see <http://www.gnu.org/licenses/>.
|
21
|
+
#++
|
22
|
+
|
23
|
+
require 'test/unit'
|
24
|
+
require 'bgp/nlris/prefix'
|
25
|
+
|
26
|
+
class Prefix_Test < Test::Unit::TestCase
|
27
|
+
include BGP
|
28
|
+
def test_inet
|
29
|
+
pfx = Prefix.new('10.0.0.0')
|
30
|
+
assert_equal('10.0.0.0/32', pfx.to_s)
|
31
|
+
assert_equal('200a000000', pfx.to_shex)
|
32
|
+
pfx = Prefix.new('10.1.1.1/16')
|
33
|
+
assert_equal('10.1.0.0/16', pfx.to_s)
|
34
|
+
assert_equal('100a01', pfx.to_shex)
|
35
|
+
pfx = Prefix.new('10.255.255.255/17')
|
36
|
+
assert_equal(17, pfx.mlen)
|
37
|
+
assert_equal('10.255.128.0/17', pfx.to_s)
|
38
|
+
assert_equal('110aff80', pfx.to_shex)
|
39
|
+
assert pfx.ipv4?
|
40
|
+
assert ! pfx.ipv6?
|
41
|
+
assert ! pfx.iso?
|
42
|
+
assert_equal(1, pfx.afi)
|
43
|
+
assert ! pfx.extended?
|
44
|
+
assert_equal('IPv4=10.255.128.0/17', pfx.to_s_with_afi)
|
45
|
+
end
|
46
|
+
def test_extended
|
47
|
+
pfx = Prefix.new(100, '10.0.0.0')
|
48
|
+
assert pfx.extended?
|
49
|
+
assert_equal('00000064200a000000', pfx.to_shex)
|
50
|
+
assert_equal('ID=100, 10.0.0.0/32', pfx.to_s)
|
51
|
+
pfx1 = Prefix.new_ntop_extended(pfx.encode)
|
52
|
+
assert_equal(pfx.to_shex, pfx.to_shex)
|
53
|
+
pfx = Prefix.new(100, '2011:13:11::0/64')
|
54
|
+
assert pfx.extended?
|
55
|
+
assert_equal('ID=100, 2011:13:11::/64', pfx.to_s)
|
56
|
+
assert_equal('00000064402011001300110000', pfx.to_shex)
|
57
|
+
assert_equal('ID=100, IPv6=2011:13:11::/64', pfx.to_s_with_afi)
|
58
|
+
|
59
|
+
end
|
60
|
+
def test_inet6
|
61
|
+
pfx = Prefix.new('2011:13:11::0/64')
|
62
|
+
assert_equal('2011:13:11::/64', pfx.to_s)
|
63
|
+
assert_equal(64, pfx.mlen)
|
64
|
+
assert_equal('402011001300110000', pfx.to_shex)
|
65
|
+
pfx = Prefix.new('2011:13:11::0')
|
66
|
+
assert_equal('2011:13:11::/128', pfx.to_s)
|
67
|
+
assert_equal('8020110013001100000000000000000000', pfx.to_shex)
|
68
|
+
assert ! pfx.ipv4?
|
69
|
+
assert pfx.ipv6?
|
70
|
+
assert ! pfx.iso?
|
71
|
+
assert_equal(2, pfx.afi)
|
72
|
+
assert_equal('IPv6=2011:13:11::/128', pfx.to_s_with_afi)
|
73
|
+
end
|
74
|
+
def test_nsap
|
75
|
+
pfx = Prefix.new('49.0001.0002.0003')
|
76
|
+
assert_equal('9849000100020003000000000000000000000000', pfx.to_shex )
|
77
|
+
assert_equal('49.0001.0002.0003.0000.0000.0000.0000.0000.0000.00/152', pfx.to_s)
|
78
|
+
|
79
|
+
pfx = Prefix.new('49.0001.0002.0003/32')
|
80
|
+
assert_equal('2049000100', pfx.to_shex )
|
81
|
+
assert_equal('49.0001.0000.0000.0000.0000.0000.0000.0000.0000.00/32', pfx.to_s)
|
82
|
+
|
83
|
+
pfx = Prefix.new('49.0001.0002.0003/48')
|
84
|
+
assert_equal('30490001000200', pfx.to_shex )
|
85
|
+
assert_equal('49.0001.0002.0000.0000.0000.0000.0000.0000.0000.00/48', pfx.to_s)
|
86
|
+
|
87
|
+
pfx = Prefix.new('49.0001.0002.0003/55')
|
88
|
+
assert_equal('3749000100020002', pfx.to_shex )
|
89
|
+
assert_equal('49.0001.0002.0002.0000.0000.0000.0000.0000.0000.00/55', pfx.to_s)
|
90
|
+
|
91
|
+
pfx = Prefix.new('49.0001.0002.0003/56')
|
92
|
+
assert_equal('3849000100020003', pfx.to_shex )
|
93
|
+
assert_equal('49.0001.0002.0003.0000.0000.0000.0000.0000.0000.00/56', pfx.to_s)
|
94
|
+
|
95
|
+
assert ! pfx.ipv4?
|
96
|
+
assert ! pfx.ipv6?
|
97
|
+
assert pfx.iso?
|
98
|
+
assert_equal(3, pfx.afi)
|
99
|
+
assert_equal('NSAP=49.0001.0002.0003.0000.0000.0000.0000.0000.0000.00/56', pfx.to_s_with_afi)
|
100
|
+
end
|
101
|
+
def test_new_ntop_inet
|
102
|
+
s = '110aff80'
|
103
|
+
pfx = Prefix.new_ntop([s].pack('H*'))
|
104
|
+
assert_equal(s, pfx.to_shex)
|
105
|
+
assert_equal('10.255.128.0/17', pfx.to_s)
|
106
|
+
end
|
107
|
+
def test_new_ntop_inet6
|
108
|
+
s = '402011001300110000'
|
109
|
+
pfx = Prefix.new_ntop([s].pack('H*'),:ipv6)
|
110
|
+
assert_equal(s, pfx.to_shex)
|
111
|
+
assert_equal('2011:13:11::/64', pfx.to_s)
|
112
|
+
s = '402011001300110000'
|
113
|
+
pfx = Prefix.new_ntop([s].pack('H*'),2)
|
114
|
+
assert_equal(s, pfx.to_shex)
|
115
|
+
assert_equal('2011:13:11::/64', pfx.to_s)
|
116
|
+
assert_equal(2, pfx.afi)
|
117
|
+
end
|
118
|
+
def test_new_ntop_inet_extended
|
119
|
+
s = '00000064402011001300110000'
|
120
|
+
pfx = Prefix.new_ntop_extended([s].pack('H*'),2)
|
121
|
+
assert_equal(s, pfx.to_shex)
|
122
|
+
assert_equal('ID=100, 2011:13:11::/64', pfx.to_s)
|
123
|
+
end
|
124
|
+
def test_new_ntop_nsap
|
125
|
+
s = '30490001000200'
|
126
|
+
pfx = Prefix.new_ntop([s].pack('H*'),3)
|
127
|
+
assert_equal(s, pfx.to_shex)
|
128
|
+
assert_equal('49.0001.0002.0000.0000.0000.0000.0000.0000.0000.00/48', pfx.to_s)
|
129
|
+
end
|
130
|
+
def test_new_ntop_nsap_extended
|
131
|
+
s = '000000652049000100'
|
132
|
+
pfx = Prefix.new_ntop_extended([s].pack('H*'),:nsap)
|
133
|
+
assert_equal(s, pfx.to_shex)
|
134
|
+
assert_equal('ID=101, 49.0001.0000.0000.0000.0000.0000.0000.0000.0000.00/32', pfx.to_s)
|
135
|
+
end
|
136
|
+
end
|
@@ -38,11 +38,6 @@ class Capability_Test < Test::Unit::TestCase
|
|
38
38
|
cap = Capability.factory([s].pack('H*'))
|
39
39
|
assert_instance_of(Graceful_restart, cap)
|
40
40
|
end
|
41
|
-
def test_factory_add_path
|
42
|
-
s = '020e450c000101010002800200020103'
|
43
|
-
cap = Capability.factory([s].pack('H*'))
|
44
|
-
assert_instance_of(Add_path, cap)
|
45
|
-
end
|
46
41
|
def test_factory_as4
|
47
42
|
s = '0206410400000064'
|
48
43
|
cap = Capability.factory([s].pack('H*'))
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require "bgp/optional_parameters/graceful_restart"
|
3
|
+
require 'bgp/common'
|
4
|
+
require 'bgp/iana'
|
5
|
+
|
6
|
+
class TestBgpOptionalParametersGracefulCapRestart < Test::Unit::TestCase
|
7
|
+
include BGP::OPT_PARM::CAP
|
8
|
+
def test_new
|
9
|
+
gr = Graceful_restart.new 0, 120
|
10
|
+
gr.add( 1, 1, 0x80)
|
11
|
+
assert_equal '02084006007800010180', gr.to_shex
|
12
|
+
gr2 = Graceful_restart.new(gr.encode)
|
13
|
+
assert_equal gr.to_shex, gr2.to_shex
|
14
|
+
gr.add( 1, 2, 0x80)
|
15
|
+
assert_equal '020c400a00780001018000010280', gr.to_shex
|
16
|
+
gr2 = Graceful_restart.new 0, 120
|
17
|
+
gr2.add(:ipv4, :unicast)
|
18
|
+
assert_equal '02084006007800010100', gr2.to_shex
|
19
|
+
gr2.add( :ipv4, :multicast)
|
20
|
+
assert_equal '020c400a00780001018000010280', gr.to_shex
|
21
|
+
assert_match(/Restart Time 120s/, gr2.to_s)
|
22
|
+
assert_match(/AFI IPv4 \(1\), SAFI Unicast \(1\)/, gr2.to_s)
|
23
|
+
assert_match(/AFI IPv4 \(1\), SAFI Multicast \(2\)/, gr2.to_s)
|
24
|
+
assert_match(/Restart Time 120s/, gr2.to_s)
|
25
|
+
end
|
26
|
+
def test_add_afi_safi_with_af_state
|
27
|
+
gr = Graceful_restart.new 0, 120
|
28
|
+
gr.ipv4_unicast_forwarding_state_preserved
|
29
|
+
gr.ipv4_unicast_forwarding_state_not_preserved
|
30
|
+
gr.ipv4_multicast_forwarding_state_preserved
|
31
|
+
gr.ipv4_multicast_forwarding_state_not_preserved
|
32
|
+
gr.nsap_unicast_forwarding_state_preserved
|
33
|
+
gr.nsap_mpls_vpn_unicast_forwarding_state_not_preserved
|
34
|
+
gr.ipv6_mpls_vpn_multicast_forwarding_state_not_preserved
|
35
|
+
gr.ipv6_label_nlri_forwarding_state_not_preserved
|
36
|
+
assert_match(/Restart Time 120s/, gr.to_s)
|
37
|
+
assert_match(/AFI IPv4 \(1\), SAFI Unicast \(1\)/, gr.to_s)
|
38
|
+
assert_match(/AFI IPv4 \(1\), SAFI Multicast \(2\)/, gr.to_s)
|
39
|
+
assert_match(/Restart Time 120s/, gr.to_s)
|
40
|
+
end
|
41
|
+
end
|
@@ -32,4 +32,24 @@ class Mbgp_cap_Test < Test::Unit::TestCase
|
|
32
32
|
assert_equal(mbgp2.encode, mbgp3.encode)
|
33
33
|
assert_equal "Option Capabilities Advertisement (2): [0206010400010001]\n Multiprotocol Extensions (1), length: 4\n AFI IPv4 (1), SAFI Unicast (1)", mbgp2.to_s
|
34
34
|
end
|
35
|
+
def test_mbgp_capabilities
|
36
|
+
assert_equal(1,Mbgp.ipv4_unicast.afi)
|
37
|
+
assert_equal(1,Mbgp.ipv4_unicast.safi)
|
38
|
+
assert_equal(2,Mbgp.ipv6_unicast.afi)
|
39
|
+
assert_equal(1,Mbgp.ipv6_unicast.safi)
|
40
|
+
assert_equal(3,Mbgp.nsap_unicast.afi)
|
41
|
+
assert_equal(1,Mbgp.nsap_unicast.safi)
|
42
|
+
assert_equal(1,Mbgp.ipv4_multicast.afi)
|
43
|
+
assert_equal(2,Mbgp.ipv4_multicast.safi)
|
44
|
+
assert_equal(2,Mbgp.ipv6_multicast.afi)
|
45
|
+
assert_equal(2,Mbgp.ipv6_multicast.safi)
|
46
|
+
assert_equal(3,Mbgp.nsap_multicast.afi)
|
47
|
+
assert_equal(2,Mbgp.nsap_multicast.safi)
|
48
|
+
assert_equal(1,Mbgp.ipv4_mpls_vpn_unicast.afi)
|
49
|
+
assert_equal(2,Mbgp.ipv6_mpls_vpn_multicast.afi)
|
50
|
+
assert_equal(3,Mbgp.nsap_mpls_vpn_unicast.afi)
|
51
|
+
assert_equal(128,Mbgp.ipv4_mpls_vpn_unicast.safi)
|
52
|
+
assert_equal(129,Mbgp.ipv6_mpls_vpn_multicast.safi)
|
53
|
+
assert_equal(128,Mbgp.nsap_mpls_vpn_unicast.safi)
|
54
|
+
end
|
35
55
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
__END__
|
2
|
+
|
3
|
+
3. AIGP Attribute
|
4
|
+
|
5
|
+
The AIGP Attribute is an optional non-transitive BGP Path Attribute.
|
6
|
+
The attribute type code for the AIGP Attribute is 26.
|
7
|
+
|
8
|
+
The value field of the AIGP Attribute is defined here to be a set of
|
9
|
+
elements encoded as "Type/Length/Value" (i.e., a set of "TLVs").
|
10
|
+
Each such TLV is encoded as shown in Figure 1.
|
11
|
+
|
12
|
+
|
13
|
+
0 1 2 3
|
14
|
+
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
|
15
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
16
|
+
| Type | Length | |
|
17
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
18
|
+
~ ~
|
19
|
+
| Value |
|
20
|
+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+..........................
|
21
|
+
|
22
|
+
|
23
|
+
AIGP TLV
|
24
|
+
Figure 1
|
25
|
+
|
26
|
+
|
27
|
+
- Type: A single octet encoding the TLV Type. Only type 1, "AIGP
|
28
|
+
TLV", is defined in this document.
|
29
|
+
|
30
|
+
- Length: Two octets encoding the length in octets of the TLV,
|
31
|
+
including the type and length fields. The length is encoded as an
|
32
|
+
unsigned binary integer. (Note that the minimum length is 3,
|
33
|
+
indicating that no value field is present.)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
Mohapatra, et al. [Page 5]
|
40
|
+
|
41
|
+
Internet Draft draft-ietf-idr-aigp-06.txt June 2011
|
42
|
+
|
43
|
+
|
44
|
+
- A value field containing zero or more octets.
|
45
|
+
|
46
|
+
This document defines only a single such TLV, the "AIGP TLV". The
|
47
|
+
AIGP TLV is encoded as follows:
|
48
|
+
|
49
|
+
- Type: 1
|
50
|
+
|
51
|
+
- Length: 11
|
52
|
+
|
53
|
+
- Accumulated IGP Metric.
|
54
|
+
|
55
|
+
The value field of the AIGP TLV is always 8 bytes long. IGP
|
56
|
+
metrics are frequently expressed as 4-octet values, and this
|
57
|
+
ensures that the AIGP attribute can be used to hold the sum of an
|
58
|
+
arbitrary number of 4-octet values.
|
59
|
+
|
@@ -49,6 +49,7 @@ class Extended_communitiesTest < Test::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
def test_sort
|
51
51
|
ec = Extended_communities.new
|
52
|
+
ec.add(Link_bandwidth.new(999_999_999))
|
52
53
|
ec.add(Route_target.new('10.0.1.2',10))
|
53
54
|
ec.add(Ospf_domain_id.new('9.1.0.1'))
|
54
55
|
ec.add(Route_target.new('11.0.1.1',10))
|
@@ -67,9 +68,11 @@ class Extended_communitiesTest < Test::Unit::TestCase
|
|
67
68
|
assert_equal("Ospf domain id: 9.1.0.1:0",ec.sort.communities[6].to_s)
|
68
69
|
assert_equal("Ospf domain id: 20.0.0.1:0",ec.sort.communities[7].to_s)
|
69
70
|
assert_equal("Ospf router id: 10.0.0.1:0",ec.sort.communities[8].to_s)
|
71
|
+
assert_equal("Link bandwidth: 1000000000.0",ec.sort.communities[9].to_s)
|
70
72
|
end
|
71
73
|
def test_sort!
|
72
74
|
ec = Extended_communities.new
|
75
|
+
ec.add(Link_bandwidth.new(999_999_999))
|
73
76
|
ec.add(Route_target.new('10.0.1.2',10))
|
74
77
|
ec.add(Ospf_domain_id.new('9.1.0.1'))
|
75
78
|
ec.add(Route_target.new('11.0.1.1',10))
|
@@ -89,6 +92,7 @@ class Extended_communitiesTest < Test::Unit::TestCase
|
|
89
92
|
assert_equal("Ospf domain id: 9.1.0.1:0",ec.communities[6].to_s)
|
90
93
|
assert_equal("Ospf domain id: 20.0.0.1:0",ec.communities[7].to_s)
|
91
94
|
assert_equal("Ospf router id: 10.0.0.1:0",ec.communities[8].to_s)
|
95
|
+
assert_equal("Link bandwidth: 1000000000.0",ec.communities[9].to_s)
|
92
96
|
ec1 = Extended_communities.new(ec)
|
93
97
|
assert_equal(ec.encode, ec1.encode)
|
94
98
|
end
|
@@ -89,5 +89,14 @@ class Extended_community_Test < Test::Unit::TestCase
|
|
89
89
|
assert_equal("Bgp data collect: 100:100",Bgp_data_collect.new(100,100).to_s)
|
90
90
|
assert_equal("Bgp data collect: 100:100", Bgp_data_collect.new(['0008006400000064'].pack('H*')).to_s)
|
91
91
|
end
|
92
|
+
|
93
|
+
def test_link_bandwidth
|
94
|
+
assert_equal('04040000461c4000', Link_bandwidth.new(10_000).to_shex)
|
95
|
+
assert_equal('Link bandwidth: 10000.0', Link_bandwidth.new(10_000).to_s)
|
96
|
+
assert_equal('Link bandwidth: 10000.0', Link_bandwidth.new(['04040000461c4000'].pack('H*')).to_s)
|
97
|
+
assert_equal('040400004cbebc20', Link_bandwidth.new(99_999_999).to_shex)
|
98
|
+
assert_equal('Link bandwidth: 100000000.0', Link_bandwidth.new(99_999_999).to_s)
|
99
|
+
assert_equal('Link bandwidth: 100000000.0', Link_bandwidth.new(['040400004cbebc20'].pack('H*')).to_s)
|
100
|
+
end
|
92
101
|
|
93
102
|
end
|