Class: Lib::DHCP::Message::LeaseQuery
- Inherits:
-
Lib::DHCP::Message
- Object
- BOOTP::Packet
- Packet
- Lib::DHCP::Message
- Lib::DHCP::Message::LeaseQuery
- Defined in:
- lib/lib/dhcp/messages/lease_query.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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(op: BOOTREQUEST, htype: 1, hlen: 6, hops: 0, xid: nil, secs: 0, flags: 0, ciaddr: 0, yiaddr: 0, siaddr: 0, giaddr: 0, chaddr: 0, sname: '.', file: '.', options: nil) ⇒ LeaseQuery
constructor
A new instance of LeaseQuery.
- #pack ⇒ Object
- #query_by_client_id? ⇒ Boolean
- #query_by_ip? ⇒ Boolean
- #query_by_mac? ⇒ Boolean
Methods inherited from Lib::DHCP::Message
Methods inherited from Packet
#option0, #option255, #options, #options=, #to_h, #to_s
Constructor Details
#initialize(op: BOOTREQUEST, htype: 1, hlen: 6, hops: 0, xid: nil, secs: 0, flags: 0, ciaddr: 0, yiaddr: 0, siaddr: 0, giaddr: 0, chaddr: 0, sname: '.', file: '.', options: nil) ⇒ LeaseQuery
Returns a new instance of LeaseQuery.
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 38 39 40 41 |
# File 'lib/lib/dhcp/messages/lease_query.rb', line 12 def initialize(op:BOOTREQUEST, htype: 1, hlen: 6, hops: 0, xid: nil, secs: 0, flags: 0, ciaddr: 0, yiaddr: 0, siaddr: 0, giaddr: 0, chaddr: 0, sname: '.', file: '.', options: nil) if block_given? yield self else super( :op => BOOTREQUEST, :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 .is_a? Array or .is_a? Lib::DHCP::Options .each { |option| self..add option unless option.oid.to_i == Option::MESSAGE_TYPE } elsif .is_a? Lib::DHCP::Option self..add elsif !.nil? raise TypeError, "Can't convert #{options.class.name} to Lib::DHCP::Option" end end self..add Lib::DHCP::Option53.new(LEASE_QUERY) end |
Class Method Details
.unpack(packet) ⇒ Object
51 52 53 54 55 |
# File 'lib/lib/dhcp/messages/lease_query.rb', line 51 def self.unpack(packet) res = super(packet) raise TypeError, "No implicit conversion of #{res.class.name} into #{self.name}" unless res.is_a? self res end |
Instance Method Details
#pack ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/lib/dhcp/messages/lease_query.rb', line 43 def pack # noinspection RubyResolve self.option53 = LEASE_QUERY self.op = BOOTREQUEST sanity_check super end |
#query_by_client_id? ⇒ Boolean
65 66 67 |
# File 'lib/lib/dhcp/messages/lease_query.rb', line 65 def query_by_client_id? option61.nil? ? false : true end |
#query_by_ip? ⇒ Boolean
57 58 59 |
# File 'lib/lib/dhcp/messages/lease_query.rb', line 57 def query_by_ip? (ciaddr != 0) ? true : false end |
#query_by_mac? ⇒ Boolean
61 62 63 |
# File 'lib/lib/dhcp/messages/lease_query.rb', line 61 def query_by_mac? (htype != 0 and hlen != 0 and chaddr != 0) ? true : false end |