Sha256: 7e19c94cfce56c4ba1844d37d149497ceb62485878516258022d44aaead9731a

Contents?: true

Size: 1.46 KB

Versions: 34

Compression:

Stored size: 1.46 KB

Contents

module Pio
  class Dhcp
    # DHCP Common Options.
    module CommonOptions
      BOOTPC = 68
      BOOTPS = 67
      QUAD_ZERO_IP_ADDRESS = IPv4Address.new(0)
      BROADCAST_MAC_ADDRESS = Mac.new(0xffffffffffff)
      BROADCAST_IP_ADDRESS = IPv4Address.new(0xffffffff)

      def dhcp_data
        Dhcp::DhcpField.new(dhcp_field_values)
      end

      def type
        @options[:type]
      end

      def source_mac
        Mac.new(@options[:source_mac])
      end

      def destination_mac
        Mac.new(@options[:destination_mac] || BROADCAST_MAC_ADDRESS)
      end

      def ip_source_address
        IPv4Address.new(@options[:ip_source_address])
      end

      def ip_destination_address
        IPv4Address.new(@options[:ip_destination_address])
      end

      def server_identifier
        IPv4Address.new(
          @options[:server_identifier] || ip_source_address
        )
      end

      def subnet_mask
        subnet = @options[:subnet_mask]
        IPv4Address.new(subnet) if subnet
      end

      def transaction_id
        @options[:transaction_id]
      end

      def renewal_time_value
        @options[:renewal_time_value]
      end

      def rebinding_time_value
        @options[:rebinding_time_value]
      end

      def ip_address_lease_time
        @options[:ip_address_lease_time]
      end

      def requested_ip_address
        IPv4Address.new(
          @options[:requested_ip_address] || QUAD_ZERO_IP_ADDRESS
        )
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

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