pio 0.27.2 → 0.28.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.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -0
  3. data/Rakefile +1 -1
  4. data/bin/{code_metrics → terminal-notifier} +2 -2
  5. data/features/dhcp.feature +12 -12
  6. data/features/icmp.feature +12 -12
  7. data/features/open_flow10/aggregate_stats_request.feature +10 -10
  8. data/features/open_flow10/enqueue.feature +7 -7
  9. data/features/open_flow10/exact_match.feature +15 -15
  10. data/features/open_flow10/features_reply.feature +40 -40
  11. data/features/open_flow10/flow_mod.feature +49 -49
  12. data/features/open_flow10/flow_removed.feature +34 -0
  13. data/features/open_flow10/flow_stats_reply.feature +14 -14
  14. data/features/open_flow10/flow_stats_request.feature +15 -15
  15. data/features/open_flow10/nicira_resubmit.feature +30 -0
  16. data/features/open_flow10/nicira_resubmit_table.feature +32 -0
  17. data/features/open_flow10/port_stats_request.feature +48 -0
  18. data/features/open_flow10/port_stats_request.raw +0 -0
  19. data/features/open_flow10/queue_stats_request.feature +51 -0
  20. data/features/open_flow10/queue_stats_request.raw +0 -0
  21. data/features/open_flow10/send_out_port.feature +40 -40
  22. data/features/open_flow10/set_destination_mac_address.feature +16 -0
  23. data/features/open_flow10/set_ip_destination_address.feature +6 -6
  24. data/features/open_flow10/set_source_ip_address.feature +16 -0
  25. data/features/open_flow10/set_source_mac_address.feature +16 -0
  26. data/features/open_flow10/{set_ip_tos.feature → set_tos.feature} +3 -3
  27. data/features/open_flow10/set_transport_destination_port.feature +6 -6
  28. data/features/open_flow10/set_transport_source_port.feature +6 -6
  29. data/features/open_flow10/set_vlan_priority.feature +3 -3
  30. data/features/open_flow10/set_vlan_vid.feature +6 -6
  31. data/features/open_flow10/strip_vlan_header.feature +5 -5
  32. data/features/open_flow10/table_stats_request.feature +31 -0
  33. data/features/open_flow13/match.feature +33 -33
  34. data/features/open_flow13/send_out_port.feature +45 -45
  35. data/features/udp.feature +2 -2
  36. data/lib/pio/arp/format.rb +5 -5
  37. data/lib/pio/dhcp/boot_reply_options.rb +6 -6
  38. data/lib/pio/dhcp/boot_request_options.rb +2 -2
  39. data/lib/pio/dhcp/common_options.rb +5 -5
  40. data/lib/pio/dhcp/message.rb +2 -2
  41. data/lib/pio/icmp/options.rb +2 -2
  42. data/lib/pio/icmp/reply.rb +6 -6
  43. data/lib/pio/icmp/request.rb +6 -6
  44. data/lib/pio/ipv4_header.rb +11 -11
  45. data/lib/pio/open_flow.rb +5 -2
  46. data/lib/pio/open_flow/action.rb +41 -0
  47. data/lib/pio/open_flow/nicira_action.rb +17 -0
  48. data/lib/pio/open_flow10.rb +12 -1
  49. data/lib/pio/open_flow10/actions.rb +17 -15
  50. data/lib/pio/open_flow10/enqueue.rb +27 -46
  51. data/lib/pio/open_flow10/features/reply.rb +5 -5
  52. data/lib/pio/open_flow10/flow_removed.rb +40 -0
  53. data/lib/pio/open_flow10/match.rb +33 -33
  54. data/lib/pio/open_flow10/nicira_resubmit.rb +20 -0
  55. data/lib/pio/open_flow10/nicira_resubmit_table.rb +17 -0
  56. data/lib/pio/open_flow10/port_stats/request.rb +25 -0
  57. data/lib/pio/open_flow10/queue_stats/request.rb +22 -0
  58. data/lib/pio/open_flow10/send_out_port.rb +6 -27
  59. data/lib/pio/open_flow10/set_destination_ip_address.rb +16 -0
  60. data/lib/pio/open_flow10/set_destination_mac_address.rb +18 -0
  61. data/lib/pio/open_flow10/set_source_ip_address.rb +16 -0
  62. data/lib/pio/open_flow10/set_source_mac_address.rb +18 -0
  63. data/lib/pio/open_flow10/set_tos.rb +24 -0
  64. data/lib/pio/open_flow10/set_transport_port.rb +32 -48
  65. data/lib/pio/open_flow10/set_vlan_priority.rb +16 -11
  66. data/lib/pio/open_flow10/set_vlan_vid.rb +16 -11
  67. data/lib/pio/open_flow10/stats_request.rb +5 -1
  68. data/lib/pio/open_flow10/strip_vlan_header.rb +8 -25
  69. data/lib/pio/open_flow10/table_stats/request.rb +19 -0
  70. data/lib/pio/open_flow13/actions.rb +1 -1
  71. data/lib/pio/open_flow13/match.rb +19 -19
  72. data/lib/pio/open_flow13/send_out_port.rb +9 -28
  73. data/lib/pio/udp_header.rb +4 -4
  74. data/lib/pio/version.rb +1 -1
  75. data/pio.gemspec +3 -2
  76. data/spec/pio/dhcp/ack_spec.rb +8 -8
  77. data/spec/pio/dhcp/offer_spec.rb +8 -8
  78. data/spec/pio/dhcp_spec.rb +16 -16
  79. data/spec/pio/icmp/reply_spec.rb +4 -4
  80. data/spec/pio/icmp/request_spec.rb +6 -6
  81. data/spec/pio/icmp_spec.rb +4 -4
  82. data/spec/pio/open_flow10/enqueue_spec.rb +13 -11
  83. data/spec/pio/open_flow10/flow_mod_spec.rb +20 -20
  84. data/spec/pio/open_flow10/flow_stats_request_spec.rb +4 -4
  85. data/spec/pio/open_flow10/match_spec.rb +59 -59
  86. data/spec/pio/open_flow10/packet_out_spec.rb +31 -29
  87. data/spec/pio/open_flow10/set_destination_ip_address_spec.rb +27 -0
  88. data/spec/pio/open_flow10/set_destination_mac_address_spec.rb +28 -0
  89. data/spec/pio/open_flow10/set_source_ip_address_spec.rb +27 -0
  90. data/spec/pio/open_flow10/set_source_mac_address_spec.rb +28 -0
  91. data/spec/pio/open_flow10/set_tos_spec.rb +30 -0
  92. data/spec/pio/open_flow10/set_transport_destination_port_spec.rb +4 -4
  93. data/spec/pio/open_flow10/set_transport_source_port_spec.rb +4 -4
  94. data/spec/pio/open_flow10/set_vlan_priority_spec.rb +4 -4
  95. data/spec/pio/open_flow10/set_vlan_vid_spec.rb +4 -4
  96. data/spec/pio/open_flow10/strip_vlan_header_spec.rb +5 -5
  97. data/spec/pio/open_flow10/wildcards_spec.rb +18 -18
  98. data/spec/pio/open_flow13/match_spec.rb +20 -20
  99. metadata +73 -37
  100. data/bin/code_metrics-profile +0 -16
  101. data/features/open_flow10/set_ether_destination_address.feature +0 -16
  102. data/features/open_flow10/set_ether_source_address.feature +0 -16
  103. data/features/open_flow10/set_ip_source_address.feature +0 -16
  104. data/lib/pio/open_flow10/set_ether_address.rb +0 -53
  105. data/lib/pio/open_flow10/set_ip_address.rb +0 -49
  106. data/lib/pio/open_flow10/set_ip_tos.rb +0 -42
  107. data/lib/pio/open_flow10/set_vlan.rb +0 -37
  108. data/spec/pio/open_flow10/set_ether_destination_address_spec.rb +0 -28
  109. data/spec/pio/open_flow10/set_ether_source_address_spec.rb +0 -28
  110. data/spec/pio/open_flow10/set_ip_destination_address_spec.rb +0 -27
  111. data/spec/pio/open_flow10/set_ip_source_address_spec.rb +0 -25
  112. data/spec/pio/open_flow10/set_ip_tos_spec.rb +0 -30
@@ -18,8 +18,8 @@ Feature: Pio::Udp
18
18
  | ip_ttl | 250 |
19
19
  | ip_protocol | 17 |
20
20
  | ip_header_checksum | 6027 |
21
- | ip_source_address | 0.0.0.0 |
22
- | ip_destination_address | 255.255.255.255 |
21
+ | source_ip_address | 0.0.0.0 |
22
+ | destination_ip_address | 255.255.255.255 |
23
23
  | ip_option | |
24
24
  | udp_source_port | 68 |
25
25
  | udp_destination_port | 67 |
@@ -31,15 +31,15 @@ module Pio
31
31
  def to_exact_match(in_port)
32
32
  match_options = {
33
33
  in_port: in_port,
34
- ether_source_address: source_mac,
35
- ether_destination_address: destination_mac,
34
+ source_mac_address: source_mac,
35
+ destination_mac_address: destination_mac,
36
36
  vlan_vid: vlan_vid,
37
37
  vlan_priority: vlan_pcp,
38
38
  ether_type: ether_type,
39
- ip_tos: 0,
39
+ tos: 0,
40
40
  ip_protocol: operation,
41
- ip_source_address: sender_protocol_address,
42
- ip_destination_address: target_protocol_address,
41
+ source_ip_address: sender_protocol_address,
42
+ destination_ip_address: target_protocol_address,
43
43
  transport_source_port: 0,
44
44
  transport_destination_port: 0
45
45
  }
@@ -11,8 +11,8 @@ module Pio
11
11
 
12
12
  mandatory_option :source_mac
13
13
  mandatory_option :destination_mac
14
- mandatory_option :ip_source_address
15
- mandatory_option :ip_destination_address
14
+ mandatory_option :source_ip_address
15
+ mandatory_option :destination_ip_address
16
16
  mandatory_option :type
17
17
  option :subnet_mask
18
18
  option :renewal_time_value
@@ -29,8 +29,8 @@ module Pio
29
29
  {
30
30
  destination_mac: destination_mac,
31
31
  source_mac: source_mac,
32
- ip_destination_address: ip_destination_address,
33
- ip_source_address: ip_source_address,
32
+ destination_ip_address: destination_ip_address,
33
+ source_ip_address: source_ip_address,
34
34
  udp_source_port: BOOTPS,
35
35
  udp_destination_port: BOOTPC,
36
36
  dhcp: dhcp_data
@@ -44,7 +44,7 @@ module Pio
44
44
  message_type: BootReply::MESSAGE_TYPE,
45
45
  transaction_id: transaction_id,
46
46
  client_ip_address: QUAD_ZERO_IP_ADDRESS,
47
- your_ip_address: ip_destination_address,
47
+ your_ip_address: destination_ip_address,
48
48
  next_server_ip_address: QUAD_ZERO_IP_ADDRESS,
49
49
  relay_agent_ip_address: QUAD_ZERO_IP_ADDRESS,
50
50
  client_mac_address: source_mac,
@@ -65,7 +65,7 @@ module Pio
65
65
 
66
66
  def server_identifier
67
67
  IPv4Address.new(
68
- @options[:server_identifier] || ip_source_address
68
+ @options[:server_identifier] || source_ip_address
69
69
  )
70
70
  end
71
71
  end
@@ -25,8 +25,8 @@ module Pio
25
25
  {
26
26
  destination_mac: destination_mac,
27
27
  source_mac: source_mac,
28
- ip_source_address: QUAD_ZERO_IP_ADDRESS,
29
- ip_destination_address: BROADCAST_IP_ADDRESS,
28
+ source_ip_address: QUAD_ZERO_IP_ADDRESS,
29
+ destination_ip_address: BROADCAST_IP_ADDRESS,
30
30
  udp_source_port: BOOTPC,
31
31
  udp_destination_port: BOOTPS,
32
32
  dhcp: dhcp_data
@@ -24,17 +24,17 @@ module Pio
24
24
  Mac.new(@options[:destination_mac] || BROADCAST_MAC_ADDRESS)
25
25
  end
26
26
 
27
- def ip_source_address
28
- IPv4Address.new(@options[:ip_source_address])
27
+ def source_ip_address
28
+ IPv4Address.new(@options[:source_ip_address])
29
29
  end
30
30
 
31
- def ip_destination_address
32
- IPv4Address.new(@options[:ip_destination_address])
31
+ def destination_ip_address
32
+ IPv4Address.new(@options[:destination_ip_address])
33
33
  end
34
34
 
35
35
  def server_identifier
36
36
  IPv4Address.new(
37
- @options[:server_identifier] || ip_source_address
37
+ @options[:server_identifier] || source_ip_address
38
38
  )
39
39
  end
40
40
 
@@ -20,8 +20,8 @@ module Pio
20
20
  def_delegators :@frame, :ip_ttl
21
21
  def_delegators :@frame, :ip_protocol
22
22
  def_delegators :@frame, :ip_header_checksum
23
- def_delegators :@frame, :ip_source_address
24
- def_delegators :@frame, :ip_destination_address
23
+ def_delegators :@frame, :source_ip_address
24
+ def_delegators :@frame, :destination_ip_address
25
25
  def_delegators :@frame, :udp_source_port
26
26
  def_delegators :@frame, :udp_destination_port
27
27
  def_delegators :@frame, :udp_length
@@ -9,8 +9,8 @@ module Pio
9
9
  icmp_type: @type,
10
10
  source_mac: @source_mac,
11
11
  destination_mac: @destination_mac,
12
- ip_source_address: @ip_source_address,
13
- ip_destination_address: @ip_destination_address,
12
+ source_ip_address: @source_ip_address,
13
+ destination_ip_address: @destination_ip_address,
14
14
  icmp_identifier: @identifier,
15
15
  icmp_sequence_number: @sequence_number,
16
16
  echo_data: @echo_data
@@ -13,8 +13,8 @@ module Pio
13
13
  class Options < Pio::Icmp::Options
14
14
  mandatory_option :source_mac
15
15
  mandatory_option :destination_mac
16
- mandatory_option :ip_source_address
17
- mandatory_option :ip_destination_address
16
+ mandatory_option :source_ip_address
17
+ mandatory_option :destination_ip_address
18
18
  mandatory_option :identifier
19
19
  mandatory_option :sequence_number
20
20
  option :echo_data
@@ -27,10 +27,10 @@ module Pio
27
27
 
28
28
  @source_mac = Mac.new(options[:source_mac]).freeze
29
29
  @destination_mac = Mac.new(options[:destination_mac]).freeze
30
- @ip_source_address =
31
- IPv4Address.new(options[:ip_source_address]).freeze
32
- @ip_destination_address =
33
- IPv4Address.new(options[:ip_destination_address]).freeze
30
+ @source_ip_address =
31
+ IPv4Address.new(options[:source_ip_address]).freeze
32
+ @destination_ip_address =
33
+ IPv4Address.new(options[:destination_ip_address]).freeze
34
34
  @identifier = options[:identifier]
35
35
  @sequence_number = options[:sequence_number]
36
36
  @echo_data = options[:echo_data] || ''
@@ -16,8 +16,8 @@ module Pio
16
16
 
17
17
  mandatory_option :source_mac
18
18
  mandatory_option :destination_mac
19
- mandatory_option :ip_source_address
20
- mandatory_option :ip_destination_address
19
+ mandatory_option :source_ip_address
20
+ mandatory_option :destination_ip_address
21
21
  option :identifier
22
22
  option :sequence_number
23
23
  option :echo_data
@@ -30,10 +30,10 @@ module Pio
30
30
 
31
31
  @source_mac = Mac.new(options[:source_mac]).freeze
32
32
  @destination_mac = Mac.new(options[:destination_mac]).freeze
33
- @ip_source_address =
34
- IPv4Address.new(options[:ip_source_address]).freeze
35
- @ip_destination_address =
36
- IPv4Address.new(options[:ip_destination_address]).freeze
33
+ @source_ip_address =
34
+ IPv4Address.new(options[:source_ip_address]).freeze
35
+ @destination_ip_address =
36
+ IPv4Address.new(options[:destination_ip_address]).freeze
37
37
  @identifier =
38
38
  options[:icmp_identifier] ||
39
39
  options[:identifier] ||
@@ -26,8 +26,8 @@ module Pio
26
26
  uint8 :ip_ttl, initial_value: 128
27
27
  uint8 :ip_protocol, initial_value: options[:ip_protocol] || 0
28
28
  uint16be :ip_header_checksum, initial_value: :calculate_ip_checksum
29
- ip_address :ip_source_address
30
- ip_address :ip_destination_address
29
+ ip_address :source_ip_address
30
+ ip_address :destination_ip_address
31
31
  string :ip_option, read_length: :ip_option_length
32
32
  end
33
33
  end
@@ -37,15 +37,15 @@ module Pio
37
37
  def to_exact_match(in_port)
38
38
  match_options = {
39
39
  in_port: in_port,
40
- ether_source_address: source_mac,
41
- ether_destination_address: destination_mac,
40
+ source_mac_address: source_mac,
41
+ destination_mac_address: destination_mac,
42
42
  vlan_vid: vlan_vid,
43
43
  vlan_priority: vlan_pcp,
44
44
  ether_type: ether_type,
45
- ip_tos: ip_type_of_service,
45
+ tos: ip_type_of_service,
46
46
  ip_protocol: ip_protocol,
47
- ip_source_address: ip_source_address,
48
- ip_destination_address: ip_destination_address,
47
+ source_ip_address: source_ip_address,
48
+ destination_ip_address: destination_ip_address,
49
49
  transport_source_port: transport_source_port,
50
50
  transport_destination_port: transport_destination_port
51
51
  }
@@ -66,10 +66,10 @@ module Pio
66
66
  ip_identifier,
67
67
  ip_flag << 13 | ip_fragment,
68
68
  ip_ttl << 8 | ip_protocol,
69
- ip_source_address >> 16,
70
- ip_source_address & 0xffff,
71
- ip_destination_address >> 16,
72
- ip_destination_address & 0xffff].reduce(:+)
69
+ source_ip_address >> 16,
70
+ source_ip_address & 0xffff,
71
+ destination_ip_address >> 16,
72
+ destination_ip_address & 0xffff].reduce(:+)
73
73
  ~((sum & 0xffff) + (sum >> 16)) & 0xffff
74
74
  end
75
75
  # rubocop:enable AbcSize
@@ -16,8 +16,10 @@ module Pio
16
16
 
17
17
  def self.switch_version(version)
18
18
  [:Barrier, :Echo, :Features, :FlowMod, :Hello, :Match,
19
- :PacketIn, :PacketOut, :SendOutPort, :PortStatus, :Stats,
20
- :FlowStats, :DescriptionStats, :AggregateStats, :Error].each do |each|
19
+ :PacketIn, :FlowRemoved, :PacketOut, :SendOutPort, :PortStatus,
20
+ :Stats, :FlowStats, :DescriptionStats, :AggregateStats,
21
+ :TableStats, :PortStats, :QueueStats, :Error, :NiciraResubmit,
22
+ :NiciraResubmitTable].each do |each|
21
23
  set_message_class_name each, version
22
24
  @version = version.to_s
23
25
  end
@@ -33,6 +35,7 @@ module Pio
33
35
  5 => Pio::Features::Request,
34
36
  6 => Pio::Features::Reply,
35
37
  10 => Pio::PacketIn,
38
+ 11 => Pio::FlowRemoved,
36
39
  12 => Pio::PortStatus,
37
40
  13 => Pio::PacketOut,
38
41
  14 => Pio::FlowMod,
@@ -0,0 +1,41 @@
1
+ require 'bindata'
2
+
3
+ module Pio
4
+ module OpenFlow
5
+ # OpenFlow actions.
6
+ class Action
7
+ def self.inherited(child_klass)
8
+ child_klass.const_set :Format, Class.new(BinData::Record)
9
+ end
10
+
11
+ def self.action_header(options)
12
+ module_eval do
13
+ endian :big
14
+
15
+ uint16 :action_type, value: options.fetch(:action_type)
16
+ uint16 :action_length, value: options.fetch(:action_length)
17
+ end
18
+ end
19
+
20
+ def self.read(raw_data)
21
+ action = allocate
22
+ action.instance_variable_set :@format, const_get(:Format).read(raw_data)
23
+ action
24
+ end
25
+
26
+ def self.method_missing(method, *args, &block)
27
+ const_get(:Format).__send__ method, *args, &block
28
+ return if method == :endian || method == :virtual
29
+ define_method(args.first) { @format.__send__ args.first }
30
+ end
31
+
32
+ def initialize(user_options)
33
+ @format = self.class.const_get(:Format).new(user_options)
34
+ end
35
+
36
+ def to_binary
37
+ @format.to_binary_s
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ require 'pio/open_flow/action'
2
+
3
+ module Pio
4
+ module OpenFlow
5
+ # NXAST_* actions
6
+ class NiciraAction < Action
7
+ def self.nicira_action_header(options)
8
+ module_eval do
9
+ action_header action_type: options.fetch(:action_type),
10
+ action_length: options.fetch(:action_length)
11
+ uint32 :vendor, value: 0x2320
12
+ uint16 :subtype, value: options.fetch(:subtype)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,4 @@
1
1
  # Messages
2
- require 'pio/open_flow10/stats_reply'
3
2
  require 'pio/open_flow10/aggregate_stats/reply'
4
3
  require 'pio/open_flow10/aggregate_stats/request'
5
4
  require 'pio/open_flow10/barrier/reply'
@@ -14,16 +13,28 @@ require 'pio/open_flow10/error/hello_failed'
14
13
  require 'pio/open_flow10/features/reply'
15
14
  require 'pio/open_flow10/features/request'
16
15
  require 'pio/open_flow10/flow_mod'
16
+ require 'pio/open_flow10/flow_removed'
17
17
  require 'pio/open_flow10/flow_stats/reply'
18
18
  require 'pio/open_flow10/flow_stats/request'
19
19
  require 'pio/open_flow10/hello'
20
20
  require 'pio/open_flow10/packet_in'
21
21
  require 'pio/open_flow10/packet_out'
22
+ require 'pio/open_flow10/port_stats/request'
22
23
  require 'pio/open_flow10/port_status'
24
+ require 'pio/open_flow10/queue_stats/request'
25
+ require 'pio/open_flow10/stats_reply'
23
26
  require 'pio/open_flow10/stats_request'
27
+ require 'pio/open_flow10/table_stats/request'
24
28
 
25
29
  # Actions
30
+ require 'pio/open_flow10/nicira_resubmit'
31
+ require 'pio/open_flow10/nicira_resubmit_table'
26
32
  require 'pio/open_flow10/send_out_port'
33
+ require 'pio/open_flow10/set_destination_mac_address'
34
+ require 'pio/open_flow10/set_source_mac_address'
35
+ require 'pio/open_flow10/set_tos'
36
+ require 'pio/open_flow10/set_vlan_priority'
37
+ require 'pio/open_flow10/set_vlan_vid'
27
38
 
28
39
  # Misc.
29
40
  require 'pio/open_flow10/exact_match'
@@ -1,9 +1,11 @@
1
1
  require 'bindata'
2
2
  require 'pio/open_flow10/enqueue'
3
3
  require 'pio/open_flow10/send_out_port'
4
- require 'pio/open_flow10/set_ether_address'
5
- require 'pio/open_flow10/set_ip_address'
6
- require 'pio/open_flow10/set_ip_tos'
4
+ require 'pio/open_flow10/set_destination_ip_address'
5
+ require 'pio/open_flow10/set_destination_mac_address'
6
+ require 'pio/open_flow10/set_source_ip_address'
7
+ require 'pio/open_flow10/set_source_mac_address'
8
+ require 'pio/open_flow10/set_tos'
7
9
  require 'pio/open_flow10/set_transport_port'
8
10
  require 'pio/open_flow10/set_vlan_priority'
9
11
  require 'pio/open_flow10/set_vlan_vid'
@@ -16,17 +18,17 @@ module Pio
16
18
  class Actions < BinData::Primitive
17
19
  ACTION_CLASS = {
18
20
  0 => Pio::OpenFlow10::SendOutPort,
19
- 1 => Pio::SetVlanVid,
20
- 2 => Pio::SetVlanPriority,
21
- 3 => Pio::StripVlanHeader,
22
- 4 => Pio::SetEtherSourceAddress,
23
- 5 => Pio::SetEtherDestinationAddress,
24
- 6 => Pio::SetIpSourceAddress,
25
- 7 => Pio::SetIpDestinationAddress,
26
- 8 => Pio::SetIpTos,
27
- 9 => Pio::SetTransportSourcePort,
28
- 10 => Pio::SetTransportDestinationPort,
29
- 11 => Pio::Enqueue,
21
+ 1 => Pio::OpenFlow10::SetVlanVid,
22
+ 2 => Pio::OpenFlow10::SetVlanPriority,
23
+ 3 => Pio::OpenFlow10::StripVlanHeader,
24
+ 4 => Pio::OpenFlow10::SetSourceMacAddress,
25
+ 5 => Pio::OpenFlow10::SetDestinationMacAddress,
26
+ 6 => Pio::OpenFlow10::SetSourceIpAddress,
27
+ 7 => Pio::OpenFlow10::SetDestinationIpAddress,
28
+ 8 => Pio::OpenFlow10::SetTos,
29
+ 9 => Pio::OpenFlow10::SetTransportSourcePort,
30
+ 10 => Pio::OpenFlow10::SetTransportDestinationPort,
31
+ 11 => Pio::OpenFlow10::Enqueue,
30
32
  0xffff => Pio::VendorAction
31
33
  }
32
34
 
@@ -49,7 +51,7 @@ module Pio
49
51
  type = BinData::Uint16be.read(tmp)
50
52
  begin
51
53
  action = ACTION_CLASS.fetch(type).read(tmp)
52
- tmp = tmp[action.length..-1]
54
+ tmp = tmp[action.action_length..-1]
53
55
  actions << action
54
56
  rescue KeyError
55
57
  raise "action type #{type} is not supported."
@@ -1,62 +1,43 @@
1
- require 'bindata'
2
- require 'forwardable'
3
1
  require 'pio/monkey_patch/integer'
2
+ require 'pio/open_flow/action'
4
3
  require 'pio/open_flow10/port16'
5
4
 
6
5
  module Pio
7
- # An action to enqueue the packet on the specified queue attached to
8
- # a port.
9
- class Enqueue
10
- # OpenFlow 1.0 OFPAT_ENQUEUE action format.
11
- class Format < BinData::Record
12
- endian :big
13
-
14
- uint16 :action_type, value: 11
15
- uint16 :action_length, value: 16
6
+ module OpenFlow10
7
+ # An action to enqueue the packet on the specified queue attached
8
+ # to a port.
9
+ class Enqueue < OpenFlow::Action
10
+ action_header action_type: 11, action_length: 16
16
11
  port16 :port
17
- uint48 :padding
12
+ string :padding, length: 6
18
13
  hide :padding
19
14
  uint32 :queue_id
20
- end
21
-
22
- def self.read(raw_data)
23
- enqueue = allocate
24
- enqueue.instance_variable_set :@format, Format.read(raw_data)
25
- enqueue
26
- end
27
-
28
- extend Forwardable
29
15
 
30
- def_delegators :@format, :action_type
31
- def_delegator :@format, :action_length, :length
32
- def_delegators :@format, :port
33
- def_delegators :@format, :queue_id
34
- def_delegator :@format, :to_binary_s, :to_binary
35
-
36
- def initialize(user_options)
37
- validate_port user_options
38
- validate_queue_id user_options
39
- @format = Format.new(user_options)
40
- end
16
+ def initialize(user_options)
17
+ validate_port user_options
18
+ validate_queue_id user_options
19
+ super(user_options)
20
+ end
41
21
 
42
- private
22
+ private
43
23
 
44
- def validate_port(user_options)
45
- port = user_options.fetch(:port)
46
- if port.is_a?(Symbol) && port != :in_port
47
- fail(ArgumentError,
48
- ':port must be a valid physical port or :in_port')
24
+ def validate_port(user_options)
25
+ port = user_options.fetch(:port)
26
+ if port.is_a?(Symbol) && port != :in_port
27
+ fail(ArgumentError,
28
+ ':port must be a valid physical port or :in_port')
29
+ end
30
+ rescue KeyError
31
+ raise ArgumentError, ':port is a mandatory option'
49
32
  end
50
- rescue KeyError
51
- raise ArgumentError, ':port is a mandatory option'
52
- end
53
33
 
54
- def validate_queue_id(user_options)
55
- unless user_options.fetch(:queue_id).unsigned_32bit?
56
- fail ArgumentError, ':queue_id must be an unsigned 32-bit integer'
34
+ def validate_queue_id(user_options)
35
+ unless user_options.fetch(:queue_id).unsigned_32bit?
36
+ fail ArgumentError, ':queue_id must be an unsigned 32-bit integer'
37
+ end
38
+ rescue KeyError
39
+ raise ArgumentError, ':queue_id is a mandatory option'
57
40
  end
58
- rescue KeyError
59
- raise ArgumentError, ':queue_id is a mandatory option'
60
41
  end
61
42
  end
62
43
  end