Class: DHCP::IPAddressLeaseTimeOption
- Defined in:
- lib/net/dhcp/options.rb
Overview
This option is used in a client request (DHCPDISCOVER or DHCPREQUEST) to allow the client to request a lease time for the IP address. In a server reply (DHCPOFFER), a DHCP server uses this option to specify the lease time it is willing to offer.
The time is in units of seconds, and is specified as a 32-bit unsigned integer.
The code for this option is 51, and its length is 4.
The default value is 7200 (2h)
Instance Attribute Summary
Attributes inherited from Option
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ IPAddressLeaseTimeOption
constructor
A new instance of IPAddressLeaseTimeOption.
- #to_s ⇒ Object
Methods inherited from Option
Constructor Details
#initialize(params = {}) ⇒ IPAddressLeaseTimeOption
Returns a new instance of IPAddressLeaseTimeOption.
224 225 226 227 228 |
# File 'lib/net/dhcp/options.rb', line 224 def initialize(params={}) params[:type] = $DHCP_LEASETIME params[:payload] = params.fetch(:payload, [7200].pack('N').unpack('C*')) super(params) end |
Instance Method Details
#to_s ⇒ Object
230 231 232 233 234 235 |
# File 'lib/net/dhcp/options.rb', line 230 def to_s() value = self.payload.pack('C*').unpack('N').first value = "infinite" if value == 0xffffffff "IP Address Lease Time = #{value} seg" end |