Class: Trema::Enqueue

Inherits:
Action
  • Object
show all
Defined in:
ruby/trema/enqueue.rb

Overview

An action to enqueue the packet on the specified queue attached to a port.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Enqueue

Creates an action to enqueue the packet on the specified queue attached to a port. When a queue is configured the user can associate a flow with this action to forward a packet through the specific queue in that port.

Examples:

Enqueue.new( :port_number => 1, :queue_id => 2 )

Options Hash (options):

  • :port_number (Number)

    the port the queue is attached to.

  • :queue_id (Number)

    the configured queue. Currently only minimum rate queues provided.

Raises:

  • (TypeError)

    if options is not a Hash.

  • (ArgumentError)

    if both port_number and queue_id arguments not supplied.

  • (ArgumentError)

    if port_number is not an unsigned 16-bit integer.

  • (ArgumentError)

    if queue id is not an unsigned 32-bit integer.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'ruby/trema/enqueue.rb', line 56

def initialize options
  if options.is_a?( Hash )
    @port_number = options[ :port_number ]
    @queue_id = options[ :queue_id ]
    if @port_number.nil?
      raise ArgumentError, "Port number is a mandatory option"
    end
    unless @port_number.unsigned_16bit?
      raise ArgumentError, "Port number must be an unsigned 16-bit integer"
    end
    if @queue_id.nil?
      raise ArgumentError, "Queue ID is a mandatory option"
    end
    unless @queue_id.unsigned_32bit?
      raise ArgumentError, "Queue ID must be an unsigned 32-bit integer"
    end
  else
    raise "Invalid option"
  end
end

Instance Attribute Details

#port_numberObject (readonly)

Returns the value of attribute port_number.



29
30
31
# File 'ruby/trema/enqueue.rb', line 29

def port_number
  @port_number
end

#queue_idObject (readonly)

Returns the value of attribute queue_id.



30
31
32
# File 'ruby/trema/enqueue.rb', line 30

def queue_id
  @queue_id
end