netwerk/dns/nsIDNSRecord.idl
author Mike Hommey <mh+mozilla@glandium.org>
Mon, 11 Jun 2012 08:23:29 +0200
changeset 101676 c7e76fae10e569921c485dcf6033a4b80436344c
parent 98983 f4157e8c410708d76703f19e4dfb61859bfe32d8
child 108991 a16372ce30b5f6b747246b01fcd215a4bf3b6342
permissions -rw-r--r--
Backout changeset a78601d88586 (bug 759115) because of B2G bustage

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

native PRNetAddr(union PRNetAddr);

/**
 * nsIDNSRecord
 *
 * this interface represents the result of a DNS lookup.  since a DNS
 * query may return more than one resolved IP address, the record acts
 * like an enumerator, allowing the caller to easily step through the
 * list of IP addresses.
 */
[scriptable, uuid(ead9e9d8-7eef-4dae-a7f0-a1edcfb20478)]
interface nsIDNSRecord : nsISupports
{
    /**
     * @return the canonical hostname for this record.  this value is empty if
     * the record was not fetched with the RESOLVE_CANONICAL_NAME flag.
     *
     * e.g., www.mozilla.org --> rheet.mozilla.org
     */
    readonly attribute ACString canonicalName;

    /**
     * this function copies the value of the next IP address into the
     * given PRNetAddr struct and increments the internal address iterator.
     *
     * @param aPort
     *        A port number to initialize the PRNetAddr with.
     *
     * @throws NS_ERROR_NOT_AVAILABLE if there is not another IP address in
     * the record.
     */
    [noscript] PRNetAddr getNextAddr(in PRUint16 aPort);

    /**
     * this function returns the value of the next IP address as a
     * string and increments the internal address iterator.
     *
     * @throws NS_ERROR_NOT_AVAILABLE if there is not another IP address in
     * the record.
     */
    ACString getNextAddrAsString();

    /**
     * this function returns true if there is another address in the record.
     */
    boolean hasMore();

    /**
     * this function resets the internal address iterator to the first
     * address in the record.
     */
    void rewind();

    /**
     * This function indicates that the last address obtained via getNextAddr*()
     * was not usuable and should be skipped in future uses of this
     * record if other addresses are available.
     *
     * @param aPort is the port number associated with the failure, if any.
     *        It may be zero if not applicable.
     */
    void reportUnusable(in PRUint16 aPort);
};