Sha256: 6de3ca151e6c400e6d4663e481f0cfc532fc22c3ccab60f2e5344805bd288bf6

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

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

module PacketGen
  module Header
    class DHCP
      # Container class for {Option 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 real_type(obj)
          case obj.type
          when 0
            Pad
          when 1, 3, 4, 5, 6, 7, 8, 9, 28, 41, 42, 44, 45, 50, 54, 65, 69,
               70, 71, 72, 73, 74
            IPAddrOption
          when 53
            Int8Option
          when 57
            Int16Option
          when 51, 58, 59
            Int32Option
          when 255
            End
          else
            Option
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
packetgen-3.3.3 lib/packetgen/header/dhcp/options.rb
packetgen-3.3.2 lib/packetgen/header/dhcp/options.rb