atomvm_gleam/mdns
Types
Options for start_link.
hostname— local name without.local(required)interface— IPv4 address of the interface to advertise (required)ttl— DNS TTL in seconds; omit for the upstream default (900)
See mdns:start_link/1.
pub type Config {
Config(
hostname: String,
interface: Ipv4Address,
ttl: option.Option(Int),
)
}
Constructors
-
Config( hostname: String, interface: Ipv4Address, ttl: option.Option(Int), )
Parsed / serializable DNS message (#dns_message{}).
Field order matches the upstream Erlang record so FFI can pass values through without reshaping.
pub type DnsMessage {
DnsMessage(
id: Int,
qr: Int,
opcode: Int,
aa: Int,
questions: List(DnsQuestion),
answers: List(DnsRrecord),
authority_rr: List(DnsRrecord),
additional_rr: List(DnsRrecord),
)
}
Constructors
-
DnsMessage( id: Int, qr: Int, opcode: Int, aa: Int, questions: List(DnsQuestion), answers: List(DnsRrecord), authority_rr: List(DnsRrecord), additional_rr: List(DnsRrecord), )
One DNS question (#dns_question{}).
unicast_response is the mDNS unicast-response bit (0 or 1) parsed from
the high bit of qclass on the wire.
pub type DnsQuestion {
DnsQuestion(
qname: List(BitArray),
qtype: Int,
unicast_response: Int,
qclass: Int,
)
}
Constructors
-
DnsQuestion( qname: List(BitArray), qtype: Int, unicast_response: Int, qclass: Int, )
One DNS resource record (#dns_rrecord{}).
record_type is upstream type (Gleam reserves type as a keyword).
pub type DnsRrecord {
DnsRrecord(
name: List(BitArray),
record_type: Int,
class: Int,
ttl: Int,
rdata: BitArray,
)
}
Constructors
-
DnsRrecord( name: List(BitArray), record_type: Int, class: Int, ttl: Int, rdata: BitArray, )
Errors from the mDNS responder and DNS protocol helpers.
pub type Error {
Failed
NotSupported
Badarg
Timeout
Other(String)
}
Constructors
-
Failed -
NotSupported -
Badarg -
Timeout -
Other(String)
IPv4 address as four octets (inet:ip4_address()).
pub type Ipv4Address {
Ipv4Address(a: Int, b: Int, c: Int, d: Int)
}
Constructors
-
Ipv4Address(a: Int, b: Int, c: Int, d: Int)
Values
pub fn parse_dns_message(
message: BitArray,
) -> Result(DnsMessage, Error)
Parse a DNS message binary into a DnsMessage.
Protocol helper; not part of the responder lifecycle.
pub fn parse_dns_name(
message: BitArray,
data: BitArray,
) -> Result(#(List(BitArray), BitArray), Error)
Parse a DNS name from data, resolving compression pointers against
the full message binary. Returns labels and the remaining tail.
Protocol helper; not part of the responder lifecycle.
pub fn serialize_dns_message(
message: DnsMessage,
) -> Result(BitArray, Error)
Serialize a DnsMessage to a DNS wire binary.
Protocol helper; not part of the responder lifecycle.
pub fn serialize_dns_name(
name: List(BitArray),
) -> Result(BitArray, Error)
Serialize DNS name labels to a wire binary (no compression).
Protocol helper; not part of the responder lifecycle.
pub fn start_link(config: Config) -> Result(Server, Error)
Start an mDNS responder and resolve hostname.local on interface.
See mdns:start_link/1.
pub fn stop(server: Server) -> Result(Nil, Error)
Stop an mDNS responder started with start_link.
See mdns:stop/1.