Sha256: 0269214df970744c30773db819028e4fb8c422f185da9e8763603fb630ba4e1d

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'pio/packet_in/format'
require 'pio/parse_error'

module Pio
  # OpenFlow 1.0 Packet-In message
  class PacketIn
    def self.read(raw_data)
      packet_in = allocate
      packet_in.instance_variable_set :@format, Format.read(raw_data)
      packet_in
    rescue BinData::ValidityError
      raise Pio::ParseError, 'Invalid Packet-In message.'
    end

    def_delegators :body, :buffer_id
    def_delegators :body, :total_len
    def_delegators :body, :in_port
    def_delegators :body, :reason
    def_delegators :body, :data

    # @reek This method smells of :reek:FeatureEnvy
    def initialize(user_options)
      header_options = { transaction_id: user_options[:transaction_id] ||
                                         user_options[:xid] || 0 }
      @format = Format.new(open_flow_header: header_options, body: user_options)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.9.0 lib/pio/packet_in.rb