Class: PacketGen::Header::DHCPv6
- Inherits:
-
Base
- Object
- Types::Fields
- Base
- PacketGen::Header::DHCPv6
- Defined in:
- lib/packetgen/header/dhcpv6.rb,
lib/packetgen/header/dhcpv6.rb,
lib/packetgen/header/dhcpv6/duid.rb,
lib/packetgen/header/dhcpv6/relay.rb,
lib/packetgen/header/dhcpv6/option.rb,
lib/packetgen/header/dhcpv6/options.rb
Overview
Dynamic Host Configuration Protocol for IPv6, RFC 3315
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| msg-type | transaction-id |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. options .
. (variable) .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
A DHCPv6 header is made of:
-
a #msg_type field (Types::Int8Enum),
-
a #transaction_id field (Types::Int24),
Create a DHCPv6 header
# standalone
dhcpv6 = PacketGen::Header::DHCPv6.new(msg_type: 'SOLLICIT')
# in a packet
pkt = PacketGen.gen('IPv6').add('DHCPv6', msg_type: 'SOLLICIT')
# access to DHCPv6 header from packet
pkt.dhcpv6 #=> PacketGen::Header::DHCPv6
Add options
DHCPv6 options are defined by subclasses of Option.
Options may be added by pushing a hash to #options:
dhcpv6 = PacketGen::Header::DHCPv6.new(msg_type: 'SOLLICIT')
dhcpv6. << { type: 'Preference', value: 1 }
Defined Under Namespace
Classes: ClientID, DUID, DUID_EN, DUID_LL, DUID_LLT, ElapsedTime, IAAddr, IANA, IATA, ORO, Option, Options, Preference, RapidCommit, Relay, RelayMessage, RequestedOptions, ServerID, ServerUnicast, StatusCode
Constant Summary collapse
- UDP_CLIENT_PORT =
DHCPv6 UDP client port
546
- UDP_SERVER_PORT =
DHCPv6 UDP client port
547
- MESSAGE_TYPES =
DHCPv6 message types
{ 'SOLLICIT' => 1, 'ADVERTISE' => 2, 'REQUEST' => 3, 'CONFIRM' => 4, 'RENEW' => 5, 'REBIND' => 6, 'REPLY' => 7, 'RELEASE' => 8, 'DECLINE' => 9, 'RECONFIGURE' => 10, 'INFORMATION-REQUEST' => 11 }.freeze
Instance Attribute Summary collapse
-
#msg_type ⇒ Integer
8-bit message type.
- #options ⇒ DHCPv6::Options
-
#transaction_id ⇒ Object
24-bit transaction ID.
Instance Method Summary collapse
-
#human_msg_type ⇒ String
Get human readable message type.
-
#read(str) ⇒ DHCPv6, DHCPv6::Relay
Populate object from string.
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header
Methods included from PacketGen::Headerable
#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_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::Header::Base
Instance Attribute Details
#msg_type ⇒ Integer
8-bit message type
75 |
# File 'lib/packetgen/header/dhcpv6.rb', line 75 define_field :msg_type, Types::Int8Enum, enum: MESSAGE_TYPES |
#options ⇒ DHCPv6::Options
82 |
# File 'lib/packetgen/header/dhcpv6.rb', line 82 define_field :options, DHCPv6::Options |
Instance Method Details
#human_msg_type ⇒ String
Get human readable message type
100 101 102 |
# File 'lib/packetgen/header/dhcpv6.rb', line 100 def human_msg_type self[:msg_type].to_human end |