DHCPv6.Message (DHCP v0.5.0)

View Source

DHCPv6 Message

DHCPv6 message format and parsing according to RFC3315.

DHCPv6 Message Format

DHCPv6 messages have a fixed-format header followed by options. The message format is much simpler than DHCPv4 as it omits many legacy BOOTP fields.

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 (3 octets)       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                                                               |
.                            options                            .
.                      (variable length)                      .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

DHCPv6 Message Types

DHCPv6 defines the following message types:

  • 1 - SOLICIT: Client broadcast to locate available servers
  • 2 - ADVERTISE: Server offers configuration parameters
  • 3 - REQUEST: Client requests configuration parameters
  • 4 - CONFIRM: Client verifies configuration parameters
  • 5 - RENEW: Client requests renewal of configuration parameters
  • 6 - REBIND: Client requests renewal without server contact
  • 7 - REPLY: Server responds to client request
  • 8 - RELEASE: Client releases assigned addresses
  • 9 - DECLINE: Client indicates address already in use
  • 10 - RECONFIGURE: Server initiates configuration renegotiation
  • 11 - INFORMATION-REQUEST: Client requests configuration only
  • 12 - RELAY-FORW: Relay agent forwards client message
  • 13 - RELAY-REPL: Relay agent forwards server reply

DHCPv6 vs DHCPv4 Key Differences

  • No legacy BOOTP fields: DHCPv6 eliminates legacy BOOTP fields like htype, hlen, chaddr, etc.
  • Larger address space: Uses IPv6 addresses (128-bit vs 32-bit)
  • Simplified header: Fixed 4-byte header vs 236-byte DHCPv4 header
  • Different option format: 2-byte code + 2-byte length vs 1-byte code + 1-byte length
  • DUID-based identification: Uses DHCP Unique Identifiers instead of MAC addresses
  • Multicast support: Uses IPv6 multicast addresses instead of broadcasts

DHCPv6 Option Overview

DHCPv6 options are encoded using a two-octet option code followed by a two-octet option length, followed by the option data. Common options include:

  • Option 1: Client Identifier (DUID)
  • Option 2: Server Identifier (DUID)
  • Option 3: Identity Association for Non-temporary Addresses (IA_NA)
  • Option 5: Identity Association Address (IAADDR)
  • Option 6: Option Request List
  • Option 23: DNS Recursive Name Server

Summary

Functions

Parse DHCPv6 message from binary.

Create a new DHCPv6 message.

Convert DHCPv6 message to binary.

Types

t()

@type t() :: %DHCPv6.Message{
  msg_type: integer(),
  options: [DHCPv6.Message.Option.t()],
  transaction_id: binary()
}

Functions

from_iodata(data)

@spec from_iodata(binary()) :: {:ok, t()} | {:error, String.t()}

Parse DHCPv6 message from binary.

new()

@spec new() :: t()

Create a new DHCPv6 message.

to_iodata(message)

@spec to_iodata(t()) :: binary()

Convert DHCPv6 message to binary.