pio 0.1.0
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.
- data/.gitignore +19 -0
- data/Gemfile +32 -0
- data/Guardfile +16 -0
- data/LICENSE +674 -0
- data/README.md +4 -0
- data/Rakefile +89 -0
- data/lib/pio/lldp.rb +45 -0
- data/lib/pio/lldp/chassis-id-tlv.rb +57 -0
- data/lib/pio/lldp/end-of-lldpdu-value.rb +21 -0
- data/lib/pio/lldp/frame.rb +38 -0
- data/lib/pio/lldp/mac-address.rb +28 -0
- data/lib/pio/lldp/management-address-value.rb +21 -0
- data/lib/pio/lldp/optional-tlv.rb +73 -0
- data/lib/pio/lldp/port-description-value.rb +21 -0
- data/lib/pio/lldp/port-id-tlv.rb +44 -0
- data/lib/pio/lldp/system-capabilities-value.rb +22 -0
- data/lib/pio/lldp/system-description-value.rb +21 -0
- data/lib/pio/lldp/system-name-value.rb +21 -0
- data/lib/pio/lldp/ttl-tlv.rb +33 -0
- data/lib/pio/version.rb +30 -0
- data/pio.gemspec +31 -0
- data/spec/pio/lldp/chassis-id-tlv_spec.rb +27 -0
- data/spec/pio/lldp/end-of-lldpdu-value_spec.rb +20 -0
- data/spec/pio/lldp/frame_spec.rb +82 -0
- data/spec/pio/lldp/mac-address_spec.rb +20 -0
- data/spec/pio/lldp/optional-tlv_spec.rb +81 -0
- data/spec/pio/lldp/port-id-tlv_spec.rb +27 -0
- data/spec/pio/lldp/ttl-tlv_spec.rb +26 -0
- data/spec/pio/lldp_spec.rb +63 -0
- data/spec/spec_helper.rb +18 -0
- metadata +96 -0
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.join( File.dirname( __FILE__ ), "..", "spec_helper" )
|
2
|
+
require "pio/lldp"
|
3
|
+
|
4
|
+
|
5
|
+
module Pio
|
6
|
+
describe Lldp do
|
7
|
+
subject { Lldp.read( data.pack( "C*" ) ) }
|
8
|
+
|
9
|
+
context "parsing a minimal LLDP frame" do
|
10
|
+
let( :data ) {
|
11
|
+
[
|
12
|
+
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, # Destination MAC
|
13
|
+
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Source MAC
|
14
|
+
0x88, 0xcc, # Ethertype
|
15
|
+
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Chassis ID TLV
|
16
|
+
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x74, 0x6f, 0x20, 0x53, 0x31, # Port ID TLV
|
17
|
+
0x06, 0x02, 0x00, 0x78, # Time to live TLV
|
18
|
+
0x00, 0x00 # End of LLDPDU TLV
|
19
|
+
]
|
20
|
+
}
|
21
|
+
|
22
|
+
its( :dpid ) { should eq 108173701773 }
|
23
|
+
|
24
|
+
it "should successfully parse the data" do
|
25
|
+
lambda { subject }.should_not raise_error
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
context "parsing a detailed LLDP frame" do
|
31
|
+
let( :data ) {
|
32
|
+
[
|
33
|
+
0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e, # Destination MAC
|
34
|
+
0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Source MAC
|
35
|
+
0x88, 0xcc, # Ethertype
|
36
|
+
0x02, 0x07, 0x04, 0x00, 0x19, 0x2f, 0xa7, 0xb2, 0x8d, # Chassis ID TLV
|
37
|
+
0x04, 0x0d, 0x01, 0x55, 0x70, 0x6c, 0x69, 0x6e, 0x6b, 0x20, 0x74, 0x6f, 0x20, 0x53, 0x31, # Port ID TLV
|
38
|
+
0x06, 0x02, 0x00, 0x78, # Time to live TLV
|
39
|
+
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
|
40
|
+
0x0a, 0x0d, 0x53, 0x75, 0x6d, 0x6d, 0x69, 0x74, 0x33, 0x30, 0x30, 0x2d, 0x34, 0x38, 0x00, # System Name
|
41
|
+
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
|
42
|
+
0x0e, 0x04, 0x00, 0x14, 0x00, 0x14, # System Capabilities
|
43
|
+
0x10, 0x0e, 0x07, 0x06, 0x00, 0x01, 0x30, 0xf9, 0xad, 0xa0, 0x02, 0x00, 0x00, 0x03, 0xe9, 0x00,
|
44
|
+
0xfe, 0x07, 0x00, 0x12, 0x0f, 0x02, 0x07, 0x01, 0x00,
|
45
|
+
0x00, 0x00 # End of LLDPDU TLV
|
46
|
+
]
|
47
|
+
}
|
48
|
+
|
49
|
+
its( :dpid ) { should eq 108173701773 }
|
50
|
+
|
51
|
+
it "should successfully parse the data" do
|
52
|
+
lambda { subject }.should_not raise_error
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
### Local variables:
|
60
|
+
### mode: Ruby
|
61
|
+
### coding: utf-8-unix
|
62
|
+
### indent-tabs-mode: nil
|
63
|
+
### End:
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
|
3
|
+
require "rspec"
|
4
|
+
require "rspec/autorun"
|
5
|
+
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir[ "#{ File.dirname( __FILE__ ) }/support/**/*.rb" ].each do | each |
|
10
|
+
require File.expand_path( each )
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
### Local variables:
|
15
|
+
### mode: Ruby
|
16
|
+
### coding: utf-8-unix
|
17
|
+
### indent-tabs-mode: nil
|
18
|
+
### End:
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Yasuhito Takamiya
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2013-07-31 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Pure ruby packet parser and generator.
|
22
|
+
email:
|
23
|
+
- yasuhito@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.md
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- Guardfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- lib/pio/lldp.rb
|
38
|
+
- lib/pio/lldp/chassis-id-tlv.rb
|
39
|
+
- lib/pio/lldp/end-of-lldpdu-value.rb
|
40
|
+
- lib/pio/lldp/frame.rb
|
41
|
+
- lib/pio/lldp/mac-address.rb
|
42
|
+
- lib/pio/lldp/management-address-value.rb
|
43
|
+
- lib/pio/lldp/optional-tlv.rb
|
44
|
+
- lib/pio/lldp/port-description-value.rb
|
45
|
+
- lib/pio/lldp/port-id-tlv.rb
|
46
|
+
- lib/pio/lldp/system-capabilities-value.rb
|
47
|
+
- lib/pio/lldp/system-description-value.rb
|
48
|
+
- lib/pio/lldp/system-name-value.rb
|
49
|
+
- lib/pio/lldp/ttl-tlv.rb
|
50
|
+
- lib/pio/version.rb
|
51
|
+
- pio.gemspec
|
52
|
+
- spec/pio/lldp/chassis-id-tlv_spec.rb
|
53
|
+
- spec/pio/lldp/end-of-lldpdu-value_spec.rb
|
54
|
+
- spec/pio/lldp/frame_spec.rb
|
55
|
+
- spec/pio/lldp/mac-address_spec.rb
|
56
|
+
- spec/pio/lldp/optional-tlv_spec.rb
|
57
|
+
- spec/pio/lldp/port-id-tlv_spec.rb
|
58
|
+
- spec/pio/lldp/ttl-tlv_spec.rb
|
59
|
+
- spec/pio/lldp_spec.rb
|
60
|
+
- spec/spec_helper.rb
|
61
|
+
homepage: http://github.com/trema/pio
|
62
|
+
licenses:
|
63
|
+
- GPL3
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
84
|
+
segments:
|
85
|
+
- 0
|
86
|
+
version: "0"
|
87
|
+
requirements: []
|
88
|
+
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 1.8.25
|
91
|
+
signing_key:
|
92
|
+
specification_version: 3
|
93
|
+
summary: Packet parser and generator.
|
94
|
+
test_files: []
|
95
|
+
|
96
|
+
has_rdoc:
|