pio 0.8.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -1
  3. data/README.md +24 -11
  4. data/Rakefile +0 -2
  5. data/examples/features_new.rb +17 -6
  6. data/features/packet_data/aggregate_stats_reply.raw +0 -0
  7. data/features/packet_data/aggregate_stats_request.raw +0 -0
  8. data/features/packet_data/barrier_reply.raw +0 -0
  9. data/features/packet_data/barrier_request.raw +0 -0
  10. data/features/packet_data/desc_stats_reply.raw +0 -0
  11. data/features/packet_data/desc_stats_request.raw +0 -0
  12. data/features/packet_data/echo_reply.raw +0 -0
  13. data/features/packet_data/echo_request.raw +0 -0
  14. data/features/packet_data/error.raw +0 -0
  15. data/features/packet_data/features_reply.raw +0 -0
  16. data/features/packet_data/flow_mod_add.raw +0 -0
  17. data/features/packet_data/flow_mod_delete.raw +0 -0
  18. data/features/packet_data/flow_removed.raw +0 -0
  19. data/features/packet_data/flow_stats_reply.raw +0 -0
  20. data/features/packet_data/flow_stats_request.raw +0 -0
  21. data/features/packet_data/get_config_reply.raw +0 -0
  22. data/features/packet_data/get_config_request.raw +0 -0
  23. data/features/packet_data/hello.raw +0 -0
  24. data/features/packet_data/packet_in.raw +0 -0
  25. data/features/packet_data/packet_out.raw +0 -0
  26. data/features/packet_data/port_mod.raw +0 -0
  27. data/features/packet_data/port_stats_reply.raw +0 -0
  28. data/features/packet_data/port_stats_request.raw +0 -0
  29. data/features/packet_data/port_status.raw +0 -0
  30. data/features/packet_data/queue_get_config_reply.raw +0 -0
  31. data/features/packet_data/queue_get_config_request.raw +0 -0
  32. data/features/packet_data/set_config.raw +0 -0
  33. data/features/packet_data/table_stats_reply.raw +0 -0
  34. data/features/packet_data/table_stats_request.raw +0 -0
  35. data/features/packet_data/vendor.raw +0 -0
  36. data/features/packet_data/vendor_stats_request.raw +0 -0
  37. data/features/step_definitions/packet_data_steps.rb +0 -2
  38. data/features/step_definitions/pending_steps.rb +0 -2
  39. data/features/support/env.rb +0 -2
  40. data/lib/pio.rb +0 -2
  41. data/lib/pio/arp.rb +0 -2
  42. data/lib/pio/arp/format.rb +0 -2
  43. data/lib/pio/arp/message.rb +14 -22
  44. data/lib/pio/arp/reply.rb +0 -2
  45. data/lib/pio/arp/request.rb +0 -2
  46. data/lib/pio/dhcp.rb +0 -2
  47. data/lib/pio/dhcp/ack.rb +0 -2
  48. data/lib/pio/dhcp/boot_reply.rb +0 -2
  49. data/lib/pio/dhcp/boot_reply_options.rb +0 -2
  50. data/lib/pio/dhcp/boot_request.rb +0 -2
  51. data/lib/pio/dhcp/boot_request_options.rb +0 -2
  52. data/lib/pio/dhcp/client_id.rb +0 -2
  53. data/lib/pio/dhcp/common_options.rb +0 -2
  54. data/lib/pio/dhcp/csum_util.rb +0 -2
  55. data/lib/pio/dhcp/dhcp_field.rb +0 -2
  56. data/lib/pio/dhcp/dhcp_tlv_options.rb +0 -2
  57. data/lib/pio/dhcp/discover.rb +0 -2
  58. data/lib/pio/dhcp/field_util.rb +0 -2
  59. data/lib/pio/dhcp/frame.rb +0 -2
  60. data/lib/pio/dhcp/message.rb +0 -2
  61. data/lib/pio/dhcp/offer.rb +0 -2
  62. data/lib/pio/dhcp/optional_tlv.rb +0 -2
  63. data/lib/pio/dhcp/parameter_list.rb +0 -2
  64. data/lib/pio/dhcp/request.rb +0 -2
  65. data/lib/pio/echo.rb +3 -6
  66. data/lib/pio/echo/format.rb +10 -6
  67. data/lib/pio/echo/message.rb +16 -41
  68. data/lib/pio/echo/reply.rb +8 -7
  69. data/lib/pio/echo/request.rb +6 -6
  70. data/lib/pio/features.rb +15 -9
  71. data/lib/pio/features/reply.rb +79 -44
  72. data/lib/pio/features/request.rb +30 -28
  73. data/lib/pio/hello.rb +17 -29
  74. data/lib/pio/hello/format.rb +8 -8
  75. data/lib/pio/icmp.rb +0 -2
  76. data/lib/pio/icmp/format.rb +0 -2
  77. data/lib/pio/icmp/message.rb +23 -31
  78. data/lib/pio/icmp/options.rb +0 -2
  79. data/lib/pio/icmp/reply.rb +2 -4
  80. data/lib/pio/icmp/request.rb +0 -2
  81. data/lib/pio/ipv4_address.rb +1 -5
  82. data/lib/pio/lldp.rb +0 -2
  83. data/lib/pio/lldp/chassis_id_tlv.rb +0 -2
  84. data/lib/pio/lldp/end_of_lldpdu_value.rb +0 -2
  85. data/lib/pio/lldp/frame.rb +0 -2
  86. data/lib/pio/lldp/management_address_value.rb +0 -2
  87. data/lib/pio/lldp/optional_tlv.rb +0 -2
  88. data/lib/pio/lldp/options.rb +0 -2
  89. data/lib/pio/lldp/organizationally_specific_value.rb +0 -2
  90. data/lib/pio/lldp/port_description_value.rb +0 -2
  91. data/lib/pio/lldp/port_id_tlv.rb +0 -2
  92. data/lib/pio/lldp/system_capabilities_value.rb +0 -2
  93. data/lib/pio/lldp/system_description_value.rb +0 -2
  94. data/lib/pio/lldp/system_name_value.rb +0 -2
  95. data/lib/pio/lldp/ttl_tlv.rb +0 -2
  96. data/lib/pio/mac.rb +2 -6
  97. data/lib/pio/message_type_selector.rb +5 -4
  98. data/lib/pio/open_flow.rb +5 -0
  99. data/lib/pio/open_flow/flags.rb +38 -0
  100. data/lib/pio/open_flow/message.rb +20 -0
  101. data/lib/pio/open_flow/open_flow_header.rb +18 -0
  102. data/lib/pio/open_flow/phy_port.rb +74 -0
  103. data/lib/pio/open_flow/type.rb +12 -0
  104. data/lib/pio/options.rb +0 -2
  105. data/lib/pio/parse_error.rb +0 -2
  106. data/lib/pio/pcap.rb +0 -2
  107. data/lib/pio/type/ethernet_header.rb +0 -2
  108. data/lib/pio/type/ip_address.rb +0 -2
  109. data/lib/pio/type/ipv4_header.rb +2 -2
  110. data/lib/pio/type/mac_address.rb +6 -3
  111. data/lib/pio/type/udp_header.rb +0 -2
  112. data/lib/pio/version.rb +1 -3
  113. data/pio.gemspec +18 -20
  114. data/spec/pio/arp/reply/options_spec.rb +0 -2
  115. data/spec/pio/arp/reply_spec.rb +0 -2
  116. data/spec/pio/arp/request/options_spec.rb +0 -2
  117. data/spec/pio/arp/request_spec.rb +0 -2
  118. data/spec/pio/arp_spec.rb +0 -2
  119. data/spec/pio/dhcp/ack_spec.rb +0 -2
  120. data/spec/pio/dhcp/discover_spec.rb +0 -2
  121. data/spec/pio/dhcp/offer_spec.rb +0 -2
  122. data/spec/pio/dhcp/request_spec.rb +0 -2
  123. data/spec/pio/dhcp_spec.rb +0 -2
  124. data/spec/pio/echo/reply_spec.rb +13 -15
  125. data/spec/pio/echo/request_spec.rb +15 -15
  126. data/spec/pio/echo_spec.rb +5 -7
  127. data/spec/pio/features/reply_spec.rb +47 -17
  128. data/spec/pio/features/request_spec.rb +6 -11
  129. data/spec/pio/features_spec.rb +70 -51
  130. data/spec/pio/hello_spec.rb +1 -3
  131. data/spec/pio/icmp/reply_spec.rb +0 -2
  132. data/spec/pio/icmp/request_spec.rb +0 -2
  133. data/spec/pio/icmp_spec.rb +0 -2
  134. data/spec/pio/ipv4_address_spec.rb +0 -2
  135. data/spec/pio/lldp/options_spec.rb +0 -2
  136. data/spec/pio/lldp_spec.rb +0 -2
  137. data/spec/pio/mac_spec.rb +0 -1
  138. data/spec/pio/open_flow/phy_port_spec.rb +25 -0
  139. data/spec/pio/open_flow/type_spec.rb +5 -0
  140. data/spec/spec_helper.rb +9 -24
  141. metadata +105 -40
  142. data/lib/pio/features/format.rb +0 -18
  143. data/lib/pio/features/message.rb +0 -14
  144. data/lib/pio/type/open_flow.rb +0 -34
@@ -0,0 +1,12 @@
1
+ module Pio
2
+ module OpenFlow
3
+ # OFPT_* constants.
4
+ module Type
5
+ HELLO = 0
6
+ ECHO_REQUEST = 2
7
+ ECHO_REPLY = 3
8
+ FEATURES_REQUEST = 5
9
+ FEATURES_REPLY = 6
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pio
4
2
  # User options utility.
5
3
  class Options
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pio
4
2
  # Raised when the packet data is in wrong format.
5
3
  class ParseError < StandardError; end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bindata'
4
2
 
5
3
  module Pio
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/type/mac_address'
4
2
 
5
3
  module Pio
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bindata'
4
2
  require 'pio/ipv4_address'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/type/ip_address'
4
2
 
5
3
  module Pio
@@ -7,6 +5,7 @@ module Pio
7
5
  # IP Version 4 Header Format
8
6
  module IPv4Header
9
7
  # rubocop:disable MethodLength
8
+ # rubocop:disable AbcSize
10
9
  def ipv4_header(options)
11
10
  class_eval do
12
11
  bit4 :ip_version, initial_value: 0x4
@@ -25,6 +24,7 @@ module Pio
25
24
  ip_address :ip_destination_address
26
25
  end
27
26
  end
27
+ # rubocop:enable AbcSize
28
28
  # rubocop:enable MethodLength
29
29
  end
30
30
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bindata'
4
2
  require 'pio/mac'
5
3
 
@@ -10,7 +8,12 @@ module Pio
10
8
  array :octets, type: :uint8, initial_length: 6
11
9
 
12
10
  def set(value)
13
- self.octets = value.to_a
11
+ case value
12
+ when String
13
+ self.octets = value.split(':').map { |each| ('0x' + each).hex }
14
+ else
15
+ self.octets = value.to_a
16
+ end
14
17
  end
15
18
 
16
19
  def get
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pio
4
2
  module Type
5
3
  # UDP Header Format.
@@ -1,7 +1,5 @@
1
- # encoding: utf-8
2
-
3
1
  # Base module.
4
2
  module Pio
5
3
  # gem version.
6
- VERSION = '0.8.1'.freeze
4
+ VERSION = '0.8.2'.freeze
7
5
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  lib = File.expand_path('../lib', __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'pio/version'
@@ -34,37 +32,37 @@ Gem::Specification.new do |gem|
34
32
  gem.test_files = Dir.glob('spec/**/*')
35
33
  gem.test_files += Dir.glob('features/**/*')
36
34
 
37
- gem.required_ruby_version = '>= 1.9.3'
35
+ gem.required_ruby_version = '>= 2.0.0'
38
36
 
39
37
  gem.add_dependency 'bindata', '~> 2.1.0'
40
38
 
41
39
  gem.add_development_dependency 'rake'
42
- gem.add_development_dependency 'bundler', '~> 1.6.2'
43
- gem.add_development_dependency 'pry', '~> 0.9.12.6'
40
+ gem.add_development_dependency 'bundler', '~> 1.7.6'
41
+ gem.add_development_dependency 'pry', '~> 0.10.1'
44
42
 
45
43
  # Guard
46
- gem.add_development_dependency 'guard', '~> 2.6.1'
44
+ gem.add_development_dependency 'guard', '~> 2.8.2'
47
45
  gem.add_development_dependency 'guard-bundler', '~> 2.0.0'
48
- gem.add_development_dependency 'guard-cucumber', '~> 1.4.1'
49
- gem.add_development_dependency 'guard-rspec', '~> 4.2.9'
50
- gem.add_development_dependency 'guard-rubocop', '~> 1.1.0'
46
+ gem.add_development_dependency 'guard-cucumber', '~> 1.5.1'
47
+ gem.add_development_dependency 'guard-rspec', '~> 4.3.1'
48
+ gem.add_development_dependency 'guard-rubocop', '~> 1.2.0'
51
49
  gem.add_development_dependency 'rb-fchange', '~> 0.0.6'
52
50
  gem.add_development_dependency 'rb-fsevent', '~> 0.9.4'
53
- gem.add_development_dependency 'rb-inotify', '~> 0.9.3'
54
- gem.add_development_dependency 'terminal-notifier-guard', '~> 1.5.3'
51
+ gem.add_development_dependency 'rb-inotify', '~> 0.9.5'
52
+ gem.add_development_dependency 'terminal-notifier-guard', '~> 1.6.4'
55
53
 
56
54
  # Docs
57
- gem.add_development_dependency 'inch', '~> 0.4.6'
58
- gem.add_development_dependency 'yard', '~> 0.8.7.4'
55
+ gem.add_development_dependency 'inch', '~> 0.5.7'
56
+ gem.add_development_dependency 'yard', '~> 0.8.7.6'
59
57
 
60
58
  # Test
61
- gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.3.0'
62
- gem.add_development_dependency 'coveralls', '~> 0.7.0'
63
- gem.add_development_dependency 'cucumber', '~> 1.3.15'
59
+ gem.add_development_dependency 'codeclimate-test-reporter', '~> 0.4.1'
60
+ gem.add_development_dependency 'coveralls', '~> 0.7.2'
61
+ gem.add_development_dependency 'cucumber', '~> 1.3.17'
64
62
  gem.add_development_dependency 'flay', '~> 2.5.0'
65
- gem.add_development_dependency 'flog', '~> 4.2.1'
66
- gem.add_development_dependency 'reek', '~> 1.3.7'
67
- gem.add_development_dependency 'rspec', '~> 3.0.0'
63
+ gem.add_development_dependency 'flog', '~> 4.3.0'
64
+ gem.add_development_dependency 'reek', '~> 1.4.0'
65
+ gem.add_development_dependency 'rspec', '~> 3.1.0'
68
66
  gem.add_development_dependency 'rspec-given', '~> 3.5.4'
69
- gem.add_development_dependency 'rubocop', '~> 0.23.0'
67
+ gem.add_development_dependency 'rubocop', '~> 0.27.1'
70
68
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::Arp::Reply::Options, '.new' do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::ARP::Reply do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::Arp::Request::Options, '.new' do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::ARP::Request do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::ARP do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::DHCP::Ack do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::DHCP::Discover do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::DHCP::Offer do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::Dhcp::Request do
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
 
5
3
  describe Pio::DHCP do
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
-
3
- require 'pio'
1
+ require 'pio/echo'
4
2
 
5
3
  describe Pio::Echo::Reply do
6
4
  describe '.new' do
@@ -8,11 +6,11 @@ describe Pio::Echo::Reply do
8
6
  When(:echo_reply) { Pio::Echo::Reply.new }
9
7
 
10
8
  Then { echo_reply.ofp_version == 1 }
11
- Then { echo_reply.message_type == Pio::Echo::REPLY }
9
+ Then { echo_reply.message_type == Pio::OpenFlow::Type::ECHO_REPLY }
12
10
  Then { echo_reply.message_length == 8 }
13
11
  Then { echo_reply.transaction_id == 0 }
14
12
  Then { echo_reply.xid == 0 }
15
- Then { echo_reply.data == '' }
13
+ Then { echo_reply.user_data == '' }
16
14
  Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 0].pack('C*') }
17
15
  end
18
16
 
@@ -20,11 +18,11 @@ describe Pio::Echo::Reply do
20
18
  When(:echo_reply) { Pio::Echo::Reply.new(123) }
21
19
 
22
20
  Then { echo_reply.ofp_version == 1 }
23
- Then { echo_reply.message_type == Pio::Echo::REPLY }
21
+ Then { echo_reply.message_type == Pio::OpenFlow::Type::ECHO_REPLY }
24
22
  Then { echo_reply.message_length == 8 }
25
23
  Then { echo_reply.transaction_id == 123 }
26
24
  Then { echo_reply.xid == 123 }
27
- Then { echo_reply.data == '' }
25
+ Then { echo_reply.user_data == '' }
28
26
  Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 123].pack('C*') }
29
27
  end
30
28
 
@@ -41,11 +39,11 @@ describe Pio::Echo::Reply do
41
39
  When(:echo_reply) { Pio::Echo::Reply.new(transaction_id: 123) }
42
40
 
43
41
  Then { echo_reply.ofp_version == 1 }
44
- Then { echo_reply.message_type == Pio::Echo::REPLY }
42
+ Then { echo_reply.message_type == Pio::OpenFlow::Type::ECHO_REPLY }
45
43
  Then { echo_reply.message_length == 8 }
46
44
  Then { echo_reply.transaction_id == 123 }
47
45
  Then { echo_reply.xid == 123 }
48
- Then { echo_reply.data == '' }
46
+ Then { echo_reply.user_data == '' }
49
47
  Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 123].pack('C*') }
50
48
  end
51
49
 
@@ -53,23 +51,23 @@ describe Pio::Echo::Reply do
53
51
  When(:echo_reply) { Pio::Echo::Reply.new(xid: 123) }
54
52
 
55
53
  Then { echo_reply.ofp_version == 1 }
56
- Then { echo_reply.message_type == Pio::Echo::REPLY }
54
+ Then { echo_reply.message_type == Pio::OpenFlow::Type::ECHO_REPLY }
57
55
  Then { echo_reply.message_length == 8 }
58
56
  Then { echo_reply.transaction_id == 123 }
59
57
  Then { echo_reply.xid == 123 }
60
- Then { echo_reply.data == '' }
58
+ Then { echo_reply.user_data == '' }
61
59
  Then { echo_reply.to_binary == [1, 3, 0, 8, 0, 0, 0, 123].pack('C*') }
62
60
  end
63
61
 
64
- context "with transaction_id: 123, data: 'foobar'" do
65
- When(:echo_reply) { Pio::Echo::Reply.new(xid: 123, data: 'foobar') }
62
+ context "with transaction_id: 123, user_data: 'foobar'" do
63
+ When(:echo_reply) { Pio::Echo::Reply.new(xid: 123, user_data: 'foobar') }
66
64
 
67
65
  Then { echo_reply.ofp_version == 1 }
68
- Then { echo_reply.message_type == Pio::Echo::REPLY }
66
+ Then { echo_reply.message_type == Pio::OpenFlow::Type::ECHO_REPLY }
69
67
  Then { echo_reply.message_length == 14 }
70
68
  Then { echo_reply.transaction_id == 123 }
71
69
  Then { echo_reply.xid == 123 }
72
- Then { echo_reply.data == 'foobar' }
70
+ Then { echo_reply.user_data == 'foobar' }
73
71
  Then do
74
72
  echo_reply.to_binary ==
75
73
  [1, 3, 0, 14, 0, 0, 0, 123, 102, 111, 111, 98, 97, 114].pack('C*')
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
-
3
- require 'pio'
1
+ require 'pio/echo'
4
2
 
5
3
  describe Pio::Echo::Request do
6
4
  describe '.new' do
@@ -8,11 +6,11 @@ describe Pio::Echo::Request do
8
6
  When(:echo_request) { Pio::Echo::Request.new }
9
7
 
10
8
  Then { echo_request.ofp_version == 1 }
11
- Then { echo_request.message_type == Pio::Echo::REQUEST }
9
+ Then { echo_request.message_type == Pio::OpenFlow::Type::ECHO_REQUEST }
12
10
  Then { echo_request.message_length == 8 }
13
11
  Then { echo_request.transaction_id == 0 }
14
12
  Then { echo_request.xid == 0 }
15
- Then { echo_request.data == '' }
13
+ Then { echo_request.user_data == '' }
16
14
  Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 0].pack('C*') }
17
15
  end
18
16
 
@@ -20,11 +18,11 @@ describe Pio::Echo::Request do
20
18
  When(:echo_request) { Pio::Echo::Request.new(123) }
21
19
 
22
20
  Then { echo_request.ofp_version == 1 }
23
- Then { echo_request.message_type == Pio::Echo::REQUEST }
21
+ Then { echo_request.message_type == Pio::OpenFlow::Type::ECHO_REQUEST }
24
22
  Then { echo_request.message_length == 8 }
25
23
  Then { echo_request.transaction_id == 123 }
26
24
  Then { echo_request.xid == 123 }
27
- Then { echo_request.data == '' }
25
+ Then { echo_request.user_data == '' }
28
26
  Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 123].pack('C*') }
29
27
  end
30
28
 
@@ -41,11 +39,11 @@ describe Pio::Echo::Request do
41
39
  When(:echo_request) { Pio::Echo::Request.new(transaction_id: 123) }
42
40
 
43
41
  Then { echo_request.ofp_version == 1 }
44
- Then { echo_request.message_type == Pio::Echo::REQUEST }
42
+ Then { echo_request.message_type == Pio::OpenFlow::Type::ECHO_REQUEST }
45
43
  Then { echo_request.message_length == 8 }
46
44
  Then { echo_request.transaction_id == 123 }
47
45
  Then { echo_request.xid == 123 }
48
- Then { echo_request.data == '' }
46
+ Then { echo_request.user_data == '' }
49
47
  Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 123].pack('C*') }
50
48
  end
51
49
 
@@ -53,23 +51,25 @@ describe Pio::Echo::Request do
53
51
  When(:echo_request) { Pio::Echo::Request.new(xid: 123) }
54
52
 
55
53
  Then { echo_request.ofp_version == 1 }
56
- Then { echo_request.message_type == Pio::Echo::REQUEST }
54
+ Then { echo_request.message_type == Pio::OpenFlow::Type::ECHO_REQUEST }
57
55
  Then { echo_request.message_length == 8 }
58
56
  Then { echo_request.transaction_id == 123 }
59
57
  Then { echo_request.xid == 123 }
60
- Then { echo_request.data == '' }
58
+ Then { echo_request.user_data == '' }
61
59
  Then { echo_request.to_binary == [1, 2, 0, 8, 0, 0, 0, 123].pack('C*') }
62
60
  end
63
61
 
64
- context "with transaction_id: 123, data: 'foobar'" do
65
- When(:echo_request) { Pio::Echo::Request.new(xid: 123, data: 'foobar') }
62
+ context "with transaction_id: 123, user_data: 'foobar'" do
63
+ When(:echo_request) do
64
+ Pio::Echo::Request.new(xid: 123, user_data: 'foobar')
65
+ end
66
66
 
67
67
  Then { echo_request.ofp_version == 1 }
68
- Then { echo_request.message_type == Pio::Echo::REQUEST }
68
+ Then { echo_request.message_type == Pio::OpenFlow::Type::ECHO_REQUEST }
69
69
  Then { echo_request.message_length == 14 }
70
70
  Then { echo_request.transaction_id == 123 }
71
71
  Then { echo_request.xid == 123 }
72
- Then { echo_request.data == 'foobar' }
72
+ Then { echo_request.user_data == 'foobar' }
73
73
  Then do
74
74
  echo_request.to_binary ==
75
75
  [1, 2, 0, 14, 0, 0, 0, 123, 102, 111, 111, 98, 97, 114].pack('C*')
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
-
3
- require 'pio'
1
+ require 'pio/echo'
4
2
 
5
3
  describe Pio::Echo do
6
4
  describe '.read' do
@@ -15,10 +13,10 @@ describe Pio::Echo do
15
13
 
16
14
  Then { echo_request.class == Pio::Echo::Request }
17
15
  Then { echo_request.ofp_version == 1 }
18
- Then { echo_request.message_type == Pio::Echo::REQUEST }
16
+ Then { echo_request.message_type == Pio::OpenFlow::Type::ECHO_REQUEST }
19
17
  Then { echo_request.message_length == 8 }
20
18
  Then { echo_request.xid == 0 }
21
- Then { echo_request.data == '' }
19
+ Then { echo_request.user_data == '' }
22
20
  Then { echo_request.to_binary == echo_request_dump }
23
21
  end
24
22
 
@@ -33,10 +31,10 @@ describe Pio::Echo do
33
31
 
34
32
  Then { echo_reply.class == Pio::Echo::Reply }
35
33
  Then { echo_reply.ofp_version == 1 }
36
- Then { echo_reply.message_type == Pio::Echo::REPLY }
34
+ Then { echo_reply.message_type == Pio::OpenFlow::Type::ECHO_REPLY }
37
35
  Then { echo_reply.message_length == 8 }
38
36
  Then { echo_reply.xid == 0 }
39
- Then { echo_reply.data == '' }
37
+ Then { echo_reply.user_data == '' }
40
38
  Then { echo_reply.to_binary == echo_reply_dump }
41
39
  end
42
40
 
@@ -1,30 +1,60 @@
1
- # encoding: utf-8
2
-
3
- require 'pio'
1
+ require 'pio/features'
4
2
 
5
3
  describe Pio::Features::Reply do
6
- describe '.new' do
7
- Given(:options) do
8
- {
9
- dpid: 0x123,
10
- n_buffers: 0x100,
11
- n_tables: 0xfe,
12
- capabilities: 0xc7,
13
- actions: 0xfff
14
- }
15
- end
4
+ Given(:options) do
5
+ {
6
+ dpid: 0x123,
7
+ n_buffers: 0x100,
8
+ n_tables: 0xfe,
9
+ capabilities: [:flow_stats, :table_stats, :port_stats, :queue_stats,
10
+ :arp_match_ip],
11
+ actions: [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
12
+ :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
13
+ :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue],
14
+ ports: [{ port_no: 1,
15
+ hardware_address: '11:22:33:44:55:66',
16
+ name: 'port123',
17
+ config: [:port_down],
18
+ state: [:link_down],
19
+ curr: [:port_10gb_fd, :port_copper] }]
20
+ }
21
+ end
16
22
 
23
+ describe '.new' do
17
24
  When(:features_reply) { Pio::Features::Reply.new(options) }
18
25
 
19
26
  Then { features_reply.ofp_version == 1 }
20
- Then { features_reply.message_type == Pio::Features::REPLY }
27
+ Then { features_reply.message_type == Pio::OpenFlow::Type::FEATURES_REPLY }
21
28
  Then { features_reply.transaction_id == 0 }
22
29
  Then { features_reply.xid == 0 }
23
30
  Then { features_reply.dpid == 0x123 }
24
31
  Then { features_reply.n_buffers == 0x100 }
25
32
  Then { features_reply.n_tables == 0xfe }
26
- Then { features_reply.capabilities == 0xc7 }
27
- Then { features_reply.actions == 0xfff }
28
- Then { features_reply.ports == [] }
33
+ Then do
34
+ features_reply.capabilities ==
35
+ [:flow_stats, :table_stats, :port_stats, :queue_stats, :arp_match_ip]
36
+ end
37
+ Then do
38
+ features_reply.actions ==
39
+ [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan, :set_dl_src,
40
+ :set_dl_dst, :set_nw_src, :set_nw_dst, :set_nw_tos, :set_tp_src,
41
+ :set_tp_dst, :enqueue]
42
+ end
43
+ Then { features_reply.ports.length == 1 }
44
+ Then { features_reply.ports[0].port_no == 1 }
45
+ Then { features_reply.ports[0].hardware_address == '11:22:33:44:55:66' }
46
+ Then { features_reply.ports[0].name == 'port123' }
47
+ Then { features_reply.ports[0].config == [:port_down] }
48
+ Then { features_reply.ports[0].state == [:link_down] }
49
+ Then { features_reply.ports[0].curr == [:port_10gb_fd, :port_copper] }
50
+ Then { features_reply.ports[0].advertised.empty? }
51
+ Then { features_reply.ports[0].supported.empty? }
52
+ Then { features_reply.ports[0].peer.empty? }
53
+ end
54
+
55
+ describe '#to_binary' do
56
+ When(:binary) { Pio::Features::Reply.new(options).to_binary }
57
+
58
+ Then { binary.length > 0 }
29
59
  end
30
60
  end