package dns
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=00472d566bbfd66da13642eab5fade12fde56b20dd7ac5c50415b88d052d6175
sha512=0ddeee4a155852c7ffa619de603e54dabe9ec315b79e4a1cb22a13884f9d3893458f1fa3c7b97f2eda60b29f1bfa401e53d531d8ded1089dcd8497ffa3ad1afb
doc/dns/Dns/Packet/index.html
Module Dns.Packet
Source
The DNS packet.
Encoding and decoding from binary. Definition of types for multiple DNS operations.
The type of a DNS request: depending on opcode and rr_typ.
equal_request a b
is true
if the request a
is the same as b
, false
otherwise.
type reply = [
| `Answer of Answer.t
| `Notify_ack
| `Axfr_reply of Axfr.t
| `Axfr_partial_reply of [ `First of Soa.t | `Mid | `Last of Soa.t ] * Name_rr_map.t
| `Ixfr_reply of Ixfr.t
| `Update_ack
| `Rcode_error of Rcode.t * Opcode.t * Answer.t option
]
The type of a DNS reply: depending on opcode, rr_typ, and rcode.
equal_reply a b
is true
if the reply a
is the same as b
, false
otherwise.
equal_data a b
is true
if a
and b
are the same, false
otherwise.
type t = private {
header : Header.t;
question : Question.t;
data : data;
additional : Name_rr_map.t;
edns : Edns.t option;
tsig : ([ `raw ] Domain_name.t * Tsig.t * int) option;
}
The type of a DNS packet: its header, question, data, additional section, and optional EDNS and TSIG records.
val create :
?max_size:int ->
?additional:Name_rr_map.t ->
?edns:Edns.t ->
?tsig:([ `raw ] Domain_name.t * Tsig.t * int) ->
Header.t ->
Question.t ->
data ->
t
create ~max_size ~additional ~edns ~tsig hdr q data
is a DNS packet.
equal a b
is true
if the DNS packet a
and b
are equal, false
otherwise.
type err = [
| `Bad_edns_version of int
| `Leftover of int * string
| `Malformed of int * string
| `Not_implemented of int * string
| `Notify_ack_answer_count of int
| `Notify_answer_count of int
| `Partial
| `Query_answer_count of int
| `Rcode_cant_change of Rcode.t
| `Rcode_error_cant_noerror of Rcode.t
| `Request_rcode of Rcode.t
| `Truncated_request
| `Update_ack_answer_count of int
]
The type of decode errors.
decode cs
decode the binary data cs
to a DNS packet t
or an error.
type mismatch = [
| `Not_a_reply of request
| `Id_mismatch of int * int
| `Operation_mismatch of request * reply
| `Question_mismatch of Question.t * Question.t
| `Expected_request
]
The type of request / reply mismatches.
reply_matches_request ~request reply
validates that the reply
match the request
, and returns either Ok data
or an Error
. The following basic checks are performed:
- Is the header identifier of
request
andreply
equal? - Does the
request
operation match thereply
operation? - Is
question
and the question ofresponse
equal?
size_edns max_size edns protocol query
computes the size of the reply packet, and optionally an EDNS record.
encode ~max_size protocol t
allocates a buffer and encodes the DNS packet t
into it. If the maximum size (depending on max_size
and protocol
) is reached, the truncation flag is set. The last component of the result is the maximum size.
encode_axfr_reply ~max_size tsig_size protocol t axfr
encodes the axfr
into a list of buffers to be sent out (each with at least tsig_size
space for a tsig signature. The second component of the result is the maximum size (dependent on max_size
and protocol
).