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

Add SetMetadata action #283

Merged
merged 1 commit into from
Nov 12, 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
14 changes: 14 additions & 0 deletions features/open_flow13/set_metadata.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@open_flow13
Feature: Pio::SetMetadata

Scenario: new(0x123)
When I try to create an OpenFlow action with:
"""
Pio::SetMetadata.new(0x123)
"""
Then it should finish successfully
And the action has the following fields and values:
| field | value |
| action_type | 25 |
| action_length | 16 |
| metadata.to_hex | 0x123 |
2 changes: 1 addition & 1 deletion lib/pio/open_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.switch_version(version)
:SetSourceMacAddress, :SetDestinationMacAddress, :PortStatus, :Stats,
:FlowStats, :DescriptionStats, :AggregateStats, :TableStats, :PortStats,
:QueueStats, :Error, :SetArpOperation, :SetArpSenderProtocolAddress,
:SetArpSenderHardwareAddress, :NiciraRegMove,
:SetArpSenderHardwareAddress, :NiciraRegMove, :SetMetadata,
:NiciraRegLoad].each do |each|
set_message_class_name each, version
@version = version.to_s
Expand Down
1 change: 1 addition & 0 deletions lib/pio/open_flow13.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require 'pio/open_flow13/set_arp_sender_hardware_address'
require 'pio/open_flow13/set_arp_sender_protocol_address'
require 'pio/open_flow13/set_destination_mac_address'
require 'pio/open_flow13/set_metadata'
require 'pio/open_flow13/set_source_mac_address'

# Instructions
Expand Down
21 changes: 21 additions & 0 deletions lib/pio/open_flow13/set_metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'pio/open_flow/action'
require 'pio/open_flow13/match'

module Pio
module OpenFlow13
# Set metadata
class SetMetadata < OpenFlow::Action
action_header action_type: 25, action_length: 16

uint16 :oxm_class, value: Match::OpenFlowBasicValue::OXM_CLASS
bit7 :oxm_field, value: Match::ArpOperation::OXM_FIELD
bit1 :oxm_hasmask, value: 0
uint8 :oxm_length, value: 8
uint64 :metadata

def initialize(metadata)
super metadata: metadata
end
end
end
end