Class: DHCP::MessageTypeOption

Inherits:
Option
  • Object
show all
Defined in:
lib/net/dhcp/options.rb

Overview

This option is used to convey the type of the DHCP message. The code for this option is 53, and its length is 1. Legal values for this option are:

Value   Message Type
-----   ------------
  1     DHCPDISCOVER
  2     DHCPOFFER
  3     DHCPREQUEST
  4     DHCPDECLINE
  5     DHCPACK
  6     DHCPNAK
  7     DHCPRELEASE
  8     DHCPINFORM

The default value is 1 (DHCPDISCOVER)

Instance Attribute Summary

Attributes inherited from Option

#len, #payload, #type

Instance Method Summary collapse

Methods inherited from Option

#eql?, #pack, #to_a

Constructor Details

#initialize(params = {}) ⇒ MessageTypeOption

DEBUG



256
257
258
259
260
# File 'lib/net/dhcp/options.rb', line 256

def initialize(params={})
  params[:type] = $DHCP_MESSAGETYPE
  params[:payload] = params.fetch(:payload, [$DHCP_MSG_DISCOVER])
  super(params)
end

Instance Method Details

#to_sObject



262
263
264
# File 'lib/net/dhcp/options.rb', line 262

def to_s
  "DHCP Message Type = #{$DHCP_MSG_NAMES[self.payload[0]-1]} (#{self.payload[0]})"
end