Sha256: 87a25f01689a93a63093f5d1c1d202b7d803d7e4b860d72bd2b8772782e39820

Contents?: true

Size: 1.65 KB

Versions: 6

Compression:

Stored size: 1.65 KB

Contents

# encoding: utf-8

module Pio
  class Dhcp
    # Dhcp Field Read Methods.
    module FieldUtil
      def message_type
        get_tlv_field(53)
      end

      def server_identifier
        get_tlv_field(54)
      end

      def client_identifier
        get_tlv_field(61)
      end

      def renewal_time_value
        get_tlv_field(58)
      end

      def rebinding_time_value
        get_tlv_field(59)
      end

      def ip_address_lease_time
        get_tlv_field(51)
      end

      def requested_ip_address
        get_tlv_field(50)
      end

      def parameters_list
        get_tlv_field(55)
      end

      def subnet_mask
        get_tlv_field(1)
      end

      def hw_addr_type
        dhcp.hw_addr_type
      end

      def hw_addr_len
        dhcp.hw_addr_len
      end

      def hops
        dhcp.hops
      end

      def transaction_id
        dhcp.transaction_id
      end

      def seconds
        dhcp.seconds
      end

      def bootp_flags
        dhcp.bootp_flags
      end

      def client_ip_address
        dhcp.client_ip_address
      end

      def your_ip_address
        dhcp.your_ip_address
      end

      def next_server_ip_address
        dhcp.next_server_ip_address
      end

      def relay_agent_ip_address
        dhcp.relay_agent_ip_address
      end

      def client_mac_address
        dhcp.client_mac_address
      end

      private

      def get_tlv(tlv_type)
        tlv = dhcp.optional_tlvs.find do | each |
          each['tlv_type'] == tlv_type
        end
        tlv['tlv_value'] if tlv
      end

      def get_tlv_field(tlv_type)
        tlv = get_tlv(tlv_type)
        tlv.snapshot if tlv
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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