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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2f4f183d8a7d47bfd6ed73449452f65f0695e8fe
4
- data.tar.gz: c184b79b8c5a2e8298caaa40e58d2be00434afa8
3
+ metadata.gz: cf86d154a2025304879d8c6d252b71a2eda73ef8
4
+ data.tar.gz: 18e3dda3e1ca8061b51d9ef4d8db29e0ffbde9c8
5
5
  SHA512:
6
- metadata.gz: 7a84124f47fc65aca6fbfc6edf702fd23b2231537154460c6d34ea93f8a075e2bba08b03c60f05e7c4a7919823b7c2c8f3eecee5f794945e8d997de550046848
7
- data.tar.gz: 0a59da76fc8bbaa2d4bded717765876d52db4fd67e97e6b5b4839c4aac28db04afcaccc0f3219971d6b364e7069d707c24fce153b94bda3e963a62918caf2f46
6
+ metadata.gz: 3a66499af05e0a468ca0d272237d6fabf489f868407d78d62c43083d30b2c7ee01e3b66cdff45533adb44e6aa11a45027e0074934a0b551de68188a53cd0cad9
7
+ data.tar.gz: 49e01b280cddef5a2400f46a19ef1d622c0da2eeeb4165c1a53fdc5e86b892b95110b027868c6def6f92127dfd95f395bb86ea51b2f162b66e7014688e90ebcb
@@ -1,9 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.2 (12/18/2014)
4
+
5
+ ### Bugs fixed
6
+ * [#100](https://github.com/trema/pio/pull/100): Fix bug when passing `ports:` option to `Pio::Features::Request.new`.
7
+
8
+
3
9
  ## 0.8.1 (6/5/2014)
4
10
 
5
11
  ### Misc
6
-
7
12
  * Updated bundled gems.
8
13
  * Modernized Gemfile and .gemspec.
9
14
 
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # Pio
2
2
 
3
- <a href='https://rubygems.org/gems/pio'><img src='http://img.shields.io/gem/v/pio.svg' alt='Gem Version' /></a>
4
- <a href='https://travis-ci.org/trema/pio'><img src='http://img.shields.io/travis/trema/pio/develop.svg' alt='Build Status' /></a>
5
- <a href='https://codeclimate.com/github/trema/pio'><img src='http://img.shields.io/codeclimate/github/trema/pio.svg' alt='Code Climate' /></a>
6
- <a href='https://coveralls.io/r/trema/pio?branch=develop'><img src='http://img.shields.io/coveralls/trema/pio/develop.svg' alt='Coverage Status' /></a>
7
- <a href='https://gemnasium.com/trema/pio'><img src='https://gemnasium.com/trema/pio.svg' alt='Dependency Status' /></a>
3
+ <a href='https://rubygems.org/gems/pio'><img src='http://img.shields.io/gem/v/pio.svg?style=flat' alt='Gem Version' /></a>
4
+ <a href='https://travis-ci.org/trema/pio'><img src='http://img.shields.io/travis/trema/pio/develop.svg?style=flat' alt='Build Status' /></a>
5
+ <a href='https://codeclimate.com/github/trema/pio'><img src='http://img.shields.io/codeclimate/github/trema/pio.svg?style=flat' alt='Code Climate' /></a>
6
+ <a href='https://coveralls.io/r/trema/pio?branch=develop'><img src='http://img.shields.io/coveralls/trema/pio/develop.svg?style=flat' alt='Coverage Status' /></a>
7
+ <a href='https://gemnasium.com/trema/pio'><img src='http://img.shields.io/gemnasium/trema/pio.svg?style=flat' alt='Dependency Status' /></a>
8
+ <a href='https://gitter.im/trema/pio'><img src='https://badges.gitter.im/Join Chat.svg?style=flat' alt='Gitter Chat' /></a>
8
9
  <a href="http://inch-pages.github.io/github/trema/pio"><img src="http://inch-pages.github.io/github/trema/pio.svg" alt="Inline docs"></a>
9
10
 
10
11
  <a href="http://www.flickr.com/photos/mongogushi/4226014070/" title="pio pencil by mongo gushi, on Flickr"><img src="http://farm5.staticflickr.com/4022/4226014070_cdeb7c1e5d_n.jpg" width="320" height="290" alt="pio pencil"></a>
@@ -228,12 +229,23 @@ generate an Features Request/Reply message like below:
228
229
 
229
230
  # The Features xid (transaction_id)
230
231
  # should be same as that of the request.
231
- reply = Pio::Features::Reply.new(xid: request.xid,
232
- dpid: 0x123,
233
- n_buffers: 0x100,
234
- n_tables: 0xfe,
235
- capabilities: 0xc7,
236
- actions: 0xfff)
232
+ reply = Pio::Features::Reply.new(
233
+ xid: request.xid,
234
+ dpid: 0x123,
235
+ n_buffers: 0x100,
236
+ n_tables: 0xfe,
237
+ capabilities: [:flow_stats, :table_stats, :port_stats,
238
+ :queue_stats, :arp_match_ip],
239
+ actions: [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
240
+ :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
241
+ :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue],
242
+ ports: [{ port_no: 1,
243
+ hardware_address: '11:22:33:44:55:66',
244
+ name: 'port123',
245
+ config: [:port_down],
246
+ state: [:link_down],
247
+ curr: [:port_10gb_fd, :port_copper] }]
248
+ )
237
249
  reply.to_binary # => Features Reply message in binary format.
238
250
 
239
251
  ## Installation
@@ -269,4 +281,5 @@ and install it by running Bundler:
269
281
  ## License
270
282
 
271
283
  Pio is released under the GNU General Public License version 3.0:
284
+
272
285
  - <http://www.gnu.org/licenses/gpl.html>
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bundler/gem_tasks'
4
2
 
5
3
  # rubocop:disable HashSyntax
@@ -5,10 +5,21 @@ request.to_binary # => Features Request message in binary format.
5
5
 
6
6
  # The Features xid (transaction_id)
7
7
  # should be same as that of the request.
8
- reply = Pio::Features::Reply.new(xid: request.xid,
9
- dpid: 0x123,
10
- n_buffers: 0x100,
11
- n_tables: 0xfe,
12
- capabilities: 0xc7,
13
- actions: 0xfff)
8
+ reply = Pio::Features::Reply.new(
9
+ xid: request.xid,
10
+ dpid: 0x123,
11
+ n_buffers: 0x100,
12
+ n_tables: 0xfe,
13
+ capabilities: [:flow_stats, :table_stats, :port_stats,
14
+ :queue_stats, :arp_match_ip],
15
+ actions: [:output, :set_vlan_vid, :set_vlan_pcp, :strip_vlan,
16
+ :set_dl_src, :set_dl_dst, :set_nw_src, :set_nw_dst,
17
+ :set_nw_tos, :set_tp_src, :set_tp_dst, :enqueue],
18
+ ports: [{ port_no: 1,
19
+ hardware_address: '11:22:33:44:55:66',
20
+ name: 'port123',
21
+ config: [:port_down],
22
+ state: [:link_down],
23
+ curr: [:port_10gb_fd, :port_copper] }]
24
+ )
14
25
  reply.to_binary # => Features Reply message in binary format.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Given(/^a packet data file "(.*?)"$/) do |name|
4
2
  path = File.expand_path(File.join(File.dirname(__FILE__),
5
3
  '..', 'packet_data', name))
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  Given(/^PENDING/) do
4
2
  pending
5
3
  end
@@ -1,4 +1,2 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio'
4
2
  require 'pio/pcap'
data/lib/pio.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/parse_error'
4
2
 
5
3
  require 'pio/arp'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/arp/format'
4
2
  require 'pio/arp/request'
5
3
  require 'pio/arp/reply'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bindata'
4
2
  require 'pio/type/ethernet_header'
5
3
  require 'pio/type/ip_address'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'forwardable'
4
2
  require 'pio/arp/format'
5
3
 
@@ -9,31 +7,25 @@ module Pio
9
7
  class Message
10
8
  extend Forwardable
11
9
 
12
- def_delegators :@frame, :destination_mac
13
- def_delegators :@frame, :source_mac
14
- def_delegators :@frame, :ether_type
15
- def_delegators :@frame, :hardware_type
16
- def_delegators :@frame, :protocol_type
17
- def_delegators :@frame, :hardware_length
18
- def_delegators :@frame, :protocol_length
19
- def_delegators :@frame, :operation
20
- def_delegators :@frame, :sender_hardware_address
21
- def_delegators :@frame, :sender_protocol_address
22
- def_delegators :@frame, :target_hardware_address
23
- def_delegators :@frame, :target_protocol_address
24
- def_delegators :@frame, :to_binary
25
-
26
- def self.create_from(frame)
27
- message = allocate
28
- message.instance_variable_set :@frame, frame
29
- message
30
- end
10
+ def_delegators :@format, :destination_mac
11
+ def_delegators :@format, :source_mac
12
+ def_delegators :@format, :ether_type
13
+ def_delegators :@format, :hardware_type
14
+ def_delegators :@format, :protocol_type
15
+ def_delegators :@format, :hardware_length
16
+ def_delegators :@format, :protocol_length
17
+ def_delegators :@format, :operation
18
+ def_delegators :@format, :sender_hardware_address
19
+ def_delegators :@format, :sender_protocol_address
20
+ def_delegators :@format, :target_hardware_address
21
+ def_delegators :@format, :target_protocol_address
22
+ def_delegators :@format, :to_binary
31
23
 
32
24
  private_class_method :new
33
25
 
34
26
  def initialize(user_options)
35
27
  options = self.class.const_get(:Options).new(user_options.dup.freeze)
36
- @frame = Arp::Format.new(options.to_hash)
28
+ @format = Arp::Format.new(options.to_hash)
37
29
  end
38
30
  end
39
31
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/arp/message'
4
2
  require 'pio/mac'
5
3
  require 'pio/options'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/arp/message'
4
2
  require 'pio/mac'
5
3
  require 'pio/options'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  # Packet parser and generator library.
4
2
  module Pio
5
3
  # Dhcp parser and generator.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/boot_reply'
4
2
 
5
3
  module Pio
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/message'
4
2
  require 'pio/dhcp/boot_reply_options'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/options'
4
2
  require 'pio/dhcp/common_options'
5
3
  require 'pio/dhcp/dhcp_tlv_options'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/message'
4
2
  require 'pio/dhcp/boot_request_options'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/options'
4
2
  require 'pio/dhcp/common_options'
5
3
  require 'pio/dhcp/dhcp_tlv_options'
@@ -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
  module Pio
4
2
  class Dhcp
5
3
  # DHCP Common Options.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pio
4
2
  class Dhcp
5
3
  # Checksum Calculate Utility.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/optional_tlv'
4
2
  require 'pio/type/ip_address'
5
3
  require 'pio/type/mac_address'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/common_options'
4
2
 
5
3
  module Pio
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/boot_request'
4
2
 
5
3
  module Pio
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module Pio
4
2
  class Dhcp
5
3
  # Dhcp Field Read Methods.
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/type/ethernet_header'
4
2
  require 'pio/type/ipv4_header'
5
3
  require 'pio/type/udp_header'
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/frame'
4
2
  require 'forwardable'
5
3
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/boot_reply'
4
2
 
5
3
  module Pio
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/dhcp/parameter_list'
4
2
  require 'pio/dhcp/client_id'
5
3
  require 'pio/type/ip_address'
@@ -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/dhcp/boot_request'
4
2
 
5
3
  module Pio
@@ -1,18 +1,15 @@
1
- # encoding: utf-8
2
-
3
1
  require 'pio/echo/format'
4
2
  require 'pio/echo/reply'
5
3
  require 'pio/echo/request'
6
4
  require 'pio/message_type_selector'
5
+ require 'pio/open_flow'
7
6
 
8
7
  module Pio
9
8
  # OpenFlow Echo Request and Reply message parser.
10
9
  class Echo
11
10
  extend MessageTypeSelector
12
11
 
13
- REQUEST = 2
14
- REPLY = 3
15
-
16
- message_type REQUEST => Request, REPLY => Reply
12
+ message_type Pio::OpenFlow::Type::ECHO_REQUEST => Request,
13
+ Pio::OpenFlow::Type::ECHO_REPLY => Reply
17
14
  end
18
15
  end
@@ -1,17 +1,21 @@
1
- # encoding: utf-8
2
-
3
1
  require 'bindata'
4
- require 'pio/type/open_flow'
2
+ require 'pio/open_flow'
5
3
 
6
4
  module Pio
7
5
  class Echo
8
- # OpenFlow 1.0 Echo message format.
6
+ # OpenFlow 1.0 Echo request and reply message parser.
9
7
  class Format < BinData::Record
10
- extend Type::OpenFlow
8
+ include Pio::OpenFlow::Type
9
+
10
+ def message_type
11
+ open_flow_header.message_type
12
+ end
11
13
 
12
14
  endian :big
13
15
 
14
- openflow_header
16
+ open_flow_header :open_flow_header
17
+ virtual assert: -> { [ECHO_REQUEST, ECHO_REPLY].include?(message_type) }
18
+
15
19
  string :body
16
20
  end
17
21
  end