DNS.Message.Record.Data.A (DNS v0.5.0)
View SourceDNS A (Address) record implementation.
A records are used to map domain names to IPv4 addresses. This module provides functionality for creating, parsing, and serializing A records according to RFC 1035.
Fields
type- Resource record type (always 1 for A records)rdlength- Length of the RDATA field (always 4 bytes for IPv4 addresses)raw- Raw binary data for the recorddata- IPv4 address as a 4-tuple{a, b, c, d}
Examples
iex> record = DNS.Message.Record.Data.A.new({192, 168, 1, 1})
iex> record.data
{192, 168, 1, 1}
iex> raw = <<192, 168, 1, 1>>
iex> record = DNS.Message.Record.Data.A.from_iodata(raw)
iex> to_string(record)
"192.168.1.1"
Summary
Types
@type t() :: %DNS.Message.Record.Data.A{ data: :inet.ip4_address(), raw: bitstring(), rdlength: 4, type: DNS.ResourceRecordType.t() }
Functions
Parse A record data from binary iodata.
Parameters
raw- Binary data containing the IPv4 address (4 bytes)message- Full DNS message (unused for A records, kept for interface consistency)
Returns
t()- A record struct with parsed IPv4 address
Examples
iex> record = DNS.Message.Record.Data.A.from_iodata(<<192, 168, 1, 1>>)
iex> record.data
{192, 168, 1, 1}
@spec new(:inet.ip4_address()) :: t()
Create a new A record from an IPv4 address tuple.
Parameters
ip- IPv4 address as a 4-tuple{a, b, c, d}where each element is 0-255
Returns
t()- A record struct with the IP address data
Examples
iex> record = DNS.Message.Record.Data.A.new({192, 168, 1, 1})
iex> record.data
{192, 168, 1, 1}