Sha256: f48843be7698e6f1eea6b6ce1cde721c004f4e07ec8c3c4308561a808bca2e58

Contents?: true

Size: 1.53 KB

Versions: 21

Compression:

Stored size: 1.53 KB

Contents

require 'pio/icmp/message'
require 'pio/icmp/options'
require 'pio/mac'

module Pio
  class Icmp
    # ICMP Request packet generator
    class Request < Message
      TYPE = 8
      public_class_method :new

      # User options for creating an ICMP Request.
      class Options < Pio::Icmp::Options
        DEFAULT_IDENTIFIER = 0x0100
        DEFAULT_SEQUENCE_NUMBER = 0

        mandatory_option :source_mac
        mandatory_option :destination_mac
        mandatory_option :ip_source_address
        mandatory_option :ip_destination_address
        option :identifier
        option :sequence_number
        option :echo_data

        # rubocop:disable MethodLength
        # rubocop:disable AbcSize
        def initialize(options)
          validate options
          @type = TYPE

          @source_mac = Mac.new(options[:source_mac]).freeze
          @destination_mac = Mac.new(options[:destination_mac]).freeze
          @ip_source_address =
            IPv4Address.new(options[:ip_source_address]).freeze
          @ip_destination_address =
            IPv4Address.new(options[:ip_destination_address]).freeze
          @identifier =
            options[:icmp_identifier] ||
            options[:identifier] ||
            DEFAULT_IDENTIFIER
          @sequence_number =
            options[:icmp_sequence_number] ||
            options[:sequence_number] ||
            DEFAULT_SEQUENCE_NUMBER
          @echo_data = options[:echo_data] || ''
        end
        # rubocop:enable AbcSize
        # rubocop:enable MethodLength
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
pio-0.27.2 lib/pio/icmp/request.rb
pio-0.27.1 lib/pio/icmp/request.rb
pio-0.27.0 lib/pio/icmp/request.rb
pio-0.26.0 lib/pio/icmp/request.rb
pio-0.25.0 lib/pio/icmp/request.rb
pio-0.24.2 lib/pio/icmp/request.rb
pio-0.24.1 lib/pio/icmp/request.rb
pio-0.24.0 lib/pio/icmp/request.rb
pio-0.23.1 lib/pio/icmp/request.rb
pio-0.23.0 lib/pio/icmp/request.rb
pio-0.22.0 lib/pio/icmp/request.rb
pio-0.21.1 lib/pio/icmp/request.rb
pio-0.21.0 lib/pio/icmp/request.rb
pio-0.20.1 lib/pio/icmp/request.rb
pio-0.20.0 lib/pio/icmp/request.rb
pio-0.19.0 lib/pio/icmp/request.rb
pio-0.18.2 lib/pio/icmp/request.rb
pio-0.18.1 lib/pio/icmp/request.rb
pio-0.18.0 lib/pio/icmp/request.rb
pio-0.17.0 lib/pio/icmp/request.rb