diff --git a/Rakefile b/Rakefile index 78b36426..eb0c1a81 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'bundler/gem_tasks' RELISH_PROJECT = 'trema/pio' -FLAY_THRESHOLD = 1090 +FLAY_THRESHOLD = 1094 task default: :travis task test: [:spec, :cucumber] diff --git a/features/open_flow10/set_ether_destination_address.feature b/features/open_flow10/set_ether_destination_address.feature index 3c30678b..6bd300a3 100644 --- a/features/open_flow10/set_ether_destination_address.feature +++ b/features/open_flow10/set_ether_destination_address.feature @@ -1,10 +1,10 @@ @open_flow10 -Feature: Pio::OpenFlow10::SetEtherDestinationAddress +Feature: Pio::OpenFlow10::SetDestinationMacAddress Scenario: new('11:22:33:44:55:66') When I try to create an OpenFlow action with: """ - Pio::OpenFlow10::SetEtherDestinationAddress.new('11:22:33:44:55:66') + Pio::OpenFlow10::SetDestinationMacAddress.new('11:22:33:44:55:66') """ Then it should finish successfully And the action has the following fields and values: diff --git a/features/open_flow10/set_ether_source_address.feature b/features/open_flow10/set_ether_source_address.feature index 1bc8bd45..b9c54422 100644 --- a/features/open_flow10/set_ether_source_address.feature +++ b/features/open_flow10/set_ether_source_address.feature @@ -1,10 +1,10 @@ @open_flow10 -Feature: Pio::OpenFlow10::SetEtherSourceAddress +Feature: Pio::OpenFlow10::SetSourceMacAddress Scenario: new('11:22:33:44:55:66') When I try to create an OpenFlow action with: """ - Pio::OpenFlow10::SetEtherSourceAddress.new('11:22:33:44:55:66') + Pio::OpenFlow10::SetSourceMacAddress.new('11:22:33:44:55:66') """ Then it should finish successfully And the action has the following fields and values: diff --git a/lib/pio/open_flow10.rb b/lib/pio/open_flow10.rb index bf45b554..50814d61 100644 --- a/lib/pio/open_flow10.rb +++ b/lib/pio/open_flow10.rb @@ -30,6 +30,8 @@ require 'pio/open_flow10/nicira_resubmit' require 'pio/open_flow10/nicira_resubmit_table' require 'pio/open_flow10/send_out_port' +require 'pio/open_flow10/set_destination_mac_address' +require 'pio/open_flow10/set_source_mac_address' require 'pio/open_flow10/set_tos' require 'pio/open_flow10/set_vlan_priority' require 'pio/open_flow10/set_vlan_vid' diff --git a/lib/pio/open_flow10/actions.rb b/lib/pio/open_flow10/actions.rb index 56605e5b..56e08d2b 100644 --- a/lib/pio/open_flow10/actions.rb +++ b/lib/pio/open_flow10/actions.rb @@ -1,8 +1,9 @@ require 'bindata' require 'pio/open_flow10/enqueue' require 'pio/open_flow10/send_out_port' -require 'pio/open_flow10/set_ether_address' +require 'pio/open_flow10/set_destination_mac_address' require 'pio/open_flow10/set_ip_address' +require 'pio/open_flow10/set_source_mac_address' require 'pio/open_flow10/set_tos' require 'pio/open_flow10/set_transport_port' require 'pio/open_flow10/set_vlan_priority' @@ -19,8 +20,8 @@ class Actions < BinData::Primitive 1 => Pio::OpenFlow10::SetVlanVid, 2 => Pio::OpenFlow10::SetVlanPriority, 3 => Pio::OpenFlow10::StripVlanHeader, - 4 => Pio::OpenFlow10::SetEtherSourceAddress, - 5 => Pio::OpenFlow10::SetEtherDestinationAddress, + 4 => Pio::OpenFlow10::SetSourceMacAddress, + 5 => Pio::OpenFlow10::SetDestinationMacAddress, 6 => Pio::OpenFlow10::SetIpSourceAddress, 7 => Pio::OpenFlow10::SetIpDestinationAddress, 8 => Pio::OpenFlow10::SetTos, diff --git a/lib/pio/open_flow10/set_ether_address.rb b/lib/pio/open_flow10/set_destination_mac_address.rb similarity index 50% rename from lib/pio/open_flow10/set_ether_address.rb rename to lib/pio/open_flow10/set_destination_mac_address.rb index fe8170d7..4612878b 100644 --- a/lib/pio/open_flow10/set_ether_address.rb +++ b/lib/pio/open_flow10/set_destination_mac_address.rb @@ -3,20 +3,8 @@ module Pio module OpenFlow10 - # An action to modify the source Ethernet address of a packet. - class SetEtherSourceAddress < OpenFlow::Action - action_header action_type: 4, action_length: 16 - mac_address :mac_address - string :padding, length: 6 - hide :padding - - def initialize(mac_address) - super mac_address: mac_address - end - end - # An action to modify the destination Ethernet address of a packet. - class SetEtherDestinationAddress < OpenFlow::Action + class SetDestinationMacAddress < OpenFlow::Action action_header action_type: 5, action_length: 16 mac_address :mac_address string :padding, length: 6 diff --git a/lib/pio/open_flow10/set_source_mac_address.rb b/lib/pio/open_flow10/set_source_mac_address.rb new file mode 100644 index 00000000..ad7b1c48 --- /dev/null +++ b/lib/pio/open_flow10/set_source_mac_address.rb @@ -0,0 +1,18 @@ +require 'pio/open_flow/action' +require 'pio/type/mac_address' + +module Pio + module OpenFlow10 + # An action to modify the source Ethernet address of a packet. + class SetSourceMacAddress < OpenFlow::Action + action_header action_type: 4, action_length: 16 + mac_address :mac_address + string :padding, length: 6 + hide :padding + + def initialize(mac_address) + super mac_address: mac_address + end + end + end +end diff --git a/spec/pio/open_flow10/packet_out_spec.rb b/spec/pio/open_flow10/packet_out_spec.rb index 62928be6..aeb8ab1a 100644 --- a/spec/pio/open_flow10/packet_out_spec.rb +++ b/spec/pio/open_flow10/packet_out_spec.rb @@ -185,13 +185,13 @@ Then { result.actions[0].is_a? Pio::OpenFlow10::StripVlanHeader } end - context 'with a SetEtherSourceAddress action' do + context 'with a SetSourceMacAddress action' do When(:user_options) do { transaction_id: 0x16, buffer_id: 0xffffffff, in_port: 0xffff, - actions: Pio::OpenFlow10::SetEtherSourceAddress.new('11:22:33:44:55:66'), + actions: Pio::OpenFlow10::SetSourceMacAddress.new('11:22:33:44:55:66'), raw_data: data_dump } end @@ -199,17 +199,17 @@ Then { result.message_length == 0x60 } Then { result.actions_len == 0x10 } Then { result.actions.length == 1 } - Then { result.actions[0].is_a? Pio::OpenFlow10::SetEtherSourceAddress } + Then { result.actions[0].is_a? Pio::OpenFlow10::SetSourceMacAddress } Then { result.actions[0].mac_address == '11:22:33:44:55:66' } end - context 'with a SetEtherDestinationAddress action' do + context 'with a SetDestinationMacAddress action' do When(:user_options) do { transaction_id: 0x16, buffer_id: 0xffffffff, in_port: 0xffff, - actions: Pio::OpenFlow10::SetEtherDestinationAddress.new('11:22:33:44:55:66'), + actions: Pio::OpenFlow10::SetDestinationMacAddress.new('11:22:33:44:55:66'), raw_data: data_dump } end @@ -217,7 +217,7 @@ Then { result.message_length == 0x60 } Then { result.actions_len == 0x10 } Then { result.actions.length == 1 } - Then { result.actions[0].is_a? Pio::OpenFlow10::SetEtherDestinationAddress } + Then { result.actions[0].is_a? Pio::OpenFlow10::SetDestinationMacAddress } Then { result.actions[0].mac_address == '11:22:33:44:55:66' } end diff --git a/spec/pio/open_flow10/set_ether_destination_address_spec.rb b/spec/pio/open_flow10/set_ether_destination_address_spec.rb index e0a1ce80..0a0d1ee4 100644 --- a/spec/pio/open_flow10/set_ether_destination_address_spec.rb +++ b/spec/pio/open_flow10/set_ether_destination_address_spec.rb @@ -1,9 +1,9 @@ -require 'pio/open_flow10/set_ether_address' +require 'pio/open_flow10/set_destination_mac_address' -describe Pio::OpenFlow10::SetEtherDestinationAddress do +describe Pio::OpenFlow10::SetDestinationMacAddress do describe '.new' do Given(:set_ether_destination_address) do - Pio::OpenFlow10::SetEtherDestinationAddress.new(mac_address) + Pio::OpenFlow10::SetDestinationMacAddress.new(mac_address) end context "with '11:22:33:44:55:66'" do diff --git a/spec/pio/open_flow10/set_ether_source_address_spec.rb b/spec/pio/open_flow10/set_ether_source_address_spec.rb index 728c9e9b..534c835e 100644 --- a/spec/pio/open_flow10/set_ether_source_address_spec.rb +++ b/spec/pio/open_flow10/set_ether_source_address_spec.rb @@ -1,9 +1,9 @@ -require 'pio/open_flow10/set_ether_address' +require 'pio/open_flow10/set_source_mac_address' -describe Pio::OpenFlow10::SetEtherSourceAddress do +describe Pio::OpenFlow10::SetSourceMacAddress do describe '.new' do Given(:set_ether_source_address) do - Pio::OpenFlow10::SetEtherSourceAddress.new(mac_address) + Pio::OpenFlow10::SetSourceMacAddress.new(mac_address) end context "with '11:22:33:44:55:66'" do