Sha256: 42edd4fcd315760c20a841b5533d7babc925a00b0eb374771ee0e9743a08cd15

Contents?: true

Size: 1.07 KB

Versions: 4

Compression:

Stored size: 1.07 KB

Contents

require 'forwardable'

# Base module.
module Pio
  module OpenFlow13
    # Output to switch port.
    class SendOutPort
      # OpenFlow 1.3.4 OFPAT_OUTPUT action format.
      class Format < BinData::Record
        NO_BUFFER = 0xffff

        endian :big

        uint16 :action_type, value: 0
        uint16 :action_length, value: 16
        uint32 :port
        uint16 :max_length, initial_value: NO_BUFFER
        uint48 :padding
      end

      def self.read(raw_data)
        allocate.tap do |send_out_port|
          send_out_port.instance_variable_set :@format, Format.read(raw_data)
        end
      end

      extend Forwardable

      def_delegators :@format, :action_type
      def_delegators :@format, :action_length
      def_delegators :@format, :port
      def_delegator :@format, :to_binary_s, :to_binary

      def initialize(port)
        @format = Format.new(port: port)
      end

      def max_length
        case @format.max_length
        when Format::NO_BUFFER
          :no_buffer
        else
          @format.max_length
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pio-0.25.0 lib/pio/open_flow13/send_out_port.rb
pio-0.24.2 lib/pio/open_flow13/send_out_port.rb
pio-0.24.1 lib/pio/open_flow13/send_out_port.rb
pio-0.24.0 lib/pio/open_flow13/send_out_port.rb