Sha256: d972caf87d00006b16fa0d8a2ac3cc2439c862c8f97535549c09234dd3538a5b

Contents?: true

Size: 1.23 KB

Versions: 4

Compression:

Stored size: 1.23 KB

Contents

require 'pio/monkey_patch/integer'
require 'pio/open_flow/action'

module Pio
  module OpenFlow10
    # An action to modify the source TCP/UDP port of a packet.
    class SetTransportSourcePort < OpenFlow::Action
      action_header action_type: 9, action_length: 8
      uint16 :port
      string :padding, length: 2
      hide :padding

      def initialize(number)
        port = number.to_i
        unless port.unsigned_16bit?
          fail ArgumentError, 'TCP/UDP port must be an unsigned 16-bit integer.'
        end
        super(port: port)
      rescue NoMethodError
        raise TypeError, 'TCP/UDP port must be an unsigned 16-bit integer.'
      end
    end

    # An action to modify the source TCP/UDP port of a packet.
    class SetTransportDestinationPort < OpenFlow::Action
      action_header action_type: 10, action_length: 8
      uint16 :port
      string :padding, length: 2
      hide :padding

      def initialize(number)
        port = number.to_i
        unless port.unsigned_16bit?
          fail ArgumentError, 'TCP/UDP port must be an unsigned 16-bit integer.'
        end
        super(port: port)
      rescue NoMethodError
        raise TypeError, 'TCP/UDP port must be an unsigned 16-bit integer.'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pio-0.30.0 lib/pio/open_flow10/set_transport_port.rb
pio-0.29.0 lib/pio/open_flow10/set_transport_port.rb
pio-0.28.1 lib/pio/open_flow10/set_transport_port.rb
pio-0.28.0 lib/pio/open_flow10/set_transport_port.rb