Sha256: f7757966b906f2db059cbef95dc4f7fcd9de234a5e2891592c0579e2a5799ac9

Contents?: true

Size: 921 Bytes

Versions: 10

Compression:

Stored size: 921 Bytes

Contents

# frozen_string_literal: true

# This file is part of PacketGen
# See https://github.com/sdaubert/packetgen for more informations
# Copyright (C) 2016 Sylvain Daubert <sylvain.daubert@laposte.net>
# This program is published under MIT license.

module PacketGen
  module Header
    class IP
      # Class to handle IP options
      # @author Sylvain Daubert
      class Options < Types::Array
        set_of Option

        HUMAN_SEPARATOR = ';'

        # Get binary string
        # @return [String]
        def to_s
          str = super
          str += ([0] * (4 - (str.length % 4))).pack('C*') if str.length % 4 != 0
          str
        end

        private

        def record_from_hash(hsh)
          Option.build(hsh)
        end

        def real_type(opt)
          types = Option.types
          types.value?(opt.type) ? IP.const_get(types.key(opt.type)) : opt.class
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
packetgen-3.3.1 lib/packetgen/header/ip/options.rb
packetgen-3.3.0 lib/packetgen/header/ip/options.rb
packetgen-3.2.2 lib/packetgen/header/ip/options.rb
packetgen-3.2.1 lib/packetgen/header/ip/options.rb
packetgen-3.2.0 lib/packetgen/header/ip/options.rb
packetgen-3.1.8 lib/packetgen/header/ip/options.rb
packetgen-3.1.7 lib/packetgen/header/ip/options.rb
packetgen-3.1.6 lib/packetgen/header/ip/options.rb
packetgen-3.1.5 lib/packetgen/header/ip/options.rb
packetgen-3.1.4 lib/packetgen/header/ip/options.rb