nsISocketTransport.idl 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "nsITransport.idl"
  6. interface nsIInterfaceRequestor;
  7. interface nsINetAddr;
  8. %{ C++
  9. #include "mozilla/BasePrincipal.h"
  10. namespace mozilla {
  11. namespace net {
  12. union NetAddr;
  13. }
  14. }
  15. %}
  16. native NetAddr(mozilla::net::NetAddr);
  17. [ptr] native NetAddrPtr(mozilla::net::NetAddr);
  18. native NeckoOriginAttributes(mozilla::NeckoOriginAttributes);
  19. [ref] native const_OriginAttributesRef(const mozilla::NeckoOriginAttributes);
  20. /**
  21. * nsISocketTransport
  22. *
  23. * NOTE: Connection setup is triggered by opening an input or output stream,
  24. * it does not start on its own. Completion of the connection setup is
  25. * indicated by a STATUS_CONNECTED_TO notification to the event sink (if set).
  26. *
  27. * NOTE: This is a free-threaded interface, meaning that the methods on
  28. * this interface may be called from any thread.
  29. */
  30. [scriptable, uuid(79221831-85e2-43a8-8152-05d77d6fde31)]
  31. interface nsISocketTransport : nsITransport
  32. {
  33. /**
  34. * Get the peer's host for the underlying socket connection.
  35. * For Unix domain sockets, this is a pathname, or the empty string for
  36. * unnamed and abstract socket addresses.
  37. */
  38. readonly attribute AUTF8String host;
  39. /**
  40. * Get the port for the underlying socket connection.
  41. * For Unix domain sockets, this is zero.
  42. */
  43. readonly attribute long port;
  44. /**
  45. * The origin attributes are used to create sockets. The first party domain
  46. * will eventually be used to isolate OCSP cache and is only non-empty when
  47. * "privacy.firstparty.isolate" is enabled. Setting this is the only way to
  48. * carry origin attributes down to NSPR layers which are final consumers.
  49. * It must be set before the socket transport is built.
  50. */
  51. [implicit_jscontext, binaryname(ScriptableOriginAttributes)]
  52. attribute jsval originAttributes;
  53. [noscript, nostdcall, binaryname(GetOriginAttributes)]
  54. NeckoOriginAttributes binaryGetOriginAttributes();
  55. [noscript, nostdcall, binaryname(SetOriginAttributes)]
  56. void binarySetOriginAttributes(in const_OriginAttributesRef aOriginAttrs);
  57. /**
  58. * The platform-specific network interface id that this socket
  59. * associated with. Note that this attribute can be only accessed
  60. * in the socket thread.
  61. */
  62. attribute ACString networkInterfaceId;
  63. /**
  64. * Returns the IP address of the socket connection peer. This
  65. * attribute is defined only once a connection has been established.
  66. */
  67. [noscript] NetAddr getPeerAddr();
  68. /**
  69. * Returns the IP address of the initiating end. This attribute
  70. * is defined only once a connection has been established.
  71. */
  72. [noscript] NetAddr getSelfAddr();
  73. /**
  74. * Bind to a specific local address.
  75. */
  76. [noscript] void bind(in NetAddrPtr aLocalAddr);
  77. /**
  78. * Returns a scriptable version of getPeerAddr. This attribute is defined
  79. * only once a connection has been established.
  80. */
  81. nsINetAddr getScriptablePeerAddr();
  82. /**
  83. * Returns a scriptable version of getSelfAddr. This attribute is defined
  84. * only once a connection has been established.
  85. */
  86. nsINetAddr getScriptableSelfAddr();
  87. /**
  88. * Security info object returned from the secure socket provider. This
  89. * object supports nsISSLSocketControl, nsITransportSecurityInfo, and
  90. * possibly other interfaces.
  91. *
  92. * This attribute is only available once the socket is connected.
  93. */
  94. readonly attribute nsISupports securityInfo;
  95. /**
  96. * Security notification callbacks passed to the secure socket provider
  97. * via nsISSLSocketControl at socket creation time.
  98. *
  99. * NOTE: this attribute cannot be changed once a stream has been opened.
  100. */
  101. attribute nsIInterfaceRequestor securityCallbacks;
  102. /**
  103. * Test if this socket transport is (still) connected.
  104. */
  105. boolean isAlive();
  106. /**
  107. * Socket timeouts in seconds. To specify no timeout, pass UINT32_MAX
  108. * as aValue to setTimeout. The implementation may truncate timeout values
  109. * to a smaller range of values (e.g., 0 to 0xFFFF).
  110. */
  111. unsigned long getTimeout(in unsigned long aType);
  112. void setTimeout(in unsigned long aType, in unsigned long aValue);
  113. /**
  114. * Values for the aType parameter passed to get/setTimeout.
  115. */
  116. const unsigned long TIMEOUT_CONNECT = 0;
  117. const unsigned long TIMEOUT_READ_WRITE = 1;
  118. /**
  119. * nsITransportEventSink status codes.
  120. *
  121. * Although these look like XPCOM error codes and are passed in an nsresult
  122. * variable, they are *not* error codes. Note that while they *do* overlap
  123. * with existing error codes in Necko, these status codes are confined
  124. * within a very limited context where no error codes may appear, so there
  125. * is no ambiguity.
  126. *
  127. * The values of these status codes must never change.
  128. *
  129. * The status codes appear in near-chronological order (not in numeric
  130. * order). STATUS_RESOLVING may be skipped if the host does not need to be
  131. * resolved. STATUS_WAITING_FOR is an optional status code, which the impl
  132. * of this interface may choose not to generate.
  133. *
  134. * In C++, these constants have a type of uint32_t, so C++ callers must use
  135. * the NS_NET_STATUS_* constants defined below, which have a type of
  136. * nsresult.
  137. */
  138. const unsigned long STATUS_RESOLVING = 0x804b0003;
  139. const unsigned long STATUS_RESOLVED = 0x804b000b;
  140. const unsigned long STATUS_CONNECTING_TO = 0x804b0007;
  141. const unsigned long STATUS_CONNECTED_TO = 0x804b0004;
  142. const unsigned long STATUS_SENDING_TO = 0x804b0005;
  143. const unsigned long STATUS_WAITING_FOR = 0x804b000a;
  144. const unsigned long STATUS_RECEIVING_FROM = 0x804b0006;
  145. const unsigned long STATUS_TLS_HANDSHAKE_STARTING = 0x804b000c;
  146. const unsigned long STATUS_TLS_HANDSHAKE_ENDED = 0x804b000d;
  147. /**
  148. * connectionFlags is a bitmask that can be used to modify underlying
  149. * behavior of the socket connection. See the flags below.
  150. */
  151. attribute unsigned long connectionFlags;
  152. /**
  153. * Values for the connectionFlags
  154. *
  155. * When making a new connection BYPASS_CACHE will force the Necko DNS
  156. * cache entry to be refreshed with a new call to NSPR if it is set before
  157. * opening the new stream.
  158. */
  159. const unsigned long BYPASS_CACHE = (1 << 0);
  160. /**
  161. * When setting this flag, the socket will not apply any
  162. * credentials when establishing a connection. For example,
  163. * an SSL connection would not send any client-certificates
  164. * if this flag is set.
  165. */
  166. const unsigned long ANONYMOUS_CONNECT = (1 << 1);
  167. /**
  168. * If set, we will skip all IPv6 addresses the host may have and only
  169. * connect to IPv4 ones.
  170. */
  171. const unsigned long DISABLE_IPV6 = (1 << 2);
  172. /**
  173. * If set, indicates that the connection was initiated from a source
  174. * defined as being private in the sense of Private Browsing. Generally,
  175. * there should be no state shared between connections that are private
  176. * and those that are not; it is OK for multiple private connections
  177. * to share state with each other, and it is OK for multiple non-private
  178. * connections to share state with each other.
  179. */
  180. const unsigned long NO_PERMANENT_STORAGE = (1 << 3);
  181. /**
  182. * If set, we will skip all IPv4 addresses the host may have and only
  183. * connect to IPv6 ones.
  184. */
  185. const unsigned long DISABLE_IPV4 = (1 << 4);
  186. /**
  187. * If set, indicates that the socket should not connect if the hostname
  188. * resolves to an RFC1918 address or IPv6 equivalent.
  189. */
  190. const unsigned long DISABLE_RFC1918 = (1 << 5);
  191. /**
  192. * This flag is an explicit opt-in that allows a normally secure socket
  193. * provider to use, at its discretion, an insecure algorithm. e.g.
  194. * a TLS socket without authentication.
  195. */
  196. const unsigned long MITM_OK = (1 << 6);
  197. /**
  198. * If set, do not use newer protocol features that might have interop problems
  199. * on the Internet. Intended only for use with critical infra like the updater.
  200. * default is false.
  201. */
  202. const unsigned long BE_CONSERVATIVE = (1 << 7);
  203. /**
  204. * Socket QoS/ToS markings. Valid values are IPTOS_DSCP_AFxx or
  205. * IPTOS_CLASS_CSx (or IPTOS_DSCP_EF, but currently no supported
  206. * services require expedited-forwarding).
  207. * Not setting this value will leave the socket with the default
  208. * ToS value, which on most systems if IPTOS_CLASS_CS0 (formerly
  209. * IPTOS_PREC_ROUTINE).
  210. */
  211. attribute octet QoSBits;
  212. /**
  213. * TCP send and receive buffer sizes. A value of 0 means OS level
  214. * auto-tuning is in effect.
  215. */
  216. attribute unsigned long recvBufferSize;
  217. attribute unsigned long sendBufferSize;
  218. /**
  219. * TCP keepalive configuration (support varies by platform).
  220. * Note that the attribute as well as the setter can only accessed
  221. * in the socket thread.
  222. */
  223. attribute boolean keepaliveEnabled;
  224. void setKeepaliveVals(in long keepaliveIdleTime,
  225. in long keepaliveRetryInterval);
  226. };