bgp4r 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/README.rdoc +21 -15
  2. data/bgp/common.rb +13 -12
  3. data/bgp/iana.rb +28 -205
  4. data/bgp/io.rb +0 -1
  5. data/bgp/messages/capability.rb +1 -1
  6. data/bgp/messages/message.rb +1 -1
  7. data/bgp/messages/open.rb +1 -1
  8. data/bgp/messages/route_refresh.rb +4 -7
  9. data/bgp/messages/update.rb +9 -6
  10. data/bgp/misc/live_feed.rb +1 -2
  11. data/bgp/neighbor/add_path_cap.rb +14 -13
  12. data/bgp/neighbor/neighbor.rb +30 -18
  13. data/bgp/nlris/inet.rb +9 -11
  14. data/bgp/nlris/label.rb +1 -1
  15. data/bgp/nlris/labeled.rb +31 -4
  16. data/bgp/nlris/nlri.rb +23 -183
  17. data/bgp/nlris/nsap.rb +101 -0
  18. data/bgp/nlris/prefix.rb +162 -24
  19. data/bgp/nlris/rd.rb +1 -1
  20. data/bgp/nlris/vpn.rb +23 -5
  21. data/bgp/optional_parameters/add_path.rb +11 -37
  22. data/bgp/optional_parameters/as4.rb +1 -1
  23. data/bgp/optional_parameters/capability.rb +1 -11
  24. data/bgp/optional_parameters/dynamic.rb +1 -1
  25. data/bgp/optional_parameters/graceful_restart.rb +35 -22
  26. data/bgp/optional_parameters/mbgp.rb +23 -37
  27. data/bgp/optional_parameters/orf.rb +1 -1
  28. data/bgp/optional_parameters/route_refresh.rb +1 -1
  29. data/bgp/orfs/prefix_orf.rb +3 -6
  30. data/bgp/path_attributes/aggregator.rb +1 -1
  31. data/bgp/path_attributes/as_path.rb +1 -1
  32. data/bgp/path_attributes/atomic_aggregate.rb +1 -1
  33. data/bgp/path_attributes/cluster_list.rb +1 -1
  34. data/bgp/path_attributes/communities.rb +1 -1
  35. data/bgp/path_attributes/extended_communities.rb +1 -1
  36. data/bgp/path_attributes/extended_community.rb +55 -26
  37. data/bgp/path_attributes/local_pref.rb +1 -1
  38. data/bgp/path_attributes/mp_reach.rb +178 -76
  39. data/bgp/path_attributes/mp_unreach.rb +11 -67
  40. data/bgp/path_attributes/multi_exit_disc.rb +1 -1
  41. data/bgp/path_attributes/next_hop.rb +1 -1
  42. data/bgp/path_attributes/origin.rb +1 -1
  43. data/bgp/path_attributes/originator_id.rb +1 -1
  44. data/bgp/path_attributes/path_attribute.rb +1 -1
  45. data/bgp4r.gemspec +130 -183
  46. data/examples/routegen +0 -1
  47. data/examples/test.rb +15 -0
  48. data/examples/test2.rb +116 -0
  49. data/examples/unit-testing/{malformed_update.rb → malformed_update_test.rb} +6 -6
  50. data/examples/unit-testing/{no_export.rb → no_export_test.rb} +6 -6
  51. data/examples/unit-testing/{prepend_aspath.rb → prepend_aspath_test.rb} +6 -6
  52. data/test/functional/add_path_test.rb +32 -0
  53. data/test/helpers/server.rb +11 -4
  54. data/test/{common_test.rb → unit/common_test.rb} +7 -10
  55. data/test/{iana_test.rb → unit/iana_test.rb} +7 -6
  56. data/test/{messages → unit/messages}/capability_test.rb +26 -9
  57. data/test/{messages → unit/messages}/route_refresh_test.rb +4 -4
  58. data/test/{messages → unit/messages}/update_test.rb +28 -17
  59. data/test/{neighbor → unit/neighbor}/add_path_cap_test.rb +41 -0
  60. data/test/{neighbor → unit/neighbor}/neighbor_test.rb +31 -13
  61. data/test/unit/nlris/labeled_test.rb +30 -0
  62. data/test/unit/nlris/nlri_test.rb +103 -0
  63. data/test/unit/nlris/nsap_test.rb +80 -0
  64. data/test/unit/nlris/prefix_test.rb +136 -0
  65. data/test/{optional_parameters → unit/optional_parameters}/capability_test.rb +0 -5
  66. data/test/unit/optional_parameters/graceful_restart_test.rb +41 -0
  67. data/test/{optional_parameters → unit/optional_parameters}/mbgp_test.rb +20 -0
  68. data/test/unit/path_attributes/aigp.rb +59 -0
  69. data/test/{path_attributes → unit/path_attributes}/extended_communities_test.rb +4 -0
  70. data/test/{path_attributes → unit/path_attributes}/extended_community_test.rb +9 -0
  71. data/test/unit/path_attributes/mp_reach_test.rb +563 -0
  72. data/test/{path_attributes → unit/path_attributes}/path_attribute_test.rb +1 -1
  73. metadata +128 -136
  74. data/examples/unit-testing/test.rb +0 -82
  75. data/examples/unit-testing/test1.rb +0 -82
  76. data/examples/unit-testing/test2.rb +0 -44
  77. data/test/nlris/ext_nlri_test.rb +0 -32
  78. data/test/nlris/nlri_test.rb +0 -130
  79. data/test/optional_parameters/graceful_restart_test.rb +0 -24
  80. data/test/path_attributes/mp_reach_test.rb +0 -305
  81. /data/examples/unit-testing/{unknown_transitive_attr.rb → unknown_transitive_attr_test.rb} +0 -0
  82. /data/test/{misc → functional}/live_feed_test.rb +0 -0
  83. /data/test/{messages → unit/messages}/keepalive_test.rb +0 -0
  84. /data/test/{messages → unit/messages}/markers_test.rb +0 -0
  85. /data/test/{messages → unit/messages}/message_test.rb +0 -0
  86. /data/test/{messages → unit/messages}/notification_test.rb +0 -0
  87. /data/test/{messages → unit/messages}/open_test.rb +0 -0
  88. /data/test/{nlris → unit/nlris}/inet_test.rb +0 -0
  89. /data/test/{nlris/labeled_test.rb → unit/nlris/label_test.rb} +0 -0
  90. /data/test/{nlris → unit/nlris}/rd_test.rb +0 -0
  91. /data/test/{optional_parameters → unit/optional_parameters}/add_path_test.rb +0 -0
  92. /data/test/{optional_parameters → unit/optional_parameters}/as4_test.rb +0 -0
  93. /data/test/{optional_parameters → unit/optional_parameters}/dynamic_test.rb +0 -0
  94. /data/test/{optional_parameters → unit/optional_parameters}/optional_parameter_test.rb +0 -0
  95. /data/test/{optional_parameters → unit/optional_parameters}/orf_test.rb +0 -0
  96. /data/test/{optional_parameters → unit/optional_parameters}/route_refresh_test.rb +0 -0
  97. /data/test/{orfs → unit/orfs}/prefix_orf_test.rb +0 -0
  98. /data/test/{path_attributes → unit/path_attributes}/aggregator_test.rb +0 -0
  99. /data/test/{path_attributes → unit/path_attributes}/as_path_test.rb +0 -0
  100. /data/test/{path_attributes → unit/path_attributes}/atomic_aggregate_test.rb +0 -0
  101. /data/test/{path_attributes → unit/path_attributes}/attribute_test.rb +0 -0
  102. /data/test/{path_attributes → unit/path_attributes}/cluster_list_test.rb +0 -0
  103. /data/test/{path_attributes → unit/path_attributes}/communities_test.rb +0 -0
  104. /data/test/{path_attributes → unit/path_attributes}/local_pref_test.rb +0 -0
  105. /data/test/{path_attributes → unit/path_attributes}/mp_unreach_test.rb +0 -0
  106. /data/test/{path_attributes → unit/path_attributes}/multi_exit_disc_test.rb +0 -0
  107. /data/test/{path_attributes → unit/path_attributes}/next_hop_test.rb +0 -0
  108. /data/test/{path_attributes → unit/path_attributes}/origin_test.rb +0 -0
  109. /data/test/{path_attributes → unit/path_attributes}/originator_id_test.rb +0 -0
metadata CHANGED
@@ -1,33 +1,25 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bgp4r
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 0
8
- - 12
9
- version: 0.0.12
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.13
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Jean-Michel Esnault
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-02-13 00:00:00 -08:00
18
- default_executable:
12
+ date: 2011-10-28 00:00:00.000000000Z
19
13
  dependencies: []
20
-
21
- description: BGP4R is a BGP-4 ruby library to create, send, and receive BGP messages in an object oriented manner
14
+ description: BGP4R is a BGP-4 ruby library to create, send, and receive BGP messages
15
+ in an object oriented manner
22
16
  email: bgp4r@esnault.org
23
17
  executables: []
24
-
25
18
  extensions: []
26
-
27
- extra_rdoc_files:
19
+ extra_rdoc_files:
28
20
  - LICENSE.txt
29
21
  - README.rdoc
30
- files:
22
+ files:
31
23
  - COPYING
32
24
  - LICENSE.txt
33
25
  - README.rdoc
@@ -51,6 +43,7 @@ files:
51
43
  - bgp/nlris/labeled.rb
52
44
  - bgp/nlris/nlri.rb
53
45
  - bgp/nlris/nlris.rb
46
+ - bgp/nlris/nsap.rb
54
47
  - bgp/nlris/prefix.rb
55
48
  - bgp/nlris/rd.rb
56
49
  - bgp/nlris/vpn.rb
@@ -89,135 +82,134 @@ files:
89
82
  - examples/routegen
90
83
  - examples/routegen.yml
91
84
  - examples/simple.rb
92
- - examples/unit-testing/malformed_update.rb
93
- - examples/unit-testing/no_export.rb
94
- - examples/unit-testing/prepend_aspath.rb
95
- - examples/unit-testing/test.rb
96
- - examples/unit-testing/test1.rb
97
- - examples/unit-testing/test2.rb
98
- - examples/unit-testing/unknown_transitive_attr.rb
99
- - test/common_test.rb
85
+ - examples/test.rb
86
+ - examples/test2.rb
87
+ - examples/unit-testing/malformed_update_test.rb
88
+ - examples/unit-testing/no_export_test.rb
89
+ - examples/unit-testing/prepend_aspath_test.rb
90
+ - examples/unit-testing/unknown_transitive_attr_test.rb
91
+ - test/functional/add_path_test.rb
92
+ - test/functional/live_feed_test.rb
100
93
  - test/helpers/server.rb
101
- - test/iana_test.rb
102
- - test/messages/capability_test.rb
103
- - test/messages/keepalive_test.rb
104
- - test/messages/markers_test.rb
105
- - test/messages/message_test.rb
106
- - test/messages/notification_test.rb
107
- - test/messages/open_test.rb
108
- - test/messages/route_refresh_test.rb
109
- - test/messages/update_test.rb
110
- - test/misc/live_feed_test.rb
111
94
  - test/misc/misc.rb
112
- - test/neighbor/add_path_cap_test.rb
113
- - test/neighbor/neighbor_test.rb
114
- - test/nlris/ext_nlri_test.rb
115
- - test/nlris/inet_test.rb
116
- - test/nlris/labeled_test.rb
117
- - test/nlris/nlri_test.rb
118
- - test/nlris/rd_test.rb
119
- - test/optional_parameters/add_path_test.rb
120
- - test/optional_parameters/as4_test.rb
121
- - test/optional_parameters/capability_test.rb
122
- - test/optional_parameters/dynamic_test.rb
123
- - test/optional_parameters/graceful_restart_test.rb
124
- - test/optional_parameters/mbgp_test.rb
125
- - test/optional_parameters/optional_parameter_test.rb
126
- - test/optional_parameters/orf_test.rb
127
- - test/optional_parameters/route_refresh_test.rb
128
- - test/orfs/prefix_orf_test.rb
129
- - test/path_attributes/aggregator_test.rb
130
- - test/path_attributes/as_path_test.rb
131
- - test/path_attributes/atomic_aggregate_test.rb
132
- - test/path_attributes/attribute_test.rb
133
- - test/path_attributes/cluster_list_test.rb
134
- - test/path_attributes/communities_test.rb
135
- - test/path_attributes/extended_communities_test.rb
136
- - test/path_attributes/extended_community_test.rb
137
- - test/path_attributes/local_pref_test.rb
138
- - test/path_attributes/mp_reach_test.rb
139
- - test/path_attributes/mp_unreach_test.rb
140
- - test/path_attributes/multi_exit_disc_test.rb
141
- - test/path_attributes/next_hop_test.rb
142
- - test/path_attributes/origin_test.rb
143
- - test/path_attributes/originator_id_test.rb
144
- - test/path_attributes/path_attribute_test.rb
145
- has_rdoc: true
95
+ - test/unit/common_test.rb
96
+ - test/unit/iana_test.rb
97
+ - test/unit/messages/capability_test.rb
98
+ - test/unit/messages/keepalive_test.rb
99
+ - test/unit/messages/markers_test.rb
100
+ - test/unit/messages/message_test.rb
101
+ - test/unit/messages/notification_test.rb
102
+ - test/unit/messages/open_test.rb
103
+ - test/unit/messages/route_refresh_test.rb
104
+ - test/unit/messages/update_test.rb
105
+ - test/unit/neighbor/add_path_cap_test.rb
106
+ - test/unit/neighbor/neighbor_test.rb
107
+ - test/unit/nlris/inet_test.rb
108
+ - test/unit/nlris/label_test.rb
109
+ - test/unit/nlris/labeled_test.rb
110
+ - test/unit/nlris/nlri_test.rb
111
+ - test/unit/nlris/nsap_test.rb
112
+ - test/unit/nlris/prefix_test.rb
113
+ - test/unit/nlris/rd_test.rb
114
+ - test/unit/optional_parameters/add_path_test.rb
115
+ - test/unit/optional_parameters/as4_test.rb
116
+ - test/unit/optional_parameters/capability_test.rb
117
+ - test/unit/optional_parameters/dynamic_test.rb
118
+ - test/unit/optional_parameters/graceful_restart_test.rb
119
+ - test/unit/optional_parameters/mbgp_test.rb
120
+ - test/unit/optional_parameters/optional_parameter_test.rb
121
+ - test/unit/optional_parameters/orf_test.rb
122
+ - test/unit/optional_parameters/route_refresh_test.rb
123
+ - test/unit/orfs/prefix_orf_test.rb
124
+ - test/unit/path_attributes/aggregator_test.rb
125
+ - test/unit/path_attributes/aigp.rb
126
+ - test/unit/path_attributes/as_path_test.rb
127
+ - test/unit/path_attributes/atomic_aggregate_test.rb
128
+ - test/unit/path_attributes/attribute_test.rb
129
+ - test/unit/path_attributes/cluster_list_test.rb
130
+ - test/unit/path_attributes/communities_test.rb
131
+ - test/unit/path_attributes/extended_communities_test.rb
132
+ - test/unit/path_attributes/extended_community_test.rb
133
+ - test/unit/path_attributes/local_pref_test.rb
134
+ - test/unit/path_attributes/mp_reach_test.rb
135
+ - test/unit/path_attributes/mp_unreach_test.rb
136
+ - test/unit/path_attributes/multi_exit_disc_test.rb
137
+ - test/unit/path_attributes/next_hop_test.rb
138
+ - test/unit/path_attributes/origin_test.rb
139
+ - test/unit/path_attributes/originator_id_test.rb
140
+ - test/unit/path_attributes/path_attribute_test.rb
146
141
  homepage: http://github.com/jesnault/bgp4r/tree/master
147
142
  licenses: []
148
-
149
143
  post_install_message:
150
- rdoc_options:
151
- - --charset=UTF-8
152
- require_paths:
144
+ rdoc_options: []
145
+ require_paths:
153
146
  - .
154
- required_ruby_version: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - ">="
157
- - !ruby/object:Gem::Version
158
- segments:
159
- - 1
160
- - 8
161
- - 6
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ none: false
149
+ requirements:
150
+ - - ! '>='
151
+ - !ruby/object:Gem::Version
162
152
  version: 1.8.6
163
- required_rubygems_version: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- segments:
168
- - 0
169
- version: "0"
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
170
159
  requirements: []
171
-
172
160
  rubyforge_project: bgp4r
173
- rubygems_version: 1.3.6
161
+ rubygems_version: 1.8.10
174
162
  signing_key:
175
163
  specification_version: 3
176
164
  summary: A BGP-4 Ruby Library
177
- test_files:
178
- - test/common_test.rb
165
+ test_files:
166
+ - test/functional/add_path_test.rb
167
+ - test/functional/live_feed_test.rb
179
168
  - test/helpers/server.rb
180
- - test/iana_test.rb
181
- - test/messages/capability_test.rb
182
- - test/messages/keepalive_test.rb
183
- - test/messages/markers_test.rb
184
- - test/messages/message_test.rb
185
- - test/messages/notification_test.rb
186
- - test/messages/open_test.rb
187
- - test/messages/route_refresh_test.rb
188
- - test/messages/update_test.rb
189
- - test/misc/live_feed_test.rb
190
169
  - test/misc/misc.rb
191
- - test/neighbor/add_path_cap_test.rb
192
- - test/neighbor/neighbor_test.rb
193
- - test/nlris/ext_nlri_test.rb
194
- - test/nlris/inet_test.rb
195
- - test/nlris/labeled_test.rb
196
- - test/nlris/nlri_test.rb
197
- - test/nlris/rd_test.rb
198
- - test/optional_parameters/add_path_test.rb
199
- - test/optional_parameters/as4_test.rb
200
- - test/optional_parameters/capability_test.rb
201
- - test/optional_parameters/dynamic_test.rb
202
- - test/optional_parameters/graceful_restart_test.rb
203
- - test/optional_parameters/mbgp_test.rb
204
- - test/optional_parameters/optional_parameter_test.rb
205
- - test/optional_parameters/orf_test.rb
206
- - test/optional_parameters/route_refresh_test.rb
207
- - test/orfs/prefix_orf_test.rb
208
- - test/path_attributes/aggregator_test.rb
209
- - test/path_attributes/as_path_test.rb
210
- - test/path_attributes/atomic_aggregate_test.rb
211
- - test/path_attributes/attribute_test.rb
212
- - test/path_attributes/cluster_list_test.rb
213
- - test/path_attributes/communities_test.rb
214
- - test/path_attributes/extended_communities_test.rb
215
- - test/path_attributes/extended_community_test.rb
216
- - test/path_attributes/local_pref_test.rb
217
- - test/path_attributes/mp_reach_test.rb
218
- - test/path_attributes/mp_unreach_test.rb
219
- - test/path_attributes/multi_exit_disc_test.rb
220
- - test/path_attributes/next_hop_test.rb
221
- - test/path_attributes/origin_test.rb
222
- - test/path_attributes/originator_id_test.rb
223
- - test/path_attributes/path_attribute_test.rb
170
+ - test/unit/common_test.rb
171
+ - test/unit/iana_test.rb
172
+ - test/unit/messages/capability_test.rb
173
+ - test/unit/messages/keepalive_test.rb
174
+ - test/unit/messages/markers_test.rb
175
+ - test/unit/messages/message_test.rb
176
+ - test/unit/messages/notification_test.rb
177
+ - test/unit/messages/open_test.rb
178
+ - test/unit/messages/route_refresh_test.rb
179
+ - test/unit/messages/update_test.rb
180
+ - test/unit/neighbor/add_path_cap_test.rb
181
+ - test/unit/neighbor/neighbor_test.rb
182
+ - test/unit/nlris/inet_test.rb
183
+ - test/unit/nlris/label_test.rb
184
+ - test/unit/nlris/labeled_test.rb
185
+ - test/unit/nlris/nlri_test.rb
186
+ - test/unit/nlris/nsap_test.rb
187
+ - test/unit/nlris/prefix_test.rb
188
+ - test/unit/nlris/rd_test.rb
189
+ - test/unit/optional_parameters/add_path_test.rb
190
+ - test/unit/optional_parameters/as4_test.rb
191
+ - test/unit/optional_parameters/capability_test.rb
192
+ - test/unit/optional_parameters/dynamic_test.rb
193
+ - test/unit/optional_parameters/graceful_restart_test.rb
194
+ - test/unit/optional_parameters/mbgp_test.rb
195
+ - test/unit/optional_parameters/optional_parameter_test.rb
196
+ - test/unit/optional_parameters/orf_test.rb
197
+ - test/unit/optional_parameters/route_refresh_test.rb
198
+ - test/unit/orfs/prefix_orf_test.rb
199
+ - test/unit/path_attributes/aggregator_test.rb
200
+ - test/unit/path_attributes/aigp.rb
201
+ - test/unit/path_attributes/as_path_test.rb
202
+ - test/unit/path_attributes/atomic_aggregate_test.rb
203
+ - test/unit/path_attributes/attribute_test.rb
204
+ - test/unit/path_attributes/cluster_list_test.rb
205
+ - test/unit/path_attributes/communities_test.rb
206
+ - test/unit/path_attributes/extended_communities_test.rb
207
+ - test/unit/path_attributes/extended_community_test.rb
208
+ - test/unit/path_attributes/local_pref_test.rb
209
+ - test/unit/path_attributes/mp_reach_test.rb
210
+ - test/unit/path_attributes/mp_unreach_test.rb
211
+ - test/unit/path_attributes/multi_exit_disc_test.rb
212
+ - test/unit/path_attributes/next_hop_test.rb
213
+ - test/unit/path_attributes/origin_test.rb
214
+ - test/unit/path_attributes/originator_id_test.rb
215
+ - test/unit/path_attributes/path_attribute_test.rb
@@ -1,82 +0,0 @@
1
-
2
- require 'bgp4r'
3
- require 'timeout'
4
-
5
- Thread.abort_on_exception=true
6
-
7
-
8
- include BGP
9
-
10
- Log.create
11
- Log.level=Logger::DEBUG
12
-
13
- N100 = Class.new(BGP::Neighbor)
14
-
15
- class RecvMsgHandler
16
- def initialize(q)
17
- @q = q
18
- end
19
- def update(bgp_msg)
20
- @q.enq bgp_msg
21
- end
22
- end
23
-
24
- def setup
25
- @n100 = N100.new(:my_as=> 100, :remote_addr => '40.0.0.2', :local_addr => '40.0.0.1', :id=> '13.11.19.59')
26
- start_peering
27
- end
28
-
29
- def test_verify_missing_well_known_attribute_is_greeting_with_a_notification_from_as200
30
- queue = Queue.new
31
- @n100.add_observer RecvMsgHandler.new(queue)
32
- @n100.send_message malformed_update
33
- msg = recv(queue)
34
- end
35
-
36
- def teardown
37
- @n100.stop
38
- sleep(0.5)
39
- end
40
-
41
- private
42
-
43
- def start_peering
44
- @n100.capability :as4_byte
45
- @n100.start
46
- end
47
-
48
- def recv(q, timeout=5)
49
- begin
50
- Timeout::timeout(timeout) do |t|
51
- msg = q.deq
52
- end
53
- rescue Timeout::Error => e
54
- nil
55
- end
56
- end
57
-
58
- def malformed_update
59
- update = Update.new(
60
- Path_attribute.new(
61
- Origin.new(0),
62
- Multi_exit_disc.new(100),
63
- Local_pref.new(100),
64
- As_path.new(100)
65
- ),
66
- Nlri.new('77.0.0.0/17', '78.0.0.0/18', '79.0.0.0/19')
67
- )
68
- end
69
-
70
- setup
71
- p @n100.inspect
72
- p @n100.inspect
73
- p @n100.inspect
74
- p @n100.inspect
75
- p @n100.inspect
76
- p @n100.inspect
77
- p @n100.inspect
78
- p @n100.inspect
79
- p @n100.instance_eval { @cap }
80
-
81
- test_verify_missing_well_known_attribute_is_greeting_with_a_notification_from_as200
82
- teardown
@@ -1,82 +0,0 @@
1
- require "test/unit"
2
- require 'bgp4r'
3
- require 'timeout'
4
-
5
- Thread.abort_on_exception=true
6
-
7
- include BGP
8
-
9
- Log.create
10
- Log.level=Logger::DEBUG
11
-
12
- N100 = Class.new(BGP::Neighbor)
13
- N300 = Class.new(BGP::Neighbor)
14
-
15
- class RecvMsgHandler
16
- def initialize(q)
17
- @q = q
18
- end
19
- def update(bgp_msg)
20
- @q.enq bgp_msg
21
- end
22
- end
23
-
24
- def setup
25
- @n100 = N100.new(:my_as=> 100, :remote_addr => '40.0.0.2', :local_addr => '40.0.0.1', :id=> '13.11.19.59')
26
- @n300 = N300.new(:my_as=> 300, :remote_addr => '40.0.1.1', :local_addr => '40.0.1.2', :id=> '13.11.19.57')
27
- start_peering
28
- end
29
-
30
- def test_verify_that_200_is_prepended_to_aspath
31
- queue = Queue.new
32
- @n300.add_observer RecvMsgHandler.new(queue)
33
- send_update_to @n100
34
- msg = recv(queue)
35
- puts msg
36
- end
37
-
38
- def teardown
39
- [@n100, @n300].each { |n| n.stop }
40
- sleep(0.5)
41
- end
42
-
43
- private
44
-
45
- def start_peering
46
- [@n100, @n300].each { |n|
47
- n.capability :as4_byte
48
- n.start
49
- }
50
- end
51
-
52
- def recv(q, timeout=5)
53
- begin
54
- Timeout::timeout(timeout) do |t|
55
- msg = q.deq
56
- end
57
- rescue Timeout::Error => e
58
- nil
59
- end
60
- end
61
-
62
- def update1
63
- update = Update.new(
64
- Path_attribute.new(
65
- Origin.new(0),
66
- Next_hop.new('40.0.0.1'),
67
- Multi_exit_disc.new(100),
68
- Local_pref.new(100),
69
- As_path.new(100),
70
- Communities.new('1311:1 311:59 2805:64')
71
- ),
72
- Nlri.new('77.0.0.0/17', '78.0.0.0/18', '79.0.0.0/19')
73
- )
74
- end
75
-
76
- def send_update_to(n)
77
- n.send_message update1
78
- end
79
-
80
- setup
81
- test_verify_that_200_is_prepended_to_aspath
82
-
@@ -1,44 +0,0 @@
1
-
2
- require 'bgp4r'
3
- require 'test/helpers/server'
4
-
5
- include BGP
6
- include BGP::OPT_PARM::CAP
7
- include BGP::TestHelpers
8
-
9
- def test_start
10
- start_server(3456)
11
- @c = Neighbor.new(4, 100, 180, '0.0.0.2', '127.0.0.1', '127.0.0.1')
12
- @c.start :port=> 3456
13
- end
14
-
15
- def test_start_no_blocking
16
- start_server(3333)
17
- @c = Neighbor.new(4, 100, 180, '0.0.0.2', '127.0.0.1', '127.0.0.1')
18
- @c.start :port=> 3333, :no_blocking=>true
19
- assert_equal('OpenSent', @c.state)
20
- assert_match(/(Active|OpenSent)/, @s.state)
21
- stop_server
22
- end
23
-
24
- def test_send_and_receive_path_id_afi_1_safi_1
25
- server_add_path_cap = BGP::OPT_PARM::CAP::Add_path.new
26
- server_add_path_cap.add(:send_and_recv, 1, 1)
27
- start_server(3456, server_add_path_cap)
28
- @c = Neighbor.new(4, 100, 180, '0.0.0.2', '127.0.0.1', '127.0.0.1')
29
- @c.add_cap server_add_path_cap
30
- @c.start :port=> 3456
31
- assert @s.session_info.recv_inet_unicast?,
32
- "Should have the capability to recv inet unicast reachability path info."
33
- assert @s.session_info.send_inet_unicast?,
34
- "Should have the capability to send inet unicast reachability path info."
35
- assert @c.session_info.recv_inet_unicast?,
36
- "Should have the capability to recv inet unicast reachability path info."
37
- assert @c.session_info.send_inet_unicast?,
38
- "Should have the capability to send inet unicast reachability path info."
39
- stop_server
40
- end
41
-
42
- start_server(3456)
43
- @c = Neighbor.new(4, 100, 180, '0.0.0.2', '127.0.0.1', '127.0.0.1')
44
- @c.start :port=> 3456
@@ -1,32 +0,0 @@
1
- require "test/unit"
2
-
3
- require "bgp/nlris/nlri"
4
- require "bgp/nlris/inet"
5
- require "bgp/nlris/vpn"
6
- require "bgp/nlris/labeled"
7
- require "bgp/nlris/rd"
8
-
9
- class TestExtNlri < Test::Unit::TestCase
10
- include BGP
11
- def test_ext_nlri
12
- ext_nlri = Ext_Nlri.new(100, Nlri.new('10.0.0.0/8'))
13
- assert_equal '00000064080a', ext_nlri.to_shex
14
- assert_equal '00000064080a', Ext_Nlri.new_ntop(ext_nlri.encode).to_shex
15
- assert_equal '00000001200a0a0a0a', Ext_Nlri.new_ntop(['00000001200a0a0a0a'].pack('H*')).to_shex
16
- end
17
- def _test_ext_nlris
18
- ext_nlri = Ext_Nlri.new(100, Nlri.new('10.0.0.0/8','20.0.0.0/8'))
19
- assert_equal '00000064080a', ext_nlri.to_shex
20
- assert_equal '00000064080a', Ext_Nlri.new_ntop(ext_nlri.encode).to_shex
21
- end
22
- def test_ext_inet
23
- assert_equal '0000006410c0a8', Ext_Nlri.new(100, Inet_multicast.new('192.168.0.0/16')).to_shex
24
- assert_equal '00000064402011131100000000', Ext_Nlri.new(100, Inet_multicast.new('2011:1311::/64')).to_shex
25
- end
26
- def test_ext_labeled
27
- assert_equal '00000064600000100000200000310a0000', Ext_Nlri.new(100, Labeled.new(Prefix.new('10.0.0.1/24'),1,2,3)).to_shex
28
- assert_equal '00000064800006500006610000006400000064c0a8', Ext_Nlri.new(100, Labeled.new(Vpn.new('192.168.0.0/16', Rd.new(100,100)),101,102)).to_shex
29
- assert_equal '00000064b80006500006600006710000006400000064200900040005', Ext_Nlri.new(100, Labeled.new(Vpn.new('2009:4:5::1/48', Rd.new(100,100)),101,102,103)).to_shex
30
- assert_match(/ID=100, Label Stack=101/, Ext_Nlri.new(100, Labeled.new(Vpn.new('2009:4:5::1/48', Rd.new(100,100)),101,102,103)).to_s)
31
- end
32
- end
@@ -1,130 +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 'test/unit'
24
- require 'bgp/nlris/nlris'
25
-
26
- class Nlri_Test < Test::Unit::TestCase
27
- include BGP
28
- def test_ip4_element
29
- el = Base_nlri::Ip4.new('10.0.0.8/9')
30
- assert_equal('10.0.0.0/9', el.to_s)
31
- assert_equal('070a', Base_nlri::Ip4.new('10.0.0.8/7').to_shex)
32
- assert_equal('080a', Base_nlri::Ip4.new('10.0.0.8/8').to_shex)
33
- assert_equal('090a00', Base_nlri::Ip4.new('10.0.0.8/9').to_shex)
34
- assert_equal('0f0a00', Base_nlri::Ip4.new('10.0.0.8/15').to_shex)
35
- assert_equal('100a00', Base_nlri::Ip4.new('10.0.0.8/16').to_shex)
36
- assert_equal('110a0000', Base_nlri::Ip4.new('10.0.0.8/17').to_shex)
37
- assert_equal('170a0000', Base_nlri::Ip4.new('10.0.0.8/23').to_shex)
38
- assert_equal('180a0000', Base_nlri::Ip4.new('10.0.0.8/24').to_shex)
39
- assert_equal('190a000000', Base_nlri::Ip4.new('10.0.0.8/25').to_shex)
40
- assert_equal('200a000008', Base_nlri::Ip4.new('10.0.0.8/32').to_shex)
41
- end
42
- def test_ext_element
43
- assert_equal('ID: 100, 10.0.0.0/7', Base_nlri::Ext_Nlri_element.new(100, '10.0.0.0/7').to_s)
44
- assert_equal('00000064070a', Base_nlri::Ext_Nlri_element.new(100, '10.0.0.0/7').to_shex)
45
- assert_equal('00000064190a000000', Base_nlri::Ext_Nlri_element.new(100, '10.0.0.0/25').to_shex)
46
- sbin = Base_nlri::Ext_Nlri_element.new(100, '10.0.0.0/25').encode
47
- assert_equal('00000064190a000000', Base_nlri::Ext_Nlri_element.new(sbin).to_shex)
48
- sbin = ['000000650764000000660766000000670766000000680768000000690869'].pack('H*')
49
- Base_nlri::Ext_Nlri_element.new(sbin)
50
- assert_equal('000000660766000000670766000000680768000000690869', sbin.unpack('H*')[0])
51
- Base_nlri::Ext_Nlri_element.new(sbin)
52
- assert_equal('000000670766000000680768000000690869', sbin.unpack('H*')[0])
53
- Base_nlri::Ext_Nlri_element.new(sbin)
54
- assert_equal('000000680768000000690869', sbin.unpack('H*')[0])
55
- Base_nlri::Ext_Nlri_element.new(sbin)
56
- assert_equal('000000690869', sbin.unpack('H*')[0])
57
- Base_nlri::Ext_Nlri_element.new(sbin)
58
- assert_equal('', sbin.unpack('H*')[0])
59
-
60
- # sbin=['0f140010140011140000'].pack('H*')
61
- # Base_nlri::Nlri_element.new(sbin)
62
- # assert_equal('', sbin.unpack('H*')[0])
63
-
64
-
65
- end
66
- def test_nlri
67
- nlri1 = Nlri.new
68
- nlri1 << Base_nlri::Ip4.new('20.0.0.0/15')
69
- nlri1 << '20.0.0.0/17'
70
- nlri1 << '20.0.0.0/24'
71
- s = '0f140010140011140000'
72
- nlri2 = Nlri.new([s].pack('H*'))
73
- assert_equal('0f140010140011140000', nlri2.to_shex)
74
- assert_raise(ArgumentError) { nlri2.to_shex(true) }
75
- assert_equal(3,nlri2.nlris.size)
76
- end
77
- def test_nlris
78
- nlri = Nlri.new
79
- nlri << [101, '101.0.0.0/8']
80
- nlri << [102, '102.0.0.0/8']
81
- nlri << [103, '103.0.0.0/8']
82
- nlri << { :path_id=> 104, :nlri_element=> '104.0.0.0/8' }
83
- nlri << { :path_id=> 105, :nlri_element=> '105.0.0.0/8' }
84
- assert_match(/ID: 102, 102.0/, nlri.to_s)
85
- assert_match(/ID: 104, 104.0/, nlri.to_s)
86
- assert_match(/ID: 105, 105.0/, nlri.to_s)
87
- end
88
- def test_withdrawns_ext
89
- nlri = Withdrawn.new
90
- nlri << [101, '101.0.0.0/8']
91
- nlri << [102, '102.0.0.0/8']
92
- nlri << [103, '103.0.0.0/8']
93
- nlri << { :path_id=> 104, :nlri_element=> '104.0.0.0/8' }
94
- nlri << { :path_id=> 105, :nlri_element=> '105.0.0.0/8' }
95
- assert_match(/ID: 102, 102.0/, nlri.to_s)
96
- assert_match(/ID: 104, 104.0/, nlri.to_s)
97
- assert_match(/ID: 105, 105.0/, nlri.to_s)
98
- end
99
- def test_withdrawns
100
- nlri = Withdrawn.new
101
- nlri << '101.0.0.0/8'
102
- nlri << '102.0.0.0/8'
103
- nlri << '103.0.0.0/8'
104
- assert_equal('086508660867', nlri.to_shex)
105
- assert_match(/102.0/, nlri.to_s)
106
- assert_match(/103.0/, nlri.to_s)
107
- nlri1 = Withdrawn.new nlri.encode[2..-1].is_packed
108
- nlri2 = Nlri.factory nlri.encode[2..-1].is_packed, 1, 1
109
- assert_equal(nlri1.to_shex, nlri2.to_shex)
110
-
111
- # 16d403741755c68816d40830
112
- end
113
-
114
- def test_factory_ip4_elements
115
- s = '07640766076607680869'
116
- nlri = Nlri.factory([s].pack('H*'),1,1)
117
- s = '0f140010140011140000'
118
- nlri = Nlri.factory([s].pack('H*'),1,1)
119
- assert_equal("20.0.0.0/15\n20.0.0.0/16\n20.0.0.0/17", nlri.to_s)
120
- assert_equal(s, nlri.to_shex)
121
- end
122
- def test_factory_ip4_elements_extented
123
- s = '000000650764000000660766000000670766000000680768000000690869'
124
- nlri = Nlri.factory([s].pack('H*'),1,1,true)
125
- assert_match(/ID: 102, 102.0/, nlri.to_s)
126
- assert_match(/ID: 104, 104.0/, nlri.to_s)
127
- assert_match(/ID: 105, 105.0/, nlri.to_s)
128
- assert_equal(s, nlri.to_shex)
129
- end
130
- end