Class: Lib::DHCP::Message::LeaseUnknown

Inherits:
Lib::DHCP::Message show all
Defined in:
lib/lib/dhcp/messages/lease_unknown.rb

Constant Summary

Constants inherited from Lib::DHCP::Message

ACKNOWLEDGE, BOOTREPLY, BOOTREQUEST, DECLINE, DISCOVER, INFORM, LEASE_ACTIVE, LEASE_QUERY, LEASE_UNASSIGNED, LEASE_UNKNOWN, NAME, NOT_ACKNOWLEDGE, OFFER, RELEASE, REQUEST

Constants inherited from Packet

Packet::MAGICK_COOKIE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Lib::DHCP::Message

#name

Methods inherited from Packet

#option0, #option255, #options, #to_s

Constructor Details

#initialize(htype: 1, hlen: 6, hops: 0, xid: nil, secs: 0, flags: 0, ciaddr: 0, yiaddr: 0, siaddr: 0, giaddr: 0, chaddr:, sname: '.', file: '.', options: nil) ⇒ LeaseUnknown

Returns a new instance of LeaseUnknown.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/lib/dhcp/messages/lease_unknown.rb', line 12

def initialize(htype: 1, hlen: 6, hops: 0, xid: nil, secs: 0, flags: 0, ciaddr: 0, yiaddr: 0, siaddr: 0, giaddr: 0, chaddr: , sname: '.', file: '.', options: nil)
  super(
      :op => BOOTREPLY,
      :htype => htype,
      :hlen => hlen,
      :hops => hops,
      :xid => xid,
      :secs => secs,
      :flags => flags,
      :ciaddr => ciaddr,
      :yiaddr => yiaddr,
      :siaddr => siaddr,
      :giaddr => giaddr,
      :chaddr => chaddr,
      :sname => sname,
      :file => file
  )
  if options.is_a? Array or options.is_a? Lib::DHCP::Options
    options.each { |option| self.options.add option unless option.oid.to_i == Option::MESSAGE_TYPE }
  elsif options.is_a? Lib::DHCP::Option
    self.options.add options
  elsif !options.nil?
    raise TypeError, "Can't convert #{options.class.name} to Lib::DHCP::Option"
  end
  self.options.add Lib::DHCP::Option53.new(LEASE_UNKNOWN)
end

Class Method Details

.unpack(packet) ⇒ Object

Raises:

  • (TypeError)


47
48
49
50
51
# File 'lib/lib/dhcp/messages/lease_unknown.rb', line 47

def self.unpack(packet)
  res = super(packet)
  raise TypeError, "No implicit conversion of #{res.class.name} into #{self.class.name}" unless res.is_a? self.class
  res
end

Instance Method Details

#packObject



39
40
41
42
43
44
45
# File 'lib/lib/dhcp/messages/lease_unknown.rb', line 39

def pack
  # noinspection RubyResolve
  self.option53 = LEASE_UNKNOWN
  self.op = BOOTREPLY
  sanity_check
  super
end