Sha256: 3a02e3a44f6b19a55b560cddc6ba1dfc749475a1e37dfb9aa2386b2faf7822ee

Contents?: true

Size: 1.3 KB

Versions: 13

Compression:

Stored size: 1.3 KB

Contents

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

module Pio
  class Icmp
    # ICMP Reply packet generator
    class Reply < Message
      TYPE = 0
      public_class_method :new

      # User options for creating an ICMP Reply.
      class Options < Pio::Icmp::Options
        mandatory_option :source_mac
        mandatory_option :destination_mac
        mandatory_option :ip_source_address
        mandatory_option :ip_destination_address
        mandatory_option :identifier
        mandatory_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[:identifier]
          @sequence_number = options[:sequence_number]
          @echo_data = options[:echo_data] || DEFAULT_ECHO_DATA
        end
        # rubocop:enable AbcSize
        # rubocop:enable MethodLength
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pio-0.15.2 lib/pio/icmp/reply.rb
pio-0.15.1 lib/pio/icmp/reply.rb
pio-0.15.0 lib/pio/icmp/reply.rb
pio-0.14.0 lib/pio/icmp/reply.rb
pio-0.13.0 lib/pio/icmp/reply.rb
pio-0.12.0 lib/pio/icmp/reply.rb
pio-0.11.2 lib/pio/icmp/reply.rb
pio-0.11.1 lib/pio/icmp/reply.rb
pio-0.11.0 lib/pio/icmp/reply.rb
pio-0.10.1 lib/pio/icmp/reply.rb
pio-0.10.0 lib/pio/icmp/reply.rb
pio-0.9.0 lib/pio/icmp/reply.rb
pio-0.8.2 lib/pio/icmp/reply.rb