class Pio::Dhcp::BootReplyOptions

Options for creating a DHCP message.

Public Class Methods

new(options) click to toggle source
# File lib/pio/dhcp/boot_reply_options.rb, line 26
def initialize(options)
  @options = options
end

Public Instance Methods

to_hash() click to toggle source
# File lib/pio/dhcp/boot_reply_options.rb, line 30
def to_hash
  {
    destination_mac: destination_mac,
    source_mac: source_mac,
    destination_ip_address: destination_ip_address,
    source_ip_address: source_ip_address,
    udp_source_port: BOOTPS,
    udp_destination_port: BOOTPC,
    dhcp: dhcp_data
  }
end

Private Instance Methods

dhcp_field_values() click to toggle source
# File lib/pio/dhcp/boot_reply_options.rb, line 44
def dhcp_field_values
  {
    message_type: BootReply::MESSAGE_TYPE,
    transaction_id: transaction_id,
    client_ip_address: QUAD_ZERO_IP_ADDRESS,
    your_ip_address: destination_ip_address,
    next_server_ip_address: QUAD_ZERO_IP_ADDRESS,
    relay_agent_ip_address: QUAD_ZERO_IP_ADDRESS,
    client_mac_address: source_mac,
    optional_tlvs: options_for_optional_tlv
  }
end
options_for_optional_tlv() click to toggle source
# File lib/pio/dhcp/boot_reply_options.rb, line 57
def options_for_optional_tlv
  [
    message_type_hash,
    renewal_time_value_hash,
    rebinding_time_value_hash,
    ip_address_lease_time_hash,
    dhcp_server_identifier_hash,
    subnet_mask_hash
  ].compact
end
server_identifier() click to toggle source
# File lib/pio/dhcp/boot_reply_options.rb, line 68
def server_identifier
  IPv4Address.new(
    @options[:server_identifier] || source_ip_address
  )
end