Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename SetEtherSourceAddress -> SetSourceMacAddress #268

Merged
merged 1 commit into from
Nov 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
4 changes: 2 additions & 2 deletions features/open_flow10/set_ether_destination_address.feature
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
4 changes: 2 additions & 2 deletions features/open_flow10/set_ether_source_address.feature
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
2 changes: 2 additions & 0 deletions lib/pio/open_flow10.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 4 additions & 3 deletions lib/pio/open_flow10/actions.rb
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions lib/pio/open_flow10/set_source_mac_address.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions spec/pio/open_flow10/packet_out_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,39 +185,39 @@
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'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [81/80]

raw_data: data_dump
}
end

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'),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [86/80]

raw_data: data_dump
}
end

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

Expand Down
6 changes: 3 additions & 3 deletions spec/pio/open_flow10/set_ether_destination_address_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions spec/pio/open_flow10/set_ether_source_address_spec.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down