Class: Pio::OpenFlow::Actions

Inherits:
BinData::Primitive
  • Object
show all
Defined in:
lib/pio/open_flow10/actions.rb

Overview

Actions list.

Constant Summary collapse

ACTION_CLASS =
{
  0 => Pio::OpenFlow10::SendOutPort,
  1 => Pio::OpenFlow10::SetVlanVid,
  2 => Pio::OpenFlow10::SetVlanPriority,
  3 => Pio::OpenFlow10::StripVlanHeader,
  4 => Pio::OpenFlow10::SetSourceMacAddress,
  5 => Pio::OpenFlow10::SetDestinationMacAddress,
  6 => Pio::OpenFlow10::SetSourceIpAddress,
  7 => Pio::OpenFlow10::SetDestinationIpAddress,
  8 => Pio::OpenFlow10::SetTos,
  9 => Pio::OpenFlow10::SetTransportSourcePort,
  10 => Pio::OpenFlow10::SetTransportDestinationPort,
  11 => Pio::OpenFlow10::Enqueue,
  0xffff => Pio::VendorAction
}

Instance Method Summary collapse

Instance Method Details

#[](index) ⇒ Object

rubocop:enable MethodLength



64
65
66
# File 'lib/pio/open_flow10/actions.rb', line 64

def [](index)
  get[index]
end

#getObject

rubocop:disable MethodLength This method smells of :reek:TooManyStatements



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/pio/open_flow10/actions.rb', line 47

def get
  actions = []
  tmp = binary
  while tmp.length > 0
    type = BinData::Uint16be.read(tmp)
    begin
      action = ACTION_CLASS.fetch(type).read(tmp)
      tmp = tmp[action.action_length..-1]
      actions << action
    rescue KeyError
      raise "action type #{type} is not supported."
    end
  end
  actions
end

#set(actions) ⇒ Object



41
42
43
# File 'lib/pio/open_flow10/actions.rb', line 41

def set(actions)
  self.binary = Array(actions).map(&:to_binary).join
end