From 224fe410e03320c93f6e3d7e48625a96a26e06f5 Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Wed, 11 Nov 2015 14:02:58 +0900 Subject: [PATCH] Add NiciraRegLoad action --- features/open_flow13/nicira_reg_load.feature | 18 ++++++++++++ lib/pio/open_flow.rb | 2 +- lib/pio/open_flow13.rb | 1 + lib/pio/open_flow13/nicira_reg_load.rb | 30 ++++++++++++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 features/open_flow13/nicira_reg_load.feature create mode 100644 lib/pio/open_flow13/nicira_reg_load.rb diff --git a/features/open_flow13/nicira_reg_load.feature b/features/open_flow13/nicira_reg_load.feature new file mode 100644 index 00000000..942d873e --- /dev/null +++ b/features/open_flow13/nicira_reg_load.feature @@ -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 | diff --git a/lib/pio/open_flow.rb b/lib/pio/open_flow.rb index 87bdeda9..a27fb424 100644 --- a/lib/pio/open_flow.rb +++ b/lib/pio/open_flow.rb @@ -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 diff --git a/lib/pio/open_flow13.rb b/lib/pio/open_flow13.rb index 0914e8c5..ec0fe85f 100644 --- a/lib/pio/open_flow13.rb +++ b/lib/pio/open_flow13.rb @@ -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' diff --git a/lib/pio/open_flow13/nicira_reg_load.rb b/lib/pio/open_flow13/nicira_reg_load.rb new file mode 100644 index 00000000..e0c6318a --- /dev/null +++ b/lib/pio/open_flow13/nicira_reg_load.rb @@ -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