Sha256: 7e69d583b57946f3a2426be10bc89fce2b6994dc0e3c98c5e36d49c09062a574
Contents?: true
Size: 1.6 KB
Versions: 2
Compression:
Stored size: 1.6 KB
Contents
require 'bindata' require 'pio/enqueue' require 'pio/send_out_port' require 'pio/set_ether_address' require 'pio/set_ip_address' require 'pio/set_ip_tos' require 'pio/set_transport_port' require 'pio/set_vlan_priority' require 'pio/set_vlan_vid' require 'pio/strip_vlan_header' module Pio module OpenFlow # Actions list. class Actions < BinData::Primitive ACTION_CLASS = { 0 => Pio::SendOutPort, 1 => Pio::SetVlanVid, 2 => Pio::SetVlanPriority, 3 => Pio::StripVlanHeader, 4 => Pio::SetEtherSourceAddr, 5 => Pio::SetEtherDestinationAddr, 6 => Pio::SetIpSourceAddress, 7 => Pio::SetIpDestinationAddress, 8 => Pio::SetIpTos, 9 => Pio::SetTransportSourcePort, 10 => Pio::SetTransportDestinationPort, 11 => Pio::Enqueue } mandatory_parameter :length endian :big string :binary, read_length: :length def set(value) self.binary = [value].flatten.map(&:to_binary).join end # rubocop:disable MethodLength # This method smells of :reek:TooManyStatements 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.message_length..-1] actions << action rescue KeyError raise "action type #{type} is not supported." end end actions end # rubocop:enable MethodLength def [](index) get[index] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pio-0.20.1 | lib/pio/open_flow/actions.rb |
pio-0.20.0 | lib/pio/open_flow/actions.rb |