Class: PacketGen::Header::DHCPv6::DUID Abstract
- Inherits:
-
Types::Fields
- Object
- Types::Fields
- PacketGen::Header::DHCPv6::DUID
- Includes:
- Types::Fieldable
- Defined in:
- lib/packetgen/header/dhcpv6/duid.rb
Overview
This class is abstract.
Base class for DUID (DHCP Unique ID)
Constant Summary collapse
- TYPES =
{ 'DUID-LLT' => 1, 'DUID-EN' => 2, 'DUID-LL' => 3 }.freeze
Instance Attribute Summary collapse
-
#body ⇒ String
abstract
DUID data.
-
#type ⇒ Integer
16-bit DUID type.
Instance Method Summary collapse
-
#human_type ⇒ String
Get human-readable type.
-
#read(str) ⇒ DUID
Populate object from binary string.
-
#to_human ⇒ String
Get human-readable DUID description.
Methods included from Types::Fieldable
#format_inspect, #sz, #to_s, #type_name
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #inspect, #offset_of, #optional?, #optional_fields, #present?, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
This class inherits a constructor from PacketGen::Types::Fields
Instance Attribute Details
Instance Method Details
#human_type ⇒ String
Get human-readable type
65 66 67 |
# File 'lib/packetgen/header/dhcpv6/duid.rb', line 65 def human_type self[:type].to_human end |
#read(str) ⇒ DUID
Populate object from binary string
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/packetgen/header/dhcpv6/duid.rb', line 39 def read(str) if self.instance_of?(DUID) super case type when 1 DUID_LLT.new.read(str) when 2 DUID_EN.new.read(str) when 3 DUID_LL.new.read(str) else self end else private_read str end end |
#to_human ⇒ String
Get human-readable DUID description
59 60 61 |
# File 'lib/packetgen/header/dhcpv6/duid.rb', line 59 def to_human "DUID<#{type},#{body.inspect}>" end |