Sha256: b72b2be8134aa467a1df034f3e06297139d6ad63f930a93b49650dc1ec8e554f

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

# encoding: utf-8

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

6 entries across 6 versions & 1 rubygems

Version Path
pio-0.8.1 lib/pio/dhcp/common_options.rb
pio-0.8.0 lib/pio/dhcp/common_options.rb
pio-0.7.0 lib/pio/dhcp/common_options.rb
pio-0.6.0 lib/pio/dhcp/common_options.rb
pio-0.5.0 lib/pio/dhcp/common_options.rb
pio-0.4.0 lib/pio/dhcp/common_options.rb