chromium/services/network/public/mojom/mdns_responder.mojom

// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

module network.mojom;

import "services/network/public/mojom/ip_address.mojom";

// An mDNS responder is created for each Mojo binding and it manages the
// name-address maps created through the interface. The name-address maps are
// isolated among different responders, so that the creation and the removal
// of a name for an address is specific to the given responder. When the Mojo
// pipe is closed, all name-address maps created through the interface are
// removed by the responder and the responder is destroyed afterwards. For a
// given responder, all created names are reference counted, and each
// CreateNameForAddress call and RemoveNameForAddress call respectively
// increases and decreases the reference count for existing names.
//
// This interface is intended to be safe to use from renderer processes.
interface MdnsResponder {
  // Creates and returns a new name for the address if there is no name mapped
  // to it by this responder, and initializes the reference count of this name
  // to one. Otherwise the existing name mapped to the given address is returned
  // and its reference count is incremented by one. Since the name-address maps
  // are specific to the given responder, there could be separated names for the
  // same address. After a new name is mapped to an address, an mDNS response to
  // announce the ownership of this name is scheduled to send to the mDNS
  // multicast group over all interfaces, with a TTL for the name set to 120
  // seconds (see RFC 6762, Section 10). Returns true in
  // |announcement_scheduled| if the schedule is done on all interfaces after
  // rate limiting, and false otherwise. The responder will also start to
  // respond to queries for the created name until its reference count is
  // decremented to zero.
  CreateNameForAddress(IPAddress address)
      => (string name, bool announcement_scheduled);
  // Decrements the reference count of the mapped name of the given address, if
  // there is a map created previously via CreateNameForAddress; removes the
  // association between the address and its mapped name and returns true in
  // |removed| if the decremented reference count reaches zero. Otherwise no
  // operation is done and false is returned in |removed|. If the association
  // between the address and its mapped name is removed, an mDNS response to
  // renounce the ownership of this name is scheduled to send to the mDNS
  // multicast group over all interfaces, by setting a zero TTL. Returns true in
  // |goodbye_scheduled| if the schedule is done on all interfaces after rate
  // limiting, and false otherwise. The responder will also stop responding to
  // queries for the removed name. Note that this does not impact separated
  // names mapped to the same address by other responders.
  RemoveNameForAddress(IPAddress address)
      => (bool removed, bool goodbye_scheduled);
};