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 NiciraSendOutPort action #285

Closed
wants to merge 1 commit into from
Closed
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
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [82/80]

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))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [148/80]

end
# rubocop:enable AbcSize
# rubocop:enable LineLength

def offset
offset_internal
end

def n_bits
n_bits_internal + 1
end
end
end
end