From 7bf97638d158b14a0fb6c7bccd39fb347123cd7b Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Tue, 24 Nov 2015 18:06:46 +0900 Subject: [PATCH] Add CopyTtlInwards action --- Rakefile | 2 +- features/open_flow13/copy_ttl_inwards.feature | 14 ++++++++++++++ lib/pio/open_flow.rb | 2 +- lib/pio/open_flow13.rb | 1 + lib/pio/open_flow13/copy_ttl_inwards.rb | 15 +++++++++++++++ 5 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 features/open_flow13/copy_ttl_inwards.feature create mode 100644 lib/pio/open_flow13/copy_ttl_inwards.rb diff --git a/Rakefile b/Rakefile index 07441859..094337a0 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,7 @@ require 'bundler/gem_tasks' RELISH_PROJECT = 'trema/pio' -FLAY_THRESHOLD = 1450 +FLAY_THRESHOLD = 1470 task default: :travis task test: [:spec, :cucumber] diff --git a/features/open_flow13/copy_ttl_inwards.feature b/features/open_flow13/copy_ttl_inwards.feature new file mode 100644 index 00000000..8ca08848 --- /dev/null +++ b/features/open_flow13/copy_ttl_inwards.feature @@ -0,0 +1,14 @@ +@open_flow13 +Feature: Pio::CopyTtlInwards + + Copies TTL "inwards" -- from outermost to next-to-outermost + + Scenario: new + When I try to create an OpenFlow action with: + """ + Pio::CopyTtlInwards.new + """ + Then it should finish successfully + And the action has the following fields and values: + | field | value | + | action_type | 12 | diff --git a/lib/pio/open_flow.rb b/lib/pio/open_flow.rb index b5cbdbde..a9e70ae6 100644 --- a/lib/pio/open_flow.rb +++ b/lib/pio/open_flow.rb @@ -24,7 +24,7 @@ def self.switch_version(version) :SetArpSenderHardwareAddress, :NiciraRegMove, :SetMetadata, :NiciraRegLoad, :NiciraSendOutPort, :NiciraStackPush, :NiciraStackPop, :DecrementIpTtl, :SetIpTtl, - :CopyTtlOutwards].each do |each| + :CopyTtlOutwards, :CopyTtlInwards].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 96387195..5294c99f 100644 --- a/lib/pio/open_flow13.rb +++ b/lib/pio/open_flow13.rb @@ -15,6 +15,7 @@ # Actions require 'pio/open_flow/nicira_resubmit' require 'pio/open_flow/nicira_resubmit_table' +require 'pio/open_flow13/copy_ttl_inwards' require 'pio/open_flow13/copy_ttl_outwards' require 'pio/open_flow13/decrement_ip_ttl' require 'pio/open_flow13/nicira_reg_load' diff --git a/lib/pio/open_flow13/copy_ttl_inwards.rb b/lib/pio/open_flow13/copy_ttl_inwards.rb new file mode 100644 index 00000000..82b57129 --- /dev/null +++ b/lib/pio/open_flow13/copy_ttl_inwards.rb @@ -0,0 +1,15 @@ +require 'pio/open_flow/action' + +module Pio + module OpenFlow13 + # Copies TTL "inwards" -- from outermost to next-to-outermost + class CopyTtlInwards < OpenFlow::Action + action_header action_type: 12, action_length: 8 + string :padding, length: 4 + + def initialize + super({}) + end + end + end +end