Skip to content

Commit

Permalink
Add NiciraRegLoad action
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Nov 11, 2015
1 parent 6ff3161 commit 224fe41
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 1 deletion.
18 changes: 18 additions & 0 deletions features/open_flow13/nicira_reg_load.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@open_flow13
Feature: Pio::NiciraRegLoad

Scenario: new(0xdeadbeef, 0, n_bits: 32)
When I try to create an OpenFlow action with:
"""
Pio::NiciraRegLoad.new(0xdeadbeef, 0, n_bits: 32)
"""
Then it should finish successfully
And the action has the following fields and values:
| field | value |
| action_type.to_hex | 0xffff |
| action_length | 24 |
| experimenter_id.to_hex | 0x2320 |
| experimenter_type | 7 |
| n_bits | 32 |
| destination | 65540 |
| value.to_hex | 0xdeadbeef |
2 changes: 1 addition & 1 deletion lib/pio/open_flow.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.switch_version(version)
:FlowStats, :DescriptionStats, :AggregateStats, :TableStats, :PortStats,
:QueueStats, :Error, :NiciraResubmit, :SetArpOperation,
:SetArpSenderProtocolAddress, :SetArpSenderHardwareAddress,
:NiciraResubmitTable, :NiciraRegMove].each do |each|
:NiciraResubmitTable, :NiciraRegMove, :NiciraRegLoad].each do |each|
set_message_class_name each, version
@version = version.to_s
end
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 @@ -13,6 +13,7 @@
require 'pio/open_flow13/stats_request'

# Actions
require 'pio/open_flow13/nicira_reg_load'
require 'pio/open_flow13/nicira_reg_move'
require 'pio/open_flow13/send_out_port'
require 'pio/open_flow13/set_arp_operation'
Expand Down
30 changes: 30 additions & 0 deletions lib/pio/open_flow13/nicira_reg_load.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'pio/open_flow/action'

module Pio
module OpenFlow13
# NXAST_REG_LOAD action
class NiciraRegLoad < OpenFlow::Action
action_header action_type: 0xffff, action_length: 24
uint32 :experimenter_id, value: 0x2320
uint16 :experimenter_type, value: 7
bit10 :ofs
bit6 :n_bits_internal
uint32 :destination
uint64 :value_internal

def initialize(value, register, n_bits: 64)
super(value_internal: value,
destination: ((1 << 16) | (register << 9) | 4),
n_bits_internal: n_bits - 1)
end

def value
value_internal
end

def n_bits
n_bits_internal + 1
end
end
end
end

0 comments on commit 224fe41

Please sign in to comment.