Sha256: 2d29e708044b9848a678f269375b40a8b7ec403c72357a5d1a40d0a3b76c4997

Contents?: true

Size: 751 Bytes

Versions: 1

Compression:

Stored size: 751 Bytes

Contents

require 'pio/open_flow'

# Base module.
module Pio
  # OpenFlow 1.0 Port Status message
  class PortStatus
    # What changed about the physical port
    class Reason < BinData::Primitive
      REASONS = { add: 0, delete: 1, modify: 2 }

      uint8 :reason

      def get
        REASONS.invert.fetch(reason)
      end

      def set(value)
        self.reason = REASONS.fetch(value)
      end
    end

    # Message body of Port Status
    class Body < BinData::Record
      endian :big

      reason :reason
      uint56 :padding
      hide :padding
      phy_port :desc
    end
  end

  OpenFlow::Message.factory(PortStatus, OpenFlow::PORT_STATUS) do
    def_delegators :body, :desc

    def reason
      body.reason.to_s.to_sym
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.15.1 lib/pio/port_status.rb