Skip to content

Commit

Permalink
Add NiciraSendOutPort action
Browse files Browse the repository at this point in the history
  • Loading branch information
yasuhito committed Nov 14, 2015
1 parent 927733a commit 16c0356
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
20 changes: 20 additions & 0 deletions features/open_flow13/nicira_send_out_port.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@open_flow13
Feature: Pio::NiciraSendOutPort

Scenario: new(:reg0)
When I try to create an OpenFlow action with:
"""
Pio::NiciraSendOutPort.new(:reg0)
"""
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 | 15 |
| offset | 0 |
| source | :reg0 |
| max_length | 0 |


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, :SetArpOperation, :SetArpSenderProtocolAddress,
:SetArpSenderHardwareAddress, :NiciraRegMove, :SetMetadata,
:NiciraRegLoad].each do |each|
:NiciraRegLoad, :NiciraSendOutPort].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 @@ -17,6 +17,7 @@
require 'pio/open_flow/nicira_resubmit_table'
require 'pio/open_flow13/nicira_reg_load'
require 'pio/open_flow13/nicira_reg_move'
require 'pio/open_flow13/nicira_send_out_port'
require 'pio/open_flow13/send_out_port'
require 'pio/open_flow13/set_arp_operation'
require 'pio/open_flow13/set_arp_sender_hardware_address'
Expand Down
38 changes: 38 additions & 0 deletions lib/pio/open_flow13/nicira_send_out_port.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
require 'pio/open_flow/action'

module Pio
module OpenFlow13
# NXAST_OUTPUT_REG action
class NiciraSendOutPort < OpenFlow::Action
action_header action_type: 0xffff, action_length: 24
uint32 :experimenter_id, value: 0x2320
uint16 :experimenter_type, value: 15
bit10 :offset_internal, value: 0
bit6 :n_bits_internal
uint32 :source_internal
uint16 :max_length, value: 0
string :zero, length: 6

attr_reader :source

# rubocop:disable AbcSize
# rubocop:disable LineLength
def initialize(source)
@source = source
oxm_klass = Match.const_get(source.to_s.split('_').map(&:capitalize).join)
super(n_bits_internal: oxm_klass.new.length * 8 - 1,
source_internal: ((oxm_klass.superclass.const_get(:OXM_CLASS) << 16) | (oxm_klass.const_get(:OXM_FIELD) << 9) | oxm_klass.new.length))
end
# rubocop:enable AbcSize
# rubocop:enable LineLength

def offset
offset_internal
end

def n_bits
n_bits_internal + 1
end
end
end
end

0 comments on commit 16c0356

Please sign in to comment.