Sha256: 82e04a3da1b9eb6f01b0f9435f5e745567e5ec6450b9a8c0fab76e31e41adfd5

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

# 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.

# frozen_string_literal: true

module PacketGen
  module Header
    class DHCP
      
      # Container class for DHCP Options
      #
      # == Add DHCP options to an +Options+ instance
      #   options = PacketGen::Header::DHCP::Options.new
      #   # Add a lease_time option
      #   options << { type: 'lease_time', value: 3600 }
      #   # Add a domain option. Here, use integer type
      #   options << { type: 15, value: 'example.net'}
      #   # Add an end option
      #   options << { type: 'end' }
      #   # And finish with padding
      #   options << { type: 'pad' }
      # @author Sylvain Daubert
      class Options < Types::Array
        set_of Option

        private

        def record_from_hash(hsh)
          case hsh[:type]
          when 'pad', 0
            Pad.new
          when 'end', 255
            End.new
          else
            obj_klass = self.class.class_eval { @klass }
            obj_klass.new(hsh)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
packetgen-2.6.0 lib/packetgen/header/dhcp/options.rb
packetgen-2.5.2 lib/packetgen/header/dhcp/options.rb
packetgen-2.5.1 lib/packetgen/header/dhcp/options.rb
packetgen-2.5.0 lib/packetgen/header/dhcp/options.rb