Class: Trema::Controller::PacketOutOption

Inherits:
Object
  • Object
show all
Defined in:
lib/trema/controller.rb

Overview

Pio::PacketOut.new argument

Instance Method Summary collapse

Constructor Details

#initialize(user_options) ⇒ PacketOutOption

Returns a new instance of PacketOutOption.


84
85
86
# File 'lib/trema/controller.rb', line 84

def initialize(user_options)
  @user_options = user_options
end

Instance Method Details

#to_hashObject

rubocop:disable MethodLength


89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/trema/controller.rb', line 89

def to_hash
  if @user_options[:packet_in]
    {
      transaction_id: rand(0xffffffff),
      buffer_id: 0xffffffff,
      actions: @user_options[:actions],
      in_port: @user_options.fetch(:packet_in).in_port,
      raw_data: @user_options.fetch(:packet_in).raw_data
    }
  else
    {
      transaction_id: rand(0xffffffff),
      buffer_id: 0xffffffff,
      actions: @user_options[:actions],
      raw_data: @user_options.fetch(:raw_data)
    }
  end
end