pio 0.1.1 → 0.2.1
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.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/Gemfile +3 -2
- data/Guardfile +4 -1
- data/README.md +44 -6
- data/Rakefile +5 -23
- data/lib/pio.rb +15 -0
- data/lib/pio/arp.rb +31 -0
- data/lib/pio/arp/frame.rb +38 -0
- data/lib/pio/arp/message.rb +66 -0
- data/lib/pio/arp/reply.rb +55 -0
- data/lib/pio/arp/request.rb +55 -0
- data/lib/pio/ip.rb +90 -0
- data/lib/pio/lldp.rb +74 -12
- data/lib/pio/lldp/frame.rb +53 -4
- data/lib/pio/lldp/management-address-value.rb +7 -1
- data/lib/pio/lldp/optional-tlv.rb +3 -1
- data/lib/pio/lldp/organizationally-specific-value.rb +23 -0
- data/lib/pio/mac.rb +156 -0
- data/lib/pio/type/ethernet-header.rb +16 -0
- data/lib/pio/type/ip-address.rb +28 -0
- data/lib/pio/{lldp → type}/mac-address.rb +4 -3
- data/lib/pio/version.rb +1 -19
- data/pio.org +518 -0
- data/pio.org_archive +389 -0
- data/spec/pio/arp/reply_spec.rb +150 -0
- data/spec/pio/arp/request_spec.rb +131 -0
- data/spec/pio/arp_spec.rb +136 -0
- data/spec/pio/ip_spec.rb +38 -0
- data/spec/pio/lldp_spec.rb +195 -38
- data/spec/pio/mac_spec.rb +82 -0
- data/spec/spec_helper.rb +9 -0
- metadata +27 -17
- data/spec/pio/lldp/chassis-id-tlv_spec.rb +0 -27
- data/spec/pio/lldp/end-of-lldpdu-value_spec.rb +0 -20
- data/spec/pio/lldp/frame_spec.rb +0 -82
- data/spec/pio/lldp/mac-address_spec.rb +0 -20
- data/spec/pio/lldp/optional-tlv_spec.rb +0 -81
- data/spec/pio/lldp/port-id-tlv_spec.rb +0 -27
- data/spec/pio/lldp/ttl-tlv_spec.rb +0 -26
@@ -0,0 +1,82 @@
|
|
1
|
+
require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
2
|
+
require "pio/mac"
|
3
|
+
|
4
|
+
|
5
|
+
module Pio
|
6
|
+
describe Mac do
|
7
|
+
context ".new" do
|
8
|
+
subject { Mac.new( value ) }
|
9
|
+
|
10
|
+
|
11
|
+
context %{with "11:22:33:44:55:66"} do
|
12
|
+
let( :value ) { "11:22:33:44:55:66" }
|
13
|
+
it { should eq Mac.new( "11:22:33:44:55:66" ) }
|
14
|
+
its( :value ) { should eq 0x112233445566 }
|
15
|
+
its( :to_s ) { should eq "11:22:33:44:55:66" }
|
16
|
+
its( :to_a ) { should eq [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 ] }
|
17
|
+
its( :multicast? ){ should be_true }
|
18
|
+
its( :broadcast? ){ should be_false }
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
context "with 0" do
|
23
|
+
let( :value ) { 0 }
|
24
|
+
it { should eq Mac.new( 0 ) }
|
25
|
+
its( :value ) { should eq 0 }
|
26
|
+
its( :to_s ) { should eq "00:00:00:00:00:00" }
|
27
|
+
its( :to_a ) { should eq [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ] }
|
28
|
+
its( :multicast? ){ should be_false }
|
29
|
+
its( :broadcast? ){ should be_false }
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
context "with 0xffffffffffff" do
|
34
|
+
let( :value ) { 0xffffffffffff }
|
35
|
+
it { should eq Mac.new( 0xffffffffffff ) }
|
36
|
+
its( :value ) { should eq 0xffffffffffff }
|
37
|
+
its( :to_s ) { should eq "ff:ff:ff:ff:ff:ff" }
|
38
|
+
its( :to_a ) { should eq [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ] }
|
39
|
+
its( :multicast? ){ should be_true }
|
40
|
+
its( :broadcast? ){ should be_true }
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
context %{with "INVALID MAC ADDRESS"} do
|
45
|
+
let( :value ) { "INVALID MAC ADDRESS" }
|
46
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
context "with -1" do
|
51
|
+
let( :value ) { -1 }
|
52
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
context "with 0x1000000000000" do
|
57
|
+
let( :value ) { 0x1000000000000 }
|
58
|
+
it { expect { subject }.to raise_error( ArgumentError ) }
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
context "with [ 1, 2, 3 ]" do
|
63
|
+
let( :value ) { [ 1, 2, 3 ] }
|
64
|
+
it { expect { subject }.to raise_error( TypeError ) }
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
context %{with "00:00:00:00:00:01"} do
|
69
|
+
let( :value ) { "00:00:00:00:00:01" }
|
70
|
+
it { expect( subject ).to eql Mac.new( "00:00:00:00:00:01" ) }
|
71
|
+
its( :hash ) { should eq Mac.new( "00:00:00:00:00:01" ).hash }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
### Local variables:
|
79
|
+
### mode: Ruby
|
80
|
+
### coding: utf-8-unix
|
81
|
+
### indent-tabs-mode: nil
|
82
|
+
### End:
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
$LOAD_PATH.unshift File.join( File.dirname( __FILE__ ), "..", "lib" )
|
2
|
+
|
1
3
|
require "rubygems"
|
2
4
|
|
3
5
|
require "simplecov"
|
@@ -7,6 +9,13 @@ require "rspec"
|
|
7
9
|
require "rspec/autorun"
|
8
10
|
|
9
11
|
|
12
|
+
RSpec.configure do | config |
|
13
|
+
config.expect_with :rspec do | c |
|
14
|
+
c.syntax = :expect
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
|
10
19
|
# Requires supporting files with custom matchers and macros, etc,
|
11
20
|
# in ./support/ and its subdirectories.
|
12
21
|
Dir[ "#{ File.dirname( __FILE__ ) }/support/**/*.rb" ].each do | each |
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yasuhito Takamiya
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bindata
|
@@ -33,35 +33,47 @@ extra_rdoc_files:
|
|
33
33
|
- README.md
|
34
34
|
files:
|
35
35
|
- .gitignore
|
36
|
+
- .rspec
|
36
37
|
- .travis.yml
|
37
38
|
- Gemfile
|
38
39
|
- Guardfile
|
39
40
|
- LICENSE
|
40
41
|
- README.md
|
41
42
|
- Rakefile
|
43
|
+
- lib/pio.rb
|
44
|
+
- lib/pio/arp.rb
|
45
|
+
- lib/pio/arp/frame.rb
|
46
|
+
- lib/pio/arp/message.rb
|
47
|
+
- lib/pio/arp/reply.rb
|
48
|
+
- lib/pio/arp/request.rb
|
49
|
+
- lib/pio/ip.rb
|
42
50
|
- lib/pio/lldp.rb
|
43
51
|
- lib/pio/lldp/chassis-id-tlv.rb
|
44
52
|
- lib/pio/lldp/end-of-lldpdu-value.rb
|
45
53
|
- lib/pio/lldp/frame.rb
|
46
|
-
- lib/pio/lldp/mac-address.rb
|
47
54
|
- lib/pio/lldp/management-address-value.rb
|
48
55
|
- lib/pio/lldp/optional-tlv.rb
|
56
|
+
- lib/pio/lldp/organizationally-specific-value.rb
|
49
57
|
- lib/pio/lldp/port-description-value.rb
|
50
58
|
- lib/pio/lldp/port-id-tlv.rb
|
51
59
|
- lib/pio/lldp/system-capabilities-value.rb
|
52
60
|
- lib/pio/lldp/system-description-value.rb
|
53
61
|
- lib/pio/lldp/system-name-value.rb
|
54
62
|
- lib/pio/lldp/ttl-tlv.rb
|
63
|
+
- lib/pio/mac.rb
|
64
|
+
- lib/pio/type/ethernet-header.rb
|
65
|
+
- lib/pio/type/ip-address.rb
|
66
|
+
- lib/pio/type/mac-address.rb
|
55
67
|
- lib/pio/version.rb
|
56
68
|
- pio.gemspec
|
57
|
-
-
|
58
|
-
-
|
59
|
-
- spec/pio/
|
60
|
-
- spec/pio/
|
61
|
-
- spec/pio/
|
62
|
-
- spec/pio/
|
63
|
-
- spec/pio/lldp/ttl-tlv_spec.rb
|
69
|
+
- pio.org
|
70
|
+
- pio.org_archive
|
71
|
+
- spec/pio/arp/reply_spec.rb
|
72
|
+
- spec/pio/arp/request_spec.rb
|
73
|
+
- spec/pio/arp_spec.rb
|
74
|
+
- spec/pio/ip_spec.rb
|
64
75
|
- spec/pio/lldp_spec.rb
|
76
|
+
- spec/pio/mac_spec.rb
|
65
77
|
- spec/spec_helper.rb
|
66
78
|
homepage: http://github.com/trema/pio
|
67
79
|
licenses:
|
@@ -88,13 +100,11 @@ signing_key:
|
|
88
100
|
specification_version: 4
|
89
101
|
summary: Packet parser and generator.
|
90
102
|
test_files:
|
91
|
-
- spec/pio/
|
92
|
-
- spec/pio/
|
93
|
-
- spec/pio/
|
94
|
-
- spec/pio/
|
95
|
-
- spec/pio/lldp/optional-tlv_spec.rb
|
96
|
-
- spec/pio/lldp/port-id-tlv_spec.rb
|
97
|
-
- spec/pio/lldp/ttl-tlv_spec.rb
|
103
|
+
- spec/pio/arp/reply_spec.rb
|
104
|
+
- spec/pio/arp/request_spec.rb
|
105
|
+
- spec/pio/arp_spec.rb
|
106
|
+
- spec/pio/ip_spec.rb
|
98
107
|
- spec/pio/lldp_spec.rb
|
108
|
+
- spec/pio/mac_spec.rb
|
99
109
|
- spec/spec_helper.rb
|
100
110
|
has_rdoc:
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
|
2
|
-
require "pio/lldp/chassis-id-tlv"
|
3
|
-
|
4
|
-
|
5
|
-
module Pio
|
6
|
-
class Lldp
|
7
|
-
describe ChassisIdTlv do
|
8
|
-
subject { ChassisIdTlv.read( data.pack( "C*" ) ) }
|
9
|
-
|
10
|
-
context "parsing a raw data" do
|
11
|
-
let( :data ) { [ 0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d ] }
|
12
|
-
|
13
|
-
its( :tlv_type ) { should eq 1 }
|
14
|
-
its( :tlv_info_length ) { should eq 7 }
|
15
|
-
its( :subtype ) { should eq 4 }
|
16
|
-
its( :chassis_id ) { should eq data[ -6..-1 ].pack( "C*" ) }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
### Local variables:
|
24
|
-
### mode: Ruby
|
25
|
-
### coding: utf-8-unix
|
26
|
-
### indent-tabs-mode: nil
|
27
|
-
### End:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
|
2
|
-
require "pio/lldp/end-of-lldpdu-value"
|
3
|
-
|
4
|
-
|
5
|
-
module Pio
|
6
|
-
class Lldp
|
7
|
-
describe EndOfLldpduValue do
|
8
|
-
subject { EndOfLldpduValue.new }
|
9
|
-
|
10
|
-
its( :tlv_info_string ) { should be_empty }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
### Local variables:
|
17
|
-
### mode: Ruby
|
18
|
-
### coding: utf-8-unix
|
19
|
-
### indent-tabs-mode: nil
|
20
|
-
### End:
|
data/spec/pio/lldp/frame_spec.rb
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
|
2
|
-
require "pio/lldp/frame"
|
3
|
-
|
4
|
-
|
5
|
-
module Pio
|
6
|
-
class Lldp
|
7
|
-
describe Frame do
|
8
|
-
it "should parse a minimal LLDP" do
|
9
|
-
sample_packet = [
|
10
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, # Destination MAC
|
11
|
-
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Source MAC
|
12
|
-
0x88, 0xcc, # Ethertype
|
13
|
-
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Chassis ID TLV
|
14
|
-
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x74, 0x6f, 0x20, 0x53, 0x31, # Port ID TLV
|
15
|
-
0x06, 0x02, 0x00, 0x78, # Time to live TLV
|
16
|
-
0x00, 0x00, # End of LLDPDU TLV
|
17
|
-
].pack( "C*" )
|
18
|
-
|
19
|
-
lldp = Frame.read( sample_packet )
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
it "should parse LLDP" do
|
24
|
-
sample_packet = [
|
25
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, # Destination MAC
|
26
|
-
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Source MAC
|
27
|
-
0x88, 0xcc, # Ethertype
|
28
|
-
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Chassis ID TLV
|
29
|
-
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x74, 0x6f, 0x20, 0x53, 0x31, # Port ID TLV
|
30
|
-
0x06, 0x02, 0x00, 0x78, # Time to live TLV
|
31
|
-
0x08, 0x17, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x2d, 0x50, 0x6f, 0x72, 0x74, 0x20, 0x31, 0x30, 0x30, 0x31, 0x00, # Port Description
|
32
|
-
0x0a, 0x0d, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x00, # System Name
|
33
|
-
0x0c, 0x4c, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x20, 0x2d, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x37, 0x2e, 0x34, 0x65, 0x2e, 0x31, 0x20, 0x28, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x35, 0x29, 0x20, 0x62, 0x79, 0x20, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x30, 0x35, 0x2f, 0x32, 0x37, 0x2f, 0x30, 0x35, 0x20, 0x30, 0x34, 0x3a, 0x35, 0x33, 0x3a, 0x31, 0x31, 0x00, # System Description
|
34
|
-
0x0e, 0x04, 0x00, 0x14, 0x00, 0x14, # System Capabilities
|
35
|
-
0x10, 0x0e, 0x07, 0x06, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x02, 0x00, 0x00, 0x03, 0xe9, 0x00, # Management Address
|
36
|
-
0xfe, 0x07, 0x00, 0x12, 0x0f, 0x02, 0x07, 0x01, 0x00,
|
37
|
-
0x00, 0x00, # End of LLDPDU TLV
|
38
|
-
].pack( "C*" )
|
39
|
-
|
40
|
-
lldp = Frame.read( sample_packet )
|
41
|
-
lldp.optional_tlv[ 0 ][ :tlv_type ].should eq 4
|
42
|
-
lldp.optional_tlv[ 1 ][ :tlv_type ].should eq 5
|
43
|
-
lldp.optional_tlv[ 2 ][ :tlv_type ].should eq 6
|
44
|
-
lldp.optional_tlv[ 3 ][ :tlv_type ].should eq 7
|
45
|
-
lldp.optional_tlv[ 4 ][ :tlv_type ].should eq 8
|
46
|
-
lldp.optional_tlv[ 5 ][ :tlv_type ].should eq 0
|
47
|
-
end
|
48
|
-
|
49
|
-
|
50
|
-
it "should create a valid LLDP packet" do
|
51
|
-
# sample packet taken from http://www.cloudshark.org/captures/05a981251df9
|
52
|
-
sample_packet = [
|
53
|
-
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, # Destination MAC
|
54
|
-
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Source MAC
|
55
|
-
0x88, 0xcc, # Ethertype
|
56
|
-
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Chassis ID TLV
|
57
|
-
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x74, 0x6f, 0x20, 0x53, 0x31, # Port ID TLV
|
58
|
-
0x06, 0x02, 0x00, 0x78, # Time to live TLV
|
59
|
-
0x00, 0x00 # End of LLDPDU TLV
|
60
|
-
].pack( "C*" )
|
61
|
-
|
62
|
-
lldp_frame = Frame.new
|
63
|
-
lldp_frame.destination_mac = "01:80:c2:00:00:0e"
|
64
|
-
lldp_frame.source_mac = "00:19:2f:a7:b2:8d"
|
65
|
-
lldp_frame.chassis_id.subtype = 4
|
66
|
-
lldp_frame.chassis_id = "\x00\x19\x2f\xa7\xb2\x8d"
|
67
|
-
lldp_frame.port_id.subtype = 1
|
68
|
-
lldp_frame.port_id = "Uplink to S1"
|
69
|
-
lldp_frame.ttl = 120
|
70
|
-
|
71
|
-
( lldp_frame.to_binary_s.unpack( "H*" )[ 0 ] + "0000" ).should == sample_packet.unpack( "H*" )[ 0 ]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
### Local variables:
|
79
|
-
### mode: Ruby
|
80
|
-
### coding: utf-8-unix
|
81
|
-
### indent-tabs-mode: nil
|
82
|
-
### End:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
|
2
|
-
require "pio/lldp/mac-address"
|
3
|
-
|
4
|
-
|
5
|
-
module Pio
|
6
|
-
class Lldp
|
7
|
-
describe MacAddress do
|
8
|
-
subject { MacAddress.new( "01:80:c2:00:00:0e" ) }
|
9
|
-
|
10
|
-
its( :to_binary_s ) { should eq [ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e ].pack( "C6" ) }
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
### Local variables:
|
17
|
-
### mode: Ruby
|
18
|
-
### coding: utf-8-unix
|
19
|
-
### indent-tabs-mode: nil
|
20
|
-
### End:
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
|
2
|
-
require "pio/lldp/optional-tlv"
|
3
|
-
|
4
|
-
|
5
|
-
module Pio
|
6
|
-
class Lldp
|
7
|
-
describe OptionalTlv do
|
8
|
-
subject { OptionalTlv.read( data ) }
|
9
|
-
|
10
|
-
|
11
|
-
context "when parsing End Of LLDPDU TLV" do
|
12
|
-
let( :data ) { [ 0x00, 0x00 ].pack( "C*" ) }
|
13
|
-
|
14
|
-
its( :tlv_type ) { should eq 0 }
|
15
|
-
its( :tlv_info_length ) { should eq 0 }
|
16
|
-
its( :tlv_value ) { should eq "tlv_info_string" => "" }
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
context "when parsing Port Description TLV" do
|
21
|
-
let( :data ) { [ 0x08, 0x17, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x2d, 0x50, 0x6f, 0x72, 0x74, 0x20, 0x31, 0x30, 0x30, 0x31, 0x00 ].pack( "C*" ) }
|
22
|
-
|
23
|
-
its( :tlv_type ) { should eq 4 }
|
24
|
-
its( :tlv_info_length ) { should eq 23 }
|
25
|
-
its( :tlv_value ) { should eq( { "port_description" => "Summit300-48-Port 1001" } ) }
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
context "when parsing System Name TLV" do
|
30
|
-
let( :data ) { [ 0x0a, 0x0d, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x00 ].pack( "C*" ) }
|
31
|
-
|
32
|
-
its( :tlv_type ) { should eq 5 }
|
33
|
-
its( :tlv_info_length ) { should eq 13 }
|
34
|
-
its( :tlv_value ) { should eq( { "system_name" => "Summit300-48" } ) }
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
context "when parsing System Description TLV" do
|
39
|
-
let( :data ) { [ 0x0c, 0x4c, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x20, 0x2d, 0x20, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x37, 0x2e, 0x34, 0x65, 0x2e, 0x31, 0x20, 0x28, 0x42, 0x75, 0x69, 0x6c, 0x64, 0x20, 0x35, 0x29, 0x20, 0x62, 0x79, 0x20, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x4d, 0x61, 0x73, 0x74, 0x65, 0x72, 0x20, 0x30, 0x35, 0x2f, 0x32, 0x37, 0x2f, 0x30, 0x35, 0x20, 0x30, 0x34, 0x3a, 0x35, 0x33, 0x3a, 0x31, 0x31, 0x00 ].pack( "C*" ) }
|
40
|
-
|
41
|
-
its( :tlv_type ) { should eq 6 }
|
42
|
-
its( :tlv_info_length ) { should eq 76 }
|
43
|
-
its( :tlv_value ) { should eq( { "system_description"=>"Summit300-48 - Version 7.4e.1 (Build 5) by Release_Master 05/27/05 04:53:11" } ) }
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
context "when parsing System Capabilities TLV" do
|
48
|
-
let( :data ) { [ 0x0e, 0x04, 0x00, 0x14, 0x00, 0x14 ].pack( "C*" ) }
|
49
|
-
|
50
|
-
its( :tlv_type ) { should eq 7 }
|
51
|
-
its( :tlv_info_length ) { should eq 4 }
|
52
|
-
its( :tlv_value ) { should eq( { "system_capabilities" => 20, "enabled_capabilities" => 20 } ) }
|
53
|
-
end
|
54
|
-
|
55
|
-
|
56
|
-
context "when parsing Management Address TLV" do
|
57
|
-
let( :data ) { [ 0x10, 0x0e, 0x07, 0x06, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x02, 0x00, 0x00, 0x03, 0xe9, 0x00 ].pack( "C*" ) }
|
58
|
-
|
59
|
-
its( :tlv_type ) { should eq 8 }
|
60
|
-
its( :tlv_info_length ) { should eq 14 }
|
61
|
-
its( :tlv_value ) { should eq( { "management_address" => "\a\006" } ) } # FIXME
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
context "when parsing Organizationally Specific TLV" do
|
66
|
-
let( :data ) { [ 0xfe, 0x07, 0x00, 0x12, 0x0f, 0x02, 0x07, 0x01, 0x00 ].pack( "C*" ) }
|
67
|
-
|
68
|
-
its( :tlv_type ) { should eq 127 }
|
69
|
-
its( :tlv_info_length ) { should eq 7 }
|
70
|
-
its( :tlv_value ) { should eq "" } # FIXME
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
### Local variables:
|
78
|
-
### mode: Ruby
|
79
|
-
### coding: utf-8-unix
|
80
|
-
### indent-tabs-mode: nil
|
81
|
-
### End:
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require File.join( File.dirname( __FILE__ ), "..", "..", "spec_helper" )
|
2
|
-
require "pio/lldp/port-id-tlv"
|
3
|
-
|
4
|
-
|
5
|
-
module Pio
|
6
|
-
class Lldp
|
7
|
-
describe PortIdTlv do
|
8
|
-
subject { PortIdTlv.read( data.pack( "C*" ) ) }
|
9
|
-
|
10
|
-
context "parsing a raw data" do
|
11
|
-
let( :data ) { [ 0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x74, 0x6f, 0x20, 0x53, 0x31 ] }
|
12
|
-
|
13
|
-
its( :tlv_type ) { should eq 2 }
|
14
|
-
its( :tlv_info_length ) { should eq 13 }
|
15
|
-
its( :subtype ) { should eq 1 }
|
16
|
-
its( :port_id ) { should eq data[ -12..-1 ].pack( "C*" ) }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
### Local variables:
|
24
|
-
### mode: Ruby
|
25
|
-
### coding: utf-8-unix
|
26
|
-
### indent-tabs-mode: nil
|
27
|
-
### End:
|