package dns

  1. Overview
  2. Docs

Extensions to DNS

An extension record (EDNS) is extendable, includes a version number, payload size restrictions, TCP keepalive timers, etc. This is only used in transaction, and not persisted to a store. It is treat specially in decode and encode.

type extension =
  1. | Nsid of Cstruct.t
  2. | Cookie of Cstruct.t
  3. | Tcp_keepalive of int option
  4. | Padding of int
  5. | Extension of int * Cstruct.t
    (*

    The type of supported extensions.

    *)
type t = private {
  1. extended_rcode : int;
  2. version : int;
  3. dnssec_ok : bool;
  4. payload_size : int;
  5. extensions : extension list;
}

The type of an EDNS record.

val create : ?extended_rcode:int -> ?version:int -> ?dnssec_ok:bool -> ?payload_size:int -> ?extensions:extension list -> unit -> t

create ~extended_rcode ~version ~dnssec_ok ~payload_size ~extensions () constructs an EDNS record with the optionally provided data. The extended_rcode defaults to 0, version defaults to 0, dnssec_ok to false, payload_size to the minimum payload size (512 byte), extensions to the empty list.

val reply : t option -> int option * t option

reply edns either constructs an EDNS record and returns a maximum payload size, or None (if no EDNS is provided).

val compare : t -> t -> int

compare a b compares the EDNS record a with b by comparing individual fields in-order. The extension list must be exactly in the same order.

val pp : t Fmt.t

pp ppf t pretty-prints the EDNS record t on ppf.

val allocate_and_encode : t -> Cstruct.t

allocate_and_encode t allocates a buffer and encodes t into that buffer.