Class: PacketGen::Header::DHCPv6::DUID Abstract
- Inherits:
-
BinStruct::Struct
- Object
- BinStruct::Struct
- PacketGen::Header::DHCPv6::DUID
- Includes:
- BinStruct::Structable
- 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.
Instance Attribute Details
#body ⇒ String
This method is abstract.
replaced by specific attributes in subclasses
DUID data.
31 |
# File 'lib/packetgen/header/dhcpv6/duid.rb', line 31 define_attr :body, BinStruct::String |
#type ⇒ Integer
16-bit DUID type
26 |
# File 'lib/packetgen/header/dhcpv6/duid.rb', line 26 define_attr :type, BinStruct::Int16Enum, enum: TYPES |
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 |