Sha256: b062c49235397e548c7b1cb6d07f2a01c47be87a814325c9c572ec04c4b037e1

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

#
# Copyright (C) 2008-2012 NEC Corporation
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2, as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#


require "trema/action"
require "trema/monkey-patch/integer"


module Trema
  #
  # An action to modify the IP ToS/DSCP field of a packet.
  #
  class SetIpTos < Action
    attr_reader :type_of_service


    #
    # Creates an action to modify the IP ToS/DSCP field of a packet.
    #
    # @example
    #   SetIpTos.new(32)
    #
    # @param [Integer] :type_of_service
    #   the ToS/DSCP field to set to.
    #
    # @raise [ArgumentError] if type_of_service argument is not an unsigned 8-bit Integer.
    # @raise [TypeError] if type_of_service argument is not an Integer.
    #
    def initialize type_of_service
      if not type_of_service.is_a?( Integer )
        raise TypeError, "ToS must be an unsigned 8-bit integer"
      end
      if not type_of_service.unsigned_8bit?
        raise ArgumentError, "ToS must be an unsigned 8-bit integer"
      end
      @type_of_service = type_of_service
    end
  end


  ActionSetNwTos = SetIpTos
end


### Local variables:
### mode: Ruby
### coding: utf-8-unix
### indent-tabs-mode: nil
### End:

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trema-0.2.3 ruby/trema/set-ip-tos.rb