bgp4r 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -10
- data/bgp/io.rb +4 -2
- data/bgp/messages/capability.rb +176 -0
- data/bgp/messages/keepalive.rb +30 -0
- data/bgp/messages/markers.rb +10 -0
- data/bgp/messages/message.rb +85 -0
- data/bgp/messages/messages.rb +17 -0
- data/bgp/messages/notification.rb +116 -0
- data/bgp/messages/open.rb +117 -0
- data/bgp/messages/route_refresh.rb +181 -0
- data/bgp/messages/update.rb +148 -0
- data/bgp/neighbor.rb +20 -11
- data/bgp/nlris/inet.rb +18 -0
- data/bgp/{label.rb → nlris/label.rb} +1 -1
- data/bgp/nlris/labeled.rb +39 -0
- data/bgp/nlris/nlri.rb +154 -0
- data/bgp/{attributes.rb → nlris/nlris.rb} +11 -13
- data/bgp/nlris/prefix.rb +33 -0
- data/bgp/{rd.rb → nlris/rd.rb} +1 -1
- data/bgp/nlris/vpn.rb +68 -0
- data/bgp/optional_parameters/as4.rb +59 -0
- data/bgp/optional_parameters/capabilities.rb +13 -0
- data/bgp/optional_parameters/capability.rb +145 -0
- data/bgp/optional_parameters/dynamic.rb +37 -0
- data/bgp/optional_parameters/graceful_restart.rb +116 -0
- data/bgp/optional_parameters/mbgp.rb +97 -0
- data/bgp/optional_parameters/optional_parameter.rb +76 -0
- data/bgp/optional_parameters/orf.rb +90 -0
- data/bgp/optional_parameters/route_refresh.rb +36 -0
- data/bgp/{prefix_orf.rb → orfs/prefix_orf.rb} +4 -10
- data/bgp/{aggregator.rb → path_attributes/aggregator.rb} +2 -2
- data/bgp/{as_path.rb → path_attributes/as_path.rb} +2 -2
- data/bgp/{atomic_aggregate.rb → path_attributes/atomic_aggregate.rb} +2 -2
- data/bgp/{attribute.rb → path_attributes/attribute.rb} +2 -2
- data/bgp/path_attributes/attributes.rb +21 -0
- data/bgp/{cluster_list.rb → path_attributes/cluster_list.rb} +2 -2
- data/bgp/{communities.rb → path_attributes/communities.rb} +2 -2
- data/bgp/{extended_communities.rb → path_attributes/extended_communities.rb} +3 -3
- data/bgp/{extended_community.rb → path_attributes/extended_community.rb} +1 -1
- data/bgp/{local_pref.rb → path_attributes/local_pref.rb} +2 -2
- data/bgp/{mp_reach.rb → path_attributes/mp_reach.rb} +3 -69
- data/bgp/path_attributes/mp_unreach.rb +97 -0
- data/bgp/{multi_exit_disc.rb → path_attributes/multi_exit_disc.rb} +2 -2
- data/bgp/{next_hop.rb → path_attributes/next_hop.rb} +2 -2
- data/bgp/{origin.rb → path_attributes/origin.rb} +2 -2
- data/bgp/{originator_id.rb → path_attributes/originator_id.rb} +2 -2
- data/bgp/{path_attribute.rb → path_attributes/path_attribute.rb} +6 -7
- data/bgp4r.gemspec +127 -67
- data/bgp4r.rb +5 -25
- data/examples/routegen +1 -1
- data/examples/routegen.yml +21 -5
- data/examples/simple.rb +4 -4
- data/examples/unit-testing/malformed_update.rb +1 -1
- data/examples/unit-testing/unknown_transitive_attr.rb +18 -10
- data/test/messages/capability_test.rb +113 -0
- data/test/messages/keepalive_test.rb +34 -0
- data/test/messages/markers_test.rb +33 -0
- data/test/messages/message_test.rb +43 -0
- data/test/messages/notification_test.rb +49 -0
- data/test/messages/open_test.rb +98 -0
- data/test/messages/route_refresh_test.rb +77 -0
- data/test/messages/update_test.rb +133 -0
- data/test/neighbor_test.rb +8 -9
- data/test/nlris/inet_test.rb +43 -0
- data/test/{label_test.rb → nlris/labeled_test.rb} +1 -1
- data/test/{nlri_test.rb → nlris/nlri_test.rb} +5 -1
- data/test/{rd_test.rb → nlris/rd_test.rb} +1 -2
- data/test/optional_parameters/as4_test.rb +34 -0
- data/test/optional_parameters/capability_test.rb +69 -0
- data/test/optional_parameters/dynamic_test.rb +34 -0
- data/test/optional_parameters/graceful_restart_test.rb +23 -0
- data/test/optional_parameters/mbgp_test.rb +35 -0
- data/test/optional_parameters/optional_parameter_test.rb +51 -0
- data/test/optional_parameters/orf_test.rb +42 -0
- data/test/optional_parameters/route_refresh_test.rb +32 -0
- data/test/{prefix_orf_test.rb → orfs/prefix_orf_test.rb} +2 -1
- data/test/{aggregator_test.rb → path_attributes/aggregator_test.rb} +1 -1
- data/test/{as_path_test.rb → path_attributes/as_path_test.rb} +1 -1
- data/test/{atomic_aggregate_test.rb → path_attributes/atomic_aggregate_test.rb} +1 -1
- data/test/{attribute_test.rb → path_attributes/attribute_test.rb} +2 -2
- data/test/{cluster_list_test.rb → path_attributes/cluster_list_test.rb} +1 -1
- data/test/{communities_test.rb → path_attributes/communities_test.rb} +1 -1
- data/test/{extended_communities_test.rb → path_attributes/extended_communities_test.rb} +1 -1
- data/test/{extended_community_test.rb → path_attributes/extended_community_test.rb} +1 -1
- data/test/{local_pref_test.rb → path_attributes/local_pref_test.rb} +1 -1
- data/test/{mp_reach_test.rb → path_attributes/mp_reach_test.rb} +1 -37
- data/test/path_attributes/mp_unreach_test.rb +67 -0
- data/test/{multi_exit_disc_test.rb → path_attributes/multi_exit_disc_test.rb} +1 -1
- data/test/{next_hop_test.rb → path_attributes/next_hop_test.rb} +1 -1
- data/test/{origin_test.rb → path_attributes/origin_test.rb} +2 -1
- data/test/{originator_id_test.rb → path_attributes/originator_id_test.rb} +1 -1
- data/test/{path_attribute_test.rb → path_attributes/path_attribute_test.rb} +2 -2
- metadata +122 -67
- data/bgp/message.rb +0 -921
- data/bgp/nlri.rb +0 -303
- data/bgp/version.rb +0 -3
- data/examples/unit-testing/keepalive_set_to_zeo.rb +0 -64
- data/test/message_test.rb +0 -347
- /data/bgp/{orf.rb → orfs/orf.rb} +0 -0
data/bgp4r.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bgp4r}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.9"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jean-Michel Esnault"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-12}
|
13
13
|
s.description = %q{BGP4R is a BGP-4 ruby library to create, send, and receive BGP messages in an object oriented manner}
|
14
14
|
s.email = %q{jesnault@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,64 +20,102 @@ Gem::Specification.new do |s|
|
|
20
20
|
"COPYING",
|
21
21
|
"LICENSE.txt",
|
22
22
|
"README.rdoc",
|
23
|
-
"bgp/aggregator.rb",
|
24
|
-
"bgp/as_path.rb",
|
25
|
-
"bgp/atomic_aggregate.rb",
|
26
|
-
"bgp/attribute.rb",
|
27
|
-
"bgp/attributes.rb",
|
28
|
-
"bgp/cluster_list.rb",
|
29
23
|
"bgp/common.rb",
|
30
|
-
"bgp/communities.rb",
|
31
|
-
"bgp/extended_communities.rb",
|
32
|
-
"bgp/extended_community.rb",
|
33
24
|
"bgp/iana.rb",
|
34
25
|
"bgp/io.rb",
|
35
|
-
"bgp/
|
36
|
-
"bgp/
|
37
|
-
"bgp/
|
38
|
-
"bgp/
|
39
|
-
"bgp/
|
26
|
+
"bgp/messages/capability.rb",
|
27
|
+
"bgp/messages/keepalive.rb",
|
28
|
+
"bgp/messages/markers.rb",
|
29
|
+
"bgp/messages/message.rb",
|
30
|
+
"bgp/messages/messages.rb",
|
31
|
+
"bgp/messages/notification.rb",
|
32
|
+
"bgp/messages/open.rb",
|
33
|
+
"bgp/messages/route_refresh.rb",
|
34
|
+
"bgp/messages/update.rb",
|
40
35
|
"bgp/neighbor.rb",
|
41
|
-
"bgp/
|
42
|
-
"bgp/
|
43
|
-
"bgp/
|
44
|
-
"bgp/
|
45
|
-
"bgp/
|
46
|
-
"bgp/
|
47
|
-
"bgp/
|
48
|
-
"bgp/
|
49
|
-
"bgp/
|
36
|
+
"bgp/nlris/inet.rb",
|
37
|
+
"bgp/nlris/label.rb",
|
38
|
+
"bgp/nlris/labeled.rb",
|
39
|
+
"bgp/nlris/nlri.rb",
|
40
|
+
"bgp/nlris/nlris.rb",
|
41
|
+
"bgp/nlris/prefix.rb",
|
42
|
+
"bgp/nlris/rd.rb",
|
43
|
+
"bgp/nlris/vpn.rb",
|
44
|
+
"bgp/optional_parameters/as4.rb",
|
45
|
+
"bgp/optional_parameters/capabilities.rb",
|
46
|
+
"bgp/optional_parameters/capability.rb",
|
47
|
+
"bgp/optional_parameters/dynamic.rb",
|
48
|
+
"bgp/optional_parameters/graceful_restart.rb",
|
49
|
+
"bgp/optional_parameters/mbgp.rb",
|
50
|
+
"bgp/optional_parameters/optional_parameter.rb",
|
51
|
+
"bgp/optional_parameters/orf.rb",
|
52
|
+
"bgp/optional_parameters/route_refresh.rb",
|
53
|
+
"bgp/orfs/orf.rb",
|
54
|
+
"bgp/orfs/prefix_orf.rb",
|
55
|
+
"bgp/path_attributes/aggregator.rb",
|
56
|
+
"bgp/path_attributes/as_path.rb",
|
57
|
+
"bgp/path_attributes/atomic_aggregate.rb",
|
58
|
+
"bgp/path_attributes/attribute.rb",
|
59
|
+
"bgp/path_attributes/attributes.rb",
|
60
|
+
"bgp/path_attributes/cluster_list.rb",
|
61
|
+
"bgp/path_attributes/communities.rb",
|
62
|
+
"bgp/path_attributes/extended_communities.rb",
|
63
|
+
"bgp/path_attributes/extended_community.rb",
|
64
|
+
"bgp/path_attributes/local_pref.rb",
|
65
|
+
"bgp/path_attributes/mp_reach.rb",
|
66
|
+
"bgp/path_attributes/mp_unreach.rb",
|
67
|
+
"bgp/path_attributes/multi_exit_disc.rb",
|
68
|
+
"bgp/path_attributes/next_hop.rb",
|
69
|
+
"bgp/path_attributes/origin.rb",
|
70
|
+
"bgp/path_attributes/originator_id.rb",
|
71
|
+
"bgp/path_attributes/path_attribute.rb",
|
50
72
|
"bgp4r.gemspec",
|
51
73
|
"bgp4r.rb",
|
52
74
|
"examples/routegen",
|
53
75
|
"examples/routegen.yml",
|
54
76
|
"examples/simple.rb",
|
55
|
-
"examples/unit-testing/keepalive_set_to_zeo.rb",
|
56
77
|
"examples/unit-testing/malformed_update.rb",
|
57
78
|
"examples/unit-testing/prepend_aspath.rb",
|
58
79
|
"examples/unit-testing/unknown_transitive_attr.rb",
|
59
|
-
"test/aggregator_test.rb",
|
60
|
-
"test/as_path_test.rb",
|
61
|
-
"test/atomic_aggregate_test.rb",
|
62
|
-
"test/attribute_test.rb",
|
63
|
-
"test/cluster_list_test.rb",
|
64
80
|
"test/common_test.rb",
|
65
|
-
"test/
|
66
|
-
"test/
|
67
|
-
"test/
|
68
|
-
"test/
|
69
|
-
"test/
|
70
|
-
"test/
|
71
|
-
"test/
|
72
|
-
"test/
|
81
|
+
"test/messages/capability_test.rb",
|
82
|
+
"test/messages/keepalive_test.rb",
|
83
|
+
"test/messages/markers_test.rb",
|
84
|
+
"test/messages/message_test.rb",
|
85
|
+
"test/messages/notification_test.rb",
|
86
|
+
"test/messages/open_test.rb",
|
87
|
+
"test/messages/route_refresh_test.rb",
|
88
|
+
"test/messages/update_test.rb",
|
73
89
|
"test/neighbor_test.rb",
|
74
|
-
"test/
|
75
|
-
"test/
|
76
|
-
"test/
|
77
|
-
"test/
|
78
|
-
"test/
|
79
|
-
"test/
|
80
|
-
"test/
|
90
|
+
"test/nlris/inet_test.rb",
|
91
|
+
"test/nlris/labeled_test.rb",
|
92
|
+
"test/nlris/nlri_test.rb",
|
93
|
+
"test/nlris/rd_test.rb",
|
94
|
+
"test/optional_parameters/as4_test.rb",
|
95
|
+
"test/optional_parameters/capability_test.rb",
|
96
|
+
"test/optional_parameters/dynamic_test.rb",
|
97
|
+
"test/optional_parameters/graceful_restart_test.rb",
|
98
|
+
"test/optional_parameters/mbgp_test.rb",
|
99
|
+
"test/optional_parameters/optional_parameter_test.rb",
|
100
|
+
"test/optional_parameters/orf_test.rb",
|
101
|
+
"test/optional_parameters/route_refresh_test.rb",
|
102
|
+
"test/orfs/prefix_orf_test.rb",
|
103
|
+
"test/path_attributes/aggregator_test.rb",
|
104
|
+
"test/path_attributes/as_path_test.rb",
|
105
|
+
"test/path_attributes/atomic_aggregate_test.rb",
|
106
|
+
"test/path_attributes/attribute_test.rb",
|
107
|
+
"test/path_attributes/cluster_list_test.rb",
|
108
|
+
"test/path_attributes/communities_test.rb",
|
109
|
+
"test/path_attributes/extended_communities_test.rb",
|
110
|
+
"test/path_attributes/extended_community_test.rb",
|
111
|
+
"test/path_attributes/local_pref_test.rb",
|
112
|
+
"test/path_attributes/mp_reach_test.rb",
|
113
|
+
"test/path_attributes/mp_unreach_test.rb",
|
114
|
+
"test/path_attributes/multi_exit_disc_test.rb",
|
115
|
+
"test/path_attributes/next_hop_test.rb",
|
116
|
+
"test/path_attributes/origin_test.rb",
|
117
|
+
"test/path_attributes/originator_id_test.rb",
|
118
|
+
"test/path_attributes/path_attribute_test.rb"
|
81
119
|
]
|
82
120
|
s.homepage = %q{http://github.com/jesnault/bgp4r/tree/master}
|
83
121
|
s.rdoc_options = ["--quiet", "--title", "A BGP-4 Ruby Library", "--line-numbers"]
|
@@ -87,28 +125,50 @@ Gem::Specification.new do |s|
|
|
87
125
|
s.rubygems_version = %q{1.3.6}
|
88
126
|
s.summary = %q{A BGP-4 Ruby Library}
|
89
127
|
s.test_files = [
|
90
|
-
"test/
|
91
|
-
"test/
|
92
|
-
"test/
|
93
|
-
"test/
|
94
|
-
"test/
|
95
|
-
"test/
|
96
|
-
"test/
|
97
|
-
"test/
|
98
|
-
"test/
|
99
|
-
"test/
|
100
|
-
"test/local_pref_test.rb",
|
101
|
-
"test/message_test.rb",
|
102
|
-
"test/mp_reach_test.rb",
|
103
|
-
"test/multi_exit_disc_test.rb",
|
128
|
+
"test/common_test.rb",
|
129
|
+
"test/messages",
|
130
|
+
"test/messages/capability_test.rb",
|
131
|
+
"test/messages/keepalive_test.rb",
|
132
|
+
"test/messages/markers_test.rb",
|
133
|
+
"test/messages/message_test.rb",
|
134
|
+
"test/messages/notification_test.rb",
|
135
|
+
"test/messages/open_test.rb",
|
136
|
+
"test/messages/route_refresh_test.rb",
|
137
|
+
"test/messages/update_test.rb",
|
104
138
|
"test/neighbor_test.rb",
|
105
|
-
"test/
|
106
|
-
"test/
|
107
|
-
"test/
|
108
|
-
"test/
|
109
|
-
"test/
|
110
|
-
"test/
|
111
|
-
"test/
|
139
|
+
"test/nlris",
|
140
|
+
"test/nlris/inet_test.rb",
|
141
|
+
"test/nlris/labeled_test.rb",
|
142
|
+
"test/nlris/nlri_test.rb",
|
143
|
+
"test/nlris/rd_test.rb",
|
144
|
+
"test/optional_parameters",
|
145
|
+
"test/optional_parameters/as4_test.rb",
|
146
|
+
"test/optional_parameters/capability_test.rb",
|
147
|
+
"test/optional_parameters/dynamic_test.rb",
|
148
|
+
"test/optional_parameters/graceful_restart_test.rb",
|
149
|
+
"test/optional_parameters/mbgp_test.rb",
|
150
|
+
"test/optional_parameters/optional_parameter_test.rb",
|
151
|
+
"test/optional_parameters/orf_test.rb",
|
152
|
+
"test/optional_parameters/route_refresh_test.rb",
|
153
|
+
"test/orfs",
|
154
|
+
"test/orfs/prefix_orf_test.rb",
|
155
|
+
"test/path_attributes",
|
156
|
+
"test/path_attributes/aggregator_test.rb",
|
157
|
+
"test/path_attributes/as_path_test.rb",
|
158
|
+
"test/path_attributes/atomic_aggregate_test.rb",
|
159
|
+
"test/path_attributes/attribute_test.rb",
|
160
|
+
"test/path_attributes/cluster_list_test.rb",
|
161
|
+
"test/path_attributes/communities_test.rb",
|
162
|
+
"test/path_attributes/extended_communities_test.rb",
|
163
|
+
"test/path_attributes/extended_community_test.rb",
|
164
|
+
"test/path_attributes/local_pref_test.rb",
|
165
|
+
"test/path_attributes/mp_reach_test.rb",
|
166
|
+
"test/path_attributes/mp_unreach_test.rb",
|
167
|
+
"test/path_attributes/multi_exit_disc_test.rb",
|
168
|
+
"test/path_attributes/next_hop_test.rb",
|
169
|
+
"test/path_attributes/origin_test.rb",
|
170
|
+
"test/path_attributes/originator_id_test.rb",
|
171
|
+
"test/path_attributes/path_attribute_test.rb"
|
112
172
|
]
|
113
173
|
|
114
174
|
if s.respond_to? :specification_version then
|
data/bgp4r.rb
CHANGED
@@ -1,27 +1,7 @@
|
|
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
1
|
require 'bgp/common'
|
24
|
-
require 'bgp/
|
2
|
+
require 'bgp/iana'
|
3
|
+
require 'bgp/messages/messages'
|
4
|
+
require 'bgp/path_attributes/attributes'
|
5
|
+
require 'bgp/nlris/nlris'
|
6
|
+
require 'bgp/optional_parameters/capabilities'
|
25
7
|
require 'bgp/neighbor'
|
26
|
-
require 'bgp/message'
|
27
|
-
require 'bgp/version'
|
data/examples/routegen
CHANGED
data/examples/routegen.yml
CHANGED
@@ -5,23 +5,39 @@ neighbor:
|
|
5
5
|
router id: 1.1.1.1
|
6
6
|
my as: 100
|
7
7
|
holdtime: 180
|
8
|
-
local address:
|
9
|
-
neighbor address:
|
8
|
+
local address: 40.0.0.1
|
9
|
+
neighbor address: 40.0.0.2
|
10
10
|
capabilities:
|
11
11
|
- four byte as
|
12
12
|
routes:
|
13
|
-
nlris: 11.0.0.0/28,
|
14
|
-
next hop:
|
13
|
+
nlris: 11.0.0.0/28, 199999, 127
|
14
|
+
next hop: 40.0.0.1
|
15
15
|
local pref: 100
|
16
16
|
med: 100
|
17
17
|
origin: 0
|
18
18
|
communities: 100:1 200:1 300:1
|
19
|
-
as path:
|
19
|
+
as path: 100 90 80
|
20
20
|
|
21
21
|
...
|
22
22
|
|
23
23
|
produces:
|
24
24
|
|
25
|
+
|
26
|
+
junos> show route logical-router Paris terse
|
27
|
+
|
28
|
+
inet.0: 200004 destinations, 200004 routes (200004 active, 0 holddown, 0 hidden)
|
29
|
+
Restart Complete
|
30
|
+
+ = Active Route, - = Last Active, * = Both
|
31
|
+
|
32
|
+
A Destination P Prf Metric 1 Metric 2 Next hop AS path
|
33
|
+
* 11.0.0.16/28 B 170 100 >40.0.0.1 100 90 80 I
|
34
|
+
* 11.0.0.32/28 B 170 100 >40.0.0.1 100 90 80 I
|
35
|
+
* 11.0.0.48/28 B 170 100 >40.0.0.1 100 90 80 I
|
36
|
+
* 11.0.0.64/28 B 170 100 >40.0.0.1 100 90 80 I
|
37
|
+
* 11.0.0.80/28 B 170 100 >40.0.0.1 100 90 80 I
|
38
|
+
...
|
39
|
+
|
40
|
+
|
25
41
|
ios#show ip route summary | inc bgp
|
26
42
|
bgp 100 0 1999 107946 287856
|
27
43
|
ios#
|
data/examples/simple.rb
CHANGED
@@ -17,8 +17,8 @@ Log.level=Logger::DEBUG
|
|
17
17
|
neighbor = Neighbor.new \
|
18
18
|
:version=> 4,
|
19
19
|
:my_as=> 100,
|
20
|
-
:remote_addr => '
|
21
|
-
:local_addr => '
|
20
|
+
:remote_addr => '40.0.0.2',
|
21
|
+
:local_addr => '40.0.0.1',
|
22
22
|
:id=> '1.1.1.1', :holdtime=> 180
|
23
23
|
|
24
24
|
neighbor.capability :as4_byte
|
@@ -49,10 +49,10 @@ neighbor.start :auto_retry
|
|
49
49
|
an_update = Update.new(
|
50
50
|
Path_attribute.new(
|
51
51
|
Origin.new(2),
|
52
|
-
Next_hop.new('
|
52
|
+
Next_hop.new('40.0.0.1'),
|
53
53
|
Multi_exit_disc.new(100),
|
54
54
|
Local_pref.new(100),
|
55
|
-
As_path.new(
|
55
|
+
As_path.new(100, 80, 60),
|
56
56
|
Communities.new('1311:1 311:59 2805:64')
|
57
57
|
),
|
58
58
|
Nlri.new('77.0.0.0/17', '78.0.0.0/18', '79.0.0.0/19')
|
@@ -2,14 +2,15 @@ require "test/unit"
|
|
2
2
|
require 'bgp4r'
|
3
3
|
require 'timeout'
|
4
4
|
|
5
|
+
|
5
6
|
Thread.abort_on_exception=true
|
6
7
|
|
7
8
|
class TestBgp < Test::Unit::TestCase
|
8
9
|
|
9
10
|
include BGP
|
10
11
|
|
11
|
-
Log.create
|
12
|
-
Log.level=Logger::DEBUG
|
12
|
+
# Log.create
|
13
|
+
# Log.level=Logger::DEBUG
|
13
14
|
|
14
15
|
N100 = Class.new(BGP::Neighbor)
|
15
16
|
N300 = Class.new(BGP::Neighbor)
|
@@ -26,6 +27,13 @@ class TestBgp < Test::Unit::TestCase
|
|
26
27
|
def setup
|
27
28
|
@n100 = N100.new(:my_as=> 100, :remote_addr => '40.0.0.2', :local_addr => '40.0.0.1', :id=> '13.11.19.59')
|
28
29
|
@n300 = N300.new(:my_as=> 300, :remote_addr => '40.0.1.1', :local_addr => '40.0.1.2', :id=> '13.11.19.57')
|
30
|
+
@n100.capability :mbgp, :ipv4, :unicast
|
31
|
+
gr = OPT_PARM::CAP::Graceful_restart.new 3, 120
|
32
|
+
gr.add :ipv4, :unicast, 1
|
33
|
+
gr.add :ipv4, :multicast, 1
|
34
|
+
gr.add :ipv6, :unicast, 1
|
35
|
+
gr.add :ipv6, :multicast, 3
|
36
|
+
@n100.capability gr
|
29
37
|
start_peering
|
30
38
|
end
|
31
39
|
|
@@ -39,7 +47,7 @@ class TestBgp < Test::Unit::TestCase
|
|
39
47
|
assert msg, "Did not receive expected BGP update message."
|
40
48
|
assert msg.path_attribute.has?(255), "The path attribute was expected to contain an attribute type 255"
|
41
49
|
assert_not_nil msg.path_attribute[255]
|
42
|
-
assert_equal 'AN OPTIONAL TRANSITIVE ATTR WITH TYPE
|
50
|
+
assert_equal 'AN OPTIONAL TRANSITIVE ATTR WITH TYPE 255', msg.path_attribute[255].value
|
43
51
|
end
|
44
52
|
|
45
53
|
def teardown
|
@@ -58,12 +66,12 @@ class TestBgp < Test::Unit::TestCase
|
|
58
66
|
|
59
67
|
def recv(q, timeout=5)
|
60
68
|
begin
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
69
|
+
Timeout::timeout(timeout) do |t|
|
70
|
+
msg = q.deq
|
71
|
+
end
|
72
|
+
rescue Timeout::Error => e
|
73
|
+
nil
|
74
|
+
end
|
67
75
|
end
|
68
76
|
|
69
77
|
def update_with_unknown_transitive_attribute
|
@@ -92,7 +100,7 @@ class TestBgp < Test::Unit::TestCase
|
|
92
100
|
Multi_exit_disc.new(100),
|
93
101
|
Local_pref.new(100),
|
94
102
|
As_path.new(100),
|
95
|
-
my_attr.new(ATTR::OPTIONAL_TRANSITIVE, 255, 'AN OPTIONAL TRANSITIVE ATTR WITH TYPE
|
103
|
+
my_attr.new(ATTR::OPTIONAL_TRANSITIVE, 255, 'AN OPTIONAL TRANSITIVE ATTR WITH TYPE 255'),
|
96
104
|
my_attr.new(ATTR::OPTIONAL_TRANSITIVE, 0, 'AN OPTIONAL TRANSITIVE ATTR WITH TYPE 0')
|
97
105
|
),
|
98
106
|
Nlri.new('77.0.0.0/17', '78.0.0.0/18', '79.0.0.0/19')
|
@@ -0,0 +1,113 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2010 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
|
+
|
24
|
+
require "test/unit"
|
25
|
+
require "bgp/messages/capability"
|
26
|
+
require 'bgp4r'
|
27
|
+
|
28
|
+
class TestOptParmCapabilityEncode < Test::Unit::TestCase
|
29
|
+
include BGP::OPT_PARM
|
30
|
+
def test_encode_dynamic
|
31
|
+
assert_equal '0206010400010001', CAP::Mbgp.new(1,1).to_shex
|
32
|
+
assert_equal '01000400010001', DYN_CAP::Mbgp.new(1,1).to_shex
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class TestBgpMessagesCapabilityRevision < Test::Unit::TestCase
|
37
|
+
include BGP::OPT_PARM
|
38
|
+
def test_capability_revision
|
39
|
+
assert_equal '01000400010001', DYN_CAP::Mbgp.new(1,1).to_shex
|
40
|
+
assert_equal '0206010400010001', CAP::Mbgp.new(1,1).to_shex
|
41
|
+
revision = BGP::Capability::Revision.new :unset, :set, :advertise, 10, DYN_CAP::Mbgp.new(1,1)
|
42
|
+
assert_equal '400000000a01000400010001', revision.to_shex
|
43
|
+
assert_equal '0x00000010 Advertise Req (0x40) MBGP IPv4, Unicast',revision.to_s
|
44
|
+
rev = BGP::Capability::Revision.advertise( 10, DYN_CAP::Mbgp.new(1,1))
|
45
|
+
assert_equal '000000000a01000400010001', rev.to_shex
|
46
|
+
rev = BGP::Capability::Revision.advertise_ack_request( 10, DYN_CAP::Mbgp.new(1,1))
|
47
|
+
assert_equal '400000000a01000400010001', rev.to_shex
|
48
|
+
end
|
49
|
+
def test_capability_revision_o1
|
50
|
+
r = BGP::Capability::Revision.new :unset, :unset, :advertise, 0, 'a cap'
|
51
|
+
assert_equal 0, r.instance_eval { @o1 }
|
52
|
+
r = BGP::Capability::Revision.new :set, :unset, :advertise, 0, 'a cap'
|
53
|
+
assert_equal 0x80, r.instance_eval { @o1 }
|
54
|
+
r = BGP::Capability::Revision.new :set, :set, :advertise, 0, 'a cap'
|
55
|
+
assert_equal 0xc0, r.instance_eval { @o1 }
|
56
|
+
r = BGP::Capability::Revision.new :unset, :set, :advertise, 0, 'a cap'
|
57
|
+
assert_equal 0x40, r.instance_eval { @o1 }
|
58
|
+
end
|
59
|
+
def test_capability_revision_factory
|
60
|
+
s = '400000000a01000400010001'
|
61
|
+
sbin = [s].pack('H*')
|
62
|
+
r = BGP::Capability::Revision.new(sbin)
|
63
|
+
assert_equal s, r.to_shex
|
64
|
+
assert_equal '', sbin
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class TestBgpMessagesCapability < Test::Unit::TestCase
|
69
|
+
include BGP
|
70
|
+
include BGP::OPT_PARM
|
71
|
+
def test_capability_1
|
72
|
+
cap_msg = BGP::Capability.new
|
73
|
+
assert_equal 'ffffffffffffffffffffffffffffffff001306', cap_msg.to_shex
|
74
|
+
cap_msg << BGP::Capability::Revision.advertise( 10, DYN_CAP::Mbgp.new(1,1))
|
75
|
+
assert_match /^(ff){16}001f06000000000a01000400010001/, cap_msg.to_shex
|
76
|
+
cap_msg << BGP::Capability::Revision.advertise( 20, DYN_CAP::Mbgp.new(1,2))
|
77
|
+
assert_match /^(ff){16}002b06\s*000000000a01000400010001\s*000000001401000400010002/, cap_msg.to_shex
|
78
|
+
end
|
79
|
+
def test_capability_2
|
80
|
+
cap_msg = BGP::Capability.new(
|
81
|
+
BGP::Capability::Revision.advertise( 10, DYN_CAP::Mbgp.new(1,1)),
|
82
|
+
BGP::Capability::Revision.advertise( 20, DYN_CAP::Mbgp.new(1,2))
|
83
|
+
)
|
84
|
+
assert_match /^(ff){16}002b06\s*000000000a01000400010001\s*000000001401000400010002/, cap_msg.to_shex
|
85
|
+
end
|
86
|
+
def test_capability_3
|
87
|
+
|
88
|
+
s = 'Capability (6), length: 91
|
89
|
+
Seqn Action Ack bits Capability
|
90
|
+
0x00000010 Advertise (0x00) MBGP IPv4, Unicast
|
91
|
+
0x00000020 Advertise Req (0x40) MBGP IPv4, Unicast
|
92
|
+
0x00000020 Advertise Rsp (0x80) MBGP IPv4, Unicast
|
93
|
+
0x00000010 Withdraw (0x01) MBGP IPv4, Unicast
|
94
|
+
0x00000020 Withdraw Req (0x41) MBGP IPv4, Unicast
|
95
|
+
0x00000020 Withdraw Rsp (0x81) MBGP IPv4, Unicast'
|
96
|
+
|
97
|
+
cap_msg = BGP::Capability.new(
|
98
|
+
BGP::Capability::Revision.advertise( 10, DYN_CAP::Mbgp.new(1,1)),
|
99
|
+
BGP::Capability::Revision.advertise_ack_request( 20, DYN_CAP::Mbgp.new(1,1)),
|
100
|
+
BGP::Capability::Revision.advertise_ack_response( 20, DYN_CAP::Mbgp.new(1,1)),
|
101
|
+
BGP::Capability::Revision.remove( 10, DYN_CAP::Mbgp.new(1,1)),
|
102
|
+
BGP::Capability::Revision.remove_ack_request( 20, DYN_CAP::Mbgp.new(1,1)),
|
103
|
+
BGP::Capability::Revision.remove_ack_response( 20, DYN_CAP::Mbgp.new(1,1))
|
104
|
+
)
|
105
|
+
assert_equal s, cap_msg.to_s
|
106
|
+
end
|
107
|
+
def test_factory
|
108
|
+
s = 'ffffffffffffffffffffffffffffffff002b06000000000a01000400010001000000001401000400010002'
|
109
|
+
msg = BGP::Message.factory([s].pack('H*'))
|
110
|
+
assert_equal(BGP::Capability, msg.class)
|
111
|
+
assert_equal s, msg.to_shex
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008, 2009, 2010 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 'bgp4r'
|
25
|
+
|
26
|
+
class Keepalive_Test < Test::Unit::TestCase
|
27
|
+
include BGP
|
28
|
+
def test_1
|
29
|
+
Keepalive.new
|
30
|
+
assert_match(/^(ff){16}001304$/, Keepalive.new.to_shex)
|
31
|
+
assert_match(/^(ff){16}001304$/, Message.keepalive.unpack('H*')[0])
|
32
|
+
assert_equal(Keepalive, Message.factory(Keepalive.new.encode).class)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright 2008, 2009, 2010 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 'bgp4r'
|
25
|
+
require 'bgp/messages/markers'
|
26
|
+
class End_of_rib_markers_Test < Test::Unit::TestCase
|
27
|
+
include BGP
|
28
|
+
def test_end_of_rib_maker_messages
|
29
|
+
assert_match /(ff){16}00170200000000/, Update.end_of_rib_marker.to_shex
|
30
|
+
assert_match /(ff){16}001d0200000006800f03000104/, Update.end_of_rib_marker(:afi=>1, :safi=>4).to_shex
|
31
|
+
assert_match /(ff){16}001d0200000006800f03000180/, Update.end_of_rib_marker(:afi=>1, :safi=>128).to_shex
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,43 @@
|
|
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 'bgp4r'
|
25
|
+
|
26
|
+
class Message_Test < Test::Unit::TestCase
|
27
|
+
include BGP
|
28
|
+
class MyMessage < Message
|
29
|
+
attr_reader :data
|
30
|
+
def initialize(s=nil)
|
31
|
+
@data= parse(s) if s
|
32
|
+
end
|
33
|
+
def encode
|
34
|
+
@msg_type=0xee
|
35
|
+
super('abcdefghihjklmopqrstuvwxyz')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
def test_1
|
39
|
+
msg1 = MyMessage.new
|
40
|
+
msg2 = MyMessage.new(msg1.encode)
|
41
|
+
assert_equal('abcdefghihjklmopqrstuvwxyz',msg2.data)
|
42
|
+
end
|
43
|
+
end
|