Sha256: 6bf14c1a08530794696ca51a7ea946fe5beab1b8ec372b08406e923205aee82d

Contents?: true

Size: 756 Bytes

Versions: 4

Compression:

Stored size: 756 Bytes

Contents

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

module Pio
  module OpenFlow10
    # An action to modify the IP ToS/DSCP field of a packet.
    class SetTos < OpenFlow::Action
      action_header action_type: 8, action_length: 8
      uint8 :type_of_service
      string :padding, length: 3
      hide :padding

      def initialize(type_of_service)
        # tos (IP ToS) value consists of 8 bits, of which only the
        # 6 high-order bits belong to DSCP, the 2 low-order bits must
        # be zero.
        unless type_of_service.unsigned_8bit? && type_of_service % 4 == 0
          fail ArgumentError, 'Invalid type_of_service (ToS) value.'
        end
        super(type_of_service: type_of_service)
      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_tos.rb
pio-0.29.0 lib/pio/open_flow10/set_tos.rb
pio-0.28.1 lib/pio/open_flow10/set_tos.rb
pio-0.28.0 lib/pio/open_flow10/set_tos.rb