netwerk/dns/nsIDNSRecord.idl
author Neil Rashbrook <neil@parkwaycc.co.uk>
Thu, 10 Jan 2013 18:44:17 +0000
changeset 128325 33e9b69e55cc0a16471d3d3228ef299118d9806c
parent 126078 7f5fad93ef78556fd77f140ac550646f3d0d8407
child 162049 2b66295c3d202ba8a0260f6cf3ab744c893d8526
permissions -rw-r--r--
Bug 826455 Expose more NetAddr functions to script r=biesi,josh

/* 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"

%{ C++
#include "mozilla/net/DNS.h"
%}
native NetAddr(mozilla::net::NetAddr);
interface nsINetAddr;

/**
 * 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(95ced6f3-44b4-4427-a149-c9a1e033d852)]
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 NetAddr struct and increments the internal address iterator.
     *
     * @param aPort
     *        A port number to initialize the NetAddr with.
     *
     * @throws NS_ERROR_NOT_AVAILABLE if there is not another IP address in
     * the record.
     */
    [noscript] NetAddr getNextAddr(in uint16_t aPort);

    /**
     * this function returns the value of the next IP address as a
     * scriptable address and increments the internal address iterator.
     *
     * @param aPort
     *        A port number to initialize the nsINetAddr with.
     *
     * @throws NS_ERROR_NOT_AVAILABLE if there is not another IP address in
     * the record.
     */
    nsINetAddr getScriptableNextAddr(in uint16_t 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 uint16_t aPort);
};