Class: Pio::Hello

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pio/hello.rb,
lib/pio/hello/format.rb

Overview

OpenFlow 1.0 Hello message

Defined Under Namespace

Classes: Format

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHello #initialize(transaction_id) ⇒ Hello #initialize(user_options) ⇒ Hello

Creates a Hello OpenFlow message.

Overloads:

  • #initializeHello

    Examples:

    Pio::Hello.new
  • #initialize(transaction_id) ⇒ Hello

    Examples:

    Pio::Hello.new(123)

    Parameters:

    • transaction_id (Number)

      An unsigned 32-bit integer number associated with this message.

  • #initialize(user_options) ⇒ Hello

    Examples:

    Pio::Hello.new(transaction_id: 123)
    Pio::Hello.new(xid: 123)

    Parameters:

    • user_options (Hash)

      The options to create a message with.

    Options Hash (user_options):

    • :transaction_id (Number)
    • :xid (Number)

      An alias to transaction_id.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/pio/hello.rb', line 55

def initialize(user_options = {})
  if user_options.respond_to?(:to_i)
    @options = { transaction_id: user_options.to_i }
  elsif user_options.respond_to?(:[])
    @options = user_options.dup
    @options[:transaction_id] ||= @options[:xid]
    @options[:transaction_id] = 0 unless @options[:transaction_id]
  else
    fail TypeError
  end
  @data = Format.new(@options)
end

Class Method Details

.read(raw_data) ⇒ Pio::Hello

Parses raw_data binary string into a Hello message object.

Examples:

Pio::Hello.read("\x01\x00\x00\b\x00\x00\x00\x00")

Returns:



25
26
27
28
29
30
31
32
33
# File 'lib/pio/hello.rb', line 25

def self.read(raw_data)
  hello = allocate
  begin
    hello.instance_variable_set :@data, Format.read(raw_data)
  rescue BinData::ValidityError
    raise ParseError, $ERROR_INFO.message
  end
  hello
end