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
@@ -1,24 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "bgp/optional_parameters/graceful_restart"
|
3
|
-
require 'bgp/common'
|
4
|
-
|
5
|
-
class TestBgpOptionalParametersGracefulCapRestart < Test::Unit::TestCase
|
6
|
-
include BGP::OPT_PARM::CAP
|
7
|
-
def test_1
|
8
|
-
|
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
|
-
|
17
|
-
gr2 = Graceful_restart.new 0, 120
|
18
|
-
gr2.add(:ipv4, :unicast, 1)
|
19
|
-
assert_equal '02084006007800010101', gr2.to_shex
|
20
|
-
gr2.add( :ipv4, :multicast, 1)
|
21
|
-
assert_equal '020c400a00780001018000010280', gr.to_shex
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
@@ -1,305 +0,0 @@
|
|
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 'bgp4r'
|
24
|
-
require 'test/unit'
|
25
|
-
|
26
|
-
class Mp_reach_Test < Test::Unit::TestCase
|
27
|
-
include BGP
|
28
|
-
def test_1
|
29
|
-
s = '800e30000202102009000900190000000000000000000100402009000100000000402009000200000000402009000300000000'
|
30
|
-
sbin = [s].pack('H*')
|
31
|
-
mpr = Mp_reach.new(sbin)
|
32
|
-
assert_equal("\n AFI IPv6 (2), SAFI Multicast (2)\n nexthop: 2009:9:19::1\n 2009:1::/64\n 2009:2::/64\n 2009:3::/64", mpr.mp_reach)
|
33
|
-
assert_equal(2, mpr.afi)
|
34
|
-
assert_equal(2, mpr.safi)
|
35
|
-
assert_equal(s, mpr.to_shex)
|
36
|
-
end
|
37
|
-
def test_2
|
38
|
-
s = "800e2500020120200900090019000000000000000000012009000900190000000000000000000200"
|
39
|
-
sbin = [s].pack('H*')
|
40
|
-
mpr = Mp_reach.new(sbin)
|
41
|
-
assert_equal("\n AFI IPv6 (2), SAFI Unicast (1)\n nexthop: 2009:9:19::1, 2009:9:19::2", mpr.mp_reach)
|
42
|
-
assert_equal(2, mpr.afi)
|
43
|
-
assert_equal(1, mpr.safi)
|
44
|
-
assert_equal(s, mpr.to_shex)
|
45
|
-
end
|
46
|
-
def test_3
|
47
|
-
s = "800e0d000102080a0000010a00000200"
|
48
|
-
sbin = [s].pack('H*')
|
49
|
-
mpr = Mp_reach.new(sbin)
|
50
|
-
assert_equal("\n AFI IPv4 (1), SAFI Multicast (2)\n nexthop: 10.0.0.1, 10.0.0.2", mpr.mp_reach)
|
51
|
-
assert_equal(1, mpr.afi)
|
52
|
-
assert_equal(2, mpr.safi)
|
53
|
-
assert_equal(s, mpr.to_shex)
|
54
|
-
end
|
55
|
-
def test_4
|
56
|
-
s = "800e11000102040a0000010018c0a80118c0a802"
|
57
|
-
sbin = [s].pack('H*')
|
58
|
-
mpr = Mp_reach.new(sbin)
|
59
|
-
assert_equal("\n AFI IPv4 (1), SAFI Multicast (2)\n nexthop: 10.0.0.1\n 192.168.1.0/24\n 192.168.2.0/24", mpr.mp_reach)
|
60
|
-
assert_equal(1, mpr.afi)
|
61
|
-
assert_equal(2, mpr.safi)
|
62
|
-
assert_equal(s, mpr.to_shex)
|
63
|
-
end
|
64
|
-
def test_5
|
65
|
-
s = "800e39000204102009000900190000000000000000000100580006512009000100000000580006612009000200000000580006712009000300000000"
|
66
|
-
sbin = [s].pack('H*')
|
67
|
-
mpr = Mp_reach.new(sbin)
|
68
|
-
assert_equal("\n AFI IPv6 (2), SAFI Labeled NLRI (4)\n nexthop: 2009:9:19::1\n Label Stack=101 (bottom) 2009:1::/64\n Label Stack=102 (bottom) 2009:2::/64\n Label Stack=103 (bottom) 2009:3::/64", mpr.mp_reach)
|
69
|
-
assert_equal(2, mpr.afi)
|
70
|
-
assert_equal(4, mpr.safi)
|
71
|
-
assert_equal(s, mpr.to_shex)
|
72
|
-
#puts mpr
|
73
|
-
end
|
74
|
-
def test_6
|
75
|
-
mpr = Mp_reach.new(:safi=>2, :nexthop=> ['2009:9:19::1/128'], :nlris=> ['2009:1::/64', '2009:2::/64', '2009:3::/64'])
|
76
|
-
assert_equal("\n AFI IPv6 (2), SAFI Multicast (2)\n nexthop: 2009:9:19::1\n 2009:1::/64\n 2009:2::/64\n 2009:3::/64", mpr.mp_reach)
|
77
|
-
assert_equal(mpr.to_shex, Mp_reach.new(mpr.encode).to_shex)
|
78
|
-
mpr = Mp_reach.new(:safi=>1, :nexthop=> ['10.0.0.1','10.0.0.2'], :nlris=> '192.168.0.0/24')
|
79
|
-
assert_equal("\n AFI IPv4 (1), SAFI Unicast (1)\n nexthop: 10.0.0.1, 10.0.0.2\n 192.168.0.0/24", mpr.mp_reach)
|
80
|
-
assert_equal(mpr.to_shex, Mp_reach.new(mpr.encode).to_shex)
|
81
|
-
mpr = Mp_reach.new(:safi=>4, :nexthop=> ['10.0.0.1','10.0.0.2'], :nlris=> {:prefix=> '192.168.0.0/24', :label=>101} )
|
82
|
-
assert_equal("\n AFI IPv4 (1), SAFI Labeled NLRI (4)\n nexthop: 10.0.0.1, 10.0.0.2\n Label Stack=101 (bottom) 192.168.0.0/24", mpr.mp_reach)
|
83
|
-
assert_equal(mpr.to_shex, Mp_reach.new(mpr.encode).to_shex)
|
84
|
-
mpr = Mp_reach.new(:safi=>128, :nexthop=> ['10.0.0.1','10.0.0.2'], :nlris=> {:rd=> [100,100], :prefix=> '192.168.0.0/24', :label=>101})
|
85
|
-
assert_equal("\n AFI IPv4 (1), SAFI Labeled VPN Unicast (128)\n nexthop: 10.0.0.1, 10.0.0.2\n Label Stack=101 (bottom) RD=100:100, IPv4=192.168.0.0/24", mpr.mp_reach)
|
86
|
-
assert_equal(mpr.to_shex, Mp_reach.new(mpr.encode).to_shex)
|
87
|
-
mpr = Mp_reach.new(:safi=>128, :nexthop=> ['10.0.0.1','10.0.0.2'], :nlris=> {:rd=> Rd.new(100,100), :prefix=> Prefix.new('192.168.0.0/24'), :label=>101})
|
88
|
-
assert_equal("\n AFI IPv4 (1), SAFI Labeled VPN Unicast (128)\n nexthop: 10.0.0.1, 10.0.0.2\n Label Stack=101 (bottom) RD=100:100, IPv4=192.168.0.0/24", mpr.mp_reach)
|
89
|
-
assert_equal(mpr.to_shex, Mp_reach.new(mpr.encode).to_shex)
|
90
|
-
end
|
91
|
-
def test_7
|
92
|
-
mpr = Mp_reach.new(:safi=>2, :nexthop=> '2009:9:19::1/128', :nlris=> [
|
93
|
-
'2009:1::/64', '2009:2::/64', '2009:3::/64', '2009:4::/64', '2009:5::/64', '2009:6::/64'])
|
94
|
-
assert_equal("\n AFI IPv6 (2), SAFI Multicast (2)\n nexthop: 2009:9:19::1\n 2009:1::/64\n 2009:2::/64\n 2009:3::/64\n 2009:4::/64\n 2009:5::/64\n 2009:6::/64", mpr.mp_reach)
|
95
|
-
mpr = Mp_reach.new(:safi=>1, :nexthop=> '10.0.0.1', :nlris=> [
|
96
|
-
'192.168.0.0/24', '192.168.1.0/24', '192.168.2.0/24', '192.168.3.0/24', '192.168.4.0/24', '192.168.5.0/24'])
|
97
|
-
assert_equal("\n AFI IPv4 (1), SAFI Unicast (1)\n nexthop: 10.0.0.1\n 192.168.0.0/24\n 192.168.1.0/24\n 192.168.2.0/24\n 192.168.3.0/24\n 192.168.4.0/24\n 192.168.5.0/24", mpr.mp_reach)
|
98
|
-
end
|
99
|
-
def test_8
|
100
|
-
mpr = Mp_reach.new(:safi=>1, :nexthop=> '10.0.0.1', :nlris=> [
|
101
|
-
'192.168.0.0/24', '192.168.1.0/24', '192.168.2.0/24', '192.168.3.0/24', '192.168.4.0/24', '192.168.5.0/24'])
|
102
|
-
assert_equal(Mp_unreach,mpr.new_unreach.class)
|
103
|
-
mpr2 = Mp_reach.new(mpr)
|
104
|
-
assert_equal(mpr.encode, mpr2.encode)
|
105
|
-
assert_equal(Mp_unreach, Mp_unreach.new(mpr.new_unreach).class)
|
106
|
-
end
|
107
|
-
|
108
|
-
def test_afi_1
|
109
|
-
mpr1 = Mp_reach.new(:safi=>1, :nexthop=> ['10.0.0.1'], :nlris=> '192.168.1.0/24')
|
110
|
-
mpr2 = Mp_reach.new(:safi=>1, :nexthop=> ['10.0.0.1'], :nlris=> '192.168.1.0/24', :path_id=>100)
|
111
|
-
mpr3 = Mp_reach.new(:safi=>2, :nexthop=> ['10.0.0.1'], :nlris=> ['192.168.1.0/24','192.168.2.0/24'])
|
112
|
-
mpr4 = Mp_reach.new(:safi=>2, :nexthop=> ['10.0.0.1'], :nlris=> ['192.168.1.0/24','192.168.2.0/24'], :path_id=>100)
|
113
|
-
mpr5 = Mp_reach.new(:safi=>1, :nexthop=> ['10.0.0.1'], :nlris=> [
|
114
|
-
{:prefix=> '192.168.1.0/24', :path_id=> 100},
|
115
|
-
{:prefix=> '192.168.2.0/24', :path_id=> 101},
|
116
|
-
{:prefix=> '192.168.2.0/24', :path_id=> 102},
|
117
|
-
])
|
118
|
-
|
119
|
-
assert_equal('800e0d000101040a0000010018c0a801', mpr1.to_shex)
|
120
|
-
assert_equal('800e11000101040a000001000000006418c0a801', mpr2.to_shex)
|
121
|
-
assert_equal attr_len(mpr1)+4, attr_len(mpr2)
|
122
|
-
|
123
|
-
assert_equal('800e11000102040a0000010018c0a80118c0a802', mpr3.to_shex)
|
124
|
-
assert_equal('800e19000102040a000001000000006418c0a8010000006418c0a802', mpr4.to_shex)
|
125
|
-
assert_equal attr_len(mpr3)+8, attr_len(mpr4)
|
126
|
-
|
127
|
-
assert_equal('800e21000101040a000001000000006418c0a8010000006518c0a8020000006618c0a802', mpr5.to_shex)
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
def test_afi_1_ntop
|
132
|
-
|
133
|
-
s = '800e11000102040a0000010018c0a80118c0a802'
|
134
|
-
sbin = [s].pack('H*')
|
135
|
-
mpr = Mp_reach.new(sbin, false)
|
136
|
-
assert_match(/^\s+192.168.1.0\/24/, mpr.to_s)
|
137
|
-
assert_match(/^\s+192.168.1.0\/24/, mpr.to_s)
|
138
|
-
|
139
|
-
s = '800e19000102040a000001000000006418c0a8010000006418c0a802'
|
140
|
-
sbin = [s].pack('H*')
|
141
|
-
mpr = Mp_reach.new(sbin, true)
|
142
|
-
assert_match(/^\s+ID=100, 192.168.1.0\/24/, mpr.to_s)
|
143
|
-
assert_match(/^\s+ID=100, 192.168.1.0\/24/, mpr.to_s)
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
def test_afi_2
|
148
|
-
mpr1 = Mp_reach.new(:safi=>1, :nexthop=> ['2011:1:7::1'], :nlris=> '2011:1::/32')
|
149
|
-
mpr2 = Mp_reach.new(:safi=>1, :nexthop=> ['2011:1:7::1'], :nlris=> '2011:1::/32', :path_id=>100)
|
150
|
-
mpr3 = Mp_reach.new(:safi=>2, :nexthop=> ['2011:1:7::1'], :nlris=> ['2011:1::/32','2011:2::/32'])
|
151
|
-
mpr4 = Mp_reach.new(:safi=>2, :nexthop=> ['2011:1:7::1'], :nlris=> ['2011:1::/32','2011:2::/32'], :path_id=>100)
|
152
|
-
mpr5 = Mp_reach.new(:safi=>1, :nexthop=> ['2011:1:7::1'], :nlris=> [
|
153
|
-
{:prefix=> '2011:1::/32', :path_id=> 100},
|
154
|
-
{:prefix=> '2011:2::/32', :path_id=> 101},
|
155
|
-
{:prefix=> '2011:3::/32', :path_id=> 102},
|
156
|
-
])
|
157
|
-
|
158
|
-
assert_equal('800e1a0002011020110001000700000000000000000001002020110001', mpr1.to_shex)
|
159
|
-
assert_equal('800e1e000201102011000100070000000000000000000100000000642020110001', mpr2.to_shex)
|
160
|
-
assert_equal attr_len(mpr1)+4, attr_len(mpr2)
|
161
|
-
|
162
|
-
assert_equal('800e1f00020210201100010007000000000000000000010020201100012020110002', mpr3.to_shex)
|
163
|
-
assert_equal('800e27000202102011000100070000000000000000000100000000642020110001000000642020110002', mpr4.to_shex)
|
164
|
-
assert_equal attr_len(mpr3)+8, attr_len(mpr4)
|
165
|
-
|
166
|
-
assert_equal('800e30000201102011000100070000000000000000000100000000642020110001000000652020110002000000662020110003', mpr5.to_shex)
|
167
|
-
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
def test_afi_2_ntop
|
172
|
-
|
173
|
-
s = '800e1f00020210201100010007000000000000000000010020201100012020110002'
|
174
|
-
sbin = [s].pack('H*')
|
175
|
-
mpr = Mp_reach.new(sbin, false)
|
176
|
-
assert_match(/^\s+2011:1::\/32/, mpr.to_s)
|
177
|
-
assert_match(/^\s+2011:2::\/32/, mpr.to_s)
|
178
|
-
|
179
|
-
s = '800e27000202102011000100070000000000000000000100000000642020110001000000642020110002'
|
180
|
-
sbin = [s].pack('H*')
|
181
|
-
mpr = Mp_reach.new(sbin, true)
|
182
|
-
assert_match(/^\s+ID=100, 2011:1::\/32/, mpr.to_s)
|
183
|
-
assert_match(/^\s+ID=100, 2011:2::\/32/, mpr.to_s)
|
184
|
-
end
|
185
|
-
|
186
|
-
def test_safi_4
|
187
|
-
mpr1 = Mp_reach.new(:safi=>4, :nexthop=> ['10.0.0.1'], :nlris=> {:prefix=> '192.168.0.0/24', :label=>101} )
|
188
|
-
mpr2 = Mp_reach.new(:safi=>4, :nexthop=> ['10.0.0.1'], :nlris=> {:prefix=> '192.168.0.0/24', :label=>101, :path_id=>100} )
|
189
|
-
mpr3 = Mp_reach.new(:safi=>4, :nexthop=> ['10.0.0.1'], :nlris=> [
|
190
|
-
{:prefix=> '192.168.0.0/24', :label=>101,},
|
191
|
-
{:prefix=> '192.168.1.0/24', :label=>102,},
|
192
|
-
{:prefix=> '192.168.1.0/24', :label=>103,}
|
193
|
-
])
|
194
|
-
mpr4 = Mp_reach.new(:safi=>4, :nexthop=> ['10.0.0.1'], :path_id=> 100, :nlris=> [
|
195
|
-
{:prefix=> '192.168.0.0/24', :label=>101,},
|
196
|
-
{:prefix=> '192.168.1.0/24', :label=>102,},
|
197
|
-
{:prefix=> '192.168.1.0/24', :label=>103,}
|
198
|
-
])
|
199
|
-
mpr5 = Mp_reach.new(:safi=>4, :nexthop=> ['10.0.0.1'], :nlris=> [
|
200
|
-
{:prefix=> '192.168.0.0/24', :label=>101, :path_id=>100},
|
201
|
-
{:prefix=> '192.168.1.0/24', :label=>102, :path_id=>101},
|
202
|
-
{:prefix=> '192.168.1.0/24', :label=>103, :path_id=>103},
|
203
|
-
])
|
204
|
-
|
205
|
-
assert_equal('800e10000104040a0000010030000651c0a800', mpr1.to_shex)
|
206
|
-
assert_equal('800e14000104040a000001000000006430000651c0a800', mpr2.to_shex)
|
207
|
-
assert_equal attr_len(mpr1)+4, attr_len(mpr2)
|
208
|
-
|
209
|
-
assert_equal('800e1e000104040a0000010030000651c0a80030000661c0a80130000671c0a801', mpr3.to_shex)
|
210
|
-
assert_equal('800e2a000104040a000001000000006430000651c0a8000000006430000661c0a8010000006430000671c0a801', mpr4.to_shex)
|
211
|
-
assert_equal attr_len(mpr3)+12, attr_len(mpr4)
|
212
|
-
|
213
|
-
assert_equal('800e2a000104040a000001000000006430000651c0a8000000006530000661c0a8010000006730000671c0a801', mpr5.to_shex)
|
214
|
-
|
215
|
-
end
|
216
|
-
|
217
|
-
def test_safi_128
|
218
|
-
mpr1 = Mp_reach.new :safi=>128, :nexthop=> ['10.0.0.1'], :nlris=> {:rd=> [100,100], :prefix=> '192.168.0.0/24', :label=>101}
|
219
|
-
mpr2 = Mp_reach.new :safi=>128, :nexthop=> ['10.0.0.1'], :nlris=> {:rd=> [100,100], :prefix=> '192.168.0.0/24', :label=>101, :path_id=>100}
|
220
|
-
mpr3 = Mp_reach.new :safi=>128, :nexthop=> ['10.0.0.1'], :nlris=> [
|
221
|
-
{:rd=> [100,100], :prefix=> '192.168.0.0/24', :label=>101},
|
222
|
-
{:rd=> [100,100], :prefix=> '192.168.1.0/24', :label=>102},
|
223
|
-
{:rd=> [100,100], :prefix=> '192.168.2.0/24', :label=>103},
|
224
|
-
]
|
225
|
-
mpr4 = Mp_reach.new :safi=>128, :nexthop=> ['10.0.0.1'], :path_id=> 100, :nlris=> [
|
226
|
-
{:rd=> [100,100], :prefix=> '192.168.0.0/24', :label=>101},
|
227
|
-
{:rd=> [100,100], :prefix=> '192.168.1.0/24', :label=>102},
|
228
|
-
{:rd=> [100,100], :prefix=> '192.168.2.0/24', :label=>103},
|
229
|
-
]
|
230
|
-
mpr5 = Mp_reach.new :safi=>128, :nexthop=> ['10.0.0.1'], :nlris=> [
|
231
|
-
{:rd=> [100,100], :prefix=> '192.168.0.0/24', :label=>101, :path_id=>101},
|
232
|
-
{:rd=> [100,100], :prefix=> '192.168.1.0/24', :label=>102, :path_id=>102},
|
233
|
-
{:rd=> [100,100], :prefix=> '192.168.2.0/24', :label=>103, :path_id=>103},
|
234
|
-
]
|
235
|
-
|
236
|
-
assert_equal('800e200001800c00000000000000000a00000100700006510000006400000064c0a800', mpr1.to_shex)
|
237
|
-
assert_equal('800e240001800c00000000000000000a0000010000000064700006510000006400000064c0a800', mpr2.to_shex)
|
238
|
-
assert_equal attr_len(mpr1)+4, attr_len(mpr2)
|
239
|
-
|
240
|
-
assert_equal('800e3e0001800c00000000000000000a00000100700006510000006400000064c0a800700006610000006400000064c0a801700006710000006400000064c0a802', mpr3.to_shex)
|
241
|
-
assert_equal('800e4a0001800c00000000000000000a0000010000000064700006510000006400000064c0a80000000064700006610000006400000064c0a80100000064700006710000006400000064c0a802', mpr4.to_shex)
|
242
|
-
assert_equal attr_len(mpr3)+12, attr_len(mpr4)
|
243
|
-
|
244
|
-
assert_equal('800e4a0001800c00000000000000000a0000010000000065700006510000006400000064c0a80000000066700006610000006400000064c0a80100000067700006710000006400000064c0a802', mpr5.to_shex)
|
245
|
-
|
246
|
-
# 800e3e 0001 80 0c 00000000000000000a000001 00
|
247
|
-
# 700006510000006400000064c0a800
|
248
|
-
# 700006610000006400000064c0a801
|
249
|
-
# 700006710000006400000064c0a802
|
250
|
-
#
|
251
|
-
#
|
252
|
-
# 800e4a0001800c00000000000000000a000001 00
|
253
|
-
# 00000064 700006510000006400000064c0a800
|
254
|
-
# 00000064 700006610000006400000064c0a801
|
255
|
-
# 00000064 700006710000006400000064c0a802
|
256
|
-
#
|
257
|
-
#
|
258
|
-
# 800e4a 0001 80 0c 00000000000000000a000001 00
|
259
|
-
# 00000065 700006510000006400000064c0a800
|
260
|
-
# 00000066 700006610000006400000064c0a801
|
261
|
-
# 00000067 700006710000006400000064c0a802
|
262
|
-
|
263
|
-
end
|
264
|
-
|
265
|
-
def test_safi_4_ntop
|
266
|
-
|
267
|
-
s = '800e1e000104040a0000010030000651c0a80030000661c0a80130000671c0a801'
|
268
|
-
sbin = [s].pack('H*')
|
269
|
-
mpr = Mp_reach.new(sbin, false)
|
270
|
-
assert_match(/^\s+Label Stack=101 /, mpr.to_s)
|
271
|
-
assert_match(/^\s+Label Stack=102 /, mpr.to_s)
|
272
|
-
assert_match(/^\s+Label Stack=103 /, mpr.to_s)
|
273
|
-
|
274
|
-
s = '800e2a000104040a000001000000006430000651c0a8000000006430000661c0a8010000006430000671c0a801'
|
275
|
-
sbin = [s].pack('H*')
|
276
|
-
mpr = Mp_reach.new(sbin, true)
|
277
|
-
assert_match(/ID=100, Label Stack=101 /, mpr.to_s)
|
278
|
-
assert_match(/ID=100, Label Stack=102 /, mpr.to_s)
|
279
|
-
assert_match(/ID=100, Label Stack=103 /, mpr.to_s)
|
280
|
-
end
|
281
|
-
|
282
|
-
def test_safi_128_ntop
|
283
|
-
|
284
|
-
s = '800e3e0001800c00000000000000000a00000100700006510000006400000064c0a800700006610000006400000064c0a801700006710000006400000064c0a802'
|
285
|
-
sbin = [s].pack('H*')
|
286
|
-
mpr = Mp_reach.new(sbin, false)
|
287
|
-
assert_match(/^\s+Label Stack=101 /, mpr.to_s)
|
288
|
-
assert_match(/^\s+Label Stack=102 /, mpr.to_s)
|
289
|
-
assert_match(/^\s+Label Stack=103 /, mpr.to_s)
|
290
|
-
|
291
|
-
s = '800e4a0001800c00000000000000000a0000010000000065700006510000006400000064c0a80000000066700006610000006400000064c0a80100000067700006710000006400000064c0a802'
|
292
|
-
sbin = [s].pack('H*')
|
293
|
-
mpr = Mp_reach.new(sbin, true)
|
294
|
-
assert_match(/ID=101, Label Stack=101 /, mpr.to_s)
|
295
|
-
assert_match(/ID=102, Label Stack=102 /, mpr.to_s)
|
296
|
-
assert_match(/ID=103, Label Stack=103 /, mpr.to_s)
|
297
|
-
end
|
298
|
-
|
299
|
-
private
|
300
|
-
|
301
|
-
def attr_len(attr)
|
302
|
-
attr.encode[2,1].unpack('C')[0]
|
303
|
-
end
|
304
|
-
|
305
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|