Sha256: 6b4e25845fff184c0767f1da7893121aa43cf4518d7647fc16de743a7d4c4d44

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 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?
          raise 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?
          raise 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

1 entries across 1 versions & 1 rubygems

Version Path
pio-0.30.1 lib/pio/open_flow10/set_transport_port.rb