Full DNS message encode and decode. Handles headers, question sections, resource records with RDATA codec dispatch, and EDNS OPT pseudo-record extraction/injection.
| Name | Signature |
|---|---|
decode_header | decode_header(r) -> hdr, err |
encode_header | encode_header(w, hdr, qdcount, ancount, nscount, arcount) |
decode_question | decode_question(r) -> q, err |
encode_question | encode_question(w, q) |
decode_rr | decode_rr(r) -> rr, err |
encode_rr | encode_rr(w, rr) |
extract_edns | extract_edns(additional) -> edns, filtered |
build_opt_rr | build_opt_rr(edns) -> rr |
decode | decode(raw_bytes) -> msg, err |
encode | encode(msg) -> raw_bytes |
decode_header(
r) ->hdr,err
Decode the 12-byte DNS header from a reader
encode_header(
w,hdr,qdcount,ancount,nscount,arcount)
Encode a DNS header into a writer
decode_question(
r) ->q,err
Decode a single question entry
encode_question(
w,q)
Encode a single question entry
decode_rr(
r) ->rr,err
Decode a single resource record
encode_rr(
w,rr)
Encode a single resource record
extract_edns(
additional) ->edns,filtered
Extract OPT pseudo-record from additional section into edns table
build_opt_rr(
edns) ->rr
Build OPT pseudo-record RR from edns table
decode(
raw_bytes) ->msg,err
Decode a raw DNS message into a structured table
Decodes a complete DNS message from a raw binary string. Returns a table
with header, question, answer, authority, additional, and
optionally edns fields. The OPT pseudo-record is extracted from the
additional section into msg.edns.
Section counts from the header determine how many entries are parsed in each section. If any entry fails to parse, the entire decode fails with an error (strict mode).
encode(
msg) ->raw_bytes
Encode a structured message table into raw DNS wire format
Encodes a complete DNS message from a structured table. Section counts
are computed from the array lengths. If msg.edns is set, an OPT
pseudo-record is appended to the additional section.