nsIDNSService.idl 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #include "nsISupports.idl"
  5. interface nsICancelable;
  6. interface nsIEventTarget;
  7. interface nsIDNSRecord;
  8. interface nsIDNSListener;
  9. %{C++
  10. #include "nsTArrayForwardDeclare.h"
  11. namespace mozilla { namespace net {
  12. struct DNSCacheEntries;
  13. } }
  14. %}
  15. [ptr] native EntriesArray(nsTArray<mozilla::net::DNSCacheEntries>);
  16. /**
  17. * nsIDNSService
  18. */
  19. [scriptable, uuid(de5642c6-61fc-4fcf-9a47-03226b0d4e21)]
  20. interface nsIDNSService : nsISupports
  21. {
  22. /**
  23. * kicks off an asynchronous host lookup.
  24. *
  25. * @param aHostName
  26. * the hostname or IP-address-literal to resolve.
  27. * @param aFlags
  28. * a bitwise OR of the RESOLVE_ prefixed constants defined below.
  29. * @param aListener
  30. * the listener to be notified when the result is available.
  31. * @param aListenerTarget
  32. * optional parameter (may be null). if non-null, this parameter
  33. * specifies the nsIEventTarget of the thread on which the
  34. * listener's onLookupComplete should be called. however, if this
  35. * parameter is null, then onLookupComplete will be called on an
  36. * unspecified thread (possibly recursively).
  37. *
  38. * @return An object that can be used to cancel the host lookup.
  39. */
  40. nsICancelable asyncResolve(in AUTF8String aHostName,
  41. in unsigned long aFlags,
  42. in nsIDNSListener aListener,
  43. in nsIEventTarget aListenerTarget);
  44. /**
  45. * Attempts to cancel a previously requested async DNS lookup
  46. *
  47. * @param aHostName
  48. * the hostname or IP-address-literal to resolve.
  49. * @param aFlags
  50. * a bitwise OR of the RESOLVE_ prefixed constants defined below.
  51. * @param aListener
  52. * the original listener which was to be notified about the host lookup
  53. * result - used to match request information to requestor.
  54. * @param aReason
  55. * nsresult reason for the cancellation
  56. *
  57. * @return An object that can be used to cancel the host lookup.
  58. */
  59. void cancelAsyncResolve(in AUTF8String aHostName,
  60. in unsigned long aFlags,
  61. in nsIDNSListener aListener,
  62. in nsresult aReason);
  63. /**
  64. * called to synchronously resolve a hostname. warning this method may
  65. * block the calling thread for a long period of time. it is extremely
  66. * unwise to call this function on the UI thread of an application.
  67. *
  68. * @param aHostName
  69. * the hostname or IP-address-literal to resolve.
  70. * @param aFlags
  71. * a bitwise OR of the RESOLVE_ prefixed constants defined below.
  72. *
  73. * @return DNS record corresponding to the given hostname.
  74. * @throws NS_ERROR_UNKNOWN_HOST if host could not be resolved.
  75. */
  76. nsIDNSRecord resolve(in AUTF8String aHostName,
  77. in unsigned long aFlags);
  78. /**
  79. * kicks off an asynchronous host lookup.
  80. *
  81. * This function is identical to asyncResolve except an additional
  82. * parameter aNetwortInterface. If parameter aNetworkInterface is an empty
  83. * string function will return the same result as asyncResolve.
  84. * Setting aNetworkInterface value make only sense for gonk,because it
  85. * an per networking interface query is possible.
  86. */
  87. nsICancelable asyncResolveExtended(in AUTF8String aHostName,
  88. in unsigned long aFlags,
  89. in AUTF8String aNetworkInterface,
  90. in nsIDNSListener aListener,
  91. in nsIEventTarget aListenerTarget);
  92. /**
  93. * Attempts to cancel a previously requested async DNS lookup
  94. * This is an extended versin with a additional parameter aNetworkInterface
  95. */
  96. void cancelAsyncResolveExtended(in AUTF8String aHostName,
  97. in unsigned long aFlags,
  98. in AUTF8String aNetworkInterface,
  99. in nsIDNSListener aListener,
  100. in nsresult aReason);
  101. /**
  102. * The method takes a pointer to an nsTArray
  103. * and fills it with cache entry data
  104. * Called by the networking dashboard
  105. */
  106. [noscript] void getDNSCacheEntries(in EntriesArray args);
  107. /**
  108. * @return the hostname of the operating system.
  109. */
  110. readonly attribute AUTF8String myHostName;
  111. /*************************************************************************
  112. * Listed below are the various flags that may be OR'd together to form
  113. * the aFlags parameter passed to asyncResolve() and resolve().
  114. */
  115. /**
  116. * if set, this flag suppresses the internal DNS lookup cache.
  117. */
  118. const unsigned long RESOLVE_BYPASS_CACHE = (1 << 0);
  119. /**
  120. * if set, the canonical name of the specified host will be queried.
  121. */
  122. const unsigned long RESOLVE_CANONICAL_NAME = (1 << 1);
  123. /**
  124. * if set, the query is given lower priority. Medium takes precedence
  125. * if both are used.
  126. */
  127. const unsigned long RESOLVE_PRIORITY_MEDIUM = (1 << 2);
  128. const unsigned long RESOLVE_PRIORITY_LOW = (1 << 3);
  129. /**
  130. * if set, indicates request is speculative. Speculative requests
  131. * return errors if prefetching is disabled by configuration.
  132. */
  133. const unsigned long RESOLVE_SPECULATE = (1 << 4);
  134. /**
  135. * If set, only IPv4 addresses will be returned from resolve/asyncResolve.
  136. */
  137. const unsigned long RESOLVE_DISABLE_IPV6 = (1 << 5);
  138. /**
  139. * If set, only literals and cached entries will be returned from resolve/
  140. * asyncResolve.
  141. */
  142. const unsigned long RESOLVE_OFFLINE = (1 << 6);
  143. /**
  144. * If set, only IPv6 addresses will be returned from resolve/asyncResolve.
  145. */
  146. const unsigned long RESOLVE_DISABLE_IPV4 = (1 << 7);
  147. /**
  148. * If set, allow name collision results (127.0.53.53) which are normally filtered.
  149. */
  150. const unsigned long RESOLVE_ALLOW_NAME_COLLISION = (1 << 8);
  151. };