From 15ca8a488c087e070e7dc25d23b06f47317875ec Mon Sep 17 00:00:00 2001 From: Yasuhito Takamiya Date: Tue, 24 Nov 2015 11:16:49 +0900 Subject: [PATCH] Add SetIpTtl action --- features/open_flow13/set_ip_ttl.feature | 13 +++++++++++++ lib/pio/open_flow.rb | 2 +- lib/pio/open_flow13.rb | 1 + lib/pio/open_flow13/set_ip_ttl.rb | 16 ++++++++++++++++ 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 features/open_flow13/set_ip_ttl.feature create mode 100644 lib/pio/open_flow13/set_ip_ttl.rb diff --git a/features/open_flow13/set_ip_ttl.feature b/features/open_flow13/set_ip_ttl.feature new file mode 100644 index 00000000..cee9f983 --- /dev/null +++ b/features/open_flow13/set_ip_ttl.feature @@ -0,0 +1,13 @@ +@open_flow13 +Feature: Pio::SetIpTtl + + Scenario: new(10) + When I try to create an OpenFlow action with: + """ + Pio::SetIpTtl.new(10) + """ + Then it should finish successfully + And the action has the following fields and values: + | field | value | + | action_type | 23 | + | ttl | 10 | diff --git a/lib/pio/open_flow.rb b/lib/pio/open_flow.rb index 87adb744..d1b8c3b1 100644 --- a/lib/pio/open_flow.rb +++ b/lib/pio/open_flow.rb @@ -23,7 +23,7 @@ def self.switch_version(version) :QueueStats, :Error, :SetArpOperation, :SetArpSenderProtocolAddress, :SetArpSenderHardwareAddress, :NiciraRegMove, :SetMetadata, :NiciraRegLoad, :NiciraSendOutPort, :NiciraStackPush, - :NiciraStackPop, :DecrementIpTtl].each do |each| + :NiciraStackPop, :DecrementIpTtl, :SetIpTtl].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 acfa1b9f..cfea0330 100644 --- a/lib/pio/open_flow13.rb +++ b/lib/pio/open_flow13.rb @@ -26,6 +26,7 @@ require 'pio/open_flow13/set_arp_sender_hardware_address' require 'pio/open_flow13/set_arp_sender_protocol_address' require 'pio/open_flow13/set_destination_mac_address' +require 'pio/open_flow13/set_ip_ttl' require 'pio/open_flow13/set_metadata' require 'pio/open_flow13/set_source_mac_address' diff --git a/lib/pio/open_flow13/set_ip_ttl.rb b/lib/pio/open_flow13/set_ip_ttl.rb new file mode 100644 index 00000000..bdfeab13 --- /dev/null +++ b/lib/pio/open_flow13/set_ip_ttl.rb @@ -0,0 +1,16 @@ +require 'pio/open_flow/action' + +module Pio + module OpenFlow13 + # Sets IP TTL + class SetIpTtl < OpenFlow::Action + action_header action_type: 23, action_length: 8 + uint8 :ttl + string :padding, length: 3 + + def initialize(ttl) + super(ttl: ttl) + end + end + end +end