bgp4r 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bgp4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
5
- prerelease:
4
+ version: 0.0.16
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jean-Michel Esnault
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-13 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: BGP4R is a BGP-4 ruby library to create, send, and receive BGP messages
15
14
  in an object oriented manner
@@ -47,6 +46,7 @@ files:
47
46
  - bgp/nlris/prefix.rb
48
47
  - bgp/nlris/rd.rb
49
48
  - bgp/nlris/vpn.rb
49
+ - bgp/nlris/mapped_ipv4.rb
50
50
  - bgp/optional_parameters/add_path.rb
51
51
  - bgp/optional_parameters/as4.rb
52
52
  - bgp/optional_parameters/capabilities.rb
@@ -87,6 +87,7 @@ files:
87
87
  - examples/unit-testing/no_export_test.rb
88
88
  - examples/unit-testing/prepend_aspath_test.rb
89
89
  - examples/unit-testing/unknown_transitive_attr_test.rb
90
+ - examples/bgp-vyatta-ipv6.rb
90
91
  - test/functional/add_path_test.rb
91
92
  - test/functional/live_feed_test.rb
92
93
  - test/helpers/server.rb
@@ -111,6 +112,7 @@ files:
111
112
  - test/unit/nlris/prefix_test.rb
112
113
  - test/unit/nlris/rd_test.rb
113
114
  - test/unit/nlris/vpn_test.rb
115
+ - test/unit/nlris/mapped_ipv4_test.rb
114
116
  - test/unit/optional_parameters/add_path_test.rb
115
117
  - test/unit/optional_parameters/as4_test.rb
116
118
  - test/unit/optional_parameters/capability_test.rb
@@ -138,29 +140,26 @@ files:
138
140
  - test/unit/path_attributes/origin_test.rb
139
141
  - test/unit/path_attributes/originator_id_test.rb
140
142
  - test/unit/path_attributes/path_attribute_test.rb
141
- - test/unit/path_attributes/tunnel_encapsulation_test (Jean-Michel's Laptop's conflicted
142
- copy 2011-11-02).rb
143
143
  homepage: http://github.com/jesnault/bgp4r/tree/master
144
144
  licenses: []
145
+ metadata: {}
145
146
  post_install_message:
146
147
  rdoc_options: []
147
148
  require_paths:
148
149
  - .
149
150
  required_ruby_version: !ruby/object:Gem::Requirement
150
- none: false
151
151
  requirements:
152
152
  - - ! '>='
153
153
  - !ruby/object:Gem::Version
154
154
  version: 1.8.6
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
- none: false
157
156
  requirements:
158
157
  - - ! '>='
159
158
  - !ruby/object:Gem::Version
160
159
  version: '0'
161
160
  requirements: []
162
161
  rubyforge_project: bgp4r
163
- rubygems_version: 1.8.11
162
+ rubygems_version: 2.0.3
164
163
  signing_key:
165
164
  specification_version: 3
166
165
  summary: A BGP-4 Ruby Library
@@ -216,5 +215,3 @@ test_files:
216
215
  - test/unit/path_attributes/origin_test.rb
217
216
  - test/unit/path_attributes/originator_id_test.rb
218
217
  - test/unit/path_attributes/path_attribute_test.rb
219
- - test/unit/path_attributes/tunnel_encapsulation_test (Jean-Michel's Laptop's conflicted
220
- copy 2011-11-02).rb
@@ -1,388 +0,0 @@
1
- require "test/unit"
2
- require "bgp/path_attributes/tunnel_encapsulation"
3
- require 'bgp4r'
4
- require 'test/helpers/server'
5
-
6
-
7
- class TestTunnelEncapsulation < Test::Unit::TestCase
8
- include BGP
9
-
10
- class TestColor < Test::Unit::TestCase
11
- include BGP
12
- def test_case_name
13
- color = Tunnel_encapsulation::Color.new(10)
14
- assert_equal('0408030b00000000000a',color.to_shex)
15
- assert_equal(4, color.stlv_type)
16
- end
17
- end
18
-
19
- class TestProtocolTYpe < Test::Unit::TestCase
20
- include BGP
21
- def test_case_name
22
- protocol_type = Tunnel_encapsulation::Protocol_type.new :ipv4
23
- assert_equal('02020800', protocol_type.to_shex)
24
- assert_equal(2, protocol_type.stlv_type)
25
- assert_equal('020286dd', Tunnel_encapsulation::Protocol_type.new(:ipv6).to_shex)
26
- assert_equal('02028847', Tunnel_encapsulation::Protocol_type.new(:mpls).to_shex)
27
- end
28
- end
29
-
30
- class TestEncapsulationGre < Test::Unit::TestCase
31
- include BGP
32
- def test_case_name
33
- encap = Tunnel_encapsulation::Encap_gre.new(0x12345678)
34
- assert_equal('010412345678', encap.to_shex)
35
- end
36
- end
37
-
38
- class TestEncapsulationL2tpv3 < Test::Unit::TestCase
39
- include BGP
40
- def test_case_name
41
- encap = Tunnel_encapsulation::Encap_l2tpv3.new(0x1234, '1234567890123456789')
42
- assert_equal('010e0000123412345678901234567890', encap.to_shex)
43
- end
44
- end
45
-
46
- class TestTunnel < Test::Unit::TestCase
47
- include BGP
48
- def test_case_name
49
- tlv = Tunnel_encapsulation::Tunnel.new(:tunnel_type=> :l2tpv3, :session_id=> 1, :cookie=> 'ffddeeaabb11ee3344', :proto_type=> :ipv4, :color=> 1234)
50
- assert_equal('0001001d010d00000001ffddeeaabb11ee3344020208000408030b0000000004d2', tlv.to_shex)
51
- end
52
- end
53
-
54
-
55
- def test_case_name
56
- tunnel_encap = Tunnel_encapsulation.new
57
- assert_equal('c01700', tunnel_encap.to_shex)
58
- tunnel_encap.add :tunnel_type=> :l2tpv3, :session_id=> 1, :coockie=> 0x1234, :proto_type=> :ipv4, :color=> 1234
59
- assert_equal('c01718 0001 0014 01 04 00000001 02 02 0800 04 08 030b0000000004d2'.split.join, tunnel_encap.to_shex)
60
- tunnel_encap.add :tunnel_type=> :l2tpv3, :session_id=> 2, :coockie=> 0x1234, :proto_type=> :ipv6, :color=> 1234
61
- assert_equal('c0173000010014010400000001020208000408030b0000000004d200010014010400000002020286dd0408030b0000000004d2'.split.join, tunnel_encap.to_shex)
62
- tunnel_encap.add :tunnel_type=> :l2tpv3, :session_id=> 3, :coockie=> 0x1234, :proto_type=> :mpls, :color=> 1234
63
- assert_equal('c0174800010014010400000001020208000408030b0000000004d200010014010400000002020286dd0408030b0000000004d200010014010400000003020288470408030b0000000004d2'.split.join, tunnel_encap.to_shex)
64
- tunnel_encap.add :tunnel_type=> :gre, :key=> 0x12345678
65
- assert_equal('c0175200010014010400000001020208000408030b0000000004d200010014010400000002020286dd0408030b0000000004d200010014010400000003020288470408030b0000000004d200020006010412345678', tunnel_encap.to_shex)
66
- end
67
- include BGP::TestHelpers
68
-
69
- # def teardown
70
- # stop_server
71
- # end
72
-
73
- # def test_send_update_with_tunnel_encap_attribute
74
- #
75
- # start_server(179)
76
- #
77
- # @c = Neighbor.new(4, 100, 180, '0.0.0.2', '127.0.0.1', '127.0.0.1')
78
- # @c.start :port=> 179
79
- # assert_equal('Established', @c.state)
80
- # assert_equal('Established', @s.state)
81
- #
82
- # tunnel_encap = Tunnel_encapsulation.new
83
- # tunnel_encap.add :tunnel_type=> :l2tpv3, :session_id=> 1, :coockie=> 0x1234, :proto_type=> :ipv4, :color=> 1234
84
- # tunnel_encap.add :tunnel_type=> :l2tpv3, :session_id=> 2, :coockie=> 0x1234, :proto_type=> :ipv6, :color=> 1234
85
- # tunnel_encap.add :tunnel_type=> :l2tpv3, :session_id=> 3, :coockie=> 0x1234, :proto_type=> :mpls, :color=> 1234
86
- # tunnel_encap.add :tunnel_type=> :gre, :key=> 0x12345678
87
- #
88
- # u = Update.new
89
- # u << tunnel_encap
90
- #
91
- # @c.send_message u
92
- # @c.send_message u
93
- # @c.send_message u
94
- # @c.send_message u
95
- # @c.send_message u
96
- # sleep 2
97
- #
98
- # end
99
-
100
-
101
-
102
- end
103
-
104
-
105
- __END__
106
-
107
- tunnels=[]
108
-
109
-
110
-
111
-
112
- Tunnel Type
113
- L2TPV3 =1
114
- GRE = 2
115
- IPIP = 7
116
-
117
-
118
- tunnel_encap attr:
119
-
120
- tlv type 1:
121
- value:
122
- stlv-type 1 : session_id + coockie
123
- stlv-proto-type 2 : ipv4 0x0800
124
- stlv-color 4 : 0x1234
125
-
126
-
127
- tlv type 1:
128
- value:
129
- stlv-type 1: session_id + coockie
130
- stlv-proto-type 2 : ipv6 0x86dd
131
- stlv-color 4 : 0x1234
132
-
133
- tlv type 1:
134
- value:
135
- stlv-type 1: session_id + coockie
136
- stlv-proto-type 2 : mpls 0x8847
137
- stlv-color 4 : 0x1234
138
-
139
-
140
-
141
- tlv type 2: (gre)
142
- value:
143
- stlv-type 1: gre key (4)
144
-
145
-
146
-
147
-
148
-
149
-
150
- sub-tlv: session_id + coockie
151
-
152
-
153
- For example, if we want to use three L2TPv3 sessions, one carrying
154
- IPv4 packets, one carrying IPv6 packets, and one carrying MPLS
155
- packets, the egress router will include three TLVs of L2TPv3
156
- encapsulation type, each specifying a different Session ID and a
157
- different payload type. The protocol type sub-TLV for these will be
158
- IPv4 (protocol type = 0x0800), IPv6 (protocol type = 0x86dd), and
159
- MPLS (protocol type = 0x8847), respectively. This informs the
160
- ingress routers of the appropriate encapsulation information to use
161
- with each of the given protocol types. Insertion of the specified
162
- Session ID at the ingress routers allows the egress to process the
163
- incoming packets correctly, according to their protocol type.
164
-
165
-
166
-
167
- TLVs
168
-
169
- L2TPv3 type = 1
170
- GRE = 2
171
- IP in IP = 7
172
-
173
- Sub-TLVs
174
-
175
- - Encapsulation: sub-TLV type = 1
176
-
177
- encap_l2tpv3 : session_id(4) + coockie(v)
178
- encap_gre: key(4)
179
-
180
- - Protocol type: sub-TLV tye =2
181
-
182
- ethertype(2)
183
-
184
- For example, if we want to use three L2TPv3 sessions, one carrying
185
- IPv4 packets, one carrying IPv6 packets, and one carrying MPLS
186
- packets, the egress router will include three TLVs of L2TPv3
187
- encapsulation type, each specifying a different Session ID and a
188
- different payload type. The protocol type sub-TLV for these will be
189
- IPv4 (protocol type = 0x0800), IPv6 (protocol type = 0x86dd), and
190
- MPLS (protocol type = 0x8847), respectively. This informs the
191
- ingress routers of the appropriate encapsulation information to use
192
- with each of the given protocol types. Insertion of the specified
193
- Session ID at the ingress routers allows the egress to process the
194
- incoming packets correctly, according to their protocol type.
195
-
196
- Inclusion of this sub-TLV depends on the tunnel type. It MUST be
197
- encoded for L2TPv3 tunnel type. On the other hand, the protocol type
198
- sub-TLV is not required for IP in IP or GRE tunnels.
199
-
200
-
201
- - Protocol type: sub-TLV type = 2
202
- - Color: sub-TLV type = 4
203
-
204
-
205
-
206
- 4. Tunnel Encapsulation Attribute
207
-
208
- The Tunnel Encapsulation attribute is an optional transitive
209
- attribute that is composed of a set of Type-Length-Value (TLV)
210
- encodings. The type code of the attribute is 23. Each TLV contains
211
- information corresponding to a particular tunnel technology. The TLV
212
- is structured as follows:
213
-
214
- 0 1 2 3
215
- 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
216
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
217
- | Tunnel Type (2 Octets) | Length (2 Octets) |
218
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
219
- | |
220
- | Value |
221
- | |
222
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
223
-
224
- * Tunnel Type (2 octets): identifies the type of tunneling technology
225
- being signaled. This document defines the following types:
226
-
227
- - L2TPv3 over IP [RFC3931]: Tunnel Type = 1
228
- - GRE [RFC2784]: Tunnel Type = 2
229
- - IP in IP [RFC2003] [RFC4213]: Tunnel Type = 7
230
-
231
- Unknown types are to be ignored and skipped upon receipt.
232
-
233
- * Length (2 octets): the total number of octets of the value field.
234
-
235
- * Value (variable): comprised of multiple sub-TLVs. Each sub-TLV
236
- consists of three fields: a 1-octet type, 1-octet length, and zero
237
- or more octets of value. The sub-TLV is structured as follows:
238
-
239
-
240
-
241
-
242
- Mohapatra & Rosen Standards Track [Page 5]
243
-
244
- RFC 5512 BGP Encapsulation SAFI and Tunnel Encapsulation April 2009
245
-
246
-
247
- +-----------------------------------+
248
- | Sub-TLV Type (1 Octet) |
249
- +-----------------------------------+
250
- | Sub-TLV Length (1 Octet) |
251
- +-----------------------------------+
252
- | Sub-TLV Value (Variable) |
253
- | |
254
- +-----------------------------------+
255
-
256
- * Sub-TLV Type (1 octet): each sub-TLV type defines a certain
257
- property about the tunnel TLV that contains this sub-TLV. The
258
- following are the types defined in this document:
259
-
260
- - Encapsulation: sub-TLV type = 1
261
- - Protocol type: sub-TLV type = 2
262
- - Color: sub-TLV type = 4
263
-
264
- When the TLV is being processed by a BGP speaker that will be
265
- performing encapsulation, any unknown sub-TLVs MUST be ignored and
266
- skipped. However, if the TLV is understood, the entire TLV MUST
267
- NOT be ignored just because it contains an unknown sub-TLV.
268
-
269
- * Sub-TLV Length (1 octet): the total number of octets of the sub-TLV
270
- value field.
271
-
272
- * Sub-TLV Value (variable): encodings of the value field depend on
273
- the sub-TLV type as enumerated above. The following sub-sections
274
- define the encoding in detail.
275
-
276
- 4.1. Encapsulation Sub-TLV
277
-
278
- The syntax and semantics of the encapsulation sub-TLV is determined
279
- by the tunnel type of the TLV that contains this sub-TLV.
280
-
281
- When the tunnel type of the TLV is L2TPv3 over IP, the following is
282
- the structure of the value field of the encapsulation sub-TLV:
283
-
284
- 0 1 2 3
285
- 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
286
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
287
- | Session ID (4 octets) |
288
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
289
- | |
290
- | Cookie (Variable) |
291
- | |
292
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
293
-
294
-
295
-
296
-
297
-
298
- Mohapatra & Rosen Standards Track [Page 6]
299
-
300
- RFC 5512 BGP Encapsulation SAFI and Tunnel Encapsulation April 2009
301
-
302
-
303
- * Session ID: a non-zero 4-octet value locally assigned by the
304
- advertising router that serves as a lookup key in the incoming
305
- packet's context.
306
-
307
- * Cookie: an optional, variable length (encoded in octets -- 0 to 8
308
- octets) value used by L2TPv3 to check the association of a received
309
- data message with the session identified by the Session ID.
310
- Generation and usage of the cookie value is as specified in
311
- [RFC3931].
312
-
313
- The length of the cookie is not encoded explicitly, but can be
314
- calculated as (sub-TLV length - 4).
315
-
316
- When the tunnel type of the TLV is GRE, the following is the
317
- structure of the value field of the encapsulation sub-TLV:
318
-
319
- 0 1 2 3
320
- 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
321
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
322
- | GRE Key (4 octets) |
323
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
324
-
325
- * GRE Key: 4-octet field [RFC2890] that is generated by the
326
- advertising router. The actual method by which the key is obtained
327
- is beyond the scope of this document. The key is inserted into the
328
- GRE encapsulation header of the payload packets sent by ingress
329
- routers to the advertising router. It is intended to be used for
330
- identifying extra context information about the received payload.
331
-
332
- Note that the key is optional. Unless a key value is being
333
- advertised, the GRE encapsulation sub-TLV MUST NOT be present.
334
-
335
- 4.2. Protocol Type Sub-TLV
336
-
337
- The protocol type sub-TLV MAY be encoded to indicate the type of the
338
- payload packets that will be encapsulated with the tunnel parameters
339
- that are being signaled in the TLV. The value field of the sub-TLV
340
- contains a 2-octet protocol type that is one of the types defined in
341
- [IANA-AF] as ETHER TYPEs.
342
-
343
- For example, if we want to use three L2TPv3 sessions, one carrying
344
- IPv4 packets, one carrying IPv6 packets, and one carrying MPLS
345
- packets, the egress router will include three TLVs of L2TPv3
346
- encapsulation type, each specifying a different Session ID and a
347
- different payload type. The protocol type sub-TLV for these will be
348
- IPv4 (protocol type = 0x0800), IPv6 (protocol type = 0x86dd), and
349
- MPLS (protocol type = 0x8847), respectively. This informs the
350
- ingress routers of the appropriate encapsulation information to use
351
- with each of the given protocol types. Insertion of the specified
352
- Session ID at the ingress routers allows the egress to process the
353
- incoming packets correctly, according to their protocol type.
354
-
355
- Inclusion of this sub-TLV depends on the tunnel type. It MUST be
356
- encoded for L2TPv3 tunnel type. On the other hand, the protocol type
357
- sub-TLV is not required for IP in IP or GRE tunnels.
358
-
359
- 4.3. Color Sub-TLV
360
-
361
- The color sub-TLV MAY be encoded as a way to color the corresponding
362
- tunnel TLV. The value field of the sub-TLV contains an extended
363
- community that is defined as follows:
364
-
365
- 4.3.1. Color Extended Community
366
-
367
- The Color Extended Community is an opaque extended community
368
- [RFC4360] with the following encoding:
369
-
370
- 0 1 2 3
371
- 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
372
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
373
- | 0x03 | 0x0b | Reserved |
374
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
375
- | Color Value |
376
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
377
-
378
- The value of the high-order octet of the extended type field is 0x03,
379
- which indicates it is transitive. The value of the low-order octet
380
- of the extended type field for this community is 0x0b. The color
381
- value is user defined and configured locally on the routers. The
382
- same Color Extended Community can then be attached to the UPDATE
383
- messages that contain payload prefixes. This way, the BGP speaker
384
- can express the fact that it expects the packets corresponding to
385
- these payload prefixes to be received with a particular tunnel
386
- encapsulation header.
387
-
388
-