Skip to content

Commit

Permalink
Add SetMetadata action
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Nov 11, 2015
1 parent d1be988 commit 518570c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
14 changes: 14 additions & 0 deletions features/open_flow13/set_metadata.feature
@@ -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
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
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
@@ -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

0 comments on commit 518570c

Please sign in to comment.