class PacketGen::Header::DHCPv6

Dynamic Host Configuration Protocol for IPv6, {tools.ietf.org/html/rfc3315 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:

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 {DHCPv6::Option}.

Options may be added by pushing a hash to {#options}:

dhcpv6 = PacketGen::Header::DHCPv6.new(msg_type: 'SOLLICIT')
dhcpv6.options << { type: 'Preference', value: 1 }

@author Sylvain Daubert @since 2.5.0

Constants

MESSAGE_TYPES

DHCPv6 message types

UDP_CLIENT_PORT

DHCPv6 UDP client port

UDP_SERVER_PORT

DHCPv6 UDP client port

Public Instance Methods

human_msg_type() click to toggle source

Get human readable message type @return [String]

# File lib/packetgen/header/dhcpv6.rb, line 99
def human_msg_type
  self[:msg_type].to_human
end
read(str) click to toggle source

Populate object from string @param [String] str @return [DHCPv6,DHCPv6::Relay]

Calls superclass method PacketGen::Headerable#read
# File lib/packetgen/header/dhcpv6.rb, line 86
def read(str)
  msg_type = Types::Int8.new.read(str)

  case msg_type
  when 12, 13
    DHCPv6::Relay.new.read(str)
  else
    super
  end
end