summaryrefslogtreecommitdiff
path: root/netwerk/dns/nsIDNSService.idl
blob: 2704790dc311d125f810523f8c0e052b50710c0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* 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"

interface nsICancelable;
interface nsIEventTarget;
interface nsIDNSRecord;
interface nsIDNSListener;

%{C++
#include "nsTArrayForwardDeclare.h"
namespace mozilla { namespace net {
    struct DNSCacheEntries;
} }
%}

[ptr] native EntriesArray(nsTArray<mozilla::net::DNSCacheEntries>);

/**
 * nsIDNSService
 */
[scriptable, uuid(de5642c6-61fc-4fcf-9a47-03226b0d4e21)]
interface nsIDNSService : nsISupports
{
    /**
     * kicks off an asynchronous host lookup.
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aListener
     *        the listener to be notified when the result is available.
     * @param aListenerTarget
     *        optional parameter (may be null).  if non-null, this parameter
     *        specifies the nsIEventTarget of the thread on which the
     *        listener's onLookupComplete should be called.  however, if this
     *        parameter is null, then onLookupComplete will be called on an
     *        unspecified thread (possibly recursively).
     *
     * @return An object that can be used to cancel the host lookup.
     */
    nsICancelable asyncResolve(in AUTF8String       aHostName,
                               in unsigned long     aFlags,
                               in nsIDNSListener    aListener,
                               in nsIEventTarget    aListenerTarget);

    /**
     * Attempts to cancel a previously requested async DNS lookup
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     * @param aListener
     *        the original listener which was to be notified about the host lookup
     *        result - used to match request information to requestor.
     * @param aReason
     *        nsresult reason for the cancellation
     *
     * @return An object that can be used to cancel the host lookup.
     */
    void cancelAsyncResolve(in AUTF8String       aHostName,
                            in unsigned long     aFlags,
                            in nsIDNSListener    aListener,
                            in nsresult          aReason);

    /**
     * called to synchronously resolve a hostname.  warning this method may
     * block the calling thread for a long period of time.  it is extremely
     * unwise to call this function on the UI thread of an application.
     *
     * @param aHostName
     *        the hostname or IP-address-literal to resolve.
     * @param aFlags
     *        a bitwise OR of the RESOLVE_ prefixed constants defined below.
     *
     * @return DNS record corresponding to the given hostname.
     * @throws NS_ERROR_UNKNOWN_HOST if host could not be resolved.
     */
    nsIDNSRecord resolve(in AUTF8String   aHostName,
                         in unsigned long aFlags);

    /**
     * kicks off an asynchronous host lookup.
     *
     * This function is identical to asyncResolve except an additional
     * parameter aNetwortInterface. If parameter aNetworkInterface is an empty
     * string function will return the same result as asyncResolve.
     * Setting aNetworkInterface value make only sense for gonk,because it
     * an per networking interface query is possible.
     */
    nsICancelable asyncResolveExtended(in AUTF8String       aHostName,
                                       in unsigned long     aFlags,
                                       in AUTF8String       aNetworkInterface,
                                       in nsIDNSListener    aListener,
                                       in nsIEventTarget    aListenerTarget);

    /**
     * Attempts to cancel a previously requested async DNS lookup
     * This is an extended versin with a additional parameter aNetworkInterface
     */
    void cancelAsyncResolveExtended(in AUTF8String       aHostName,
                                    in unsigned long     aFlags,
                                    in AUTF8String       aNetworkInterface,
                                    in nsIDNSListener    aListener,
                                    in nsresult          aReason);

    /**
     * The method takes a pointer to an nsTArray
     * and fills it with cache entry data
     * Called by the networking dashboard
     */
    [noscript] void getDNSCacheEntries(in EntriesArray args);

    /**
     * @return the hostname of the operating system.
     */
    readonly attribute AUTF8String myHostName;

    /*************************************************************************
     * Listed below are the various flags that may be OR'd together to form
     * the aFlags parameter passed to asyncResolve() and resolve().
     */

    /**
     * if set, this flag suppresses the internal DNS lookup cache.
     */
    const unsigned long RESOLVE_BYPASS_CACHE = (1 << 0);

    /**
     * if set, the canonical name of the specified host will be queried.
     */
    const unsigned long RESOLVE_CANONICAL_NAME = (1 << 1);

    /**
     * if set, the query is given lower priority. Medium takes precedence
     * if both are used.
     */
    const unsigned long RESOLVE_PRIORITY_MEDIUM = (1 << 2);
    const unsigned long RESOLVE_PRIORITY_LOW    = (1 << 3);

    /**
     * if set, indicates request is speculative. Speculative requests
     * return errors if prefetching is disabled by configuration.
     */
    const unsigned long RESOLVE_SPECULATE = (1 << 4);

    /**
     * If set, only IPv4 addresses will be returned from resolve/asyncResolve.
     */
    const unsigned long RESOLVE_DISABLE_IPV6 = (1 << 5);

    /**
     * If set, only literals and cached entries will be returned from resolve/
     * asyncResolve.
     */
    const unsigned long RESOLVE_OFFLINE = (1 << 6);

    /**
     * If set, only IPv6 addresses will be returned from resolve/asyncResolve.
     */
    const unsigned long RESOLVE_DISABLE_IPV4 = (1 << 7);

    /**
     * If set, allow name collision results (127.0.53.53) which are normally filtered.
     */
    const unsigned long RESOLVE_ALLOW_NAME_COLLISION = (1 << 8);
};