package dns

  1. Overview
  2. Docs

Implements the core of the unique name probing part of a Multicast DNS (mDNS) responder.

type state

The internal data structure representing the of the probing part of an mDNS responder.

type datagram = Packet.t * Ipaddr.V4.t * int

A DNS packet to be sent with its destination IP address and UDP port number.

type action =
  1. | Nothing
    (*

    The protocol is idle because all names have been confirmed unique.

    *)
  2. | ToSend of datagram
    (*

    The caller shall send the specified datagram.

    *)
  3. | Delay of float
    (*

    The caller shall wait for the specified duration in seconds.

    *)
  4. | Continue
    (*

    The caller should invoke do_probe again.

    *)
  5. | NotReady
    (*

    The call was unexpected. This may indicate a bug in the caller, and should be logged.

    *)
  6. | Stop
    (*

    stop has been called.

    *)

The I/O action that the caller of this module must take.

val new_state : Loader.db -> state

Initialises a new mDNS probe protocol.

val add_name : state -> Name.t -> state

Marks a Name.t as unique. The name will be included in the next probe cycle.

val do_probe : state -> state * action

Initiates the probe protocol and returns the I/O action that the caller should take.

val on_send_complete : state -> state * action

After completing a ToSend action, call this function to continue the probe protocol.

val on_delay_complete : state -> state * action

After completing a Delay action, call this function to continue the probe protocol.

val is_first_complete : state -> bool

Returns true if the first probe cycle has completed successfully.

type conflict =
  1. | NoConflict
    (*

    No conflict occurred.

    *)
  2. | ConflictRestart
    (*

    A conflict occurred. The caller should interrupt any Delay action that is currently executing, if possible.

    *)

Indicates whether the received datagram caused a restart of the probe cycle due to a conflict.

val on_response_received : state -> Packet.t -> state * conflict

Call this function when an mDNS response packet is received, in order to check for conflicting resource records.

val on_query_received : state -> Packet.t -> Packet.t -> Packet.t * state * conflict

Call this function when an mDNS query packet is received, in order to check for simultaneous probe conflicts.

val is_confirmed : state -> Name.t -> bool

Returns true if the name has been confirmed unique (probed successfully). This is intended for controlling the cache flush bit.

val stop : state -> state

Stops executing the protocol.